[ODE] Camera movement in ODE

jan janmeskens at pandora.be
Tue Dec 12 09:45:20 MST 2006


Hi All,

I am currently implementing a camera in ODE, which should be able to 
walk around in a virtual world (I use OpenSG for the drawing stuff, the 
camera (a box) is set as the Camera beacon).

I have some troubles while implementing this :

1) When the camera collides with an object in the world, the objects in 
the world react on a collision with the camera. For some objects this is 
desired (eg. a ball) , for others not (a wall, fixed objects). I read in 
the user-guide that a joint should be created between the camera and the 
static environment (NULL) when the camera collides. I did this, but this 
seems to be very unstable : the camera loops after a collision with an 
object and goes through the ground plane. I inserted the code I used for 
this here :

// 'Wrld' is my c++ worldclass, which contains the WorldID, SpaceID and 
GeomID of the camera
 
static void nearCallback (void *data, dGeomID o1, dGeomID o2)
{

  dBodyID b1 = dGeomGetBody(o1);
  dBodyID b2 = dGeomGetBody(o2);

  if(o1 == wrld->getCameraObject()){
        dContact contact;

        if(dCollide (o1,o2,0,&(contact.geom),sizeof(dContactGeom)))
        {
            contact.surface.mode = dContactSoftERP | dContactSoftCFM | 
dContactApprox1;
            contact.surface.mu = dInfinity;
            contact.surface.soft_erp = 0.96;
            contact.surface.soft_cfm = 0.04;
            dJointID c = dJointCreateContact 
(wrld->getWorld(),wrld->getContactGroup(),&contact);
            dJointAttach (c,b1,NULL);
        }
  }
 
  else
  {
    const int N = 32;
    dContact contact[N];
    int n = dCollide (o1,o2,N,&(contact[0].geom),sizeof(dContact));
    if (n > 0) 
    {
        for (int i=0; i<n; i++) 
        {
        contact[i].surface.mode = dContactSoftERP | dContactSoftCFM | 
dContactApprox1;
        contact[i].surface.mu = dInfinity;
        contact[i].surface.soft_erp = 0.96;
        contact[i].surface.soft_cfm = 0.04;
        dJointID c = dJointCreateContact 
(wrld->getWorld(),wrld->getContactGroup(),&contact[i]);
        dJointAttach (c,
                        dGeomGetBody(contact[i].geom.g1),
                        dGeomGetBody(contact[i].geom.g2));
         
        }
    }
  }
}

2) Is it a good choice to take a box as physically moving camera? I have 
my doubts about it. For example when I try to look down, the square 
collides with the ground plane, so only a small angle is tolerated (the 
same thing happens when I try to look upwards). Is there any better 
object to simulate a camera, walking through the world?

Thanks in advance,

Best regards,

Jan Meskens


More information about the ODE mailing list