View Full Version : normals directions
03-20-2010, 05:19 AM
I have a mesh with defined normals for each its surfaces. I want to know if there is some way(preferably OnenGL function) to know if the normals directions are inside or outside for each surface
03-20-2010, 07:05 AM
By surfaces you mean polygons? Are the polygons planar? One normal per polygon face? If that's the case, you can always compute a tempNormal of the face and dotting it against your stored normal. If it's positive, they're facing the same direction out. If it's negative, your stored normal is facing in.
For example, a triangle with vertices v1, v2, and v3. Make a vector 'a' which is v1->v2 and vector 'b' which is v1->v3. 'a' cross 'b' is new normal.
03-20-2010, 08:19 AM
I don't know if my polygons are concave or convex .Also winding of faces is not known.
Please tell me what you mean by calculating a tempNormal.
03-20-2010, 02:23 PM
If you're doing flat shading (such that the lighting uses the same normal across the polygon), it shouldn't matter if they're concave or convex. If they're non-planar, that's a whole other issue that's non-trivial to work with.
If you don't know the winding of the polygon, it gets even more tricky. Where did you get the polygon info (just curious)? I'm not sure there's a perfect way to figure that out. Is the mesh closed? If so, you can grab a polygon, calculate a normal as I described and intersect it with other polygons. If you find one that doesn't hit another polygon, it must be going off into space and therefore facing out. You now know the winding of it and can compare the normals. You can then look at its neighbors. If a neighbor polygon shares two points, it should have the same winding.
polygon with known winding (v1,v2,v3)
neighbor polygon has (v2,v3,v4)
The counter-clockwise winding for the first is v1,v2,v3 so the second must be (v3,v2,v4). You can try it on paper.
03-20-2010, 03:16 PM
thank you for reply
The mesh is not closed.
It is an academic project
The mesh is not closed. If the mesh is not closed how do you even define 'inside' and 'outside'? If you can answer that question clearly in words, we (or you) should be able to do it mathematicaly.
03-22-2010, 04:40 PM
Heh, when you say it's an academic project, are you referring to me asking about it being closed? I meant does it have any holes? Can you move from one side of a face around to the other side?
For example, a quad is not closed because from one point on the outside to the same point facing the other way. With a cube that is closed, if I pick a point facing outwards, I can't move around until I'm inside it. I'm sure there are better descriptions out there.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.