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

天行健 君子當自強而不息

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>
            欧美日韩一区成人| 中文av一区二区| 欧美成人综合网站| 老司机午夜精品| 欧美freesex8一10精品| 牛牛精品成人免费视频| 美女日韩在线中文字幕| 欧美电影免费观看高清完整版| 欧美肉体xxxx裸体137大胆| 欧美日韩福利视频| 麻豆av一区二区三区久久| 在线亚洲伦理| 欧美精品在线视频观看| 久久女同互慰一区二区三区| 久久久国产成人精品| 欧美国产视频在线观看| 国产精品国产三级国产专播品爱网 | 先锋亚洲精品| 久久欧美肥婆一二区| 亚洲经典在线| 亚洲三级电影在线观看| 亚洲一区视频在线观看视频| 久久久精品免费视频| 欧美日韩国产成人在线观看| 国内精品美女在线观看| 久久er精品视频| 久久精品国产亚洲一区二区| 亚洲免费观看在线观看| 欧美日韩综合在线| 国产一区二区在线观看免费播放 | 美女视频黄a大片欧美| 久久夜色撩人精品| 99综合在线| 久久夜色精品国产| 国产精品久久久久毛片大屁完整版| 亚洲大胆视频| 久久久www| 亚洲欧美国产高清| 欧美日韩免费一区二区三区视频| 黄色亚洲在线| 欧美一区二区精品久久911| 亚洲精品一区二区网址| 麻豆精品精华液| 伊人一区二区三区久久精品| 欧美一区在线直播| 一区二区三区av| 欧美日韩国产综合视频在线观看| 在线观看日韩精品| 久久精品国内一区二区三区| 日韩视频在线一区二区三区| 欧美激情一区二区三区成人| 亚洲国产另类 国产精品国产免费| 久久国产精彩视频| 先锋影音国产精品| 午夜国产欧美理论在线播放 | 久久婷婷国产综合国色天香| 99热精品在线观看| 欧美精品成人| 一区二区成人精品| 亚洲日本一区二区三区| 久久久精品2019中文字幕神马| 国产日韩一区二区三区在线播放| 亚洲欧美卡通另类91av| 亚洲视频你懂的| 国产乱码精品一区二区三区五月婷| 亚洲午夜精品一区二区三区他趣| 日韩香蕉视频| 国产精品久久久久久久app| 亚洲一本大道在线| 一区二区激情视频| 国产视频久久久久| 亚洲国产日韩欧美在线动漫| 久久香蕉国产线看观看网| 欧美一区二区三区四区在线| 韩国三级在线一区| 亚洲大胆人体在线| 欧美日韩免费高清一区色橹橹| 亚洲婷婷国产精品电影人久久| 一区二区三区久久精品| 国产乱码精品| 欧美韩国一区| 国产精品久久77777| 久久久91精品国产一区二区三区| 久久久久九九九九| 99v久久综合狠狠综合久久| 一区二区精品在线| 国产综合自拍| 亚洲欧洲偷拍精品| 国产日韩欧美高清免费| 另类综合日韩欧美亚洲| 欧美久久成人| 久久福利视频导航| 欧美激情片在线观看| 亚洲欧美在线aaa| 老牛影视一区二区三区| 在线一区二区三区四区五区| 欧美一区二区在线免费播放| 亚洲伦伦在线| 久久成人18免费网站| av成人免费观看| 午夜激情综合网| 亚洲精品美女91| 欧美一区二区日韩一区二区| 一本色道久久综合亚洲二区三区| 欧美一区日韩一区| 亚洲视频在线观看一区| 久久亚洲欧洲| 久久www成人_看片免费不卡| 欧美精品一线| 欧美韩日亚洲| 伊人成人开心激情综合网| 亚洲一品av免费观看| 91久久国产综合久久91精品网站| 午夜激情一区| 欧美与欧洲交xxxx免费观看| 亚洲国产mv| 狠狠色丁香婷婷综合久久片| 亚洲一区一卡| 免费中文字幕日韩欧美| 久久精品99国产精品日本| 欧美日韩国产美女| 亚洲国产精品精华液网站| 国产亚洲激情视频在线| 日韩一级黄色av| 日韩一级二级三级| 欧美成人精品一区二区三区| 麻豆成人小视频| 国语对白精品一区二区| 午夜精品久久久久| 性欧美1819性猛交| 欧美日韩免费观看中文| 亚洲日本中文| 99精品99久久久久久宅男| 免费观看一区| 久久婷婷麻豆| 好吊一区二区三区| 久久国产精品久久国产精品| 久久爱www久久做| 国产毛片精品国产一区二区三区| 亚洲图片自拍偷拍| 亚洲欧美日韩综合| 国产精品视频999| 亚洲一区三区视频在线观看| 亚洲欧美国产日韩天堂区| 欧美午夜免费| 亚洲色图制服丝袜| 久久精品导航| 在线播放中文一区| 欧美aaa级| 日韩一级在线观看| 香蕉久久夜色| 伊人色综合久久天天五月婷| 免费av成人在线| 亚洲理伦在线| 欧美在线观看视频一区二区三区 | 亚洲精品欧洲精品| 久久一区精品| 91久久国产精品91久久性色| 欧美激情亚洲另类| 亚洲在线不卡| 牛人盗摄一区二区三区视频| 亚洲狼人精品一区二区三区| 国产精品h在线观看| 午夜亚洲性色视频| 欧美激情在线狂野欧美精品| 中日韩视频在线观看| 国产欧美日韩亚洲一区二区三区| 久久久精品免费视频| 日韩一级在线观看| 蜜臀av性久久久久蜜臀aⅴ| 91久久在线观看| 国产精品一区二区久久| 久热re这里精品视频在线6| 日韩一区二区精品| 欧美成人精品不卡视频在线观看 | 久久久噜久噜久久综合| 亚洲免费观看| 国产亚洲欧美在线| 欧美日韩成人| 久久久中精品2020中文| 日韩视频不卡| 经典三级久久| 午夜在线一区| 日韩视频久久| 免费观看成人| 亚洲欧美日韩区| 亚洲人成7777| 国外成人在线| 国产欧美亚洲精品| 欧美日韩视频不卡| 你懂的网址国产 欧美| 性色av一区二区三区| 亚洲精品永久免费精品| 久久综合一区| 久久激情五月丁香伊人| 亚洲欧美视频| 亚洲欧美不卡| 亚洲午夜在线观看| 夜夜爽www精品| 日韩视频免费观看|