Sign in to follow this  
HellzGod

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

Recommended Posts

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

Share this post


Link to post
Share on other sites
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
);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this