Game Development Reference
In-Depth Information
mat4.invert(mMatrix,mMatrix);
mat4.translate(this.modelMatrix,mMatrix,vec3.fromValues(1,-3,-8));
}
Open 06-Bullet-Action-Complete.html in your editor again to accommodate
our new RightHand class. We updated our loadStageObject function. Now in the
function, we check the object name and create the corresponding object, like in our
case, we wanted a child object for RightHand . We then assign a camera object to each
stage object and then add an object to the Stage class.
function loadStageObject(url,location,rotationX,rotationY,rotationZ){
$.getJSON(url,function(data){
Var nameOfObject=data.metadata.sourceFile.split(".")[0];
var stageObject=null;
if(nameOfObject=="rightHand"){
stageObject=new RightHand();
}
else{
stageObject=new StageObject();
}
stageObject.camera=cam;
stageObject.loadObject(data);
...
}
}
Simple bullet action - linear animation
In this section, we will add another object to our scene, the bullet ( Bullet.json ),
and we will move our bullet in a straight line, unlike Angelina Jolie's movie Wanted ,
where the guys curve bullets. We can do that by applying B-spline interpolation but
we are still medieval and we will save it for our grenade.
The equation to move the bullet is simple: f(x)=z. We will simply change the z value
to move the bullet. However, this is awful because if we rotate ourselves (the camera
and subsequently, our arm), the bullet should go in the arm's direction. To achieve
this, we need to apply the camera transformation to the bullet. Each bullet will have
the same defined set of points, let's say (0,0,1),(0,0,2)...(0,0,200), but when we apply
these translations to the clone of the camera matrix, then each time we fire the bullet
from a different angle or position, we will get different trajectories. Actually, these
defined positions are with respect to the camera and not the scene. If we apply
camera transformations to the bullet, then we will get different trajectories with
respect to the scene.
Scene Co-ordinates=Camera Matrix*Translation(Position)
 
Search WWH ::




Custom Search