Sign in to follow this  

Triangle Winding Direction

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

A triangle in 3-d will be wound clockwise when viewed from one side, and counterclockwise when viewed form the other side, so without some additional point of reference you can't uniquely determine the winding of a single triangle.

What problem are you trying to solve exactly?

Share this post


Link to post
Share on other sites
This is generally done once projection into view space has been performed - as jyk says, it makes little sense otherwise.

There is some code I've personally used that works in [url="http://www.gamedev.net/page/resources/_/reference/programming/math-and-physics/polygons/polygon-to-triangles-r425"]this thread[/url].

But D3D will automatically do this for you, so not sure why you would be doing this yourself. D3D will cull counter-clockwise by default but can be set to anything by setting the D3DRS_CULLMODE render state - D3DCULL_CW, D3DCULL_CCW and D3DCULL_NONE. Better to let D3D do this in most cases as there is a good chance it will be hardware accelerated - I assume this is an operation most graphics cards would support in hardware.

I had some fairly specific reasons to do this in software when I used the code I linked to above. Certainly not related to normal rendering in any way.

Share this post


Link to post
Share on other sites
Depends in which order the vertices are called. If you have 3 vertices:
(0, 0), (0, 1), (1, 0)
Then looking at it straight on, they are defined in a clockwise order. Swap the last 2 vertices and they would be anti clockwise.

clockwise indices: 0, 1, 2
counter-clockwise indices: 0, 2, 1

Depends where your looking from though, look from behind and they wind the opposite direction.

Share this post


Link to post
Share on other sites
[quote name='Endemoniada' timestamp='1306878002' post='4818042']
I have a list of triangles that I want to be sure are all in the *same* winding order.[/quote]
If the triangles are connected, you can check to see if each shared edge is oppositely oriented with respect to the (presumably two) triangles that share the edge. If the edge is directed in the same direction for each of the two triangles, then the triangles are wound in opposite directions.

Share this post


Link to post
Share on other sites

This topic is 2390 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this