Game Development Reference
In-Depth Information
mat4.multiply(mvMatrix,mvMatrix,mMatrix);
}
else{
mat4.translate(mvMatrix,mvMatrix, stage.stageObjects[i].location);
mat4.rotateX(mvMatrix,mvMatrix,stage.stageObjects[i].rotationX);
mat4.rotateY(mvMatrix,mvMatrix,stage.stageObjects[i].rotationY);
mat4.rotateZ(mvMatrix,mvMatrix,stage.stageObjects[i].rotationZ);
}
...
}
...
}
We first compare if the object is rightHand , and then we clone the camera view matrix
( var mMatrix=mat4.clone(cam.viewMatrix) ). Then, we calculate the model matrix
by calculating the inverse of the camera matrix ( mat4.invert(mMatrix,mMatrix); ).
Then, we calculate our final ModelView matrix by multiplying it with the current
mvMatrix .( mat4.multiply(mvMatrix,mvMatrix,mMatrix); ). Now our arm is exactly
placed at our camera's position and it should look similar to the following screenshot:
 
Search WWH ::




Custom Search