|
I am having trouble rotating my camera.
I move it based on two angles (in radians).
It can move left to right just fine.
When I look straight up it starts slowing down and will stop.
Also, when the camera has turned 90 degrees right or left, it will not look up or down, it will do an odd spinning thing.
Here is my code for adding the angles to the camera direction:
direction = new Vec3( FloatMatrix.multiplyMatrix( FloatMatrix.getAxisRotationMatrix( rot.y, UP ), new FloatMatrix( direction ) ) );
Vec3 toRotateAround = Vec3.cross( direction, UP );
direction = new Vec3( FloatMatrix.multiplyMatrix( FloatMatrix.getAxisRotationMatrix( -rot.x, toRotateAround ), new FloatMatrix( direction ) ) );
Also, my LookAt matrix for the camera:
Vec3 s = Vec3.cross( direction, up );
s = s.getUnitVec3();
Vec3 u = Vec3.cross( s, direction );
float[] an = {
s.x, s.y, s.z, 0.0f,
u.x, u.y, u.z, 0.0f,
-direction.x, -direction.y, -direction.z, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
If further clarification is needed, please ask.
Thank you for your time,
Michael Mitchell
|