문제

I need to calculate normal vector for a triangle prepared for passing to opengl chain. It has vertexes enumerated in counter-clockwise order that is default for opengl. Let denote them as A, B, C, and put C-B as u and B-A as v.

In what order should I cross product vectors to gain normal vector codirectional with the normal calculated by internal opengl procedures? v × u or u × v?

I've found many topics about face-culling and vertex ordering, but not about computation normals for triangle that depends from vertex order as well as from the coordinate system orientation.

도움이 되었습니까?

해결책

Use the Right hand rule, assuming your triangle is A,B,C in CCW order. then you need

Normal = Cross(B-A, C-A);

The way you set u,v and is inconsistent both vectors should have the same tail it's more consistent this way.

If you want to use u,v the way you set, it is v x u using right hand rule.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top