# Generating a useful mesh from a poorly defined one

This topic is 4545 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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?

##### Share on other sites
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

##### Share on other sites
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?

##### Share on other sites
Quote:
 Original post by DangerDaveAh 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.

1. 1
2. 2
3. 3
4. 4
Rutin
12
5. 5

• 26
• 10
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633694
• Total Posts
3013378
×