Camera Yaw Rotation Boundry Reply Quote Edit

Started by
3 comments, last by masterchange 13 years, 5 months ago
Hi guys , i got an issue with my orbiting camera, it is yawning depeding on the mouse.X position but when my mouse got the rightmost of screen or leftmost of the screen, camera mo more yaws.Here is my rotation code;
yawAngle += -0.006f * (Mouse.GetState().X - prevMouseState.X);   prevMouseState = Mouse.GetState();            Vector3 offset = this.target - this.position;   Matrix camRot = Matrix.CreateFromAxisAngle(Vector3.Left, pitchAngle)                    * Matrix.CreateFromAxisAngle(Vector3.Up, yawAngle);                      offset = Vector3.Transform(offset,camRot);             view = Matrix.CreateLookAt(position - offset + new Vector3(0, 15, 0),                               position + new Vector3(0, 15, 0), Vector3.Up);  


Thanks for replies
Advertisement
Your camera ONLY moves when input is received from the mouse that it has moved. So, how can a mouse when the mouse isnt moving? You have to add code to check to see if the mouse is at the edge of your screen, and if so, continue rotating.

Use your code, do something like
float yawAngle=0;if(Mouse.GetState().X == ClientXResolution){   yawAngle+ = .02;} else if(Mouse.GetState().X == 0){   yawAngle- = .02;} else yawAngle += -0.006f * (Mouse.GetState().X - prevMouseState.X);


Anyways, you should get the idea. This way, if the mouse is on the left of the screen, the keep rotating, same for the right of the screen.
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.
Quote:Original post by smasherprog
Your camera ONLY moves when input is received from the mouse that it has moved. So, how can a mouse when the mouse isnt moving? You have to add code to check to see if the mouse is at the edge of your screen, and if so, continue rotating.

Use your code, do something like
float yawAngle=0;if(Mouse.GetState().X == ClientXResolution){   yawAngle+ = .02;} else if(Mouse.GetState().X == 0){   yawAngle- = .02;} else yawAngle += -0.006f * (Mouse.GetState().X - prevMouseState.X);


Anyways, you should get the idea. This way, if the mouse is on the left of the screen, the keep rotating, same for the right of the screen.


but then if i reach at ClientXResolution with mouse, the camera begins rotating automatically even if i dont move mouse.
Maybe you posted the wrong question. You said your problem is that when the house hits the rightmost part of the screen, your camera stops moving. I posted code explaining how you can get the camera to move when it hits that spot. If that isn't what you wanted, then please be more clear.
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.
Quote:Original post by smasherprog
Maybe you posted the wrong question. You said your problem is that when the house hits the rightmost part of the screen, your camera stops moving. I posted code explaining how you can get the camera to move when it hits that spot. If that isn't what you wanted, then please be more clear.


well clearly,
in the screen bounds there is no problem, but when the mouse exceed the screen problems e.g mouse.x >= ClientXResolution or mouse.x <= 0 there will be no rotation, but when mouse.x >=ClientXResolution if a get the mouse left there will be rotation with reverse angle.


edit: i solved the problem

[Edited by - masterchange on November 1, 2010 11:31:24 AM]

This topic is closed to new replies.

Advertisement