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

天行健 君子當自強而不息

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久久久久久白浆小说| 亚洲精品一区二区三区在线观看| 亚洲综合欧美日韩| 亚洲视频欧美视频| 国产精品一区二区在线观看不卡 | 国产欧美婷婷中文| 久久久久久综合| 欧美91精品| 亚洲一区二区伦理| 欧美一区二区国产| 亚洲精品国精品久久99热| 亚洲精品中文字幕在线| 国产精品毛片一区二区三区| 久久久久9999亚洲精品| 欧美成人官网二区| 欧美一区二区在线看| 久久亚洲精品一区二区| 一本色道久久| 欧美一区二视频| 亚洲久久视频| 亚洲欧美区自拍先锋| 激情亚洲成人| 正在播放亚洲| 亚洲福利国产精品| 亚洲特级毛片| 亚洲激情午夜| 午夜在线视频观看日韩17c| 亚洲国产合集| 欧美一区二区三区在线看| 亚洲国产精品一区二区三区| 亚洲综合电影| av成人免费观看| 久久精品视频va| 亚洲欧美文学| 欧美www视频在线观看| 先锋影音网一区二区| 欧美成人dvd在线视频| 久久精品国亚洲| 欧美日韩在线播放| 欧美福利专区| 国产一区二区三区精品欧美日韩一区二区三区 | 欧美婷婷六月丁香综合色| 久久深夜福利免费观看| 国产精品福利在线观看网址| 亚洲国产欧美不卡在线观看| 国产美女扒开尿口久久久| 欧美日韩黄色大片| 欧美成va人片在线观看| 国产一区二区三区免费不卡 | 欧美一区二区在线免费播放| 亚洲欧美欧美一区二区三区| 欧美国产国产综合| 欧美国产日韩视频| 在线免费观看日韩欧美| 久久成人免费日本黄色| 久久久久久久久蜜桃| 国产欧美日韩激情| 亚洲欧美一区二区三区久久| 亚洲综合视频一区| 国产精品激情| 亚洲自拍高清| 欧美中文字幕在线| 国产欧美午夜| 久久精品国产久精国产思思| 欧美自拍偷拍| 国产亚洲精品一区二区| 久久福利影视| 农夫在线精品视频免费观看| 一色屋精品视频在线观看网站| 欧美在线1区| 美女国产精品| 亚洲人体一区| 欧美日韩一级片在线观看| 日韩一区二区高清| 午夜激情一区| 国产日韩综合一区二区性色av| 亚洲欧美一区二区精品久久久| 久久久久国产免费免费| 黄色成人免费观看| 欧美顶级艳妇交换群宴| 日韩午夜精品| 欧美在线短视频| 精品成人一区二区三区四区| 欧美 亚欧 日韩视频在线| 亚洲欧洲视频| 先锋资源久久| 影音先锋久久资源网| 欧美国产视频在线观看| 亚洲婷婷综合色高清在线| 欧美中文字幕在线视频| 亚洲第一黄色| 欧美不卡福利| 亚洲午夜影视影院在线观看| 久久久噜噜噜久噜久久| 日韩小视频在线观看专区| 国产精品推荐精品| 久久天天狠狠| 99在线精品视频在线观看| 久久久国产亚洲精品| 99v久久综合狠狠综合久久| 国产精品九色蝌蚪自拍| 老鸭窝毛片一区二区三区| 一区二区三区久久网| 久久久噜噜噜久久久| 妖精成人www高清在线观看| 国产三级精品在线不卡| 蘑菇福利视频一区播放| 香蕉久久国产| 日韩亚洲国产欧美| 巨胸喷奶水www久久久免费动漫| 中文精品视频一区二区在线观看| 国产亚洲美州欧州综合国| 欧美日韩国产精品自在自线| 久久久久久网| 亚洲小说区图片区| 亚洲伦理精品| 亚洲电影免费观看高清完整版在线观看 | 亚洲一区二区精品在线观看| 依依成人综合视频| 国产精品久久久久久久浪潮网站| 美女国内精品自产拍在线播放| 亚洲欧美日韩第一区| 亚洲精品永久免费| 欧美国产日韩在线| 久久综合色婷婷| 久久成人久久爱| 午夜精品理论片| 在线综合亚洲| 亚洲毛片播放| 91久久午夜| 1000精品久久久久久久久| 国产欧美精品久久| 国产精品区二区三区日本| 欧美日韩精品免费观看视频完整 | 亚洲午夜精品久久久久久app| 亚洲国产精品成人综合色在线婷婷| 久久久爽爽爽美女图片| 午夜欧美不卡精品aaaaa| 亚洲在线视频一区| 亚洲一区高清| 性欧美暴力猛交69hd| 午夜久久电影网| 午夜激情综合网| 午夜在线播放视频欧美| 亚洲一区在线免费| 亚洲欧美综合v| 久久国产一区二区三区| 久久久www成人免费毛片麻豆| 久久久国产成人精品| 久久漫画官网| 欧美大片在线观看| 亚洲欧洲视频| 一区二区三区视频在线看| 亚洲婷婷在线| 久久国产精品久久w女人spa| 久久久久久久91| 免费高清在线一区| 欧美国产日韩免费| 国产精品国色综合久久| 国产精品视频免费| 精品成人在线观看| 日韩视频一区| 亚洲欧洲av一区二区三区久久| 欧美一站二站| 蜜桃av一区| 日韩亚洲视频| 小处雏高清一区二区三区| 久久久久国色av免费观看性色| 免费一级欧美在线大片| 欧美日韩在线免费| 国内精品免费午夜毛片| 最新国产拍偷乱拍精品| 亚洲自拍另类| 欧美成人性生活| 国产精品99久久久久久久久| 久久精品九九| 欧美三级欧美一级| 韩国v欧美v日本v亚洲v| 日韩视频三区| 久久先锋资源| 在线一区视频| 噜噜噜91成人网| 国产精品亚洲视频| 亚洲精品中文字幕在线观看| 香蕉av福利精品导航| 欧美激情国产精品| 欧美一区综合| 欧美午夜精品久久久久久浪潮| 极品尤物一区二区三区| 亚洲午夜一区二区| 欧美激情精品久久久久久| 午夜精品影院| 欧美视频四区| 亚洲精品乱码久久久久久蜜桃91| 久久国产日本精品| 99热免费精品在线观看| 欧美freesex交免费视频| 国产视频久久久久久久| 亚洲一区二区三区777| 亚洲国产日韩在线一区模特|