Jump to content

View more

Image of the Day

#ld38 #screenshotsaturday Mimosa Fizz action gif #2 https://t.co/TUzdppvfUL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Exporting Attribute Table From Mesh Object

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 Fredericvo   Members   

1711
Like
0Likes
Like

Posted 13 May 2012 - 11:04 AM

Hello,

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
D3DXMESHOPT_ATTRSORT | D3DXMESHOPT_COMPACT | D3DXMESHOPT_VERTEXCACHE
for the OptimizeInPlace() call.

#2 Fredericvo   Members   

1711
Like
0Likes
Like

Posted 15 May 2012 - 09:43 AM

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);




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.