View Full Version : Camera
I have a question about camera inplementation. I have created a camera object to be used in a game that my partners and I are creating. It is a first person camera similar to Quake, etc, etc. My problem is that when the camera looks down or up and then rotates left or right, the view rotates around the Z axis to some degree. Please don't say that this is gimbal lock and that I should use quaternions, cuz this is not the same thing. I have tried to get the camera to rotate around the world Y axis instead of the camera's local Y axis, but to no avail. Does anyone have any suggestions? Thanks in advance.
05-11-2001, 12:48 AM
I think that the problem comes from the way you apply the step rotation at each frame on the camera object.
You have to think your camera as 2 frames,
The head frame and the body frame
The yaw rotation is supposed to be applyed first around the vertical axis of the body frame (The Y axis).
The pitch rotation is supposed to be applyed secondly around the lateral axis of the head frame (The X axis if Z axis go behind the view).
If you keep this hierarchy of 2 frame matrices then you can rotate each frame independantly without any problem because each rotations will be applyed in its corresponding frame.
[Rbody] = [Rbody]*[RDeltaYaw]
[Rhead] = [Rhead]*[RDeltaPitch]
Then you will obtain the absolute camera matrix as follow:
[Rcam] = [Rbody][Rhead]
If you compute directly one single camera step rotation matrix it won't work simply like that:
[RDeltaCam] = [RDeltaYaw]*[RDeltaPitch]
[RCam] = [RCam]*[RDeltaCam]
This is wrong because the Yaw delta rotation is not applyed in the good body frame but in the old camera frame already affected by the old pitch rotations.
You can keep this method but you need to find the good axis in the current cam frame around which to rotate for yaw and pitch...
I prefer the first way...
Hopping that will help,
Thanks for the reply. I'll try it out.
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.