[ODE] collision detection/response without using ODE's collision engine

SkeedaddIer@aol.com SkeedaddIer at aol.com
Sun Jun 9 08:57:01 2002


Hi,

    I am confused as to how to do collision detection/response of SPHERE 
objects against PLANES, without using ODE's internal collision engine.

    For example, I am trying to hack the test_boxstack.cpp file to handle 
bouncing of spheres against the ground plane when the user presses 's'.

    What i did:

    1) i removed the nearCallback function and the dSpaceCollide function 
that calls it

     2) i defined a groundplane struct containing a dBodyID/dGeomID with a 
position of 0,0,0 and normal of 0,0,1
     
      groundplane.body = dBodyCreate(world); 
        dBodySetPosition(groundplane.body, 0, 0, 0);
        groundplane.geom[0] = dCreatePlane (space,0,0,1,0);
    
    3) during simLoop, i coded a simple test where:

        const dReal *p = dBodyGetPosition(obj[i].body);
        const dReal *v = dBodyGetLinearVel(obj[i].body); 

           //vector3 is a personal vector lib I use, not part of ODE & also 
well tested
        vector3 position = vector3(p[0], p[1], p[2]);
        vector3 velocity = vector3(v[0], v[1], v[2]);
            vector3 newposition = position + velocity;

        if((newposition.z - sphere.radius) <= 0.0f) {
             //..filled in dContact struct here - see 4) below...
            dJointID c = dJointCreateContact (world, contactgroup, &contact);
                dJointAttach(c, obj[i].body, groundplane.body);    
        }   


    4) this is how I filled my dContact struct:

        dVector3 contactposition = {newposition.x,
                                                    newposition.y,
                                                    (newposition.z - 
sphere.radius)};

        dVector3 contactnormal = {0.0, 0.0, 1.0};

        dContact contact;       
 
            contact.surface.mode = dContactBounce; //dContactMu2;
            contact.surface.mu = dInfinity;
            contact.surface.mu2 = 0;
            contact.surface.bounce = 1.0;
            contact.surface.bounce_vel = 0.1;

        contact.geom.pos = contactposition;
        contact.geom.normal = contactnormal;
        contact.geom.depth = 0;
        contact.geom.g1 = obj[i].geom[0];
        contact.geom.g2 = groundplane.geom[0];

        5) lastly i called dWorldStep as shown in the source.

        The spheres are not bouncing as they are expected to. Anyone have 
ideas what i may be doing wrong? Thanks in advance.