Generating a useful mesh from a poorly defined one
I have a list of triangles, each defined with arbitrary CW/CCW ordering and with no surface or vertex normals assigned. I want to turn this into a fully lit, back-face culled surface (just using materials, no texturing), but I'm not sure where to start...
Is there a specific algorithm/procedure I should be following? What are the options? If I throw everything into a D3DXMesh, can it compute outward facing normals and reorder vertices for me?
D3DX can probably do a fair bit of the work for you, but probably not all.
In particular you'll probably have to re-order the vertices so they are consistently CW or CCW wound. If you've got a CW/CCW attribute for each face it shouldn't be too hard to sort this out. Dont worry about duplicating data (or creating an optimal list) as you can use ID3DXMesh::OptimizeInPlace() to refine whatever you pass to D3DX.
Have a look at the Mesh Functions list - that should give you a good idea of what D3DX can perform for you.
hth
Jack
In particular you'll probably have to re-order the vertices so they are consistently CW or CCW wound. If you've got a CW/CCW attribute for each face it shouldn't be too hard to sort this out. Dont worry about duplicating data (or creating an optimal list) as you can use ID3DXMesh::OptimizeInPlace() to refine whatever you pass to D3DX.
Have a look at the Mesh Functions list - that should give you a good idea of what D3DX can perform for you.
hth
Jack
Ah great, thanks for the reply.
Can anyone tell me how I would go about reordering vertices to be in CW/CCW order? What do I test for to see which way its currently going?
Can anyone tell me how I would go about reordering vertices to be in CW/CCW order? What do I test for to see which way its currently going?
Quote:Original post by DangerDave
Ah great, thanks for the reply.
Can anyone tell me how I would go about reordering vertices to be in CW/CCW order? What do I test for to see which way its currently going?
You can create 2 vectors from the 3 vertices and then get cross product vector. The direction of the cross product vector will tell you how to order the vertices.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement