Game Development Reference
In-Depth Information
All of the preceding functions require a btVector3 object to define the direction and
the strength of the effect. Just like the Newtonian definition, forces (such as gravity)
continuously accelerate an object in a given direction, but do not affect their rotation.
Meanwhile, torque is the rotational equivalent of a force, applying a rotational accel-
eration to an object causing it to rotate in place around its center of mass. Hence,
applyForce() and applyTorque() provide the means for applying these effects,
respectively.
Meanwhile, the difference between forces and impulses is that impulses are forces
that are independent of time. For instance, if we applied a force to an object for a
single step, the resultant acceleration on that object would depend on how much
time had passed during that step. Thus, two computers running at slightly different
time steps would see two completely different resultant velocities of the object after
the same action. This would be very bad for a networked game, and equally bad for
a single player game that suffered a sudden spike in activity that increased the step
time temporarily.
However, applying an impulse for a single step would give us the exact same result
on both computers because the resultant velocity is calculated without any depend-
ence on time. Thus, if we want to apply an instantaneous force, it is better to use ap-
plyImpulse() . Whereas, if we want to move objects over several iterations, then it
is better to use applyForce() . Similarly, applying a Torque Impulse is an identical
concept, except it applies a rotational impulse. Hence, we would use applyTor-
queImpulse() if we wanted an instantaneous rotational kick.
Finally, the difference between applyCentralForce() and applyForce() is
simply that the former always applies the force to the center of mass of the object,
while the latter requires us to provide a position relative to the center of mass (which
could always default to the center of mass, anyway). Basically, the Central func-
tions are there for convenience, while the rest are more flexible since in the real
world if we pushed a box on its edge we would expect it to move linearly (force), but
also rotate a little (torque) as it moved. The same distinction applies to applyCen-
tralImpulse() and applyImpulse() .
Knowing all of this, if we follow the pattern of function names we may notice that ap-
plyCentralTorque() is missing. This is because there's no such thing in the laws
of physics. A torque must always be applied at an offset from the center of mass,
since a central torque would simply be a linear force.
Search WWH ::




Custom Search