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

天行健 君子當自強而不息

Working with skeletal animation(5)

Loading Skinned Meshes from .X

Loading a skinned mesh from an .X file is much like loading a standard mesh. Using a custom .X parser, you must enumerate your .X file objects using ParseObject. When it comes to processing a Mesh object, instead of calling the D3DXLoadMeshFromXof function to load the mesh data, you call the D3DXLoadSkinMeshFromXof function, which takes one additional parameter−a pointer to an ID3DXSkinInfo object. Check out the D3DXLoadSkinMeshFromXof prototype to see what I mean.

Loads a skin mesh from a DirectX .x file data object.

HRESULT D3DXLoadSkinMeshFromXof(
LPD3DXFILEDATA pxofMesh,
DWORD Options,
LPDIRECT3DDEVICE9 pD3DDevice,
LPD3DXBUFFER * ppAdjacency,
LPD3DXBUFFER * ppMaterials,
LPD3DXBUFFER * ppEffectInstances,
DWORD * pMatOut,
LPD3DXSKININFO * ppSkinInfo,
LPD3DXMESH * ppMesh
);

Parameters

pxofMesh
[in] Pointer to an ID3DXFileData interface, representing the file data object to load.
Options
[in] Combination of one or more flags, from the D3DXMESH enumeration, specifying creation options for the mesh.
pD3DDevice
[in] Pointer to an IDirect3DDevice9 interface, the device object associated with the mesh.
ppAdjacency
[out] Address of a pointer to an ID3DXBuffer interface. When this method returns, this parameter is filled with an array of three DWORDs per face that specify the three neighbors for each face in the mesh.
ppMaterials
[out] Address of a pointer to an ID3DXBuffer interface. When the method returns, this parameter is filled with an array of D3DXMATERIAL structures.
ppEffectInstances
[out] Pointer to a buffer containing an array of effect instances, one per attribute group in the returned mesh. An effect instance is a particular instance of state information used to initialize an effect. See D3DXEFFECTINSTANCE. For more information about accessing the buffer, see ID3DXBuffer.
pMatOut
[out] Pointer to the number of D3DXMATERIAL structures in the ppMaterials array, when the method returns.
ppSkinInfo
[out] Address of a pointer to an ID3DXSkinInfo interface, which represents the skinning information.
ppMesh
[out] Address of a pointer to an ID3DXMesh interface, which represents the loaded mesh.

Return Values

If the function succeeds, the return value is D3D_OK. If the function fails, the return value can be one of the following: D3DERR_INVALIDCALL.

D3DXERR_INVALIDDATA E_OUTOFMEMORY

Remarks

This method takes a pointer to an internal object in the .x file, enabling you to load the frame hierarchy.

For mesh files that do not contain effect instance information, default effect instances will be generated from the material information in the .x file. A default effect instance will have default values that correspond to the members of the D3DMATERIAL9 structure.

The default texture name is also filled in, but is handled differently. The name will be Texture0@Name, which corresponds to an effect variable by the name of "Texture0" with an annotation called "Name." This will contain the string file name for the texture.

When you are ready to load a mesh from an enumerated Mesh template, call the D3DXLoadSkinMeshFromXof function instead of calling D3DXLoadMeshFromXof. Make sure to supply an ID3DXSkinInfo object where it is shown in the prototype. Whether or not the Mesh template contains a skinned mesh doesn't matter−the D3DXLoadSkinMeshFromXof function will load regular and skinned meshes without a hitch. Here's an example:

// Define the mesh and skinned mesh info objects
ID3DXMesh *pMesh;
ID3DXSkinInfo *pSkinInfo;

// Define buffers to hold the material data and adjacency data
ID3DXBuffer *pMaterialBuffer = NULL, *pAdjacencyBuffer = NULL;

// DWORD to hold the number of materials being loaded
DWORD NumMaterials;

// Load the skinned mesh from IDirectXFileDataObject pDataObj
D3DXLoadSkinMeshFromXof(pDataObj, D3DXMESH_SYSTEMMEM, pDevice, &pAdjacencyBuffer,
&pMaterialBuffer, NULL, &NumMaterials, &pSkinInfo, &pMesh);

Just because you used the D3DXLoadSkinnedMeshFromXof function, that doesn't mean a skinned mesh was loaded. First you need to check the pSkinInfo object. If it's set to NULL, then a skinned mesh wasn't loaded. If it's a valid object (non−NULL), then you need to check whether any bones exist.

The easiest way to see whether bones exist is to call ID3DXSkinInfo::GetNumBones. The GetNumBones function will return the number of bones loaded from the Mesh template. If the number is 0, then there are no bones, and you can free the ID3DXSkinInfo object (using Release). If bones do exist, then you can continue using the skinned mesh.

Check out this example, which tests whether a skinned mesh was loaded. If so, the example checks to see whether the mesh contains any bones.

// Set a flag is there's a skinned mesh and bones to use
BOOL SkinnedMesh = FALSE;
if(pSkinInfo && pSkinInfo−>GetNumBones())
SkinnedMesh = TRUE;
else
{
// Free the skinned mesh info data object
if(pSkinInfo)
{
pSkinInfo−>Release();
pSkinInfo = NULL;
}
}

If the SkinnedMesh flag is set to TRUE, then the pSkinInfo object is valid and you're ready to work with the skinned mesh. The next step is to create another mesh object that will contain the actual deforming mesh as you change the bones' orientations.

 

Creating a Secondary Mesh Container

After you create the skinned mesh, you need to create a second mesh container. Why, you ask? Well, the skinned mesh object you loaded from the D3DXLoadSkinMeshFromXof function is sort of the base of reference for your mesh's vertex data. Since these vertices are in the right positions to match the orientations of the bones, it would mess up things quite a bit if you started altering those positions.

Let's leave things well enough alone and instead create a second mesh object (an ID3DXMesh object) that contains an exact duplicate of the skinned mesh. You need to read the vertex data from the skinned mesh data, apply the various bone transformations, and write the resulting vertex data to this duplicate mesh container (which I call the secondary mesh or secondary mesh container) that you use to render. Makes sense, doesn't it?

As I mentioned, the secondary mesh is an identical match to the skinned mesh; everything from the number of vertices to the indices needed is the same. The easiest way to duplicate the skinned mesh object is to use the ID3DXMesh::CloseMeshFVF function.

Clones a mesh using a flexible vertex format (FVF) code.

HRESULT CloneMeshFVF(
DWORD Options,
DWORD FVF,
LPDIRECT3DDEVICE9 pDevice,
LPD3DXMESH * ppCloneMesh
);

Parameters

Options
[in] A combination of one or more D3DXMESH flags specifying creation options for the mesh.
FVF
[in] Combination of FVF codes, which specifies the vertex format for the vertices in the output mesh. For the values of the codes, see D3DFVF.
pDevice
[in] Pointer to an IDirect3DDevice9 interface representing the device object associated with the mesh.
ppCloneMesh
[out, retval] Address of a pointer to an ID3DXMesh interface, representing the cloned mesh.

Return Values

If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be one of the following: D3DERR_INVALIDCALL, E_OUTOFMEMORY.

Remarks

ID3DXBaseMesh::CloneMeshFVF is used to reformat and change the vertex data layout. This is done by creating a new mesh object. For example, use it to to add space for normals, texture coordinates, colors, weights, etc. that were not present before.

ID3DXBaseMesh::UpdateSemantics updates the vertex declaration with different semantic information without changing the layout of the vertex buffer. This method does not modify the contents of the vertex buffer. For example, use it to relabel a 3D texture coordinate as a binormal or tangent or vice versa.

The Options parameter of CloneMeshFVF is just like the one from the calls to D3DXLoadMeshFromX, D3DXLoadMeshFromXof, and D3DXLoadSkinMeshFromXof, so take your pick. I tend to set Options flags to 0, but feel free to change it.

As for the FVF parameter, you only need to supply the FVF from the skinned mesh object using the skinned mesh's GetFVF function. Also, don't forget to supply the valid IDirect3DDevice9 object you are using, as well as a pointer to an ID3DXMesh object that will be your secondary mesh container.

Here's a bit of code that demonstrates cloning a skinned mesh to create your secondary mesh:

// pSkinMesh = ID3DXMesh object
ID3DXMesh *pMesh; // Secondary mesh container
pSkinMesh−>CloneMeshFVF(0, pMesh−>GetFVF(), pDevice, &pMesh);

All this talk of cloning reminds me of Star Wars Episode II: Attack of the Clones. Good thing your cloned secondary meshes aren't going to try to take over the universeor are they? Well heck, those clones aren't going anywhere without a little effort, so let's get back to work and see what's next in line.

After you've created the secondary mesh container, it's time to map your bones to the frame hierarchy. Why didn't we do this previously, when I was discussing bones and frames? Easy−the bone data was loaded until you called D3DXLoadSkinMeshFromXof!


posted on 2008-04-23 19:17 lovedday 閱讀(640) 評論(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>
            亚洲人人精品| 亚洲综合色丁香婷婷六月图片| 久久久精品日韩| 久久成人综合视频| 国语自产精品视频在线看一大j8| 久久久国产一区二区| 欧美中文字幕| 亚洲国产精品999| 亚洲日本中文字幕| 国产精品igao视频网网址不卡日韩| 亚洲视频在线播放| 亚洲欧美国产日韩天堂区| 狠狠色狠狠色综合人人| 欧美激情精品久久久久久久变态| 欧美日韩大片| 久久精品九九| 欧美成人在线免费视频| 亚洲欧美在线一区二区| 欧美影院视频| 99re国产精品| 香蕉av777xxx色综合一区| 亚洲国产欧美久久| 亚洲视频自拍偷拍| 亚洲观看高清完整版在线观看| 日韩午夜激情av| 一区二区三区在线观看视频 | 国产精品久久久久久久久借妻 | 亚洲午夜精品在线| 欧美一级夜夜爽| 9久re热视频在线精品| 亚洲一区美女视频在线观看免费| 在线观看三级视频欧美| 99在线热播精品免费99热| 国产一区深夜福利| 亚洲美女在线视频| 韩国一区二区在线观看| 亚洲视频免费在线观看| 最新精品在线| 欧美一区二区精美| 亚洲永久免费视频| 欧美国产极速在线| 六月婷婷久久| 国产欧美在线播放| 中文亚洲欧美| 一区二区毛片| 欧美jizzhd精品欧美喷水| 久久久99久久精品女同性| 欧美日韩中文字幕综合视频| 免费看黄裸体一级大秀欧美| 国产日韩免费| 亚洲视频一区二区| 亚洲视频免费在线观看| 免费观看成人鲁鲁鲁鲁鲁视频| 久久精品99国产精品| 国产精品国产一区二区| 亚洲毛片网站| 一区二区三区产品免费精品久久75| 久久久蜜桃一区二区人| 老司机免费视频一区二区| 国产亚洲va综合人人澡精品| 亚洲免费小视频| 小处雏高清一区二区三区| 欧美午夜片欧美片在线观看| 一区二区av在线| 亚洲一区二区在线视频| 欧美日韩国产首页在线观看| 亚洲精品在线观看视频| 日韩一级成人av| 欧美日韩午夜| 亚洲少妇最新在线视频| 亚洲自拍偷拍麻豆| 国产嫩草影院久久久久| 午夜精品婷婷| 久久久久久国产精品mv| 1024国产精品| 免费亚洲电影在线观看| 亚洲国产高潮在线观看| 99精品视频免费观看视频| 欧美人妖在线观看| 一本色道久久综合亚洲精品高清 | 久久影院午夜论| 怡红院精品视频在线观看极品| 久久成人av少妇免费| 女人天堂亚洲aⅴ在线观看| 91久久精品日日躁夜夜躁欧美| 欧美成人一区二区三区| 99国产精品视频免费观看一公开| 亚洲视频一二三| 国产欧美1区2区3区| 久久精品国产视频| 亚洲国产精品999| 亚洲一区二区三区精品视频| 国产日韩欧美亚洲一区| 久久xxxx精品视频| 亚洲国产精品久久久久婷婷884 | 欧美一区二区三区啪啪| 影音欧美亚洲| 欧美日韩免费网站| 欧美在线视频二区| 91久久极品少妇xxxxⅹ软件| 亚洲影音先锋| 亚洲国产精品成人精品| 欧美午夜女人视频在线| 久久日韩精品| 亚洲一级电影| 欧美国产日韩精品| 亚洲在线视频免费观看| 在线精品亚洲一区二区| 欧美日韩综合| 免费高清在线视频一区·| 亚洲一区国产| 亚洲精品乱码| 欧美夫妇交换俱乐部在线观看| 亚洲一区二区三区四区在线观看| 国产一区二区三区在线观看网站 | 久久久久久久波多野高潮日日 | 免费在线观看一区二区| 亚洲综合成人在线| 最新中文字幕一区二区三区| 国产亚洲毛片在线| 欧美日韩中文字幕在线| 欧美成人一区在线| 久久久精品国产免费观看同学| 一区二区三区四区国产| 亚洲国产天堂久久综合| 男女精品视频| 久久久久久亚洲精品杨幂换脸| 亚洲中午字幕| 一区二区精品在线| 亚洲人久久久| 亚洲国产成人精品女人久久久| 国产一区二区三区直播精品电影| 国产精品九九久久久久久久| 欧美美女bb生活片| 欧美精品xxxxbbbb| 欧美激情视频一区二区三区免费| 久久久久久久一区二区| 久久精品国产亚洲5555| 性一交一乱一区二区洋洋av| 亚洲主播在线观看| 亚洲午夜精品久久| 亚洲网站在线| 亚洲综合社区| 亚洲字幕一区二区| 午夜久久99| 久久精品主播| 久久国产精品久久国产精品| 久久精品国产视频| 久久综合色播五月| 麻豆国产精品777777在线| 另类亚洲自拍| 女人天堂亚洲aⅴ在线观看| 免费视频最近日韩| 欧美欧美天天天天操| 欧美日韩日日夜夜| 欧美网站在线观看| 国产精品视频免费在线观看| 国产精品亚洲片夜色在线| 国产精品亚发布| 国产一区 二区 三区一级| 狠狠爱综合网| 亚洲人成在线观看一区二区| 一区二区黄色| 欧美一区二视频| 欧美成人综合在线| 99国产精品久久| 亚洲欧美日韩在线高清直播| 久久狠狠一本精品综合网| 免费亚洲电影在线观看| 欧美午夜精品一区| 国产在线视频欧美一区二区三区| 在线日韩日本国产亚洲| 一区二区精品| 久久精品国产久精国产爱| 欧美v国产在线一区二区三区| 亚洲国语精品自产拍在线观看| 亚洲深夜激情| 久久久五月天| 国产精品免费一区豆花| 好男人免费精品视频| 在线视频你懂得一区| 久久久久综合一区二区三区| 亚洲精品视频一区| 久久国产主播精品| 国产精品theporn| 91久久精品国产91性色| 欧美在线关看| 亚洲人成人99网站| 午夜在线播放视频欧美| 欧美精品久久久久久久| 国产自产2019最新不卡| 中文日韩在线视频| 欧美sm视频| 亚洲综合欧美| 欧美日韩一区二区三区四区在线观看| 韩国一区电影| 欧美一级片久久久久久久| 亚洲巨乳在线| 麻豆精品精华液| 国内揄拍国内精品少妇国语|