How to save a dynamically generated mesh to a .x file?
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
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
);
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
);
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement