Normals from Cross

Started by
1 comment, last by Endemoniada 16 years, 1 month ago
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.
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.
My current game project Platform RPG
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 ?

This topic is closed to new replies.

Advertisement