CUSTOMVERTEX Vertices2[] =
{
{ 50.0f, 50.0f, 0.5f, 1.0f, 0xffff0000, }, // x, y, z, rhw, color
//{ 250.0f, 50.0f, 0.5f, 1.0f, 0xff00ffff, },
{ 250.0f, 250.0f, 0.5f, 1.0f, 0xff00ff00, },
{ 50.0f, 250.0f, 0.5f, 1.0f, 0xff00ffff, },
for( DWORD i=0; i<50; i++ )
{
FLOAT theta = (2*D3DX_PI*i)/(50-1);
pVertices[2*i+0].position = D3DXVECTOR3( sinf(theta),-1.0f, cosf(theta) );
pVertices[2*i+0].normal = D3DXVECTOR3( sinf(theta), 0.0f, cosf(theta) );
pVertices[2*i+1].position = D3DXVECTOR3( sinf(theta), 1.0f, cosf(theta) );
pVertices[2*i+1].normal = D3DXVECTOR3( sinf(theta), 0.0f, cosf(theta) );
}
في 20 يوليو 2008 09:08 م، غمغم إياس باستغراب قائلاً:
و لكن كما تلاحظون أنا حاولت ضيف نقطة جديده بمحاولة مني لرسم مربع بدل المثلث , إلا أنه لا يتم التعرف إلا على الثلاث نقاط الأولى فقط و لم أجد مكاناً يحدد بأن الكود للتعامل مع المثلث فقط ؟!! فما الطريقة لرسم مربع أو مسدس ....D3DPT_POINTLIST = 1,
D3DPT_LINELIST = 2,
D3DPT_LINESTRIP = 3,
D3DPT_TRIANGLELIST = 4,
D3DPT_TRIANGLESTRIP = 5,
D3DPT_TRIANGLEFAN = 6,
D3DPT_FORCE_DWORD = 0x7fffffff
// assume the device object is created and ready to use
// assume the Vertex structure is defined to store Vertex Pos and normal
// this is a variable for our vertex data buffer
IDirect3DVertexBuffer9* quad = 0;
// ----------------------------------------------------
device->CreateVertexBuffer(
6 * sizeof(Vertex),
D3DUSAGE_WRITEONLY,
Vertex::FVF,
D3DPOOL_MANAGED,
&quad,
0);
Vertex* v;
quad->Lock(0, 0, (void**)&v, 0);
// now set the triangles vertex data that create the qaud
// note, texture coordinates
v[0] = Vertex(-1.0f, -1.0f, 1.25f, 0.0f, 0.0f, -1.0f);
v[1] = Vertex(-1.0f, 1.0f, 1.25f, 0.0f, 0.0f, -1.0f);
v[2] = Vertex( 1.0f, 1.0f, 1.25f, 0.0f, 0.0f, -1.0f);
v[3] = Vertex(-1.0f, -1.0f, 1.25f, 0.0f, 0.0f, -1.0f);
v[4] = Vertex( 1.0f, 1.0f, 1.25f, 0.0f, 0.0f, -1.0f);
v[5] = Vertex( 1.0f, -1.0f, 1.25f, 0.0f, 0.0f, -1.0f);
quad->Unlock();
//-------------------------------------------------------
// in drawing function just set these lines between the scene begin and end function
device->SetFVF(Vertex::FVF);
device->SetStreamSource(0, quad, 0, sizeof(Vertex));
// now draw the quad as list of triangles starting from vertex 0 and draw 2 TRi
device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);