[ODE] re: trimesh woes

Ian McMeans imcmeans at telus.net
Sat Aug 21 20:47:46 MST 2004


Yeah, the data is set up to be drawn with GL_TRIANGLES. I was 
temporarily drawing it in wireframe to make sure the data looked right 
(and it does). Collisions seem to happen correctly for the most part, (I 
can make the object balance on it's nose, or on one of the wings), the 
only problem is how every mesh seems to be able to balance a fair 
distance above the ground. The problem doesn't show up when the 
controlled object is a box geom instead of a trimesh.

Here's the tetrahedron-making code, I'm using it to debug. However, even 
with this simple tetrahedron things seem to be behaving incorrectly, and 
I have no idea why.

float size = 0.05f;
   vertices[0][0] = 0;
   vertices[0][1] = 0;
   vertices[0][2] = 0;

   vertices[1][0] = size;
   vertices[1][1] = 0;
   vertices[1][2] = 0;

   vertices[2][0] = 0;
   vertices[2][1] = size;
   vertices[2][2] = 0;

   vertices[3][0] = 0;
   vertices[3][1] = 0;
   vertices[3][2] = size;

   triIndices[0] = 0;
   triIndices[1] = 2;
   triIndices[2] = 1;

   triIndices[3] = 0;
   triIndices[4] = 1;
   triIndices[5] = 3;

   triIndices[6] = 0;
   triIndices[7] = 3;
   triIndices[8] = 2;

   triIndices[9] = 1;
   triIndices[10] = 3;
   triIndices[11] = 2;

   totalVerts = 4;
   totalTriIndices = 12;

   dGeomTriMeshDataBuildSimple(odeMesh, (dReal*) vertices, totalVerts, 
triIndices, totalTriIndices);

And when I render that with GL_TRIANGLES, it shows up as a tetrahedron 
(well, a right triangle, since it's axis aligned), as I expect it to. 
Here are some screenshots of what's going wrong:
http://img55.exs.cx/my.php?loc=img55&image=problem2.jpg
http://img55.exs.cx/my.php?loc=img55&image=problem3.jpg

The dark green color is the background, the white triangle is the 
tetrahedron, the light green and pink surface is the box. I tried using 
a 1D array for verts, but that didn't fix it. The code to draw the 
object is so simple, I don't think that's where the problem is.

Ian

Mike Reinstein wrote:

>
> Ian:
>
> I think the problem is that you arent passing in vaertices for 
> triangles....the data appears to be ordered for line loops, not 
> triangles, so you'll have to do some manipulation of the vertices 
> array to get the ordered properly. GL_LINE_LOOP draws a series of 
> connected lines, where GL_TRIANGLES expects every3 vertices to form a 
> triangle. I would suggest you look at your polygons rendered as 
> GL_LINE_LOOP piece by piece...look at the first 3 vertices, and make 
> sure its being drawn as 1 triangle. If it is, look at the first 6 
> vertices and make sure its being drawn as 2 triangles correctly. then 
> look at the first 9 vertices and make sure they are drawn as 3 
> triangles, etc.
> I think you'll find that doing this will yield answers.
>
> Hope this helps,
>
> Mike
>
>
>
>
> >From: Ian McMeans <imcmeans at telus.net>
> >To: ode at q12.org
> >Subject: [ODE] re: trimesh woes
> >Date: Sat, 21 Aug 2004 03:12:32 -0700
> >
> >I've got a new problem, unfortunately. It seems like my trimeshes
> >(no matter what the mesh data is, even a simple tetrahedron) hover a
> >short distance above the box they should be resting on. And the
> >distance they hover depends on the size of the trimesh, and the
> >orientation (what I mean by that is that the "jet" (the 
> fish-shaped-
> >thing) can balance on its nose, but when I try to have it rest on
> >it's side, it rests a distance above the box.
> >
> >http://img23.exs.cx/my.php?loc=img23&image=problem.jpg
> >
> >So I thought maybe the trimesh data was bad, but when I draw the
> >collision data like this:
> >glBegin(GL_LINE_LOOP);
> >    for (int i = 0; i < totalTriIndices; i++)
> >    {
> >        glVertex3fv(vertices[triIndices[i]]);
> >    }
> >    glEnd();
> >
> >it looks the way I expect it to. The data is passed to ODE like
> >this:
> >dGeomTriMeshDataBuildSimple(odeMesh, (dReal*) vertices, totalVerts,
> >triIndices, totalTriIndices);
> >
> >Anyone have any ideas what's going on? This doesn't happen with box
> >geoms, but it happens when I hard-code the trimesh data for a cube.
> >I don't understand what could be going wrong.
> >
> >Ian
> >_______________________________________________
> >ODE mailing list
> >ODE at q12.org
> >http://q12.org/mailman/listinfo/ode
>
> _________________________________________________________________
> Check out Election 2004 for up-to-date election news, plus voter tools 
> and more! http://special.msn.com/msn/election2004.armx
>
>




More information about the ODE mailing list