[ODE] Collision Problem (Newbie)

Chris Brodie gimp at pnc.com.au
Sat Aug 17 04:42:02 2002


I'm attempting to integrate ODE in to my existing engine. As a simple
test I wanted to start by creating a body object for the camera and a
large flat box. I position the camera above the box and would have
expect to see it drop on the floor and stop dead. This doesn't happen.
It drops to the ground but after  the ground \ camera collision test
occurs the position of the camera is set to infinity.

Here is what I call from ode in order of what is called (many details
omitted as my engine is over 500 classes):

Setup:

dWorldCreate
dHashSpaceCreate
dHashSpaceSetLevels
dJointGroupCreate


Creating the Ground: 

dCreateBox(500,500,2.5)
dGeomSetBody(body set to 0, as per doco 11.4)
dGeomSetPosition(0,0,0)
dRFromAxisAngle
dGeomSetRotation


Creating the Camera: 

dBodyCreate
dCreateBox(2,2,2)
dGeomSetBody
dBodySetPos(0,5,0)
dGeomSetPos(0,5,0)
dMassSetBox
dMassAdjust(1)
dBodySetMass

Loop:
dSpaceCollide
dWorldStep (0.05f)
dJointGroupEmpty
After this I get the transform of each object to render the world in
OpenGL


My so far simple Collision Callback:

static void ProximityTest (void *data, dGeomID o1, dGeomID o2)
{
	dContact ContactPoints[3];

	dBodyID Body1 = dGeomGetBody(o1);
	dBodyID Body2 = dGeomGetBody(o2);

	//Test to see if we have a collision between a body in motion
and the static environment
	if ((Body1 == 0) || (Body2 == 0))
	{
		dJointID Contact = dJointCreateContact
(GetPhysicsWorld(), GetCollisionGroup(), &ContactPoints[0]);
		dJointAttach(Contact, Body1, Body2);
		return;
	}
}

At some close point after I hit the 'return' I get the position of the
camera set to infinity(probably the next world step). The non standard
collision test is as descried in the doco : "11.4. How can an immovable
body be created?"

Additional Info : 

-I tried just copying and existing CollisionTest callback from
BuggyTest. This doesn't reset the position of the camera to infinity but
when I crash in to the ground I seem to spin out of control in a
corkscrew. 

-If I turn gravity off I seem to be able to move around normally, the
physics portion seems to be setup correctly.

-If I copy an existing CollisionTest callback from BuggyTest then run in
to some large box in front of me I get deflected but end up tumbling
away in an almost random direction.



All help greatly appreciated. This is driving me bananas! Two full days
on the problem already...

Many thanks,

Chris Brodie
http://fourth.flipcode.com