Game Development Reference
In-Depth Information
if(stageObject.name=="streetlamp"){
..........
var streetlamp1=stageObject.clone();
.............
streetlamp1.location=[20.0,0.0,70.0];
streetlamp1.rotationX=degToRadian(-90);
............
stage.addModel(streetlamp1);
..............
}
if(stageObject.name=="railing"){
var railing1=stageObject.clone();
var railing2=stageObject.clone();
railing1.location=[40.0,2.0,0.0];
railing1.rotationY=degToRadian(-120);
railing2.location=[-30.0,5.0,-100.0];
railing2.rotationY=degToRadian(-65);
stage.addModel(railing1);
stage.addModel(railing2);
}
if(stageObject.name=="dump"){
........
}
}
Also, we do not wait for all objects to load before invoking the drawScene function.
It is invoked at a regular frame rate from the tick function. The drawScene function
also stores the state of the mvMatrix variable on stack before applying transforms for
each object.
Understanding positional lights
In the scene that we developed in the preceding section, we would like two of the
lamps to light up. There is already one global light in the scene but we want two
positional lights now.
The directional lights are parallel since they are assumed to be at an infinite distance
and are generally the global light in a scene. The intensity of a directional light on a
vertex is not dependent on its distance but on its orientation. Hence, only the normal
direction is used to calculate its intensity. For positional lights, both the distance and
orientation are involved in the intensity calculations.
 
Search WWH ::




Custom Search