[ODE] Collision objects
Ken M
wgold at flyingplastic.com
Sat Apr 27 09:32:01 2002
Sure!
Just test for that condition in your nearCallback() routine and don't add a
dCollideJoint for that collision, call a "handleInvisibleIntersection()"
method to respond to it instead. If you don't add a dCollideJoint at the
time of collision, ODE won't repond at all. The normal use case for the
nearCallback() already tests is the objects are joined with a joint, and if
so ignores the collision. Your case is a little trickier, as you'll have to
lookup the objects in a table or something of the kind to determine if it's
one of your invisible objects, but certainly not a insurmountable problem.
modified From TestBoxstack.cpp
---- snip ----
static void nearCallback (void *data, dGeomID o1, dGeomID o2)
{
int i;
// exit without doing anything if the two bodies are connected by a joint
dBodyID b1 = dGeomGetBody(o1);
dBodyID b2 = dGeomGetBody(o2);
if (b1 && b2 && dAreConnected (b1,b2)) return;
dContact contact[3]; // up to 3 contacts per box
for (i=0; i<3; i++) {
contact[i].surface.mode = dContactBounce; //dContactMu2;
contact[i].surface.mu = dInfinity;
contact[i].surface.mu2 = 0;
contact[i].surface.bounce = 0.5;
contact[i].surface.bounce_vel = 0.1;
}
if (int numc = dCollide (o1,o2,3,&contact[0].geom,sizeof(dContact))) {
// dMatrix3 RI;
// dRSetIdentity (RI);
// const dReal ss[3] = {0.02,0.02,0.02};
for (i=0; i<numc; i++) {
if ( !isIgnoreObject(o1) || !isIgnoreObject(o2) )
{
dJointID c = dJointCreateContact (world,contactgroup,contact+i);
dJointAttach (c,b1,b2);
}
}
}
}
bool isIgnoreObject( dGeomID obj )
{
// test for object .. An stl::set would be good here, filled
// and managed each frame with your 'ignorable' geom.
}
--- snip ---
Hope this helps.
Ken
----- Original Message -----
From: <symeg@tcd.ie>
To: <ode@q12.org>
Sent: Saturday, April 27, 2002 10:17 AM
Subject: [ODE] Collision objects
> Myself and some other guys are doing a project for college in which we are
> making a multiplayer space combat game. We are using ODE for the physics
and
> are well-impressed with it.
>
> I have one question though. Is it possible to insert a geometry into the
space
> which will inform you whether objects have collided with it, but not cause
any
> response to the collision? I was thinking that it would be a handy way to
check
> which objects were going to be effected by an explosion.
>
> Any Suggestions?
>
> -Gordon
> _______________________________________________
> ODE mailing list
> ODE@q12.org
> http://q12.org/mailman/listinfo/ode