PDA

View Full Version : FPS: Camera rotation and weapons



PascalM123
11-05-2010, 07:18 PM
Dear forum,

I have a question concerning the rotation of the camera in a FPS. When I want to rotate my camera, I use quaternions to change the value of my forward vector, so the player looks at a different direction. But I do not know how to change a weapon (or any other set of faces) along with the camera. Does anyone know how that can be achieved? The forward-vector is rotated like this:


forward.normalize();
right = forward.cross_product(up);
Quaternion qx(M_PI * rot_speed * dx, up);
qx.rotate(forward);
Quaternion qy(M_PI * rot_speed * dy, right);
qy.rotate(forward);


Could it be that an implementation with Euler-angles works better or is more simple? The main advantage for me for the above implementation is the fact that the forward-vector can be used in recursive raycasting etc (to see ehat a player has shot when clicking for example).

Regards

zeoverlord
11-06-2010, 02:19 AM
yea it's more simpler than that, render the weapon last and don't include the camera movements