Jump to content
  • Advertisement
Sign in to follow this  

Exporting Attribute Table From Mesh Object

This topic is 2347 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've been messing around with different ways to export models from 3D modeling software and have achieved mixed success with it.
One program I made based on Damiano Vitulli's program can read 3ds files, and I added multiple subset support but not yet normals since the format doesn't support it and I will have to calculate them procedurally. It still lacks materials too. So in the meantime I tried to use x-files which have normals & materials included and is (at least on the surface) easier to extract data from.

So in theory you are supposed to "Mesh->OptimizeInPlace()" in order to build an attribute table which gives you access to the partitioning of the mesh in different subsets. DrawSubset is supposed to use this information and issue its own DrawIndexedPrimitive calls.

Well if I draw the whole object as one I can see that I got the correct vertex & index buffers but when I try to use info from the attribute table itself i.e.

subset 0: FS:0 FC:12 VS:0 VC:24
subset 1: FS:12 FC:12 VS:24 VC:24
subset 2: FS:24 FC:12 VS:48 VC:24
subset 3: FS:36 FC:12 VS:72 VC:24
legend: FS = Face Start, FC = Face Count, VC = Vertex Count VS = Vertex Start as per D3DXATTRIBUTERANGE structure

d3ddev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 72, 24, 36, 12); //Subset 3

It doesn't work properly.

If I'm more lenient about the vertex start & count by issing the following command:

d3ddev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, totalnumberofverts, 60, 12);

It works a bit better but some subsets appear correctly and others seem mangled.

The idea of course is to achieve the following:

int k=0;
for (k=0;k<numsubsets;k++)
d3ddev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, Attrib[k].VertexStart, Attrib[k].VertexCount, Attrib[k].FaceStart, Attrib[k].FaceCount);

What am I doing wrong?

Note that I've already tried different combinations of
for the OptimizeInPlace() call.

Share this post

Link to post
Share on other sites
OK I solved my own question.

I confused index and face

The solution is to multiply FaceStart by 3 as it wants an index not a face, like so:

d3ddev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, Attrib[k].VertexStart, Attrib[k].VertexCount, Attrib[k].FaceStart * 3, Attrib[k].FaceCount);

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!