Game Development Reference
In-Depth Information
the simulation and resume it later, it is usually not necessary 20 to include
these variables in the state description:
force and torque accumulators,
linear and angular impulse accumulators,
list of current contact constraints.
We use the word “accumulators” here to reflect what often happens in
practice. These values are often reset to zero at some point within the
frame, and then different sources of external forces are polled, and the net
result stored in these variables.
Listing 12.2 is a structure that summarizes the essentials of a dynamics
body state and hints at how it might be implemented in C++. These vari-
able names are used in the pseudocode later in this chapter. You should
compare this to the corresponding class in a real physics engine implemen-
tation to see what additional data that engine chose to keep on hand, or
what different choices were made.
s t r u c t
DynamicsBody
{
/ /
/ /
P r i m a r y
q u a n t i t i e s
/ /
/ /
P o s i t i o n
o f
c e n t e r
o f
mass
V e c t o r 3
po s ;
/ /
O r i e n t a t i o n
i n
q u a t e r n i o n
f o r m a t
Q u a t e r n i o n
r o t Q u a t ;
/ / Mass
f l o a t
mass ;
/ /
Moment
o f
i n e r t i a ,
e x p r e s s e d
i n
body
space .
M a t r i x 3 x 3
j B o d y ;
/ / V e l o c i t i e s
V e c t o r 3
l i n V e l ;
V e c t o r 3
a n g V e l ;
/ /
/ /
D e r i v e d
q u a n t i t i e s
/ /
/ /
O r i e n t a t i o n ,
i n
m a t r i x
form
M a t r i x 3 x 3
r o t M a t ;
/ /
I n v e r s e
mass
and
i n e r t i a
t e n s o r
f l o a t oneOverMass ;
M a t r i x 3 x 3
i n v J B o d y ;
20 The precise details depend on the method of numerical integration. Some methods
of integration utilize historical values in order to approximate higher derivatives.
Search WWH ::




Custom Search