[ODE] A (hopefully) simple collision response question

Glenn Watson nzglenn at yahoo.com
Sun May 12 21:22:01 2002


Sure, here it is:
Sorry if the text wraps badly, the yahoo mail thing is
a tiny widget..

void ODEWorld::NearCallback(void *method , dGeomID o1,
dGeomID o2)
{
	ODEWorld	*val	=	(ODEWorld *)method;
	dWorldID	wID		=	val->GetWorldID();
	dJointGroupID		cID		=	val->GetContactGroupID();

	// Don't create contact joints between two geo
objects
	// that don't have rigid bodies (ie are static geo)
	if (dGeomGetBody( o1 ) == NULL && dGeomGetBody( o2 )
== NULL)
		return;

	dContact contacts[ODE_MAX_CONTACTS];
	// get the contacts up to a maximum of N contacts
	const unsigned int n = dCollide(o1, o2,
ODE_MAX_CONTACTS, &contacts[0].geom,
sizeof(dContact));

	for(unsigned int i = 0; i < n; ++i)
	{
        contacts[i].surface.mode = dContactBounce;
		contacts[i].surface.mu = 250;
		contacts[i].surface.bounce = 0.3f;
		contacts[i].surface.bounce_vel = 0.05f;
		dJointID c = dJointCreateContact(wID, cID,
&contacts[i]);
		dJointAttach(c, dGeomGetBody(contacts[i].geom.g1),
dGeomGetBody(contacts[i].geom.g2));

		Log::Msg( LOGCHANNEL_ALWAYS, LOGTYPE_INFO, "Creating
contact joint: between objects %x and %x", o1, o2 );
	}
}

Thanks for your help.

--- "Martin C. Martin" <martin@metahuman.org> wrote:
> Can you post the code for your callback?
> 
> - Martin
> 
> Glenn Watson wrote:
> > 
> > Hi, I am having trouble getting a rigid body
> object to
> > correctly respond to colliding with a static
> geometry
> > object.
> > 
> > The rigid body object has both a body and geometry
> ID,
> > and the static geometry is organised as:
> > 
> > Several bounding boxes -> Geometry group ->
> Geometry
> > transform.
> > 
> > The call back correctly detects when the collision
> > occurs (the logging messages appear at the exact
> time
> > the rigid body and the geometry object come in
> contact
> > with each other) but there doesn't seem to be any
> > response.
> > 
> > The rigid body just continues straight through the
> > geometry as if it is not responding at all to the
> > contact joints being created. The call back I am
> using
> > is almost exactly the same as the one provided in
> the
> > buggy demo, just loops through the contacts,
> creating
> > a list of contact joints with dBounce etc.
> > 
> > I am using a fixed time step of 0.01 but varying
> this
> > between 1 and 0.005 has no effect whatsoever..
> Does
> > anyone have any ideas on what could be causing
> this to
> > happen??
> > 
> > Thanks
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > LAUNCH - Your Yahoo! Music Experience
> > http://launch.yahoo.com
> > _______________________________________________
> > ODE mailing list
> > ODE@q12.org
> > http://q12.org/mailman/listinfo/ode


__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com