[ODE] Terrain + ODE ... again

devicezero devicezero at hotpop.com
Tue May 11 22:03:06 MST 2004


Thanks Paul, your ideea sound like a nice aproximation, and I think can 
work very good only if object body is small and cover a small number of 
triangles. I will try to implement it in this night, and let you know 
the results!:)

P.S. Just filled the ODE survey!:)


Paul Cheyrou-Lagreze wrote:

>
>> So, can someone who already have made it to explain a good way to 
>> have  terrain collision?
>
>
> Because there is many ways to handle this, Benoit CHAPEROT 
> implementation,  transform terrain into a trimesh, Create a new Ode 
> object as in slickworm  http://slickworm.sourceforge.net/, etc.
>
>> Heh... ODE is i nice stuff.. i don't understand why nobody write  
>> something strong for this,... a
>
>
> So here's another one, surely the easiest to test... (don't know if 
> it's  the best one...)
>
> I use "Sliding Planes", that is ode plane appears under entities 
> according  to terrain normals at the entity position.
>
> Here's one (in C++),
> that just need a GetHeightAt function in you terrain algos :
>
> /////code
> const dReal *pos_bod = dBodyGetPosition (entity->getBody ());
>
> float objheight = (float) pos_bod[1]; // pos_bod[1] is  entity y pos
>
> Vector3 pos = Vector3 ((Real) pos_bod[0],
>                        (Real) pos_bod[1],
>                        (Real) pos_bod[2]);
>
> getHeightAt (pos); // does modify pos.y according to terrain height 
> at  this position
>
> // if test is true, then there is some collision
> // therefore, we create a "sliding plane"
> if  (pos.y > objheight)
> {
>   Vector3 vecz = pos;
>   Vector3 vecx = pos;
>
>
>  vecx.x = vecx.x + SHIFT_POS;
>  activetempentity->getHeightAt (vecx);
>
>  vecz.z = vecz.z + SHIFT_POS;
>  activetempentity->getHeightAt (vecz);
>
>  Vector3 kEdge1 = pos - vecx;
>  Vector3 kEdge2 = vecz - vecx;
>  Vector3 normal = kEdge1.crossProduct (kEdge2);
>
>  normal.normalise();
>  Real distance = normal.dotProduct (pos);
>
>  dPlane temp  (space,
>            (dReal) normal.x, (dReal) normal.y, (dReal) normal.z,
>            (dReal) distance);
>
>  dContact contact[NUM_CONTACTS];
>  if (int numc = dCollide (entity->getGeom (),  temp.id (), 
> NUM_CONTACTS,  &contact[0].geom, sizeof(dContact)))
>   {
>      for (int i=0; i < numc; i++)
>      {       
>      [...]// usual Ode contact stuff
>      }   
>   }
> }
> /////end of code
>
> - SHIFT_POS must be equal to object width or height...
> - Vector3, Vector3::normalise and Vector3::dotProduct comes from OGRE  
> engine. but surely you have same objects or functions somewhere in 
> your  code. (perhaps there is some in Ode's?)
>
> ...
>




More information about the ODE mailing list