Game Development Reference
In-Depth Information
Physics and Terrains
In a game, we generally do not like to control our animations, typically in a case
where a bullet or a grenade is involved. We want force, impulse, and gravity to
control the motion in a game. This is what this chapter is about—physics simulation.
We will discuss how physics engines control component trajectories as well as work
with collision detection in a game. However, before we dive deep into physics, we
want to extend the terrain (ground) of our game scene. We will cover the following
topics in this chapter:
A simple terrain: plane geometry
JavaScript 3D physics engines: JigLibJS
Adding gravity and a rigid body to the game scene
Forces, impulse, and collision detection: grenade and bullet
animation revisited
Extending our terrain with physics
Understanding a simple terrain - plane
geometry
In all our previous examples, we have used a JSON file ( model/obj/terrain.json )
as our terrain or ground base, where we have added all our objects. This approach is
generally not used in games where the scene is a complete city or world. In a game,
terrains are endless. The terrain should appear to meet the sky. If we clone the OBJ
file multiple times to achieve the effect, then we might make the rendering slower; the
same effect can be achieved with fewer polygons rendered. This is why most graphic
libraries come with functionalities to create basic geometries such as a plane, sphere,
octahedron, and others. In this chapter, we will focus on a plane geometry.
Search WWH ::




Custom Search