Results 1 to 5 of 5

Thread: ODE Space Physics

  1. #1

    ODE Space Physics

    Hi everyone, as WILL is away I figured I' d post a little problem.

    i have a nice space sim I've developing. The ships are controled by thrusters which apply forces to the ODE body at certain positions to get the effect of actually flying the ship. I also have the main engines which apply force in the +ve Z direction (relative to the body). This all works fine. I have also implemented a flight control system which will reduce the angular velocity to 0 if the controls are released.

    Now the question is this...

    I want to limit the maximum linear and angualr velocity (in all directions) to a set value to ensure that the ship doesn't spin totally out of control. Now I could do this by manually setting the velocity is it has reached the maximum but the ODE documentaion advises against this. The other option would be to work out the forces needed to stop the craft accelerating any more. I'm not sure about any other possible solutions.

    Anyone got any thoughts on this?

    Dean
    <A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
    <br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
    <br /></A>

  2. #2

    ODE Space Physics

    heres how im doing it for my physics...

    [pascal]
    var
    LVelocity: TRAGEVector3;
    LCurVel: TRAGEVector3;
    LLength: Single;
    LMass: Single;
    LTimeSlice: Single;

    ...

    LCurVel := rpGetBodyVelocity(FPhysicsWorld, LPhysicsBallIndex);
    LLength := VectorLength(LCurVel);

    if LLength > GMaxSpeed then
    Begin
    LMass := rpGetBodyMass(FPhysicsWorld, LPhysicsBallIndex);
    LTimeSlice := rpGetWorldTimeSlice(FPhysicsWorld);

    LVelocity := VectorScale(LCurVel, GMaxSpeed / LLength);
    rpSetBodyForces(FPhysicsWorld, LPhysicsBallIndex,
    LMass * ((LVelocity[0] - LCurVel[0]) / LTimeSlice),
    0, // dont change Y, otherwise it flies off if it goes up a ramp
    LMass * ((LVelocity[2] - LCurVel[2]) / LTimeSlice));
    end;
    [/pascal]

    time slice is in seconds, and it uses inverse dynamics to set the speed (and its pretty acuret).

    gMaxSpeed is in meters per second


    forces needed to get speed = Mass * (desired velocity - current velocity) / time step

  3. #3

    ODE Space Physics

    thanks tux, I'll look into that. Are you using ODE as an underlying physics engine :?:

    Dean
    <A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
    <br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
    <br /></A>

  4. #4

    ODE Space Physics

    no, im using newton.

  5. #5

    ODE Space Physics

    another thing you might want to look into is adding a damping force in the inverted direction of the thrusters, that might be better for you instead of scaling the velocity (could produce un wanted behavure in 3d physics)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •