Game Development Reference
In-Depth Information
for now. We want to enrich this static model with physically motivated motion.
There are quite a lot of forces that can be taken into account, so the focus should
lie on forces that add most to the felt realism of a simulation. The question then
is how to construct them in a computationally economic way.
In the end, the sum of all acting forces is the change in velocity for each vertex
at a given time step.
The first extension we make to this basic animated mesh model is to call the
vertex positions of the animated mesh model the “rest” positions ( x i ) and give
our actual positions ( x i ) the freedom to vary from those. They will get a mass to
define how they will react on a given force (remember f = m a ?). We also have
to keep track of the accumulated forces acting on each vertex. The file structure
storing the per-vertex information for now could be something like this:
struct Ve r t ex
{
Vector3 pos; // current position
Vector3 vel; // current velocity
Vector3 restPos; // position given by data
Vector3 force; // the total force on a vertex
real mass;
}
The Vector3 data type is a structure holding the three components of a vector;
“real” can be either a single- or double-precision floating-point representation.
14.2.1 Numerical Integration
Time is a continuous quantity. When writing down equations for the positions
and the velocities of the vertices, they should hold for every time t . In computer
simulation, however, we always have to deal with discrete time steps of length h .
The introductory chapter of this topic (Chapter 1) gives an overview of the most
important integration schemes. We update the velocities and positions by the
following scheme:
v i ( t + h )= v i ( t )+ h f tota i ( t ) ,
x i ( t + h )= x i ( t )+ h v i ( t + h ) .
This is the semi-implicit Euler scheme. In contrast to the standard Euler inte-
gration, this scheme uses v ( t + h ) (implicit) in the equation for x ( t + h ) while
the standard Euler integration uses v ( t ) (explicit). This scheme still commits a
global error of the order of h every time step (see [Donelly and Rogers 05] on
this matter). If more accuracy is needed, we could consider using higher-order
integration schemes, such as the fourth-order Runge-Kutta method [Acton 70].

Custom Search