[ODE] Trimesh collisions
join at krakendev.com
join at krakendev.com
Thu Aug 26 18:50:27 MST 2004
I'm currently attempting to get up to speed on how TriMeshes are
implemented in ODE, and I've made some progress. At present, however, I
can't seem to get the trimesh I'm working with to collide with the ground.
It's a simple diamond shaped mesh to which I've attached a 'box' body as
such:
static dGeomID ground;
static dGeomID TriMesh;
static dTriMeshDataID TriMeshData;
static dBodyID TriBody;
dMass m;
// create world
world = dWorldCreate();
space = dHashSpaceCreate (0);
contactgroup = dJointGroupCreate (0);
dWorldSetGravity(world,0.0,-1.0,0.0);
ground = dCreatePlane (space,0,.5,0,0);
TriMeshData = dGeomTriMeshDataCreate();
dGeomTriMeshDataBuildSimple(TriMeshData,
(dReal*)loader->v,loader->numVerts,
loader->i,loader->numIndices);
TriMesh = dCreateTriMesh(space, TriMeshData, 0, 0, 0);
dGeomSetPosition(TriMesh,0.0,1.0,0.0);
dGeomSetData(TriMesh,TriMeshData);
TriBody = dBodyCreate (world);
// w, h , depth
dMassSetBox (&m,1,0.15,0.8,0.25);
dMassAdjust (&m,1.0);
dBodySetPosition(TriBody, 0.0, 1.0, 0.0);
dBodySetMass (TriBody,&m);
dGeomSetBody (TriMesh,TriBody);
However, the 'diamond' just cruises through the ground, where the boxes I
had created earlier landed. My collision callback is near verbatim from
the buggy example:
static void nearCallback (void *data, dGeomID o1, dGeomID o2)
{
int i,n;
const int N = 10;
dContact contact[N];
n = dCollide (o1,o2,N,&contact[0].geom,sizeof(dContact));
if (n > 0) {
for (i=0; i<n; i++) {
contact[i].surface.mode = dContactSlip1 | dContactSlip2 |
dContactSoftERP | dContactSoftCFM | dContactApprox1;
contact[i].surface.mu = dInfinity;
contact[i].surface.slip1 = 0.1;
contact[i].surface.slip2 = 0.1;
contact[i].surface.soft_erp = 0.5;
contact[i].surface.soft_cfm = 0.3;
dJointID c = dJointCreateContact (world,contactgroup,&contact[i]);
dJointAttach (c,
dGeomGetBody(contact[i].geom.g1),
dGeomGetBody(contact[i].geom.g2));
}
}
}
Thanks in advance for any help.
More information about the ODE
mailing list