Specific sequence needed for vertices?

Started by
4 comments, last by Buckeye 16 years, 2 months ago
Hey guys! I have a simple question. I was trying to make an object out of simple basic shapes like cubes and triangles. After I finished programming the shape and my output was rotated continuously specific sides of the final object started vanishing at various degrees of rotation. I wanted to know if there is a specific sequence of inputting the vertices of sides while creating a cube or triangle? Also why are these sides vanishing? Thanks!
Advertisement
The winding order of the vertices must be in clockwise order, for example:

If they are in antic clockwise order and backface culling is on then they will start getting culled and dissappearing.

Hope that helps,

EDIT: I failed miserable at ASCII art after 4 attempts, here is a linke to an article on GD, Backface Culling
Yes there, is. Vertices should be defined in a counter-clockwise order when facing the visible side. There may be a setting to change this, but I'm not certain.

The reason the faces disappear is because the process assumes that triangles which aren't defined in a counter-clockwise order are facing away from the viewer, and so they are discarded as an optimization by default.

EDIT -- Dave may be correct about clockwise over counter-clockwise. I'm not familiar with direct3D specifically. However, suffice it to say that there is indeed a specific winding order, whatever it is and that the rest of my post applies if you substitute the correct, Direct3D winding order.

throw table_exception("(? ???)? ? ???");

It depends on a d3d render state, as to which rotation is culled. I have always done it as i described.
Alright I'll try out both the anti clockwise and clockwise order to see which works. Thanks guys!
First: the default winding order for DX is clockwise.

Second: To quickly test if the problem is the winding order, use:

m_pDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );

That will render both front and back faces of each triangle.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

This topic is closed to new replies.

Advertisement