Jump to content
  • Advertisement
Sign in to follow this  
DangerDave

Generating a useful mesh from a poorly defined one

This topic is 4464 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 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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
Share on other sites
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.

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!