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

天行健 君子當自強而不息

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亚洲一区二区| 中文一区二区在线观看| 欧美一区二区三区喷汁尤物| 亚洲福利视频网| 欧美激情第10页| 亚洲日本va午夜在线影院| 亚洲免费av电影| 欧美一区二区精品| 欧美国产日韩一区二区在线观看| 欧美视频网站| 亚洲第一视频网站| 亚洲字幕在线观看| 欧美国产先锋| 亚洲一区欧美激情| 麻豆精品网站| 国产精品免费视频xxxx| 亚洲电影免费在线观看| 亚洲午夜一区二区| 乱码第一页成人| 一区二区91| 欧美jjzz| 极品尤物一区二区三区| 一区二区三区欧美视频| 久久综合伊人| 国产精品99久久99久久久二8| 久久久久国产精品一区| 国产精品久久久| 亚洲人在线视频| 久久久噜噜噜久久狠狠50岁| 日韩视频二区| 欧美大片在线影院| 国内精品久久久久影院优| 亚洲手机在线| 亚洲福利久久| 久久亚洲综合色| 国产一区二区三区在线观看网站 | 欧美激情一区二区三区在线视频观看 | 亚洲人成毛片在线播放| 欧美一级视频| 亚洲天堂av在线免费| 欧美 日韩 国产 一区| 国产精品一区二区欧美| 亚洲性夜色噜噜噜7777| 亚洲国产精品一区二区尤物区| 久久av资源网站| 国产亚洲综合精品| 久久av红桃一区二区小说| 亚洲一本视频| 国产毛片久久| 久久免费精品视频| 久久精品一区蜜桃臀影院| 国产精品久久久久aaaa樱花| 在线综合亚洲欧美在线视频| 亚洲高清视频在线| 免费一区视频| 99re国产精品| 99一区二区| 亚洲乱码国产乱码精品精可以看 | 蜜桃av一区二区| 久久精品在线| 在线免费高清一区二区三区| 久久夜色精品国产欧美乱| 欧美在线亚洲在线| 在线观看91精品国产麻豆| 蜜桃久久av一区| 免费中文字幕日韩欧美| 99v久久综合狠狠综合久久| 亚洲精品色婷婷福利天堂| 欧美日韩精品一区视频| 亚洲欧美在线aaa| 欧美在线电影| 亚洲国产精品尤物yw在线观看| 欧美护士18xxxxhd| 欧美性猛交xxxx乱大交退制版 | 午夜日韩在线观看| 欧美在线观看视频一区二区| 怡红院精品视频| 亚洲精品永久免费| 国产日韩欧美夫妻视频在线观看| 浪潮色综合久久天堂| 欧美乱大交xxxxx| 久久av一区二区三区| 欧美91大片| 久久国产视频网| 欧美精品在线一区二区| 久久精品国产96久久久香蕉| 蜜臀av国产精品久久久久| 亚洲午夜视频在线观看| 久久九九精品| 亚洲在线1234| 久久综合久久久久88| 亚洲一区二区在线免费观看| 久久精品国产视频| 亚洲专区在线视频| 免费不卡亚洲欧美| 久久岛国电影| 国产精品爱久久久久久久| 欧美国产欧美综合| 国产一区二区三区自拍| 亚洲天堂网在线观看| 亚洲人体1000| 老司机精品视频一区二区三区| 亚洲一区二区影院| 欧美国产精品中文字幕| 久久成人免费电影| 国产精品va在线播放我和闺蜜| 欧美电影在线观看完整版| 国产精品一二| 9i看片成人免费高清| 91久久精品一区二区别| 欧美在线视频一区二区| 亚洲自拍偷拍麻豆| 欧美屁股在线| 亚洲第一福利社区| 一区二区三区在线不卡| 亚洲欧美日韩综合国产aⅴ| 一本一道久久综合狠狠老精东影业| 欧美午夜影院| 欧美黑人一区二区三区| 国产在线高清精品| 99re热这里只有精品免费视频| 亚洲国产精品久久精品怡红院| 亚洲男人的天堂在线aⅴ视频| 在线亚洲+欧美+日本专区| 免费欧美电影| 欧美黄色一区二区| 亚洲国产成人精品视频| 欧美一区在线直播| 久久久亚洲高清| 国产一区二区三区久久久| 亚洲女同在线| 欧美一区二区高清| 国产日韩精品入口| 亚洲一区久久久| 久久国产精品久久久| 国产美女诱惑一区二区| 午夜在线精品偷拍| 久久青青草综合| 亚洲国产aⅴ天堂久久| 欧美aa国产视频| 99re亚洲国产精品| 午夜精品久久久久久99热软件| 国产精品日韩欧美| 欧美在线视频观看| 亚洲高清久久| 亚洲一区二区网站| 国产欧美日韩精品丝袜高跟鞋| 性久久久久久久久久久久| 久久午夜羞羞影院免费观看| 一区二区三区在线视频免费观看| 老司机67194精品线观看| 91久久精品国产91久久性色tv| 一区二区激情视频| 国产一区99| 欧美肥婆在线| 亚洲欧美在线磁力| 女仆av观看一区| 亚洲午夜精品福利| 好吊色欧美一区二区三区四区| 另类天堂视频在线观看| 一本色道久久88综合亚洲精品ⅰ | 久久综合影音| 亚洲精品影视在线观看| 欧美一区二区三区视频在线观看 | 亚洲国产欧美在线| 亚洲尤物视频网| 永久555www成人免费| 欧美日韩亚洲不卡| 久久久久久有精品国产| 99精品视频免费观看| 欧美在线中文字幕| 亚洲免费福利视频| 韩国三级电影久久久久久| 欧美日韩麻豆| 老司机精品视频网站| 午夜视黄欧洲亚洲| 亚洲美女av黄| 欧美激情国产日韩| 欧美在线一级va免费观看| 亚洲精选一区| 在线观看久久av| 亚洲综合好骚| 黄色在线一区| 国产精品久久久久久久免费软件| 欧美在线国产| 亚洲精品国产精品久久清纯直播| 久久激情五月婷婷| 亚洲一区二区三区中文字幕在线| 尤物网精品视频| 国产精品亚洲综合色区韩国| 欧美激情在线有限公司| 久久久久一本一区二区青青蜜月| 一区二区三区精品视频在线观看| 欧美岛国在线观看| 久久亚洲精品一区二区| 欧美在线观看www| 亚洲欧美日韩第一区|