Game Development Reference
In-Depth Information
The preceding code initializes the TerrainData object with the same properties
that we initialized the geometry with ( new TerrainData(this.width, this.
height,this.ws,this.wh, this.geometry); ). Then, we create a new jigLib.
JTerrain(terrain); object and assign it to the rigidBody object.
Now, when you run 07-Terrain-Physics-Modified.html in your browser and
you fire bullets or drop grenades on the bump, you will find that it is an active
physics static object.
Implementing height maps
Our implementation to modify geometry is very simple ( Plane.prototype.
modifyGeometry ), we just check the value of x and y and return a hard coded value
of z , but this not how most implementations work. Our geometry can be modified
using the following code snippet:
Plane.prototype.modifyGeometry=function(x,y){
...
else if((x>=100&&x<150)&&(y>=100&&y<150)){
return 20;
}
...
}
The correct implementation is using height maps. A height map is a simple 2D grayscale
image as shown in the following image. The image has shades of gray, one base color
with light and dark areas. The dark areas denote heights and lighter areas denote dips:
 
Search WWH ::




Custom Search