[ODE] Holding bodies like in HL2

michael kapelko kornerr at gmail.com
Tue Sep 12 03:08:44 MST 2006


I added ray for a player and when I do dGeomRaySet (ray, pos, dir) my 
player flies away from the map into the sky...
I don't do any collision detection with ray, I just added it and update 
its position + direction every graphics update, and this somehow causes 
the player to fly away into the sky.

SRC: http://kornerr.alfamoon.com/download/12.tar.bz2
It requires Irrlicht >= 1.1.
The physics player code is found in src/phys/player.{h,cpp}
and wrapper around graphics and physics representations is located in 
src/wrap/player.{h,cpp}
Update function looks like:
void WrapPlayer::Update () {
    // Make capsule standing
    dQuaternion q;
    dQFromAxisAndAngle (q, 1, 0, 0, DegreeToRadian (90));
    dBodySetQuaternion (pp->GetBody (), q);
    // Decrease body speed after releasing move buttons
    const dReal *av = dBodyGetAngularVel (pp->GetBody ());
    const float D = 1.2;
    dBodySetAngularVel (pp->GetBody (), av[0] / D, av[1] / D, av[2] / D);
    // Update camera position
    const dReal *pos = dBodyGetPosition (pp->GetBody ());
    cam->setPosition (vector3df (pos[0], pos[1], pos[2]));
    // Make gun_ray point where cam points
    vector3df cp (cam->getPosition ());
    vector3df cd (cam->getTarget ());
    dGeomRaySet (pp->GetGunRay (), cp.X, cp.Y, cp.Z, cd.X, cd.Y, cd.Z);
}
Thanks.



More information about the ODE mailing list