Polygon generator

This topic is 3496 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

If I have 3 vertices of a 3D Object and need to generate a polygon face in the direction of clockwise (or not), how should I choose if I need the normal vector of the triangle is generated in the same direction as the vector P (0, 0.0)-Q (cx, cy, cz) where cx, cy, cz is the center of the triangle?

Share on other sites
I hope I understood you correct, you want to check if a triangle is clockwise or not from relative to the vector from 0|0|0 to the center of your triangle, right?

you just need to make a dot product of the triangle normal and the vector and check the sign of the result, that will indicate which direction the normal points to and so if it is CCW or CW.

Share on other sites
¡Yes, Krypt0n! Thank you! Now, another question. There would be another way to choose the correct normal vector given three points of the triangle without the need for a dot? The object is very irregular and not all faces have the same direction with respect to the origin of coordinates.

Share on other sites
all edge of connected triangle should point to the opposide direction of their neighbour's edges, then you will get the same orientation for all normals.

if you have a mesh with indices
0 1 2
1 0 3

then vertex 0 and vertex 1 are shadered and the order of them is inverted, this means, the edges point in opposide directions and the normals will 'correct' in relation to eachother.

I hope that's what you've been looking for.

Share on other sites
Thanks, I was very helpful. Have a reference page or source code to implement this correction algorithm?

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 9
• 9
• 14
• Forum Statistics

• Total Topics
633312
• Total Posts
3011312
• Who's Online (See full list)

There are no registered users currently online

×