XNA Game Development Forums
2012/05/18 07:09:04 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Calendar Login Register  
Pages: [1]
  Print  
Author Topic: Camera Issues  (Read 3045 times)
minich21
Newbie
*
Offline Offline

Posts: 12


View Profile
« on: 2007/03/27 10:14:20 »

I think what is killing me is the whole Y is up... but my problem is I want to have my camera at a RTS/Diablo style angle.

I have my code setup like so for movement of the camera

Code:
if (game.Input.Keys.Contains(Keys.W))
            {
                EagleCameraManager.ActiveCamera.Translate(new Vector3(0,0.3f,0));
            }

            if (game.Input.Keys.Contains(Keys.A))
            {
                EagleCameraManager.ActiveCamera.Translate(new Vector3(-0.3f, 0, 0));
            }

            if (game.Input.Keys.Contains(Keys.D))
            {
                EagleCameraManager.ActiveCamera.Translate(new Vector3(0.3f, 0, 0));
            }

            if (game.Input.Keys.Contains(Keys.S))
            {
                EagleCameraManager.ActiveCamera.Translate(new Vector3(0, -0.3f, 0));
            }

works great moves the camera forward and backward left and right, the problem is my camera is facing straight down...  so I run this code

Code:
EagleCameraManager.ActiveCamera.LookAt(new Vector3(0, 15, 15), 0.25f);

and viola! my camera is exactly where I want it!!  ... now comes the problem, when i press a or d it moves left or right(thats good), but when i press w or s it goes forward and up or backward and down!!!  it works fine till i run that piece of code... been driving me nuts, any thoughts??
Logged
Nemo Krad
Global Moderator
Hero Member
*****
Offline Offline

Posts: 512


I have seen the fnords


View Profile WWW
« Reply #1 on: 2007/03/27 13:43:27 »

I think for W and S you want:

Code:
            if (game.Input.Keys.Contains(Keys.W))
            {
                EagleCameraManager.ActiveCamera.Translate(new Vector3(0,0,0.3f));
            }
            if (game.Input.Keys.Contains(Keys.S))
            {
                EagleCameraManager.ActiveCamera.Translate(new Vector3(0, 0, -0.3f));
            }

Logged
minich21
Newbie
*
Offline Offline

Posts: 12


View Profile
« Reply #2 on: 2007/03/28 17:30:49 »

Actually i have different buttons for that

Code:
            if (game.Input.Keys.Contains(Keys.Q))
            {
                EagleCameraManager.ActiveCamera.Translate(new Vector3(0, 0, -0.3f));
            }

            if (game.Input.Keys.Contains(Keys.E))
            {
                EagleCameraManager.ActiveCamera.Translate(new Vector3(0, 0, 0.3f));
            }

I changed my code to Z as up vs Y, I might have to try changing it back and see...  but i should be able to use it the other way as well.

and every thing works great till i use the LookAt function, that gives me the right angle, but even though i'm only updating Y it updates Y & Z. 
Logged
::sjm
Newbie
*
Offline Offline

Posts: 1


View Profile
« Reply #3 on: 2007/04/04 14:55:32 »

Set your Y axis back to up, translate the camera to some start position above your world and set the default view to be looking down (say, 30 degrees or something?) and do translations in the xz plane? Use rotations and not revolves, and only translate in the y when zooming (as well as either x and/or z depending on orientation)?

That sounds like it would work, I'm probably missing something.
Logged
minich21
Newbie
*
Offline Offline

Posts: 12


View Profile
« Reply #4 on: 2007/04/05 05:03:36 »

Thanks!  Have to try it out, figured i'd have to go back to the y up, gonna take some getting used to!
Logged
cannyshammy
Newbie
*
Offline Offline

Posts: 6


View Profile
« Reply #5 on: 2007/05/05 05:33:46 »

sovled this:

at the construction:

            this.Translate(new Vector3(0, -40, -20));     
            this.LookAt(new Vector3(), 0);

in the update:

        public void UpdateCameraControls()
        {
            Vector2 mouseMove = cInput.MouseMoved;
            ButtonList MouseButtons = cInput.MouseButtons;

            if (cInput.Keys.Contains(Keys.Left))
            {
                this.Translate(new Vector3(-0.3f, 0, 0));
            }
            if (cInput.Keys.Contains(Keys.Right))
            {
                this.Translate(new Vector3(0.3f, 0, 0));
            }
            if (cInput.Keys.Contains(Keys.Up))
            {
                _position += Vector3.Transform(new Vector3(0, 0, 0.3f), Matrix.CreateFromQuaternion(new Quaternion(0, 0, 0, 1)));
                this.Update();
            }
            if (cInput.Keys.Contains(Keys.Down))
            {
                _position += Vector3.Transform(new Vector3(0, 0, -0.3f), Matrix.CreateFromQuaternion(new Quaternion(0, 0, 0, 1)));
                this.Update();
            }
     }
Logged
mikeschuld
Administrator
Sr. Member
*****
Offline Offline

Posts: 389


View Profile WWW
« Reply #6 on: 2007/08/14 21:27:30 »

The whole y as up thing is what they chose for the api, although it does make some exporting programs a bit difficult that don't allow for axis swapping on exported models. :/
Logged
Pages: [1]
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Having issues with tutorial 3 Hazy Mind XNA Engine siferion 4 2375 Last post 2006/11/26 14:04:03
by mikeschuld
Tutorial 12 :: Adding in Advanced Camera Functionality Tutorial Discussion « 1 2 3 » mikeschuld 30 11100 Last post 2007/08/01 07:00:20
by Suzume
Parenting Camera to an Object Hazy Mind XNA Engine Requests rstackhouse 4 3096 Last post 2007/03/14 06:13:57
by 5parrowhawk
Not good - issues in the first tutorial. Hazy Mind XNA Engine « 1 2 » Jeddak 20 5373 Last post 2007/03/26 19:31:08
by mikeschuld
J.I Styles skin shader implementation issues Hazy Mind 3D Engine DX 1 2113 Last post 2007/03/30 07:53:25
by Nemo Krad
Camera Issues Hazy Mind XNA Engine Trano 3 2807 Last post 2008/09/17 08:27:25
by mikeschuld
Camera Tracking Hazy Mind XNA Engine muchrejoicing 4 2005 Last post 2007/05/29 19:50:23
by daenris
Camera problem Hazy Mind XNA Engine Montynis 2 1685 Last post 2007/08/02 09:54:14
by Montynis
Tutorial 9 - issues with some code Hazy Mind XNA Engine Mike2 3 2002 Last post 2007/08/31 22:30:19
by ChunkyBrewster
GameTime issues General Discussion Mike2 2 2018 Last post 2007/09/14 15:22:07
by Mike2
Mouse Input Issues Hazy Mind XNA Engine Silvo 3 2462 Last post 2008/09/15 00:10:11
by mikeschuld
Camera rotation issues (z-axis drift solved!) Hazy Mind XNA Engine ppardee 10 4266 Last post 2008/11/19 11:22:49
by inbreed
extending the camera classes/cameramanager Hazy Mind XNA Engine Mikeske 7 2076 Last post 2009/12/16 01:46:28
by Mikeske
Powered by MySQL Powered by PHP Powered by SMF 1.1.12 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.118 seconds with 18 queries.