2
\$\begingroup\$

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 quite well, except for 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.

\$\endgroup\$
0
1
\$\begingroup\$

I don't see any thing in this snippet that will cause a zooming affect. I do, however, see a problem in the pitch rotation. customAxis needs to be normalized before using it as an argument in CreateFromAxisAngle method or the rotation amount will be incorrect. This may appear masked at the moment by your .0001 scaling but it would be worth normalizing it to see if it is somehow playing a part in your errant zoom affect.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.