[ODE] Questions about representing motion in ODE

Jean-Sebastien Guay jean-sebastien.guay at polymtl.ca
Sun Mar 12 07:35:53 MST 2006


Hello,

This is my first time working with a physics library. We're making a small game
for a graphics programming class. Without explaining the whole game, I think it
will suffice to say that it has to do with submarines, in an "arcade" kind of
way (picture a kind of "Mario Kart" but with submarines instead of go-karts).

I'm having trouble representing the submarine's movement correctly using ODE,
and would like some advice on how to make it fun (even if it isn't totally
correct for a submarine). At first, to test it out, I just applied a force when
the player pressed the "accelerate" or "forward thrust" key. But that just makes
me go in one direction forever and I have to counter that force with an opposite
one to stop (which is physically what I asked ODE to do, but not what I want -
it's too hard to control in an "arcade" type of game). I also tried to reset
the force in the direction the sub is going with something like this:

// SetForce calls dBodySetForce with my application's Vector class
// GetForce calls dBodyGetForce and converts the dVector3 to my application's
//   vector class
// m_Direction is a unit vector representing the sub's direction
SetForce( m_Direction * GetForce().GetLength() );

I thought that it would just go at the same speed but always in the direction
the sub was pointing, but that didn't work. (It would just continue to go in
the direction I had given at the AddForce() call, when accelerating)

>From your experience, how would you model something like that in ODE? I'd prefer
it were a simple way. I haven't made wrappers for the joints yet either so I'd
prefer not to use them for now.

Also, is there a better way to model the sub's rotation? For now, I just get yaw
and pitch from reading the mouse and change m_Direction (and other vectors) to
reflect that, but would it be better if I applied for example a torque or
something like that? How would I do that to get what I want?

Thanks in advance,

J-S
--
______________________________________________________
Jean-Sebastien Guay     jean-sebastien.guay at polymtl.ca
                         http://whitestar02.webhop.org


More information about the ODE mailing list