Well, here is a video of my camera controller so far. It might not be as apparent when you are not pushing the buttons, but there is momentum in the camera now. I am not always pushing the move buttons in this film, sometimes the "weight" of the camera is moving it, which gives the player more feed back and makes it appear more like a helicopter now.
Here is a quick way for keeping track of local physics stats for an object (a camera in my case) like it's velocity: When keeping these variables, keep the coordinate systems relative to that object. So for the camera, I kept the velocity vector's coordinate system the same as the camera's local coordinate system, or rather I kept the positive x-axis on the velocity to move the camera to it's right. Then when it comes time to move that object relative to the world space (so a positive x-axis velocity might move the camera any direction!) find out how you need to rotate the camera's local coordinate system to match that of the world coordinate system, then apply those same rotations to the movement vectors. Here is my code to do this for my camera:
//make a quaternion that rotates the velocity vector
//from camera space to world space. Only on X-Z plane right now.
//
lookAt
is a convienence method for auto-setting the
quaternion based on a direction and an up vector.quaternion.lookAt(camOriginalDirection, Vector3f.UNIT_Y);
movementVector = quaternion.mult(velocity);
No comments:
Post a Comment