Game Development Reference
In-Depth Information
Example :
DWORD adjacencyInfo[Mesh->GetNumFaces() * 3];
Mesh->GenerateAdjacency(0.001f, adjacencyInfo);
10.7 Cloning
Sometimes we need to copy the data from one mesh to another. This is
accomplished with the ID3DXBaseMesh::CloneMeshFVF method.
HRESULT ID3DXMesh::CloneMeshFVF(
DWORD Options,
DWORD FVF,
LPDIRECT3DDEVICE9 pDevice,
LPD3DXMESH* ppCloneMesh
);
Options —One or more creation flags that are used to create the
cloned mesh. See the D3DXMESH enumerated type in the SDK doc-
umentation for a complete list of option flags. Some common flags
are:
D3DXMESH_32BIT —The mesh will use 32-bit indices.
D3DXMESH_MANAGED —The mesh will be placed in the man-
aged memory pool.
D3DXMESH_WRITEONLY —The mesh's data will only be writ-
ten to and not read from.
D3DXMESH_DYNAMIC —The mesh's buffers will be made
dynamic.
FVF —The flexible vertex format with which to create the cloned
mesh
pDevice —The device to be associated with the cloned mesh
ppCloneMesh —Outputs the cloned mesh
Notice that this method allows the creation options and flexible vertex
format of the destination mesh to be different from those of the source
mesh. For example, suppose we have a mesh that has the flexible ver-
tex format D3DFVF_XYZ and we would like to create a clone but with a
vertex format of D3DFVF_XYZ | D3DFVF_NORMAL . We would write:
// assume _mesh and device are valid
ID3DXMesh* clone = 0;
Mesh->CloneMeshFVF(
Mesh->GetOptions(), // use same options as source mesh
D3DFVF_XYZ | D3DFVF_NORMAL,// specify clones FVF
Device,
&clone);
Search WWH ::




Custom Search