Jump to content
• Advertisement

# Camera Rotate Question

This topic is 5029 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

From this web site http://www.gamedev.net/reference/programming/features/quatcam/page3.asp there has the code: MouseDirection.x = (MiddleX - MouseX)/MouseSensitivity; MouseDirection.y = (MiddleY - MouseY)/MouseSensitivity; but I really don't know what is the usage of MouseSensitivity and what is the value of this MouseSensitivity?

#### Share this post

##### Share on other sites
Advertisement
I'm just taking a guess, but it looks like this code makes the camera move quircker the farther away from the center point the mouse is. With thta being said, mousesensitivity is a global constant that can be played with to tweak how fast this is. To make it go faster give it valuse between 0 and 1 to make it more slower values > 1

in other words, set it in your globals. you could also make it an option to tweak in the options menu. Many games do this (i.e. all commecrial games I can think of).

[edited for decent & coherent english]

#### Share this post

##### Share on other sites
Or On the other words, I have several points about Camera Rotate are not clear:

1. mouseXDirection = (_xMiddle - _xMouse)/MouseSensitivity;
mouseYDirection = (_yMiddle - _yMouse)/MouseSensitivity;

** Some article need us to find the Direction or angle of mouse, but why we don't need to get the direction or angle of z direction?

2. I don't clear why :

// Rotate around the y axis
RotateCamera(mouseYDirection, Axis.x, Axis.y, Axis.z);

// Rotate around the x axis
RotateCamera(mouseXDirection, 0, 1, 0);

Why we just rotatecamera around y and x axis, how about the z axis? And I don't really want the RoateCamera do in many article. Also, I don't know why the parameter is not the same when rotate around y axis and x axis?

#### Share this post

##### Share on other sites
Quote:
 **Some article need us to find the Direction or angle of mouse, but why we don't need to get the direction or angle of z direction?...Why we just rotatecamera around y and x axis, how about the z axis?

A common mouse moves on a 2D surface (a mouse pad, for example), then it supply you values only in two directions. So, with these two mouse coordinates it's impossible to get three independent coordinates. If your mouse has a roll button, you could use it to move camera around z-axis.

In true, the mouse coordinates have nothing to do with the axes from the world or from the camera, but you could take advantage of them to move your camera.

Quote:
 Also, I don't know why the parameter is not the same when rotate around y axis and x axis?

In that code, Axis represents the x-axis. So, Axis.x, Axis.y and Axis.z are the components of the x-axis. It was created by a cross product of (View - Position) vector with Up vector.
On the other hands, (0,1,0) represents the y-axis.
If those parameters were the same, the camera will rotate arount one axis only.

Note 1: That code uses quaternions to rotate the camera.
Note 2: That code doesn't use Direct3D (although it is very easy to translate to Direct3D).

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
Rutin
54
2. 2
3. 3
4. 4
5. 5
• Advertisement

• 10
• 28
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633412
• Total Posts
3011734
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!