[ODE] objects in water
Tyler Streeter
tylerstreeter at gmail.com
Mon Jan 17 10:17:24 MST 2005
I have a few ideas about these questions. I've come up with a way to
deal with both of these issues (underwater drag/damping and buoyancy
at the surface, which is the same as when the object is underwater
except that only part of the object has buoyancy forces). These
methods are approximations that should run in real-time. Also, note
that they are very scalable. They should be dynamically scalable
(think LODs for physics calculations).
First, each object's surface is covered with a set of points. Let's
call them "shape approximation points" (SAPs). These are a way to
approximate an object's shape for the subsequent calculations. A
sphere would probably need at least six SAPs spaced around its
surface. A box would need at least 20 (one on each corner and one in
the middle of each line segment) for damping calculations or just 8
(one on each corner) for surface behavior calculations. Again, these
numbers could be scaled up for more realistic behavior.
Underwater Drag/Damping:
---------------------------------
The base underwater damping level (linear and angular) underwater
should be higher than in air, as Yordan already mentioned. Note that
if you use the right damping method, less massive object will
automatically be damped more.
"Center" here always refers to the object's center of mass. For each
object, pre-calculate (when the object is created) its average SAP
distance as follows:
1. Normalize the distance of the SAPs to the objects center (i.e. the
farthest SAP would have distance of 1).
2. Calculate the avg. SAP distance from the center.
3. Scale the object's underwater (linear and angular) damping amount
by 1/(avg. SAP distance).
Thus, higher avg. SAP distance implies more roundness which results in
less damping. A lower avg. SAP distance implies less roundness which
results in more damping. An alternative would be to scale damping by
(1 - avg. SAP distance).
Note that the SAPs must be placed at salient locations on the object
to adequately influence its avg. SAP distance. Since this scalar is
pre-computed anyway, you could use a lot of SAPs (say, 100 per object)
to get a more accurate average.
I imagine this could work similarly for air friction damping calculations.
Buoyancy Forces:
----------------------
A smaller set of SAPs should be used for this part since each one
involves a significant amount of processing and is not pre-computed.
So, a sphere would use maybe 6 SAPs, and a box would use 8 (one on
each corner). Every time step (or maybe less frequently), do the
following for each SAP:
1. Figure out if it is penetrating the water's surface. The water
could be a simple plane, any other primitive shape, or a height map.
(Note that ODE already has functions for each geom that check if a
point is inside.).
2. If the point is within the volume of water, apply a force to the
object (at that point) in the opposite direction of gravity. The
force's magnitude would be scaled using density and mass.
Here's a question: does penetration depth matter for buoyancy
calculations? I'm guessing that buoyant objects deep underwater would
have more buoyant forces than objects close to the water's surface.
Even so, it's probably not worth the effort to simulate this in most
real-time applications.
Let me know if you have any feedback.
Tyler
More information about the ODE
mailing list