[ODE] Camera movement in ODE

gabdab gabdab at spamhole.com
Wed Dec 13 02:39:33 MST 2006


I have found quite a good implementation the one used by slickworm , or
perhaps Medieval playground.
Even though I am striving to include that in my code it is quite hard .

Gab-

jan meskens wrote:
> 
> 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
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode
> 
> 

-- 
View this message in context: http://www.nabble.com/Camera-movement-in-ODE-tf2808759.html#a7849760
Sent from the ODE mailing list archive at Nabble.com.



More information about the ODE mailing list