Game Development Reference
In-Depth Information
sume that each object will be subject to gravity's pull, thus mass will be an important
attribute. Size will also be important, not only because you'll need to know how big
things are when checking for collisions and handling other interactions, but also because
size is related to the distribution of the object's mass. More precisely, each object will
have mass moment of inertia attributes. The objects will most likely also have some
ascribed coefficient of restitution that will be used during collision response handling.
Additionally, you might ascribe some friction coefficients that may be used during col‐
lision response or in situations where the objects may slide along a floor. As the objects
will likely find themselves airborne at some point, you'll probably also include a drag
coefficient for each object. All of these parameters will help you differentiate massive
objects from lighter ones or compact objects from voluminous ones.
If your simulation involves more than generic rigid bodies, then your physics will be
more specific and perhaps far more elaborate. A great example of a more complicated
model is flight simulation. No matter how good your generic rigid-body model, it won't
fly like any specific aircraft if it flies at all. You must develop a model that captures flight
aerodynamics specific to the aircraft you're simulating. Chapter 15 shows how to put
together a model for an aircraft that can be used in a real-time flight simulation.
The other chapters in Part IV of this topic are meant to give you a taste of modeling
aspects for a variety of things you might simulate in a game. Just as you cannot simulate
an aircraft with a generic rigid-body model, you cannot simulate a ship with an aircraft
model, nor can you simulate a golf ball with a ship model. The point is that you must
spend some time designing your physics model specific to what you're going to simulate
in your game. Time spent here is just as important to creating a realistic physics engine
as time spent on designing a robust integration scheme or collision detection system.
We can't overstate the importance of the physical model. The model is what defines the
behavior of the thing you're simulating.
Simulated Objects Manager
Your simulated objects manager will be responsible for instantiating, initializing, and
disposing of objects. It will also be responsible for maintaining links between object
physics and other attributes such as geometry, for example, if in a 3D simulation you
use the same polyhedron to render an object and for collision detection and response.
You must have some means of managing the objects in your simulation. One can imag‐
ine many different approaches to managing these objects, and unless your simulation
uses just a handful of objects or fewer, essentially what you need is a list of objects of
whatever class you've defined. You've seen in previous chapters' examples where we use
simple arrays of RigidBody type objects or Particle type objects. If all the objects in
your simulation are the same, then you need only a single class capturing all their be‐
havior. However, for more diversity, you should use a list of various classes with each
class encapsulating the code required to implement its own physical model. This is
Search Nedrilad ::

Custom Search