3D positioning question
I use the following code to plax a flat box on the screen.
D3DVECTOR p1 = D3DVECTOR( -.5f, -.5f,0);
D3DVECTOR p2 = D3DVECTOR( .5f, -.5f,0);
D3DVECTOR p3 = D3DVECTOR( .5f, .5f,0);
D3DVECTOR p4 = D3DVECTOR( -.5f, .5f,0);
But only one triangle shows up. When I rotate it along the y axis, I see the other triangle on the ''back'' of the first.
I have been staring at this code forever and I''m sure that I missed something ignorantly small..
BTW - I render with a D3DPT_TRIANGLESTRIP.
Thanks
D3D culls counterclockwise triangles, and you have your vectors defined in counterclockwise order. it should be like this:
D3DVECTOR p1 = D3DVECTOR( -.5f, -.5f,0);
D3DVECTOR p2 = D3DVECTOR( -.5f, .5f,0);
D3DVECTOR p3 = D3DVECTOR( .5f, .5f,0);
D3DVECTOR p4 = D3DVECTOR( .5f, -.5f,0);
or you could change the way d3d does culling by doing this:
IDirect3DDevice3->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW);
(D3DCULL_CCW is default)
i''d suggest the first way though.
D3DVECTOR p1 = D3DVECTOR( -.5f, -.5f,0);
D3DVECTOR p2 = D3DVECTOR( -.5f, .5f,0);
D3DVECTOR p3 = D3DVECTOR( .5f, .5f,0);
D3DVECTOR p4 = D3DVECTOR( .5f, -.5f,0);
or you could change the way d3d does culling by doing this:
IDirect3DDevice3->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW);
(D3DCULL_CCW is default)
i''d suggest the first way though.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement