Sign in to follow this  

Camera Rotate Question

This topic is 4688 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


Link to post
Share on other sites
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


Link to 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


Link to 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


Link to post
Share on other sites

This topic is 4688 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this