Using existing physics libraries: Newton
CS 480 Lecture,
Newton is a small, closed source but cross-platform physics library. You can download an SDK for Windows, Mac, or Linux.
Broad categories of stuff in Newton (and almost any physics library):
One rather odd aspect of Newton is the "ForceAndTorqueCallback".
This is a function you write and then attach to your Body, that applies
forces and torques to the body. Newton needs a callback to do
this because it may have to apply forces several times in one timestep.
- A Body
is the central object in Newton. A body has a position and
orientation (represented as a BodyMatrix, a 4x4 column-major matrix
just like OpenGL prefers), a mass, and rotational inertia along three
axes. You apply forces to bodies, read back body orientations
during rendering, and generally use bodies for almost everything.
- A Collision
object is attached to a Body to keep it from passing through other
Bodies. Note that the collision is usually a lot simpler than the
body's full rendered geometry--for example, an entire ant monster might
use a simple sphere for collision.
like hinge/axle or ball in socket, permanently connect two
bodies. Joints are good for building articulated structures like
ragdolls or vehicles. Curiously, joints are specified in world coordinates, not in body-local coordinates.