• Advertisement
Sign in to follow this  

DirectX Mesh Vertices

This topic is 2449 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm curious as to what the base vertex struct is for a .x file created as a LPD3DXMESH. I'm guessing I could take the FVF and convert that into a text file, and convert that into a vertex struct, but there has to be a better way. Anyone know?

Share this post


Link to post
Share on other sites
Advertisement
It depends of course.

If you create an ID3DXMesh object from an .X file, it may include tangent-base vectors or not. It may include only position and texcoords. It may include only position and normal vectors. Or it may include only position data.

If you create an ID3DXMesh object with automatic mesh creation functions (like D3DXCreateTeapot(), D3DXCreateSphere() etc), result mesh includes only position and normal vectors.

Generally, you can retrieve vertex declaration of a mesh and see what the vertex structure of that mesh contains:


bool hasNormals, hasTexcoords, hasTangents, hasBinormals;

D3DVERTEXELEMENT9 pVertElem [MAX_FVF_DECL_SIZE];

pMesh->GetDeclaration (pVertElem); //retrieve vertex declaration structure (better than FVFs)

hasNormals = hasTexcoords = hasTangents = hasBinormals = false;

D3DVERTEXELEMENT* pE = &pVertElem[0];
while (*pE != D3DDECL_END())
{
if (pE.Usage == D3DDECLUSAGE_NORMAL)
hasNormals = true;

if (pE.Usage == D3DDECLUSAGE_TEXCOORD)
hasTexcoords = true;

if (pE.Usage == D3DDECLUSAGE_TANGENT)
hasTangents = true;

if (pE.Usage == D3DDECLUSAGE_BINORMAL)
hasBinormals = true;

pE++;
}


hth.
-R

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement