Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have a camera that rotates around a center point using a rotation matrix and radius for the zoom from the object. I need to add right mouse button panning in.

Here is the problem: when I change center.x and center.y depending on my cameras rotation around the object the camera ends up moving closer or farther from the camera. What I want is no matter which way the camera is facing to the object it should move on the cameras forward and up, not the models. What kind of math do I need to use for this?

My code to change the "center" or view target is as follows

var xdelta = mousestate.X - PreviousMouseState.X;
var ydelta = mousestate.Y - PreviousMouseState.Y;
if (ydelta != 0 | xdelta != 0)
{
    center += Vector3.Transform(new Vector3(0, ydelta * .02f, 0), rotation);
}
share|improve this question
    
what is center.x and center.y ? is it the camera position? and how are you changing them exactly ? –  concept3d Oct 1 '13 at 16:36
    
Sorry, center is the vector3 of the target. I am changing them by getting the mouse x/y delta and adding that value to the target. –  Paul Wade Oct 1 '13 at 16:48
    
Also I am specifically modifying the modelviewer camera from engine nine which you can see the code for here nine.codeplex.com/SourceControl/latest#Source/Nine.Graphics.3D/… –  Paul Wade Oct 1 '13 at 16:50
    
It looks like what is happening to me is that the target x/y changes are made on the original x/y of matrix identity? and one the camera is looking down at the model y moves on the CAMERAS Z axis pulling it closer. when the center should change based on the cameras x/y at all times? –  Paul Wade Oct 1 '13 at 16:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.