Jump to content
  • Advertisement
Sign in to follow this  
Endemoniada

Normals from Cross

This topic is 3895 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

Hi guys, I'm parsing Lightwave 3D .obj files where the models are made up of triangles. Then I create the normals using the cross product. Is there a way I can check the normal to make sure it's facing outward, so if it isn't I can just reverse it ? Also, can I tell if going from vertex_01 to vertex_02 is clockwise or counter-clockwise ? Thank you.

Share this post


Link to post
Share on other sites
Advertisement
If it is a closed mesh you could cast a ray from the surface of the triangle in the direction of the normal. If the number of intersections between the mesh and the ray is even then the normal is pointing outward, if it is odd the normal is pointing inward.

As for the clockwise counter clockwise you will need the third point as well in order to determine clockwise counter clockwise. I think that you could determine CW and CCW like this.

((vertex_03 - vertex_01) x (vertex_02 - vertex_01)) dot normal > 0

So essentially if you need to flip the normal to face outward the triangle's CW or CCW direction is opposite of a triangle where the normal does not need to be flipped. I hope I was helpful.

Share this post


Link to post
Share on other sites
Thanks Happy.

I found this for testing the orientation of a triangle:

http://www.gamedev.net/reference/articles/article425.asp

I don't understand what the difference is between the orientation() and determinant() functions (except how the parameters are passed.) Neither of them use z-values so maybe they are just for 2D ?

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!