My question is: How can I draw a correct pyramid (triangular quadrilateral pyramid) using D3DPT_TRIANGLEFAN?
I used as points:
CUSTOMVERTEX vertices[] =
{
{ 0.0f, 3.0f, 0.0f, 0x00ff0000, }, //The top Vertex
{ 1.0f, 0.0f, -1.0f, 0xff00ff00, }, //(A) vertex
{ 1.0f, 0.0f, 1.0f, 0xff0000ff, }, //(B) vertex
{ -1.0f, 0.0f, 1.0f, 0xffffff00, }, //(C) vertex
{ -1.0f, 0.0f, -1.0f, 0xffff00ff, }, //(D) vertex
{ 1.0f, 0.0f, -1.0f, 0xff00ff00, }, //(A) vertex
};
where a CUSTOMVERTEX is:
struct CUSTOMVERTEX
{
float x, y, z;
DWORD color;
};
and I call it by:
g_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 5);
The pyramid draws correctly, but there is an additional triangle drawn to the screen, the one made with the top and the first vertex ( a right triangle with the PI / 2 angle in the base of the pyramind and the other point being <<1.0f, 0.0f, -1.0f>> (the first point (A)).
So what I want is to hide that triangle, I tried making the device draw from 1 to 5 but that only gives me the base ( (A)-(B)-(C)-(D) plane ), and I also tried making the culling D3DCULL_CW, and when I rotated the pyramid half the time I can see the additional triangle and half it was hidden by another plane.