Sign in to follow this  
BEHOLDER192875

DirectX Mesh Vertices

Recommended Posts

BEHOLDER192875    136
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
programci_84    336
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:

[code]
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++;
}[/code]

hth.
-R

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