Normals in /normals out triangles

Started by
8 comments, last by giugio 12 years, 6 months ago
hello.
I have created an importer from sketchup and i would to find all the meshes where the normal point in the triangle(in the mesh) and not out of the triangle(outside the mesh).
I have all the triangles of the mesh and for each triangle I have the 3 vertexes , and the normal of the triangle.

i see this :http://paulbourke.net/geometry/clockwise/index.html#clockwise

but i'm not understand how the result of a cross product is positive or not.
When a vector is positive? and when is negative?

thanks.
Advertisement
your link is 2 dimensions, so the 'cross product' which does not actually exist in 2D is replaced by the perp-dot product which produces a scalar value; not a vector.

If you take a look at the spefic image http://paulbourke.net/geometry/clockwise/clockwise1.gif from your reference, showing the z-axis. then assuming we're working in 3 dimensions, the cross product will allows be of the form (0,0,z) as all the point lies in the x-y plane. the sign of the 2d perp-dot product here corresponds to the sign (and value) of the 3d cross products' z value. sometimes the cross product results in a vector pointing up out of the xy plane, and sometimes pointing down out of the xy plane.

your link is 2 dimensions, so the 'cross product' which does not actually exist in 2D is replaced by the perp-dot product which produces a scalar value; not a vector.

If you take a look at the spefic image http://paulbourke.ne.../clockwise1.gif from your reference, showing the z-axis. then assuming we're working in 3 dimensions, the cross product will allows be of the form (0,0,z) as all the point lies in the x-y plane. the sign of the 2d perp-dot product here corresponds to the sign (and value) of the 3d cross products' z value. sometimes the cross product results in a vector pointing up out of the xy plane, and sometimes pointing down out of the xy plane.


I finally understood something.
But if I want to calculate the triangles with cw or ccw order I use only the z sign of the cross product of three dimensional vectors?
because I found this specification:
http://www.opengl.org/sdk/docs/manglsl/xhtml/gl_FrontFacing.xml
I see at the formula and I do not understand, what it means to window coordinates?
are not vertex coordinates?
would you do me a small example?
Thank you.
you cannot determine if a triangle is CW or CCW in 3D because it has no meaning. If you look at a triangle from one perspective it is CW, look at it from behind and it will be CCW. You can only talk about the winding of at triangle with some way of describing which side of the triangle is 'inside' and which is 'outside' the mesh the triangle is part of, in which case we normally talk about the winding of the triangle as though we are looking at it from outside of the mesh.

back-face culling can be described by screen coordinates (the coordinates of the triangle when transformed and projected onto the screen) since then we are in a 2D world now and CW/CCW make sense (Your link talks about the signed area of the triangle which is directly related to it's winding in 2D).

back-face culling can equaly be done in world space by considering the camera position in relation to the 3 vertices of the triangle defining it's plane and determining on what side of the triangle the camera lies with respect to the direction of it's normal.

you cannot determine if a triangle is CW or CCW in 3D because it has no meaning. If you look at a triangle from one perspective it is CW, look at it from behind and it will be CCW. You can only talk about the winding of at triangle with some way of describing which side of the triangle is 'inside' and which is 'outside' the mesh the triangle is part of, in which case we normally talk about the winding of the triangle as though we are looking at it from outside of the mesh.

back-face culling can be described by screen coordinates (the coordinates of the triangle when transformed and projected onto the screen) since then we are in a 2D world now and CW/CCW make sense (Your link talks about the signed area of the triangle which is directly related to it's winding in 2D).

back-face culling can equaly be done in world space by considering the camera position in relation to the 3 vertices of the triangle defining it's plane and determining on what side of the triangle the camera lies with respect to the direction of it's normal.

very thanks.

and is possible determinate if the triangle have a wingorder CW or CCW in 3d and not in windows coordinates?
because i create an importer for sketchup , and there is the possibility that some triangles have an inverted winding order .
I wish find all the triangles that have a CW order for select it in ruby inside sketchup or for invert the indexes and make they CCW in a c++ importer.
thanks.
Like I said, winding has no meaning when considering a single triangle. If the triangle is part of a closed mesh then there are ways to induce a consitent winding for the whole mesh which is greatly simplified when we know the mesh is convex (In the convex case we can ensure that the centre of the mesh is on the same side of all triangles; when the mesh is not convex you can do it by evaluating a point which you ensure is always inside of the mesh and within the bounds of the prism extruded by the triangle and make sure all triangles have the same result to know their winding is the same.
Or if you still have problems, you shouldnt need to get the normals. Sketchup or whatever should already export them, if they dont, get Blender for free and import your model as a .OBJ and export it. You shouldn't need to calculate normals.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal


Like I said, winding has no meaning when considering a single triangle. If the triangle is part of a closed mesh then there are ways to induce a consitent winding for the whole mesh which is greatly simplified when we know the mesh is convex (In the convex case we can ensure that the centre of the mesh is on the same side of all triangles; when the mesh is not convex you can do it by evaluating a point which you ensure is always inside of the mesh and within the bounds of the prism extruded by the triangle and make sure all triangles have the same result to know their winding is the same.


thanks Luca.
If i have the vertexes of the mesh , and the mesh is convex , how i can calculate the center?
There is a book of geometry that you can advice to me for these stuff?
I don't wish to ask you a solution for every problem.
Thanks.
i don't know about literature.

for a convex mesh, i left my definition of 'centre' ambiguous because it doesn't actually need to be any particular point aslong as it is contained inside of the mesh; which since it is convex you could just take the average of all vertex positions rather than something more complicated like the centroid.
sorry if i ask, but I have this function:

GETNORMAL:
The normal method is used to retrieve the 3D vector normal to the face in the front direction.

if the read normal is always in the front direction , may be that if the normal is negative is a backface?

thanks.

This topic is closed to new replies.

Advertisement