Jump to content
  • Advertisement
Sign in to follow this  
LowRad

Mesh and its VertexFormat

This topic is 4872 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 building a little app to play around with DX. I trying to implement my Octree and came to a problem. I need access to the vertex informations(Duh!), and i want it all (position, normal, texture coords, ...). So, to make it quick, i did use the Mesh.FromFile method. I tried to load in a test cube and it seem to worked (nb of vertices, faces are ok in my mesh object). But now, to access all the VertexBuffer informations, i want to identify the VertexFormat in use by the mesh to be able to Cast the pointer correctly, but the property Mesh.VertexFormat isnt returning anyting (i saw Texture0 once, now its allways ".nothing."). I did load my cube.x in the XFileViewer and its worked. So, i'm assuming the x file isnt the problem. Can someone guide me to a way of identifying the VertexFormat in use in a VertexBuffer? So, that i can continue working on my primary objective, my Octree. :D Thanks all... P.S. I'm using VS2005 C# with DX Managed Oct. Jonathan

Share this post


Link to post
Share on other sites
Advertisement
I'm back !!

Maybe if i rephrase my question someone will answer it.

After calling Mesh.FromFile, did the receiving mesh should contains the VertexFormat ?!

Thanks

Share this post


Link to post
Share on other sites
When you have succesfully loaded a mesh using Mesh.FromFile(), the mesh will contain the vertex format and it's accessible using the Mesh.VertexFormat property and this will give you what you are looking for.

I hope this helps.
Take care.

Share this post


Link to post
Share on other sites
That is what i've expected as per msdn documentation. But, it doesnt show up the VertexFormat used in the VertexBuffer throught the Mesh.VertexFormat property.

My call to Mesh.FromFile seems to succeeds well.. No D3D complaining, no exception...

Maybe there's another way to check from Mesh.FromFile errors?

If i do cast my VertexBuffer to an array of CustomVertexs.PositionNormalTextured, the data seems to be there, but with the wrong Struct size (the 1st vertex seems ok, the rest, i let u guest;)).. PositionNormalTexture is 32bytes (if i remember well) Mesh.NumberBytesPerVertex reports 68bytes.


Any idea are welcome....

Share this post


Link to post
Share on other sites
I just did another test... maybe i should i've done it...
Dont blame me, in microsoft i trust =) should i ?

When i load the tiger.x model the VertexFormat shows up correctly..

But, when i use the MS exporter of 3D Studio, to export my models, the VertexFormat is showing up as None..

So, since i didnt find any options in their exporter, i'm out of clues...

Thanks for your help...
Jonathan

Share this post


Link to post
Share on other sites
If the tiger.x meshes are reporting correct information and the exported meshes none then you have isolated your problem as being the exporter. Try the panda exporter series from PandaSoft and give that a whirl.

I hope this helps.
Take care.

Share this post


Link to post
Share on other sites
Quoting ID3DXBaseMesh::GetFVF documentation:


Remarks

This method can return 0 if the vertex format cannot be mapped directly to an FVF code. This will occur for a mesh created from a vertex declaration that doesn't have the same order and elements supported by the FVF codes.


If this is the case, you should use ID3DXBaseMesh::GetDeclaration to get an array of D3DVERTEXELEMENT9 structures describing the geometry format. This approach is more flexible in any case, so I recommend always using it instead of GetFVF.

Share this post


Link to post
Share on other sites
Wow !!!

At least someone that knows X-File better than Microsoft knows them. =)

At least panda's exporter seems alot more complete than the microsoft's one.

That panda exporter rocks!

Thanks Armadon !!

Now time to go to bed, ill be able to sleep now ;)

And tomorrow, ill continue that octree...

Thanks Nik02 for your post, ill look into it.

Added: I looked into the VertexDeclaration array... and i soon i want to retreive any values from it... i receive an Operation Not Supported Exception ;)

Share this post


Link to post
Share on other sites
Quote:
Original post by LowRad

Added: I looked into the VertexDeclaration array... and i soon i want to retreive any values from it... i receive an Operation Not Supported Exception ;)


That's odd, it works fine for all my mesh data.


LPD3DXMESH pMesh; //initialized earlier

D3DVERTEXELEMENT9 ve[MAX_FVF_DECL_SIZE];

pMesh->GetDeclaration(ve);




After this, the symbol "ve" is filled with the mesh's vertex format descriptors. The last valid element in that array corresponds to the values that the D3DDECL_END macro generates; it's a signal for you to ignore the rest of the elements of the array.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!