Game Development Reference
In-Depth Information
The _skin property is used to hold the transformations of the graphic element
to which we want to attach the rigid body. The _currState property has two
components: _currState.position and _currState.get_orientation . The
position vector in JigLib is defined by an array of the three elements. JigLib has its own
JVector3DUtil to manipulate the 3D vectors. The _currState.get_orientation().
glmatrix statement returns an object of type mat3 (an older version of glMatrix). The
collisions objects hold the collisions data.
The RigidBody class does not define the shape of the object in itself. The properties
that hold the shape of the object are _boundingBox and _boundingSphere . The
_boundingBox property is of the type JAABox . The JAABox class has functionalities
to handle collision points defined by shapes such as box, sphere, and capsule.
Soft bodies
Items that need to change shapes are often represented in the physics engine as soft
bodies. A soft body simulates all the aspects of a rigid body (linear and angular
velocity as well as volume) but with the additional feature of a changeable shape,
that is, deformation. This approach is used for items such as clothing, hair, and
wobbly alien jellyfish. It is considerably more expensive, both computationally and
memory-wise, than the rigid body representation.
Understanding the physics shapes
We have already discussed how the physics simulation should be decoupled as much
as possible from the rendering loop. This also applies to the data structures and to
the shapes and meshes of the game objects. The object which is rendered onto the
screen can be of any shape and can be made up of many polygons. However, it is not
practical to simulate large numbers of complexly shaped objects in the physics engine.
Almost every object that is simulated by the physics engine will be represented as a
simple convex shape, such as a sphere or cuboid, or as a collection of such shapes.
Calculating collisions and penetrations between objects can be a very expensive
process. So simplifying the shapes that represent the simulated objects greatly
improves the required computation. Hence, you will see that we use very simple
objects and shapes to represent our 3D models in physics simulations.
JigLib has defined some useful physics shapes which we generally attach to our
graphic geometries. JBox , JSphere , JCapsule , JPlain , JTerrain , and JTriangleMesh
are the most commonly used objects that inherit the RigidBody class. They have some
extra properties that define the shape, for example, JBox has width, height, depth, and
JSphere has radius.
 
Search WWH ::




Custom Search