[ODE] Collision handling

tullio.molitierno at libero.it tullio.molitierno at libero.it
Wed Jul 14 10:04:13 MST 2004


In my simulation there are spheres and boxes which collide with a trimesh. 
I have to simulate friction only for sphere-trimesh collision and it has not to
be box-trimesh friction. I have written this nearcallback function, but it
doesn't work (there isn't friction):
	
dBodyID b1 = dGeomGetBody(o1);
dBodyID b2 = dGeomGetBody(o2);

int cat1=dGeomGetClass(o1);
int cat2=dGeomGetClass(o2);

if (b1 && b2 && dAreConnectedExcluding (b1,b2,dJointTypeContact)) return;

if (b1 == b2)	return;


if( (cat1 == SPHERECLASSID && cat2 == BOXCLASSID) ||
    (cat1 == BOXCLASSID && cat2 == SPHERECLASSID))
{
	return;
}

if(cat1 == BOXCLASSID && cat2 == BOXCLASSID)
{
	return;
}

dContact cnt[MAX_CONTACTS];

for (int i=0; i<MAX_CONTACTS; i++) {
	cnt[i].surface.mode = 0;
	cnt[i].surface.mu = 0;
	cnt[i].surface.mu2= 0;
}


Num = dCollide(o1, o2, MAX_CONTACTS, &cnt[0].geom, sizeof(dContact));
	

if( (cat1 == BOXCLASSID && cat2 == TRIMESHCLASSID) ||
			(cat1 == TRIMESHCLASSID && cat2 == BOXCLASSID))
{
	//Box-trimesh collision

	cnt[i].surface.mu = 0;

					}
else if((cat1 == SPHERECLASSID && cat2 == TRIMESHCLASSID) ||
	(cat1 == TRIMESHCLASSID && cat2 == SPHERECLASSID))
{
	//Sphere-trimesh collision

	cnt[i].surface.mode = dContactFDir1 | dContactMu2;
        cnt[i].surface.mu = 1;
	cnt[i].surface.mu2= 1;
}
	
		dJointID c = dJointCreateContact(ODEworld,ODEcontactgroup, &cnt[i]);
		dJointAttach( c, b1, b2);

	}  

Thanks to all

Tullio




More information about the ODE mailing list