I've managed to draw a spinning octahedron using DrawPrimitive, and now I've duplicated the shape so the result would be two touching, spinning octahedrons. The problem is that one of them is always drawn first, so I get this awful effect during the rotation: http://d.imagehost.org/0010/d3d.jpg
Is there any way Direct3D can automatically "sort" the vertex drawing order so the octahedrons cover each other alternatively?
This is my render procedure:
g_lpD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, NULL); g_lpD3DDev->BeginScene();g_lpD3DDev->SetStreamSource(0, g_lpD3DVB, 0, sizeof(VERTEX));g_lpD3DDev->SetFVF(D3DFVF_XYZ|D3DFVF_DIFFUSE);D3DXMATRIX m1;D3DXMatrixIdentity(&m1);D3DXMatrixTranslation(&m1, 1, 0, 0);g_lpD3DDev->SetTransform(D3DTS_WORLD, &m1);g_lpD3DDev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 8);D3DXMatrixIdentity(&m1);D3DXMatrixTranslation(&m1, -1, 0, 0);g_lpD3DDev->SetTransform(D3DTS_WORLD, &m1);g_lpD3DDev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 8);DWORD tc = GetTickCount();D3DXVECTOR3 vEye (sin((float)tc/1000)*5, 0, cos((float)tc/1000)*5);D3DXVECTOR3 vLookAt (0.0f, 0.0f, 0.0f);D3DXVECTOR3 vUp (0.0f, 1.0f, 0.0f);D3DXMATRIXA16 m2;D3DXMatrixLookAtLH(&m2, &vEye, &vLookAt, &vUp);g_lpD3DDev->SetTransform(D3DTS_VIEW, &m2);D3DXMATRIX m3;D3DXMatrixPerspectiveFovLH(&m3, D3DX_PI/4, 1.0f, 1.0f, 100.0f);g_lpD3DDev->SetTransform(D3DTS_PROJECTION, &m3);g_lpD3DDev->EndScene();g_lpD3DDev->Present(NULL, NULL, NULL, NULL);
Thanks!