[ODE] newb. question about vertex indice

William Mallouk mallouk at ig.com.br
Tue Aug 26 19:35:02 2003


Hi there,

I will try to explain how to do it, but first I will tell you that
there are two very good examples on how to do this on the \ode\test dir of
the ODE distribution. The files are test_trimesh.cpp and
test_moving_trimesh.cpp. You may want to take a look at them later.

Basically, there are two steps you have to follow before calling
dGeomTriMeshDataBuildSimple.

First, you have to define what are the vertices of your mesh by creating an
array of dVector (each vector represents one vertex).

In the example below, I am defining four vertices.

   dVector3* Vertices = new dVector3[4];
    Vertices[0][0] = 10;
    Vertices[0][1] = 10;
    Vertices[0][2] = 10;
    Vertices[1][0] = -10;
    Vertices[1][1] = -10;
    Vertices[1][2] = -10;
    Vertices[2][0] = 10;
    Vertices[2][1] = -10;
    Vertices[2][2] = 10;
    Vertices[3][0] = 0;
    Vertices[3][1] = 0;
    Vertices[3][2] = 0;

Second, you have to define what vertices form the triangles (faces) of your
mesh by creating an array of int that will contain the indices of the
vertices that you have defined above.

The sample below has two triangles. One of them if made of vertices 0, 1,
and 3, and the other one is made of vertices 0, 2, and 3. Note that this
data is placed sequentially in one array, so you will one array with 6
positions in order to represent that.

    int* Indices = new int[6];
    // First triangle
    Indices[0] = 0;
    Indices[1] = 1;
    Indices[2] = 3;
    // Second triangle
    Indices[0] = 0;
    Indices[1] = 2;
    Indices[2] = 3;

After that, you just have to call dGeomTriMeshDataCreate() to generate an ID
for yor trimesh data, and then call dGeomTriMeshDataBuildSimple, and finally
call dCreateTriMesh in order to get your timesh's dGeomID.

   dTriMeshDataID Data = dGeomTriMeshDataCreate();
   dGeomTriMeshDataBuildSimple(Data, Vertices, 4, Indices, 6);
   dGeomID mGeomID = dCreateTriMesh(spaceID, Data, 0, 0, 0);

Hope that helps..!

William Mallouk

----- Original Message ----- 
From: "Foxy" <imfox.mulder@laposte.net>
To: <ode@q12.org>
Sent: Tuesday, August 26, 2003 11:47 AM
Subject: [ODE] newb. question about vertex indice


> Hello all,
>
> Im trying to use "dGeomTriMeshDataBuildSimple", but i got a pain to make
the
> vertex indice.
> Can someone tell me how to do it ?
>
> (sorry for my poor english, thats not my first language.)
>
> Thanks in adavance,
> Fox
>
> _______________________________________________
> ODE mailing list
> ODE@q12.org
> http://q12.org/mailman/listinfo/ode
>