How to save a dynamically generated mesh to a .x file?

Started by
2 comments, last by amigocz 16 years, 2 months ago
hi, I'm using Directx 9 and C++. I have dynamically generated a mesh. I want to save it to a .x file coz I can compute normals and tangents using in built functions. How do I create a .x file from the vertex buffer info? Or do I have to use blender or something? Otherwise, is it possible for me to create a mesh with a vertex buffer that I can fill in C++? Thanks, M
Advertisement
Hi, both things ar possible.
You can create a mesh from vertex/index buffer info with function

HRESULT D3DXCreateMesh(
DWORD NumFaces,
DWORD NumVertices,
DWORD Options,
CONST LPD3DVERTEXELEMENT9 * pDeclaration,
LPDIRECT3DDEVICE9 pD3DDevice,
LPD3DXMESH * ppMesh
);

And then you can save this mesh to .x file with function

HRESULT D3DXSaveMeshToX(
LPCTSTR pFilename,
LPD3DXMESH pMesh,
CONST DWORD * pAdjacency,
CONST D3DXMATERIAL * pMaterials,
CONST D3DXEFFECTINSTANCE * pEffectInstances,
DWORD NumMaterials,
DWORD Format
);
I have a 128 x 128 Mesh (Rectangular plane). What shud I give for NumFaces?

Thanks,
M
I thing you should give numrows*numcolumns*2

This topic is closed to new replies.

Advertisement