$search
An orbital camera, controlled by yaw, pitch, distance, and focal point. More...
#include <orbit_camera.h>
Public Member Functions | |
virtual void | fromString (const std::string &str) |
Loads the camera's configure from the supplied string (generated through toString()). | |
float | getDistance () |
const Ogre::Vector3 & | getFocalPoint () |
virtual Ogre::Quaternion | getOrientation () |
Get the orientation of this camera. | |
float | getPitch () |
virtual Ogre::Vector3 | getPosition () |
Get the position of this camera. | |
float | getYaw () |
virtual void | lookAt (const Ogre::Vector3 &point) |
Point the camera at the specified point. | |
virtual void | mouseLeftDown (int x, int y) |
virtual void | mouseLeftDrag (int diff_x, int diff_y, bool ctrl, bool alt, bool shift) |
Handle a left mouse button drag. | |
virtual void | mouseLeftUp (int x, int y) |
virtual void | mouseMiddleDown (int x, int y) |
virtual void | mouseMiddleDrag (int diff_x, int diff_y, bool ctrl, bool alt, bool shift) |
Handle a middle mouse button drag. | |
virtual void | mouseMiddleUp (int x, int y) |
virtual void | mouseRightDown (int x, int y) |
virtual void | mouseRightDrag (int diff_x, int diff_y, bool ctrl, bool alt, bool shift) |
Handle a right mouse button drag. | |
virtual void | mouseRightUp (int x, int y) |
virtual void | move (float x, float y, float z) |
Move the camera relative to its orientation. | |
OrbitCamera (Ogre::SceneManager *scene_manager) | |
virtual void | pitch (float angle) |
Pitch the camera. | |
virtual void | roll (float angle) |
Roll the camera. | |
virtual void | scrollWheel (int diff, bool ctrl, bool alt, bool shift) |
Handle a scrollwheel change. | |
void | setFocalPoint (const Ogre::Vector3 &focal_point) |
Set the focal point of the camera. Keeps the pitch/yaw/distance the same. | |
virtual void | setFrom (CameraBase *camera) |
Set the position/orientation of this camera from another camera. | |
virtual void | setOrientation (float x, float y, float z, float w) |
Set the orientation of the camera from a quaternion. | |
virtual void | setPosition (float x, float y, float z) |
Set the position of the camera. | |
virtual std::string | toString () |
Returns a string representation of the camera's configuration. | |
virtual void | update () |
Calculates the camera's position and orientation from the yaw, pitch, distance and focal point. | |
virtual void | yaw (float angle) |
Yaw the camera. | |
void | zoom (float amount) |
Move in/out from the focal point, ie. adjust distance_ by amount. | |
virtual | ~OrbitCamera () |
Private Member Functions | |
void | calculatePitchYawFromPosition (const Ogre::Vector3 &position) |
Calculates pitch and yaw values given a new position and the current focal point. | |
Ogre::Vector3 | getGlobalFocalPoint () |
void | normalizePitch () |
Normalizes the camera's pitch, preventing it from reaching vertical (or turning upside down). | |
void | normalizeYaw () |
Normalizes the camera's yaw in the range [0, 2*pi). | |
Private Attributes | |
float | distance_ |
The camera's distance from the focal point. | |
Ogre::Vector3 | focal_point_ |
The camera's focal point. | |
Shape * | focal_point_object_ |
float | pitch_ |
The camera's pitch (rotation around the x-axis), in radians. | |
float | yaw_ |
The camera's yaw (rotation around the y-axis), in radians. |
An orbital camera, controlled by yaw, pitch, distance, and focal point.
This camera is based on the equation of a sphere in spherical coordinates:
x = d*cos(theta)sin(phi) y = d*cos(phi) z = d*sin(theta)sin(phi)
Where:
d = distance_
theta = yaw_
phi = pitch_
Definition at line 62 of file orbit_camera.h.
ogre_tools::OrbitCamera::OrbitCamera | ( | Ogre::SceneManager * | scene_manager | ) |
Definition at line 53 of file orbit_camera.cpp.
ogre_tools::OrbitCamera::~OrbitCamera | ( | ) | [virtual] |
Definition at line 68 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::calculatePitchYawFromPosition | ( | const Ogre::Vector3 & | position | ) | [private] |
Calculates pitch and yaw values given a new position and the current focal point.
position | Position to calculate the pitch/yaw for |
Definition at line 163 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::fromString | ( | const std::string & | str | ) | [virtual] |
Loads the camera's configure from the supplied string (generated through toString()).
str | The string to load from |
Implements ogre_tools::CameraBase.
Definition at line 344 of file orbit_camera.cpp.
float ogre_tools::OrbitCamera::getDistance | ( | ) | [inline] |
Definition at line 81 of file orbit_camera.h.
const Ogre::Vector3& ogre_tools::OrbitCamera::getFocalPoint | ( | ) | [inline] |
Definition at line 82 of file orbit_camera.h.
Ogre::Vector3 ogre_tools::OrbitCamera::getGlobalFocalPoint | ( | ) | [private] |
Definition at line 95 of file orbit_camera.cpp.
Ogre::Quaternion ogre_tools::OrbitCamera::getOrientation | ( | ) | [virtual] |
Get the orientation of this camera.
Implements ogre_tools::CameraBase.
Definition at line 158 of file orbit_camera.cpp.
float ogre_tools::OrbitCamera::getPitch | ( | ) | [inline] |
Definition at line 79 of file orbit_camera.h.
Ogre::Vector3 ogre_tools::OrbitCamera::getPosition | ( | ) | [virtual] |
Get the position of this camera.
Implements ogre_tools::CameraBase.
Definition at line 153 of file orbit_camera.cpp.
float ogre_tools::OrbitCamera::getYaw | ( | ) | [inline] |
Definition at line 80 of file orbit_camera.h.
void ogre_tools::OrbitCamera::lookAt | ( | const Ogre::Vector3 & | point | ) | [virtual] |
Point the camera at the specified point.
point | The point to look at |
Implements ogre_tools::CameraBase.
Definition at line 252 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::mouseLeftDown | ( | int | x, | |
int | y | |||
) | [virtual] |
Reimplemented from ogre_tools::CameraBase.
Definition at line 314 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::mouseLeftDrag | ( | int | diff_x, | |
int | diff_y, | |||
bool | ctrl, | |||
bool | alt, | |||
bool | shift | |||
) | [virtual] |
Handle a left mouse button drag.
diff_x | Pixels the mouse has moved in the (window space) x direction | |
diff_y | Pixels the mouse has moved in the (window space) y direction |
Implements ogre_tools::CameraBase.
Definition at line 272 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::mouseLeftUp | ( | int | x, | |
int | y | |||
) | [virtual] |
Reimplemented from ogre_tools::CameraBase.
Definition at line 329 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::mouseMiddleDown | ( | int | x, | |
int | y | |||
) | [virtual] |
Reimplemented from ogre_tools::CameraBase.
Definition at line 319 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::mouseMiddleDrag | ( | int | diff_x, | |
int | diff_y, | |||
bool | ctrl, | |||
bool | alt, | |||
bool | shift | |||
) | [virtual] |
Handle a middle mouse button drag.
diff_x | Pixels the mouse has moved in the (window space) x direction | |
diff_y | Pixels the mouse has moved in the (window space) y direction |
Implements ogre_tools::CameraBase.
Definition at line 278 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::mouseMiddleUp | ( | int | x, | |
int | y | |||
) | [virtual] |
Reimplemented from ogre_tools::CameraBase.
Definition at line 334 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::mouseRightDown | ( | int | x, | |
int | y | |||
) | [virtual] |
Reimplemented from ogre_tools::CameraBase.
Definition at line 324 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::mouseRightDrag | ( | int | diff_x, | |
int | diff_y, | |||
bool | ctrl, | |||
bool | alt, | |||
bool | shift | |||
) | [virtual] |
Handle a right mouse button drag.
diff_x | Pixels the mouse has moved in the (window space) x direction | |
diff_y | Pixels the mouse has moved in the (window space) y direction |
Implements ogre_tools::CameraBase.
Definition at line 290 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::mouseRightUp | ( | int | x, | |
int | y | |||
) | [virtual] |
Reimplemented from ogre_tools::CameraBase.
Definition at line 339 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::move | ( | float | x, | |
float | y, | |||
float | z | |||
) | [virtual] |
Move the camera relative to its orientation.
x | Distance to move along the X-axis | |
y | Distance to move along the Y-axis | |
z | Distance to move along the Z-axis |
Implements ogre_tools::CameraBase.
Definition at line 228 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::normalizePitch | ( | ) | [private] |
Normalizes the camera's pitch, preventing it from reaching vertical (or turning upside down).
Definition at line 73 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::normalizeYaw | ( | ) | [private] |
Normalizes the camera's yaw in the range [0, 2*pi).
Definition at line 85 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::pitch | ( | float | angle | ) | [virtual] |
Pitch the camera.
Calls to pitch are cumulative, so: pitch(PI); pitch(PI);
is equivalent to pitch(2*PI);
angle | Angle to pitch, in radians |
Implements ogre_tools::CameraBase.
Definition at line 140 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::roll | ( | float | angle | ) | [virtual] |
Roll the camera.
Calls to roll are cumulative, so: roll(PI); roll(PI);
is equivalent to roll(2*PI);
angle | Angle to roll, in radians |
Implements ogre_tools::CameraBase.
Definition at line 149 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::scrollWheel | ( | int | diff, | |
bool | ctrl, | |||
bool | alt, | |||
bool | shift | |||
) | [virtual] |
Handle a scrollwheel change.
diff | Number of "units" the scrollwheel has moved |
Implements ogre_tools::CameraBase.
Definition at line 302 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::setFocalPoint | ( | const Ogre::Vector3 & | focal_point | ) |
Set the focal point of the camera. Keeps the pitch/yaw/distance the same.
focal_point | The new focal point |
Definition at line 221 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::setFrom | ( | CameraBase * | camera | ) | [virtual] |
Set the position/orientation of this camera from another camera.
camera | The camera to set from |
Implements ogre_tools::CameraBase.
Definition at line 183 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::setOrientation | ( | float | x, | |
float | y, | |||
float | z, | |||
float | w | |||
) | [virtual] |
Set the orientation of the camera from a quaternion.
Implements ogre_tools::CameraBase.
Definition at line 196 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::setPosition | ( | float | x, | |
float | y, | |||
float | z | |||
) | [virtual] |
Set the position of the camera.
Implements ogre_tools::CameraBase.
Definition at line 242 of file orbit_camera.cpp.
std::string ogre_tools::OrbitCamera::toString | ( | ) | [virtual] |
Returns a string representation of the camera's configuration.
Implements ogre_tools::CameraBase.
Definition at line 363 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::update | ( | ) | [virtual] |
Calculates the camera's position and orientation from the yaw, pitch, distance and focal point.
Implements ogre_tools::CameraBase.
Definition at line 107 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::yaw | ( | float | angle | ) | [virtual] |
Yaw the camera.
Calls to yaw are cumulative, so: yaw(PI); yaw(PI);
is equivalent to yaw(2*PI);
angle | Angle to yaw, in radians |
Implements ogre_tools::CameraBase.
Definition at line 131 of file orbit_camera.cpp.
void ogre_tools::OrbitCamera::zoom | ( | float | amount | ) |
Move in/out from the focal point, ie. adjust distance_ by amount.
amount | The distance to move. Positive amount moves towards the focal point, negative moves away |
Definition at line 209 of file orbit_camera.cpp.
float ogre_tools::OrbitCamera::distance_ [private] |
The camera's distance from the focal point.
Definition at line 138 of file orbit_camera.h.
Ogre::Vector3 ogre_tools::OrbitCamera::focal_point_ [private] |
The camera's focal point.
Definition at line 135 of file orbit_camera.h.
Definition at line 140 of file orbit_camera.h.
float ogre_tools::OrbitCamera::pitch_ [private] |
The camera's pitch (rotation around the x-axis), in radians.
Definition at line 137 of file orbit_camera.h.
float ogre_tools::OrbitCamera::yaw_ [private] |
The camera's yaw (rotation around the y-axis), in radians.
Definition at line 136 of file orbit_camera.h.