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

天行健 君子當自強而不息

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 閱讀(464) 評論(0)  編輯 收藏 引用

公告

導航

統計

常用鏈接

隨筆分類(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| 亚洲综合首页| 亚洲综合视频在线| 欧美在线视频在线播放完整版免费观看 | 久久米奇亚洲| 久久理论片午夜琪琪电影网| 欧美专区一区二区三区| 久久精品国产99精品国产亚洲性色| 欧美专区18| 欧美高清在线一区| 国产精品第一区| 国产亚洲欧美一区在线观看 | 日韩一级网站| 亚洲在线一区| 麻豆国产va免费精品高清在线| 牛牛影视久久网| 亚洲国产综合在线看不卡| 亚洲国产专区校园欧美| 亚洲视频播放| 久久一区视频| 国产精品免费在线| 亚洲福利小视频| 亚洲国产婷婷香蕉久久久久久| 欧美国产日韩二区| 亚洲一区二区三区成人在线视频精品| 欧美.www| 亚洲视频电影在线| 蜜桃伊人久久| 国产欧美日韩另类视频免费观看| 亚洲大胆av| 欧美一区高清| 91久久夜色精品国产网站| 亚洲永久在线| 欧美精品一线| 黄色精品一区二区| 亚洲欧美日韩精品久久奇米色影视 | 久久国产精品黑丝| 欧美日韩亚洲视频| 久久精品一区二区国产| 亚洲看片一区| 久久亚洲不卡| 亚洲在线观看视频网站| 欧美黑人国产人伦爽爽爽| 国产喷白浆一区二区三区| 一本久道久久久| 亚洲国产成人久久综合一区| 欧美一区二区三区在线观看 | 欧美大片免费久久精品三p| 国产精品久线观看视频| 亚洲视频你懂的| 亚洲韩国精品一区| 欧美一区二区三区成人| 国产精品人人爽人人做我的可爱| 一道本一区二区| 亚洲国内在线| 欧美激情精品| 亚洲精品美女91| 欧美成人第一页| 免费成人高清视频| 亚洲欧洲精品一区二区三区波多野1战4 | 久久久五月婷婷| 国产日韩欧美亚洲| 久久久久久97三级| 欧美一区三区二区在线观看| 国产偷国产偷亚洲高清97cao| 亚洲欧美日韩综合aⅴ视频| 日韩一区二区精品在线观看| 欧美激情a∨在线视频播放| 999亚洲国产精| 亚洲欧洲综合另类| 欧美激情综合网| 一区二区动漫| 亚洲一区二区三区四区中文 | 欧美性大战久久久久| 亚洲视频一区在线观看| 国产精品99久久久久久久vr| 欧美特黄一级大片| 国产欧美精品在线| 欧美在线免费看| 欧美在线关看| 亚洲韩国精品一区| 亚洲精品在线免费| 国产老女人精品毛片久久| 久久亚洲春色中文字幕久久久| 久久精品水蜜桃av综合天堂| 亚洲第一主播视频| 亚洲精品网站在线播放gif| 国产精品麻豆欧美日韩ww | 亚洲国产视频一区| 亚洲精选视频免费看| 国产区在线观看成人精品| 欧美高清视频一区二区| 欧美日韩免费区域视频在线观看| 亚洲视频网站在线观看| 午夜伦欧美伦电影理论片| 欧美成人精品| 亚洲视频视频在线| 久久久久久久91| 国产精品99久久久久久白浆小说 | 久久大逼视频| 亚洲精品1区| 亚洲尤物在线视频观看| 好男人免费精品视频| 亚洲狼人综合| 在线精品亚洲| 午夜在线精品偷拍| 一本色道久久综合亚洲二区三区| 午夜精品亚洲| 一区二区三区不卡视频在线观看| 久久aⅴ国产欧美74aaa| 亚洲综合国产激情另类一区| 久久中文字幕导航| 国精品一区二区三区| 亚洲精品一线二线三线无人区| 国产日产高清欧美一区二区三区| 欧美激情亚洲综合一区| 国内外成人免费激情在线视频| 日韩一级网站| 99热免费精品| 欧美激情精品久久久久久| 嫩草国产精品入口| 国产视频亚洲| 亚洲综合精品自拍| 亚洲免费婷婷| 欧美日韩午夜视频在线观看| 亚洲国产精品日韩| 亚洲国产精彩中文乱码av在线播放| 午夜欧美电影在线观看| 亚洲欧美日韩视频一区| 欧美日韩成人一区二区三区| 欧美成人免费va影院高清| 欧美激情一区二区三区不卡| 国产在线视频不卡二| 亚洲免费在线观看| 午夜日韩电影| 国产精品一区久久| 性色av一区二区三区| 欧美一区二区三区在线播放| 欧美日韩免费区域视频在线观看| 91久久综合| 99精品视频免费观看| 欧美日产一区二区三区在线观看| 欧美国产精品v| 亚洲欧洲视频在线| 欧美国产日韩a欧美在线观看| 欧美激情一区二区三区在线 | 极品av少妇一区二区| 久久国产精品久久久久久| 久久九九久精品国产免费直播| 国产曰批免费观看久久久| 欧美一区二区视频97| 久久久亚洲高清| 黄色一区二区在线| 卡一卡二国产精品| 亚洲国产一区二区精品专区| 亚洲欧美日韩精品综合在线观看| 亚洲一二三四区| 欧美承认网站| 亚洲美洲欧洲综合国产一区| 中文一区二区在线观看| 国产精品素人视频| 六十路精品视频| 亚洲精品视频啊美女在线直播| 亚洲视频碰碰| 国产综合久久久久影院| 欧美aⅴ一区二区三区视频| 一本久久青青| 久久国产综合精品| 亚洲欧洲日产国产网站| 欧美三级免费| 久久精品道一区二区三区| 亚洲精品日产精品乱码不卡| 午夜视频一区在线观看| 黄色精品免费| 欧美日韩日本视频| 久久久爽爽爽美女图片| 日韩视频二区| 老色批av在线精品| 亚洲视频axxx| 亚洲高清一区二| 国产精品日韩高清| 欧美成年人网| 欧美一区二区三区精品 | 久久免费视频在线观看| 亚洲精一区二区三区| 国产一区亚洲| 欧美日韩蜜桃| 久久久久女教师免费一区| 夜夜狂射影院欧美极品| 欧美a级一区| 欧美在线观看网站| 夜夜嗨av色一区二区不卡| 国产欧美一区二区三区国产幕精品| 欧美精品 日韩| 久久久午夜电影| 午夜久久影院| 亚洲午夜高清视频|