[ODE] Re: Dinamic gravity vector

Pete Baron sibaroni at hotmail.com
Fri Aug 20 00:54:53 MST 2004


Hi Andreas,

I don't think you can do gravity by attraction of masses using ODE (unless
you hack in a ton of new stuff) however you can fudge it convincingly by
modifying the part of quickstep.cpp which looks like this:

 for (i=0; i<nb; i++) {
  if ((body[i]->flags & dxBodyNoGravity)==0) {
   body[i]->facc[0] += body[i]->mass.mass * world->gravity[0];
   body[i]->facc[1] += body[i]->mass.mass * world->gravity[1];
   body[i]->facc[2] += body[i]->mass.mass * world->gravity[2];
  }
 }

What you can do here is subtract the planet's centre coordinate from the
body's position coordinate to get a 'down' vector, then apply gravity force
along that direction dependent on the radius of the planet.  (ie. normalise
the result, multiply by the magnitude of the gravity force and use the
result in place of world->gravity in quickstep.cpp). That should give you
attraction towards the planetary core from any point on the planet's
surface.

cheers,

Pete Baron
sibaroni at hotmail.com


> Message: 6
> Date: Thu, 19 Aug 2004 14:14:59 -0000
> From: Andreas Carnaily <carnaily at softhome.net>
> Subject: [ODE] Re: Dinamic gravity vector
> To: ode at q12.org
> Message-ID: <opsczgi91u1idx76 at mail.softhome.net>
> Content-Type: text/plain; format=flowed; charset=koi8-r
>
> Good time All!
>
> I am developing planetary surface and I want to use ODE library for
> phisics. Thanx for developers!
> But is it possible to make not global vector gravity but just "gravity
> point" or mass centre of planet?
>
> Best wishes, Andreas.


More information about the ODE mailing list