青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天行健 君子當自強而不息

Working with skeletal animation(7)

Updating the Skinned Mesh

When your skeletal structure is in the pose you desire, it's time to update (or rebuild) the skinned mesh to match. Before you rebuild the skinned mesh, you must make sure you have constructed the secondary mesh container and updated the frame hierarchy. To review how to construct the mesh container, consult the "Creating a Secondary Mesh Container" section earlier in this chapter. To refresh your memory about how to update the frame hierarchy, review the "Updating the Hierarchy" section earlier in this chapter. After you're sure of these two things, you can continue.

To update the skinned mesh, you must first lock the vertex buffers of the skinned mesh and the secondary mesh. This is critical because DirectX will pull the vertex data from the skinned mesh object, apply the bone transformations, and write the resulting vertex data to the secondary mesh object.

First, though, you need to copy the transformations from the frames to the array of matrices(pBoneMatrices) stored in the mesh container. At the same time, you have to combine the transformations  with the bones' inversed transformations. The inversed bone transformations are responsible for moving the mesh's vertices to the origin of the mesh before you apply the actual transformation. To better understand this, take a look at Figure 4.4

The mesh in Figure 4.4 is composed of three bones (frames) and a number of vertices. To apply a transformation to any frame, you must move the vertices belonging to the frame to the origin and then apply the transformations.

You move the vertices around the origin of the mesh before you apply a transformation because a rotation matrix simply rotates vertices around an origin. If you were to rotate a vertex belonging to any bone, the vertex would rotate around the origin of the mesh instead of the bone's joint. For example, if your body was a mesh and you bent your elbow, the vertices constructing your arm's mesh would rotate around your elbow, not the center of your body. After the vertices are moved to the center of the mesh, the transformation is applied (thus rotating the vertices to match the rotation of the bone) and finally translated into position.

Normally, these inversed bone transformations are stored in the .X file by the 3D modeler used to create the meshes. If you don't have access to this information from an .X file, you can compute it yourself by first updating the frame hierarchy, and then inverting each frame's combined transformation using the D3DXMatrixInverse function. Here's a quick example.

// pRoot = root D3DXFRAME_EX object
// pMesh = D3DXMESHCONTAINER_EX object w/mesh data
// Update the frame hierarchy
pRoot−>UpdateHierarchy();
// Go through each bone and calculate the inverse
for(DWORD i=0;i<NumBones;i++)
{
// Grab the transformation using the bone matrix
D3DXMATRIX matBone = (*pMesh−>ppFrameMatrices);
	// Invert the matrix
D3DXMatrixInverse(&matBone, NULL, &matBone);
	// Store the inversed bone transformation somewhere
}

Instead of going through all the trouble of calculating the inversed bone transformations yourself, however, you can rely on the skinned mesh object to supply that information. By calling ID3DXSkinInfo::GetBoneOffsetMatrix, you'll get the inversed bone transformation matrix pointer. Multiply this matrix by a frame transformation matrix, and you're set!

Using what you just learned, iterate through all the bones, grab the inversed bone transformation, combine it with the frame transformation, and store the result in the pBoneMatrices array.

for(DWORD i=0;i<pSkinInfo−>GetNumBones();i++) 
{
// Set the inversed bone transformation
pMesh−>pBoneMatrices[i]=(*pSkinInfo−>GetBoneOffsetMatrix(i));
	// Apply frame transformation
if(pMesh−>ppFrameMatrices[i])
pMesh−>pBoneMatrices[i] *= (*pMesh−>ppFrameMatrices[i]);
}

Now that you've copied the bones' transformations into the pBoneMatrices array, you can move on to updating the skinned mesh by first locking the vertex buffers for the skinned mesh and the secondary mesh.

// pSkinMesh = skinned mesh container
// pMesh = secondary mesh container

// Lock the meshes' vertex buffers
void *SrcPtr, *DestPtr;

pSkinMesh−>LockVertexBuffer(D3DLOCK_READONLY,(void**)&SrcPtr);
pMesh−>LockVertexBuffer(0, (void**)&DestPtr);

After you lock the vertex buffers, you need to perform a call to ID3DXSkinInfo::UpdateSkinnedMesh to apply all the bones' transformations to the vertices and write the resulting data to the secondary mesh container.

Applies software skinning to the target vertices based on the current matrices.

HRESULT UpdateSkinnedMesh(
CONST D3DXMATRIX * pBoneTransforms,
CONST D3DXMATRIX * pBoneInvTransposeTransforms,
LPCVOID pVerticesSrc,
PVOID pVerticesDst
);

Parameters

pBoneTransforms
[in] Bone transform matrix.
pBoneInvTransposeTransforms
[in] Inverse transpose of the bone transform matrix.
pVerticesSrc
[in] Pointer to the buffer containing the source vertices.
pVerticesDst
[in] Pointer to the buffer containing the destination vertices.

Return Values

If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be D3DERR_INVALIDCALL.

Remarks

When used to skin vertices with two position elements, this method skins the second position element with the inverse of the bone instead of the bone itself.

To finish, you simply unlock the vertex buffers, and you're ready to render!

// pSkinInfo = skinned mesh info object

// Update the skinned mesh using provided transformations
pSkinInfo−>UpdateSkinnedMesh(pBoneMatrices, NULL, SrcPtr, DestPtr);

// Unlock the meshes vertex buffers
pSkinMesh−>UnlockVertexBuffer();
pMesh−>UnlockVertexBuffer();

 

Rendering the Skinned Mesh

Now comes the good part−rendering your secondary mesh and showing the world what it's like to play with powerthe power of skeletal animation and skinned meshes, that is. You only need to depend on the typical mesh−rendering functions to render the secondary mesh. Loop through each material, set the material and texture, and call the ID3DXMesh::DrawSubset function. Loop and continue until all of the subsets have been drawn.

// pMesh = D3DXMESHCONTAINER_EX object with material data
// pMeshToDraw = secondary mesh pointer to render
for(DWORD i=0;i<pMesh−>NumMaterials;i++)
{
// Set material and texture
pD3DDevice−>SetMaterial(&pMesh−>pMaterials[i].MatD3D);
pD3DDevice−>SetTexture(0, pMesh−>pTextures[i]);
	// Draw the mesh subset
pMeshToDraw−>DrawSubset(i);
}

posted on 2008-04-23 20:06 lovedday 閱讀(478) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導航

統計

常用鏈接

隨筆分類(178)

3D游戲編程相關鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            久久人人爽人人| 国产精品青草综合久久久久99 | 日韩视频在线一区二区| 欧美区日韩区| 亚洲专区在线| 亚欧成人精品| 在线观看精品视频| 亚洲国产欧美国产综合一区| 久久亚洲不卡| 中日韩高清电影网| 亚洲综合电影| 在线免费精品视频| 亚洲国产精品成人一区二区| 欧美午夜激情小视频| 欧美一区二区三区电影在线观看| 久久aⅴ国产紧身牛仔裤| 91久久极品少妇xxxxⅹ软件| 一本高清dvd不卡在线观看| 国产日韩欧美精品综合| 欧美高清在线一区| 国产精品a级| 久久综合精品国产一区二区三区| 欧美黄色免费| 久久av资源网站| 美女视频黄a大片欧美| 亚洲性人人天天夜夜摸| 亚洲欧美另类久久久精品2019| 在线成人激情视频| 夜夜爽夜夜爽精品视频| 国产一区二区精品在线观看| 亚洲国产精品va在线观看黑人| 国产精品免费电影| 欧美黄色aaaa| 国产精品自拍网站| 亚洲国产导航| 国产精一区二区三区| 欧美激情在线狂野欧美精品| 欧美一级午夜免费电影| 欧美中文在线视频| 亚洲色图自拍| 久久人91精品久久久久久不卡| 亚洲天堂第二页| 久久久久久久一区| 亚洲欧美视频在线观看视频| 免费的成人av| 久久精品国产亚洲精品| 欧美日韩国产不卡| 老司机一区二区| 国产精品视频自拍| 亚洲国产欧美日韩精品| 国内精品写真在线观看| 99精品热视频| 最新国产乱人伦偷精品免费网站| 亚洲一级二级| av成人福利| 麻豆精品91| 久久精品国产91精品亚洲| 欧美日韩午夜| 欧美激情中文字幕乱码免费| 国产亚洲精品久久久久久| 99香蕉国产精品偷在线观看| 亚洲黄色三级| 久久久国产精品一区二区中文| 亚洲欧美视频在线观看视频| 欧美另类视频在线| 欧美成人午夜影院| 国模精品娜娜一二三区| 亚洲一级在线观看| 一区二区欧美精品| 男人的天堂亚洲在线| 久久久久国产精品厨房| 国产精品欧美久久| 99riav1国产精品视频| 亚洲精品孕妇| 美女91精品| 久久视频一区| 国产一区二区高清不卡| 亚洲欧美日韩精品综合在线观看 | 夜夜嗨av一区二区三区| 久久综合给合久久狠狠狠97色69| 久久国产精品99精品国产| 国产精品成人观看视频免费| 亚洲久久在线| 日韩天堂在线视频| 蜜桃av噜噜一区| 美女网站久久| 好吊成人免视频| 欧美一区=区| 欧美一区二区女人| 国产精品成人一区二区三区夜夜夜 | 亚洲国产精品激情在线观看| 美女主播一区| 国产综合视频在线观看| 亚洲综合日韩在线| 亚洲欧美日韩国产中文| 国产精品v片在线观看不卡 | 亚洲一区二区三区中文字幕 | 麻豆久久婷婷| 麻豆91精品| 激情亚洲网站| 久久夜色精品国产亚洲aⅴ| 噜噜噜噜噜久久久久久91| 狠狠色2019综合网| 欧美在线播放一区二区| 久久久久国色av免费观看性色| 国产欧美精品久久| 午夜视黄欧洲亚洲| 亚洲欧美影院| 国产日韩欧美一区在线| 香蕉视频成人在线观看 | 国产欧美日韩亚洲一区二区三区| 亚洲一区二区三| 香蕉久久国产| 国产亚洲精品久久久久久| 久久国产精品久久精品国产| 老**午夜毛片一区二区三区| 亚洲电影免费观看高清完整版| 美女主播精品视频一二三四| 亚洲国产清纯| 国产精品99久久久久久久女警 | 国产亚洲成人一区| 久久精品视频在线看| 暖暖成人免费视频| 亚洲精品国产系列| 欧美日韩午夜激情| 亚洲欧美日韩成人高清在线一区| 久久国产福利| 亚洲高清不卡一区| 欧美伦理视频网站| 亚洲视频欧洲视频| 久久精品免费| 亚洲国产精品va| 欧美日本乱大交xxxxx| 亚洲一区999| 久久偷看各类wc女厕嘘嘘偷窃| 亚洲第一精品福利| 欧美日韩1区| 亚洲欧美一区二区视频| 久久亚洲精品欧美| 亚洲美女视频在线观看| 国产精品分类| 久久久久久国产精品一区| 欧美激情一区在线| 亚洲欧美国产精品va在线观看 | 国产精品久久久久久久午夜| 午夜在线a亚洲v天堂网2018| 男女视频一区二区| 宅男噜噜噜66一区二区| 国产精品一区久久久| 久久综合亚洲社区| 1204国产成人精品视频| 久久国产精品72免费观看| 欧美激情一区二区三区成人| 亚洲免费网站| 在线观看日韩专区| 欧美日韩在线免费| 久久福利电影| 日韩视频免费看| 久久乐国产精品| 亚洲免费高清视频| 国产欧美精品一区| 欧美国产精品劲爆| 亚洲欧美日韩网| 亚洲激情第一区| 欧美制服丝袜| 亚洲精选视频免费看| 国产精品日韩精品欧美精品| 久久一区二区三区四区五区| 99精品欧美| 欧美成人三级在线| 午夜亚洲福利| 日韩亚洲一区在线播放| 国产麻豆精品在线观看| 欧美国产日韩一区| 欧美一区视频| 99精品视频免费观看视频| 快she精品国产999| 亚洲欧美日韩系列| 亚洲人在线视频| 国产亚洲欧美日韩美女| 欧美日韩亚洲综合在线| 久久男女视频| 午夜在线视频观看日韩17c| 最新成人在线| 免费看亚洲片| 久久国产日韩| 亚洲一区二区三区国产| 亚洲欧洲日本在线| 国际精品欧美精品| 国产精品xxx在线观看www| 欧美77777| 久久久噜噜噜久久人人看| 亚洲午夜电影网| 亚洲精品视频免费| 欧美韩日亚洲| 免费观看成人| 久久精品在线视频| 性欧美办公室18xxxxhd| 亚洲视频在线免费观看| 亚洲精品久久久久久下一站 |