A first-person camera, controlled by yaw, pitch, and position. More...
#include <fps_camera.h>
Public Member Functions | |
FPSCamera (Ogre::SceneManager *scene_manager) | |
virtual void | fromString (const std::string &str) |
Loads the camera's configure from the supplied string (generated through toString()) | |
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 | mouseLeftDrag (int diff_x, int diff_y, bool ctrl, bool alt, bool shift) |
Handle a left mouse button drag. | |
virtual void | mouseMiddleDrag (int diff_x, int diff_y, bool ctrl, bool alt, bool shift) |
Handle a middle mouse button drag. | |
virtual void | mouseRightDrag (int diff_x, int diff_y, bool ctrl, bool alt, bool shift) |
Handle a right mouse button drag. | |
virtual void | move (float x, float y, float z) |
Move the camera relative to its orientation. | |
virtual void | pitch (float angle) |
Pitch the camera. | |
virtual void | relativeNodeChanged () |
Called when the relative node changes. | |
virtual void | roll (float angle) |
Roll the camera. | |
virtual void | scrollWheel (int diff, bool ctrl, bool alt, bool shift) |
Handle a scrollwheel change. | |
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 | yaw (float angle) |
Yaw the camera. | |
virtual | ~FPSCamera () |
Protected Member Functions | |
void | normalizePitch () |
Normalizes the camera's pitch, preventing it from turning upside down. | |
void | normalizeYaw () |
Normalizes yaw in the range [0, 2*pi) | |
void | update () |
Sets the camera's orientation based on pitch_ and yaw_. | |
Protected Attributes | |
float | pitch_ |
Pitch of the camera (rotation around the x-axis), in radians. | |
float | yaw_ |
Yaw of the camera (rotation around the y-axis), in radians. |
A first-person camera, controlled by yaw, pitch, and position.
Definition at line 49 of file fps_camera.h.
FPSCamera::FPSCamera | ( | Ogre::SceneManager * | scene_manager | ) |
Definition at line 47 of file fps_camera.cpp.
FPSCamera::~FPSCamera | ( | ) | [virtual] |
Definition at line 54 of file fps_camera.cpp.
void FPSCamera::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 214 of file fps_camera.cpp.
Ogre::Quaternion FPSCamera::getOrientation | ( | ) | [virtual] |
Get the orientation of this camera.
Implements ogre_tools::CameraBase.
Definition at line 162 of file fps_camera.cpp.
float ogre_tools::FPSCamera::getPitch | ( | ) | [inline] |
Definition at line 55 of file fps_camera.h.
Ogre::Vector3 FPSCamera::getPosition | ( | ) | [virtual] |
Get the position of this camera.
Implements ogre_tools::CameraBase.
Definition at line 179 of file fps_camera.cpp.
float ogre_tools::FPSCamera::getYaw | ( | ) | [inline] |
Definition at line 56 of file fps_camera.h.
void FPSCamera::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 184 of file fps_camera.cpp.
void FPSCamera::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 193 of file fps_camera.cpp.
void FPSCamera::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 199 of file fps_camera.cpp.
void FPSCamera::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 204 of file fps_camera.cpp.
void FPSCamera::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 167 of file fps_camera.cpp.
void FPSCamera::normalizePitch | ( | ) | [protected] |
Normalizes the camera's pitch, preventing it from turning upside down.
Definition at line 76 of file fps_camera.cpp.
void FPSCamera::normalizeYaw | ( | ) | [protected] |
Normalizes yaw in the range [0, 2*pi)
Definition at line 88 of file fps_camera.cpp.
void FPSCamera::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 107 of file fps_camera.cpp.
void FPSCamera::relativeNodeChanged | ( | ) | [virtual] |
Called when the relative node changes.
Reimplemented from ogre_tools::CameraBase.
Definition at line 58 of file fps_camera.cpp.
void FPSCamera::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 116 of file fps_camera.cpp.
void FPSCamera::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 209 of file fps_camera.cpp.
void FPSCamera::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 120 of file fps_camera.cpp.
void FPSCamera::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 126 of file fps_camera.cpp.
void FPSCamera::setPosition | ( | float | x, |
float | y, | ||
float | z | ||
) | [virtual] |
Set the position of the camera.
Implements ogre_tools::CameraBase.
Definition at line 174 of file fps_camera.cpp.
std::string FPSCamera::toString | ( | ) | [virtual] |
Returns a string representation of the camera's configuration.
Implements ogre_tools::CameraBase.
Definition at line 235 of file fps_camera.cpp.
void FPSCamera::update | ( | ) | [protected, virtual] |
Sets the camera's orientation based on pitch_ and yaw_.
Implements ogre_tools::CameraBase.
Definition at line 66 of file fps_camera.cpp.
void FPSCamera::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 98 of file fps_camera.cpp.
float ogre_tools::FPSCamera::pitch_ [protected] |
Pitch of the camera (rotation around the x-axis), in radians.
Definition at line 94 of file fps_camera.h.
float ogre_tools::FPSCamera::yaw_ [protected] |
Yaw of the camera (rotation around the y-axis), in radians.
Definition at line 95 of file fps_camera.h.