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

天行健 君子當自強而不息

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 閱讀(476) 評論(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>
            亚洲午夜一二三区视频| 久久国产视频网| 亚洲三级电影全部在线观看高清| 亚洲欧美制服另类日韩| 国产欧美日韩综合一区在线播放 | 久久久久国产一区二区三区| 国产午夜久久| 久久一区国产| 美国十次了思思久久精品导航| 亚洲日本成人网| 日韩午夜在线观看视频| 国产精品网红福利| 久久九九久精品国产免费直播| 久久天天躁狠狠躁夜夜av| 亚洲国产精品成人综合| 亚洲精品一区二区在线| 国产精品美女久久| 久久久久欧美精品| 欧美成人久久| 午夜精品在线| 麻豆av福利av久久av| 一区二区三区精品视频在线观看| 亚洲在线免费视频| 亚洲成色999久久网站| 亚洲美女啪啪| 国产主播一区二区| 亚洲七七久久综合桃花剧情介绍| 国产精品久久久久久久浪潮网站| 久久久亚洲午夜电影| 欧美激情在线播放| 欧美制服丝袜第一页| 免费在线观看日韩欧美| 午夜在线一区| 欧美国产欧美亚洲国产日韩mv天天看完整 | 日韩天堂av| 国产日韩av高清| 最近中文字幕日韩精品 | 亚洲第一级黄色片| 在线亚洲免费视频| 亚洲国产影院| 欧美淫片网站| 欧美一级精品大片| 欧美精品系列| 欧美α欧美αv大片| 国产精品视频第一区| 亚洲欧洲精品成人久久奇米网| 国产日韩欧美一二三区| 日韩午夜视频在线观看| 亚洲激情在线播放| 久久高清国产| 久久精品国语| 国产精品专区一| 亚洲人体影院| 亚洲黄色成人| 久久久久久亚洲综合影院红桃 | 亚洲精品乱码久久久久久日本蜜臀 | 久久国产一区二区三区| 欧美日韩精品高清| 亚洲国产精品一区| 亚洲国产精品ⅴa在线观看| 午夜精品影院| 欧美制服丝袜第一页| 国产精品久久国产三级国电话系列| 欧美国产欧美亚洲国产日韩mv天天看完整| 国产美女精品视频免费观看| 日韩一级大片| 亚洲天堂视频在线观看| 欧美日本不卡高清| 亚洲国产1区| 亚洲精品国产精品国自产在线 | 国产精品久久久久免费a∨| 亚洲人在线视频| 中文亚洲免费| 欧美性猛交视频| 亚洲视频在线播放| 欧美夜福利tv在线| 国产日韩在线一区| 欧美一区二区三区精品| 久久久久久久久久久一区 | 国产精品一区一区三区| 亚洲女同同性videoxma| 久久精品综合网| 在线免费观看成人网| 美女国内精品自产拍在线播放| 欧美激情一区二区三区全黄 | 伊人成人开心激情综合网| 久久久天天操| 最新国产成人av网站网址麻豆| 99国产一区| 国产精品美女在线| 久久精品女人的天堂av| 亚洲国产精品成人| 中文在线资源观看视频网站免费不卡| 欧美日韩在线视频一区| 欧美亚洲日本网站| 久久永久免费| 在线视频欧美一区| 国内揄拍国内精品少妇国语| 久久这里有精品视频 | 欧美在线地址| 亚洲福利在线看| 欧美日本一区二区视频在线观看| 亚洲一区二区三区精品视频| 久久久久久有精品国产| 99精品国产在热久久下载| 国产精品一卡二| 榴莲视频成人在线观看| 一本色道久久综合亚洲二区三区 | 欧美与黑人午夜性猛交久久久| 在线日韩电影| 国产精品日韩欧美一区| 模特精品在线| 欧美在线视频播放| 亚洲伦理久久| 欧美大片免费| 久久福利视频导航| 亚洲性线免费观看视频成熟| 激情久久久久久久| 国产精品毛片大码女人| 欧美高清在线播放| 久久激情视频久久| 亚洲一区二区三区四区在线观看| 欧美成人伊人久久综合网| 午夜精品久久久久影视| 日韩视频免费| 亚洲激情图片小说视频| 国产日韩久久| 国产精品影片在线观看| 欧美日韩一区二区国产| 女同一区二区| 麻豆精品视频| 久久久精品国产免大香伊| 亚洲午夜久久久久久尤物| 99视频一区| 日韩视频―中文字幕| 亚洲黑丝一区二区| 欧美黄色aa电影| 欧美v国产在线一区二区三区| 久久精品国产欧美激情| 性做久久久久久久免费看| 亚洲综合不卡| 亚洲欧美在线一区二区| 亚洲欧美美女| 新67194成人永久网站| 亚洲免费影视| 欧美一级大片在线免费观看| 午夜精品久久久久99热蜜桃导演| 亚洲在线中文字幕| 午夜精品区一区二区三| 午夜欧美不卡精品aaaaa| 欧美亚洲系列| 久久久99精品免费观看不卡| 久久久久国产一区二区三区四区| 欧美在线免费观看亚洲| 久久精品72免费观看| 久久国产乱子精品免费女 | 午夜日韩在线观看| 欧美亚洲一区三区| 久久久福利视频| 免费人成网站在线观看欧美高清| 免费在线成人av| 亚洲老板91色精品久久| 一区二区三区黄色| 亚洲综合精品四区| 久久精品99国产精品| 男人天堂欧美日韩| 欧美日韩精品免费看| 欧美体内she精视频| 国产欧美精品日韩| 1000精品久久久久久久久| 9久草视频在线视频精品| 亚洲自拍偷拍麻豆| 蜜桃精品一区二区三区 | 久久久久国产精品一区三寸 | 欧美一区亚洲二区| 欧美aa在线视频| av成人动漫| 久久深夜福利| 欧美视频在线视频| 狠狠色噜噜狠狠色综合久| 亚洲伦理自拍| 久久久国产91| 亚洲美女黄网| 久久精品亚洲热| 欧美日韩亚洲视频| 在线观看国产日韩| 亚洲综合日本| 欧美成人精品高清在线播放| 一区二区三区 在线观看视频| 久久狠狠婷婷| 国产精品区免费视频| 最新国产成人在线观看| 校园春色综合网| 亚洲日本中文字幕| 久久精品综合网| 国产精品视频xxxx| 中日韩男男gay无套| 欧美成va人片在线观看| 欧美亚洲视频在线观看| 欧美日韩在线视频一区二区|