[ODE] Trimesh - box collision problem

Matthias Weigand weigole at gmx.de
Tue Jan 24 03:05:33 MST 2006


Hi,

I have some weird collision problems with a trimesh and a box. Below I'm 
building up a triangle mesh with simply two triangles. And test it 
against a box, that should definitly collide with the first triangle. 
But in the code below it does not collide, until I do one of the following:
- Pass 3 instead of 6 to the indexCount parameter of 
dGeomTriMeshDataBuildSimple.
- Set the height of the second triangle to 60.
- Link the program against the debug build of ODE's library (producing 
debugging symbols was essential)

int main()
{
  //vertices
  //colliding triangle
  dVector3 v[6];
  v[0][0] = 0;
  v[0][1] = 74;
  v[0][2] = 16;

  v[1][0] = 16;
  v[1][1] = 74;
  v[1][2] = 16;

  v[2][0] = 16;
  v[2][1] = 74;
  v[2][2] = 0;

  //useless triangle
  v[3][0] = 0;
  v[3][1] = 0;
  v[3][2] = 1;

  v[4][0] = 1;
  v[4][1] = 0;
  v[4][2] = 0;

  v[5][0] = 1;
  v[5][1] = 0;
  v[5][2] = 1;

  //indices
  int32 i[6];
  for (int32 s=0; s < 6; s++) i[s] = s;

  dTriMeshDataID tridata = dGeomTriMeshDataCreate();
  dGeomTriMeshDataBuildSimple(tridata, (dReal*)v, 6, i, 6);
  dGeomID mesh = dCreateTriMesh(0, tridata,NULL,NULL,NULL);

  dGeomID boxt = dCreateBox(0,5,5,5);
  dGeomSetPosition(boxt,16,76,8);

  dContactGeom g;
  cout << dCollide(boxt,mesh,1,&g,sizeof(dContactGeom));

  return 0;
}

What the hell is going on here?

BTW: A sphere behaves correctly.

Thanks for help,
weigo


More information about the ODE mailing list