Radar's picture

Quaternion Camera And Movement

Hi all,

i've implemented a Quaternion-Camera and it works so far i can rotate and move around BUT:
The movement does not follow the rotation. I can only move on the Z and X axes, but not inbetween them. So it feels like iam sitting in a train and look outide the window.
But i want a FPS Camera.

I guess this is a know problem for the cracks but i couldn't find an answer to this problem (i don't even know how to describe that for google)

Someone already knows what i made wrong/forgot?

Thanks in andvance!


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Tal's picture

3 popular kinds of cameras:
1. FPS
2. TPS(third person camera)
3. Quaternion camera.
There is a huge different between 1 and 3.

  • The former use yaw, pitch and roll, and the latter use only Quaternion for rotation, but both use Vector3 for camera position.
  • The former suffers from Gimbel lock(if it's for the "character head" it's OK), and the latter suffers from floating point inaccuracy(but there is a solution for it).

For FPS and TPS, see:
http://roecode.wordpress.com/2008/02/11/xna-framework-gameengine-develop...

If I understand you wrong and you want quaternion camera, tel it in your comment.

Radar's picture

Hi!

Thank you for your answer.
The basic idea was:
I have a self-made Point3d Class which has a Pos.-Vector and a Quaternion rotation. (like a pivot point)
Then i have a QuaternionCamera Class which extends the Point3d.
And finally i make a FPS Camera which extends the QuaternionCamera.

Any other camera type just extends the QuaternionCamera et viola...

Yeah... that was the idea. But i have a few problems with the camera. Like: How do i limit the rotation of a quaternion or as you mentioned the problem with the precision.

Was the whole idea bad? And if so, why?

Thanks!

Tal's picture

For FPS, it is very recommend you will use yaw, pitch and roll. I've link you to how to do it in XNA, but the math methods are kinda the same in OpenTK.
If you don't know what is it yaw-pitch-roll, see:
http://en.wikipedia.org/wiki/Flight_dynamics
http://en.wikipedia.org/wiki/Euler_angles