#### Archived

This topic is now archived and is closed to further replies.

# Triangle Culling Orders...

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

## Recommended Posts

Hi, In D3D (and OpenGL I do believe), it''l cull triangles that are either clockwise, or counter-clockwise... How do I tell if a triangle is wound CW or CCW? say I have 3 vertices, v0:v1:v2... I know how to do it on paper (to a certain extent!), but I need to do this mathematically/algorithmically... Such that Triangle Goes in -> Tested -> Corrected if necessary -> triangle goes out I know I read the formula on some massive graphics FAQ (but I lost it/cant find it) ages ago... and all my searches haven''t come up with anything useful (Except for a wind up triangle kids toy!!) Can anyone quote the formula/explain/point me in the right direction?? many thanks in advance. Jack;

##### Share on other sites
Here''s a very brief description:

Triangle is described by 3 points, P1, P2, and P3.

1) project triangle points onto the image plane (no need to do the viewport transformations, just the camera/view transformations). Once transformed, P1, P2, and P3 will all have the same Z coordinate value.

2) Take the cross product N = (P2-P1) x (P3-P1). Look at the sign of the Z coordinate of N. If the Z coordinate is positive, the triangle is counterclockwise. If the Z coordinate is negative, the triangle is clockwise. (This assumes the OpenGL convention where positive Z is facing towards the camera.)

There are other ways to do this without the cross product, e.g., using logic to figure out which points are the left and right-most points in image plane space, then seeing whether the remaining point is below or above those two points. A purely logical decision rather than a mathematical decision. But the cross product method is nice and clean.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

1. 1
2. 2
3. 3
4. 4
Rutin
12
5. 5

• 12
• 17
• 10
• 14
• 10
• ### Forum Statistics

• Total Topics
632660
• Total Posts
3007697
• ### Who's Online (See full list)

There are no registered users currently online

×