Sign in to follow this  

calculate the normal vector

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

Hello friends. I need help to complete a project that I designed. The problem is: I have a 3D model generated at runtime that has misdirected the normal vector of some of their faces. What I need is an algorithm that corrects all sides. And tried to make an algorithm but I have not been able to operate. What we tried to do is reverse the edges of all adjacent faces, but I was complicated because I do not know how to determine which seed to use the normal vector is correct, then generate it from all sides correct. ......c....b....d...e.... ...../|....|\....\..|.... ..../.|....|.\....\.|.... .../..|....|..\....\|.... ..a.-.b....c.-.d....b.... .face 1 face 2 face 3 neighboring I also tried to calculate the normal vector of the triangle and make a dot product with a reference point, but did not work either because the object is irregular in their faces. I do not know what to do, how they could solve the problem? [Edited by - I CAN DO on April 30, 2009 8:57:16 AM]

Share this post


Link to post
Share on other sites
I'm not sure I understand your whole problem but I'll take a shot at it. Most triangular meshes have a winding, either clockwise or counter clockwise. What this means is if you have clockwise winding and you are looking at the outside of the object, your points will be in clockwise order. In structures that also store edges, instead of faces being directly linked to points, the edges can't all have the correct winding. So this case you may sometimes need to disregard the direction of the edge and just concentrate on the polygon winding. This assumes the triangle has some way of determining winding.

For instance in my the case of my world mesh, edge1 always goes from point 1 to point 2, edge 3 goes from point 1 to point 3 but edge 2 can go either from point 2 to point 3 or point 3 to point 2. I can therefore rely on a point winding of:

Point 1 = Edge 1 first point
Point 2 = Edge 1 second point
Point 3 = Edge 3 second point

Again I don't use Edge 2 for this because it can go either way. There are lots of other schemes for determining winding, this is just an example. In any case once you have your points in order then you can just do a cross product to get the normal:
N = Normalize( CrossProduct( Vector(  Point2-Point1 ),  Vector( Point3-Point1) ) )

In this case I am assuming clockwise winding and a left handed coordinate system, but you can make it work for any system.

Share this post


Link to post
Share on other sites

This topic is 3149 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this