Getting an array of the vertices and indices from an ID3DXMesh?

C815f3804514d0bb6dfa9aadf2a486dd
0
chillypacman 101 May 31, 2007 at 13:51

Hi all :)

I’m trying to create a method that will take out the vertices and indices of an ID3DXMesh and put them in an array so that I can use it to create a trimesh in ode.

Basically I want to do this:

dGeomID plane;
dTriMeshDataID triMesh;
...
    // Plane geometry
    const int indexes[6] = {2, 1, 0, 3, 2, 0};// <--- THIS
    const dVector3 triVert[4] = { //<------- AND THIS
        { 10.0,  0.0,  10.0},
        {-10.0,  0.0,  10.0},
        {-10.0,  0.0, -10.0},
        { 10.0,  0.0, -10.0}
    };
 
    triMesh = dGeomTriMeshDataCreate();
    dGeomTriMeshDataBuildSimple(triMesh, (dReal*)triVert, 4, indexes, 6);
    plane = dCreateTriMesh(space, triMesh, NULL, NULL, NULL);
    dGeomSetData(plane, "Plane");
    dGeomSetPosition(plane, 0, -10.0, 0);

Heres what I have so far and it doesn’t work:

int* indexes;
    float* vert;

    LPDIRECT3DVERTEXBUFFER9 VB;
    LPDIRECT3DINDEXBUFFER9 IB;
    dVector3 triVert;
    
    model->GetVertexBuffer(&VB);
    model->GetIndexBuffer(&IB);

    memcpy_s(indexes, sizeof(IB), IB, sizeof(IB));
    memcpy_s(vert, sizeof(VB), VB, sizeof(VB));

If anyone could shed osme light on this it would be GREATLY appreciated :)

1 Reply

Please log in or register to post a reply.

Bb6f53a8aeb7ad02f5f0824bec672721
0
Oybl 101 May 31, 2007 at 19:56

You have to lock the buffers first, then you get a pointer to actual data