• Advertisement
Sign in to follow this  

How to colliding bodies x bodies and bodies x mesh in ODE?

This topic is 4587 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How to colliding bodies x bodies and bodies x mesh in ODE? I read the doc and i no understand how to do this, and in the internet i no find more explanations about =Please anyone help me.

Share this post

Link to post
Share on other sites
Start with body x body collisions first, then once you've got them figured out, work on the mesh. Then you'll need the simulation and physics model code (the order in which everything gets updated/etc.), and the collision response function (the function that responds to collisions, and moves objects approprately). Information on both of these things can be found in the documentation (Section 3.10/3.11 for the simulation and physics model, and Section 10.5 for the collision response). Just to let you know, the collision response function is part 'd' of step 9. I assume you can get the basic model done (it's not too hard), so here's a slight modification of the collision response function mentioned in section 10.5, that should have the bodies colliding:

extern dWorldID worldID;
extern dJointGroupID contactGroup;
const int MAX_CONTACTS = 16;

//object parts can still collide with other parts...
void myCollisionResponse(void* data,dGeomID o1, dGeomID o2){
if (dGeomIsSpace(o1) || dGeomIsSpace(o2)){
if (dGeomIsSpace(o1)) dSpaceCollide((dSpaceID)o1,data,&myCollisionResponse);
if (dGeomIsSpace(o2)) dSpaceCollide((dSpaceID)o2,data,&myCollisionResponse);
dBodyID b1 = dGeomGetBody(o1);
dBodyID b2 = dGeomGetBody(o2);

// return without doing anything if both bodies are part of the static environment.
if (b1 == 0 && b2 == 0) return;

//return without doing anything if the two bodies are connected by a joint
if (b1 && b2 && dAreConnectedExcluding(b1,b2,dJointTypeContact)) return;

dContact contacts[MAX_CONTACTS];
int i,numc;
if (numc = dCollide(o1,o2,MAX_CONTACTS,&contacts[0].geom,sizeof(dContact))){
for (i = 0;i < numc;i++){
contacts.surface.mode = dContactSlip1 | dContactSlip2 | dContactSoftERP | dContactSoftCFM | dContactApprox1;
contacts.surface.mu = dInfinity;
contacts.surface.slip1 = 0.1;
contacts.surface.slip2 = 0.1;
contacts.surface.soft_erp = 0.5;
contacts.surface.soft_cfm = 0.0;

dJointID c = dJointCreateContact(worldID,contactGroup,&contacts);

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement