Question about Camera rotation
Hello
I can get the x and y valuse (x,y mouse coordination) of mouse in my screen, but i dont know how to use them in a way to rotate my camera to UP, Down, Left and Right. do you know the maths behind this? I mean how can i calculate the Pitch and Heading of my camera from x and y?
Thank you in advance
i have my camera set so that when i use the mouse wheel the camera's Distance value is changed in/out and when mouse button 2 is pressed any changes in mouseX or MouseY are added to camera yaw and height.
my camera is positioned based on its own distance, yaw, and height from that of the player.
but it depends on how you defined the camera. mine is just a vector for position, and target < always the players location > and then distance, height, and yaw.
my camera is positioned based on its own distance, yaw, and height from that of the player.
but it depends on how you defined the camera. mine is just a vector for position, and target < always the players location > and then distance, height, and yaw.
You're going to have to (well, one way is to) use sin and cos with angles, where the angles are incrememnted/decrememnted by moving the mouse.
For a third person camera,
y = distance * sin(phi);
y_distance = distance * cos(phi);
x = y_distance * sin(theta);
z = y_distance * cos(theta);
Where phi is the vertical angle, and theta the horizontal angle. We calculate the y_distance so that the movement is spherical, rather than cylindrical.
For a third person camera,
y = distance * sin(phi);
y_distance = distance * cos(phi);
x = y_distance * sin(theta);
z = y_distance * cos(theta);
Where phi is the vertical angle, and theta the horizontal angle. We calculate the y_distance so that the movement is spherical, rather than cylindrical.
what he means by distance, is that you have to assume that the lookat coordinate will always be a fixed distance away from the camera.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement