Jump to content
  • Advertisement
Sign in to follow this  
Alessandro

normal values flipped (sometimes) ...

This topic is 2443 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 complex 3D mesh and I'd like to calculate the normal of a point laying in one of the mesh triangles.

So I have a point P which is laying in a triangle with vertices A,B,C (to calculate ABC coordinates I iterate all the mesh vertices and gather the 3 points which are closest to P).

I calculate the normal vector to the triangle like this:

normalVector = (C-A)^(B-A); // ^ is the cross product

The problem is that the resulting vector is sometimes flipped, and I can't understand why. Is the order of of vector subtractions important?
Thanks

Share this post


Link to post
Share on other sites
Advertisement

The problem is that the resulting vector is sometimes flipped, and I can't understand why. Is the order of of vector subtractions important?
Thanks

Order is important when it comes to a cross product. That is A cross B != B cross A (in fact, A cross B == -(B cross A)). In other words, switching the order of A and B will flip the result of the cross product. Looking at this, you can hopefully see what it is I'm trying to convey. It sounds like, in your case, ABC will be clockwise for some of the triangles, whereas ABC will be counterclockwise for the other triangles.

Share this post


Link to post
Share on other sites
If you're importing from Blender (I suspect the problem might arise with other DCC tools as well), there might be another thing worth trying before you crack your head open...

Blender by default will try to guess the "out" face for you. It will also render triangles with no backface culling. It is therefore dead simple to have a normal flipped, yet do not recognize it. Normal's direction will then be used to choose the "visible" face when exporting. Perhaps it is worth checking normals are actually born in the expected direction.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!