Game Development Reference
In-Depth Information
If you want to perform collision detection on arbitrary static and dynamic meshes,
such as a teapot against a stairway, you ' ll need more firepower. For that, I ' d suggest
going straight to a real physics SDK.
Choosing a Physics SDK
There are a lot of options these days for programmers who don
twanttowritetheir
own collision system or a system to handle dynamics. Some of these systems have really
interesting components for handling nonrigid bodies like bowls of Jell-o or vehicles.
Whether you choose to grab one off-the-shelf or write your own, it should have the
following minimum set of features:
'
n Allow user data to relate physics objects with your game objects.
n Optimize collisions for static actors or geometry.
n Trap and report collision events.
n Provide a fast raycaster.
n Draw debug information visually.
n Output errors in a rational way.
n Allow custom memory allocators.
n Add and remove objects, or regions of objects, from the physics simulation
for optimal CPU usage.
n Save and load its own state.
As the physics system simulates the movements of physical objects in a game, it will
need some way to associate objects in its data structures to actual objects in your
game. This is especially true since the physics object will usually have a simpler
geometry than the visible object
a good reason to keep them separate. When phys-
ics objects are created, look for a way to provide a reference, or special user data, to
these objects so you can figure out which physics and game object pairs match.
Most physics systems allow static, or unmovable, actors by setting their mass to zero.
These objects would be the geometry that makes the walls, floors, terrain, and the rest
of the environment, as well as any really heavy object that will never be moved, like a
tree. Most physics systems take advantage of static actors to speed dynamics calculations.
Besides moving objects around, you
ll
also want to know all kinds of things about the collision, such as the force of the
collision, the collision normal, and the two objects that collided. All these things are
'
ll want to know if and when they collide. You
'
 
 
Search WWH ::




Custom Search