XNA UK User Group

A helping hand for bedroom coders throughout the land.
in

camera's

Last post 07-17-2008 9:20 AM by Nemo Krad. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 07-15-2008 8:12 PM

    camera's

    Hi all,

      I have been working with the cameras in xna and ave it looking at position 0,0,0. However once i go over 0,0,0 forward becomes back and back becomes forward. what do i need to do to translate the x and z vectors so it works correctly where ever i am. i have been looking at a few things but have had no luck.

     

    Regards

    Mark

     

    If something is to hard. You must be doing it wrong.
  • 07-16-2008 3:53 PM In reply to

    • Phantom
    • Top 10 Contributor
    • Joined on 05-30-2007
    • Gloucester

    Re: camera's

    Ok ill try and give you a hand ill just try adn flesh out teh situation first of all so we both know if im on the right track.

    Your lookign at 0,0,0 and you camera say starts at 10,0,0 and when you go forward it takes say 1 unit of the X so it would go to 9,0,0 then 8,0,0.

    There for when you get to 0,0,0 a push forwrd would mean it goes to -1,0,0 then -2,0,0 whilst still looking at 0,0,0. So whilst the effect is that you now move away from the object you are actually still traveling in the same direction as before.

    If the abouve is correct that what you want is at some point either on the user input or probally better whin the camera movment routine when x (or y or z) > 0 (or better > lookat x) x *= -1. This will instantly make any negative posative again, you cant do it to a whole vector because if the x is negative but the y isnt then the x would become posative and the y negative. so you would need to do each dimention seperately.

    The end result of this would be as you press forward you would approach the lookout location untill you hit it and would go no further

    Phantom
  • 07-17-2008 9:20 AM In reply to

    Re: camera's

    Here is how I move my camera:

    public static void Translate(Vector3 distance)

    {

    myPosition +=
    Vector3.Transform(distance, Matrix.CreateFromQuaternion(myRotation));

    Update();

    }

    So what it will do is move your camera by the "distance" vector based on your rotation. I guess you could see the "distance" variable as a velocity.

    The update method just updates my View and Projection. Down load any of my 3D samples and you will see my camera in there.

    Beware the fnords....
Page 1 of 1 (3 items)