Camera closes in on the fixed point

Posted by V1ncam on Game Development See other posts from Game Development or by V1ncam
Published on 2012-10-01T14:51:48Z Indexed on 2012/10/01 15:54 UTC
Read the original article Hit count: 209

Filed under:

I've been trying to create a camera that is controlled by the mouse and rotates around a fixed point (read: (0,0,0)), both vertical and horizontal. This is what I've come up with:

            camera.Eye = Vector3.Transform(camera.Eye, Matrix.CreateRotationY(camRotYFloat));

            Vector3 customAxis = new Vector3(-camera.Eye.Z, 0, camera.Eye.X);

            camera.Eye = Vector3.Transform(camera.Eye, Matrix.CreateFromAxisAngle(customAxis, camRotXFloat * 0.0001f));

This works quit well, except from the fact that when I 'use' the second transformation (go up and down with the mouse) the camera not only goes up and down, it also closes in on the point. It zooms in.

How do I prevent this?

Thanks in advance.

© Game Development or respective owner

Related posts about XNA

Related posts about c#