locked
Drawing Polygons RRS feed

  • Question

  • I'm reading a 3ds file so got all cordinates Vertex x,y,z and polygons a,b,c

    now i want to draw my object but i dont know how, what do I need to use ?

    D3DPT_TRIANGLELIST,  D3DPT_TRIANGLESTRIP,....????

    I took all vertex, and i tried D3DPT_POINTLIST so i can see all the vertex and they're in right place, but i need to draw my object, i mean i can see just vertex no the polygons of my object , im using this code:

     

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14

    //Loop to get all vertex

    ..

    t_vert2Idea.X = file3ds.vertexIdea.x;

    t_vert2Idea.Y = file3ds.vertexIdea.y;

    t_vert2Idea.Z = file3ds.vertexIdea.z;

    ..

    // end of loop

     

     

    // create vertex buffer

    device->CreateVertexBuffer

    (

    sizeof(t_vert2),

    0,

    D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1,

    D3DPOOL_MANAGED,

    &vertex,

    NULL

    );

     

    VOID* pVoid;

    vertex->Lock(0, 0, (void**)&pVoid, 0);

    memcpy(pVoid, t_vert2, sizeof(t_vert2));

    vertex->Unlock();

    ...

     

    // drawing
    device->SetStreamSource(0, vertex, 0, sizeof(Vector3df));

    for (int i = 0; i < 152; i++)

    {

    device->DrawPrimitive(D3DPT_POINTLIST, i, 1);
    }

     

    Thank you !

    Patrick Carvalho

    Friday, February 8, 2008 7:01 PM