Jump to content
  • Advertisement
Sign in to follow this  

Polygon generator

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

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 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!