[ODE] Pushing through collisions
Alen Ladavac
alenl-ml at croteam.com
Sat May 1 10:35:52 MST 2004
> I did really want to
> use ODE's motorized joints for setting the velocity when I started using
> it, but I couldn't come up with a way that would work. What type of
> joint would you use?
I am not very familiar with the ODE joint types, but I don't think that the
one you need is built in. Still, it is very easy to derive, just like I
described under #1a in mail last post.
To elaborate more... What you want is a method to apply just enough force to
keep the object going at given constant velocity in given direction, with
respect to all other external and constraint forces, while still not
exceeding some maximum "propelling" force. The propelling force should be
something like m/a where m is object's mass and a is desired maximum
acceleration of the object. You might want to add the friction in the
equation, but it is all elementary physics.
What is not elementary physics is how do you apply just the right amount?
Because the m/a gives only the _maximum available_ force, and if you keep
applying that constantly you will keep accelerating constantly. You need
some way to determine amount to apply in this step, so that it will
automatically adapt to external and joint forces, some of which are not
known yet. Ideal solution for that is another joint.
Joint J matrix describes the direction(s) (in world space) along which
constraint forces will act. Each row corresponds to one direction (i.e. one
force). The correction term for that row (is that called "c" is ODE?)
describes velocity that you want the body to achieve along that direction.
Usually, joints put error/stepsize*ERP there, and so they get positional
correction. Lo/Hi limits define mimimum and maximum amount of force that may
be applied along that direction.
We can tweak those by putting our desired movement direction (normalized
vector) in one row of J, putting velocity in the correction term for that
row, and setting Hi/Lo limits to maximum available force. This will give you
exactly the effect you need.
For a final touch you will want an additional row whose direction is
orthogonal to the first one, and with velocity ("c" term) set to 0, so it
cancels sideways movement when your avatar is cornering.
It really is more text that it would be code, but I don't have any ODE
compatible code for such joint to paste here. Overall, it is very easy to
implement.
HTH,
Alen
----- Original Message -----
From: "Colin Bonstead" <colin at cyan.com>
To: "ode" <ODE at q12.org>
Sent: Thursday, April 29, 2004 15:48
Subject: Re: Re[2]: [ODE] Pushing through collisions
> >1a) Side note, for Colin... don't set velocities directly. I'm sure
> >you've been told so before. :) But I guess you weren't told how to
> >give constant velocity to your avatar in a simple way using forces.
> >Just create a simple motor joint with two constraints in J, one along
> >desired axis of motion, another orthogonal to it. Put desired
> >velocity in the right side of first row and zero in the right side of
> >second row, and finaly set hi/lo limits to +/- desired force (F=M/a).
>
> In my defense, I inherited the velocity setting code, and it worked fine
> before so I didn't want to try and change it. :) I did really want to
> use ODE's motorized joints for setting the velocity when I started using
> it, but I couldn't come up with a way that would work. What type of
> joint would you use? The only one I can think of that would work the
> way you describe would be the slider joint, and I would think something
> bad would happen if you attached 2 of those to one object. Maybe the
> Croteam engine has a type of joint that ODE doesn't.
>
>
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode
>
More information about the ODE
mailing list