This is a simplified controller class for use with cameras. More...
#include <cameracontroller.h>
Public Types | |
enum | MovementMode { CCM_Fly, CCM_Walk } |
Possible options for determining how the camera should move relative to the world. More... | |
Public Member Functions | |
CameraController () | |
Blank constructor. | |
CameraController (Graphics::CameraProxy *ToBeControlled) | |
Camera constructor. More... | |
~CameraController () | |
Class destructor. | |
Graphics::CameraProxy * | GetControlledCamera () const |
Gets the camera this controller is controlling. More... | |
Real | GetHoverHeight () const |
Gets the distance the camera hovers over terrain while in CCM_Walk mode. More... | |
MovementMode | GetMovementMode () const |
Gets the currently set movement mode. More... | |
void | MoveBackward (Real Units) |
Moves the camera backward. More... | |
void | MoveForward (Real Units) |
Moves the camera forward. More... | |
void | RemovePitchLimits () |
Clears any set limits on pitch(X axis) rotation. | |
void | RemoveRollLimits () |
Clears any set limits on roll(Z axis) rotation. | |
void | RemoveYawLimits () |
Clears any set limits on yaw(Y axis) rotation. | |
void | Rotate (Real Yaw, Real Pitch, Real Roll) |
Rotates the camera. More... | |
void | Rotate6DOF (Real Yaw, Real Pitch, Real Roll) |
Rotates the camera. More... | |
void | SetControlledCamera (Graphics::CameraProxy *ToBeControlled) |
Sets the camera being controlled by this controller. More... | |
void | SetHoverHeight (const Real &Hover) |
Sets the hover distance for the camera while it's moving. More... | |
void | SetMovementMode (const MovementMode &MoveMode) |
Sets the movement mode for this camera/controller. More... | |
void | SetPitchLimits (const Real &UpperLimit, const Real &LowerLimit) |
Sets rotational limits on the X axis. More... | |
void | SetRollLimits (const Real &UpperLimit, const Real &LowerLimit) |
Sets rotational limits on the Z axis. More... | |
void | SetYawLimits (const Real &UpperLimit, const Real &LowerLimit) |
Sets rotational limits on the Y axis. More... | |
void | StrafeLeft (Real Units) |
Moves the camera to the left. More... | |
void | StrafeRight (Real Units) |
Moves the camera to the right. More... | |
Protected Member Functions | |
void | CheckAllAngles () |
Calls CheckAngleLimits() and CheckAngleRollover(Real). More... | |
void | CheckAngleLimits () |
Clamps all current rotation values to their set limits. More... | |
void | CheckAngleRollover (Real Angle) |
Wraps an angle value if it goes outside the range of [-pi,+pi]. More... | |
void | CheckHeight () |
Ensures the camera position is at the desired height above any world terrain. More... | |
Real | FindDistanceToGround () |
Performs a raycast to get the distance to any terrain beneath the camera. More... | |
Protected Attributes | |
Graphics::CameraProxy * | Controlled |
A pointer to the Camera being controlled. More... | |
MovementMode | CurrentMMode |
The mode with which the camera should move around the scene. More... | |
Real | HoverHeight |
The height at which the camera is to remain above the terrain. More... | |
AngleLimits * | PitchLimits |
A pointer to the angle limits for rotations on the X axis. More... | |
Real | PitchRad |
The current rotation of the camera on the X axis. More... | |
RayQueryTool | RayCaster |
A ray casting tool used to determine surrounding geometry to limit movement. More... | |
AngleLimits * | RollLimits |
A pointer to the angle limits for rotations on the Z axis. More... | |
Real | RollRad |
The current rotation of the camera on the Z axis. More... | |
AngleLimits * | YawLimits |
A pointer to the angle limits for rotations on the Y axis. More... | |
Real | YawRad |
The current rotation of the camera on the Y axis. More... | |
This is a simplified controller class for use with cameras.
This class is useful for manipulating cameras to move around in simple ways, such as flying through a scene.
Definition at line 77 of file cameracontroller.h.
Possible options for determining how the camera should move relative to the world.
Definition at line 81 of file cameracontroller.h.
Mezzanine::CameraController::CameraController | ( | Graphics::CameraProxy * | ToBeControlled | ) |
Camera constructor.
ToBeControlled | The camera this controller is controlling. |
Definition at line 68 of file cameracontroller.cpp.
|
protected |
Calls CheckAngleLimits() and CheckAngleRollover(Real).
Definition at line 119 of file cameracontroller.cpp.
|
protected |
Clamps all current rotation values to their set limits.
Definition at line 97 of file cameracontroller.cpp.
|
protected |
Wraps an angle value if it goes outside the range of [-pi,+pi].
Angle | The angle to be checked. |
Definition at line 87 of file cameracontroller.cpp.
|
protected |
Ensures the camera position is at the desired height above any world terrain.
Definition at line 127 of file cameracontroller.cpp.
|
protected |
Performs a raycast to get the distance to any terrain beneath the camera.
Definition at line 138 of file cameracontroller.cpp.
Graphics::CameraProxy * Mezzanine::CameraController::GetControlledCamera | ( | ) | const |
Gets the camera this controller is controlling.
Definition at line 159 of file cameracontroller.cpp.
Real Mezzanine::CameraController::GetHoverHeight | ( | ) | const |
Gets the distance the camera hovers over terrain while in CCM_Walk mode.
Definition at line 174 of file cameracontroller.cpp.
CameraController::MovementMode Mezzanine::CameraController::GetMovementMode | ( | ) | const |
Gets the currently set movement mode.
Definition at line 168 of file cameracontroller.cpp.
void Mezzanine::CameraController::MoveBackward | ( | Real | Units | ) |
Moves the camera backward.
Units | The distance to be moved in world units. |
Definition at line 236 of file cameracontroller.cpp.
void Mezzanine::CameraController::MoveForward | ( | Real | Units | ) |
Moves the camera forward.
Units | The distance to be moved in world units. |
Definition at line 228 of file cameracontroller.cpp.
Rotates the camera.
This is a safer rotation method that applies all the checks and can lock behaviors such as roll if configured to do so.
Yaw | The amount to rotate the camera on it's local Y axis in Radians. |
Pitch | The amount to rotate the camera on it's local X axis in Radians. |
Roll | The amount to rotate the camera on it's local Z axis in Radians. |
Definition at line 260 of file cameracontroller.cpp.
Rotates the camera.
This is a freeform rotation method that will apply the rotation desired to the camera without any checks. This is ideal for spacecraft style controls.
Yaw | The amount to rotate the camera on it's local Y axis in Radians. |
Pitch | The amount to rotate the camera on it's local X axis in Radians. |
Roll | The amount to rotate the camera on it's local Z axis in Radians. |
Definition at line 287 of file cameracontroller.cpp.
void Mezzanine::CameraController::SetControlledCamera | ( | Graphics::CameraProxy * | ToBeControlled | ) |
Sets the camera being controlled by this controller.
ToBeControlled | The camera this controller is controlling. |
Definition at line 153 of file cameracontroller.cpp.
void Mezzanine::CameraController::SetHoverHeight | ( | const Real & | Hover | ) |
Sets the hover distance for the camera while it's moving.
Hover is only applied in CCM_Walk mode. Default: 1.0.
Hover | The distance above the ground to hover, in world units. |
Definition at line 171 of file cameracontroller.cpp.
void Mezzanine::CameraController::SetMovementMode | ( | const MovementMode & | MoveMode | ) |
Sets the movement mode for this camera/controller.
MoveMode | The MovementMode value for which mode you want applied. See MovementMode enum for more info. |
Definition at line 165 of file cameracontroller.cpp.
void Mezzanine::CameraController::SetPitchLimits | ( | const Real & | UpperLimit, |
const Real & | LowerLimit | ||
) |
Sets rotational limits on the X axis.
The rotation range is from -Pi to Pi.
UpperLimit | The allowed upper rotation limit in radians. |
LowerLimit | The allowed upper rotation limit in radians. |
Definition at line 193 of file cameracontroller.cpp.
void Mezzanine::CameraController::SetRollLimits | ( | const Real & | UpperLimit, |
const Real & | LowerLimit | ||
) |
Sets rotational limits on the Z axis.
The rotation range is from -Pi to Pi.
UpperLimit | The allowed upper rotation limit in radians. |
LowerLimit | The allowed upper rotation limit in radians. |
Definition at line 209 of file cameracontroller.cpp.
Sets rotational limits on the Y axis.
The rotation range is from -Pi to Pi.
UpperLimit | The allowed upper rotation limit in radians. |
LowerLimit | The allowed lower rotation limit in radians. |
Definition at line 177 of file cameracontroller.cpp.
void Mezzanine::CameraController::StrafeLeft | ( | Real | Units | ) |
Moves the camera to the left.
Units | The distance to be moved in world units. |
Definition at line 244 of file cameracontroller.cpp.
void Mezzanine::CameraController::StrafeRight | ( | Real | Units | ) |
Moves the camera to the right.
Units | The distance to be moved in world units. |
Definition at line 252 of file cameracontroller.cpp.
|
protected |
A pointer to the Camera being controlled.
Definition at line 92 of file cameracontroller.h.
|
protected |
The mode with which the camera should move around the scene.
Definition at line 116 of file cameracontroller.h.
|
protected |
The height at which the camera is to remain above the terrain.
Definition at line 104 of file cameracontroller.h.
|
protected |
A pointer to the angle limits for rotations on the X axis.
Definition at line 98 of file cameracontroller.h.
|
protected |
The current rotation of the camera on the X axis.
Definition at line 110 of file cameracontroller.h.
|
protected |
A ray casting tool used to determine surrounding geometry to limit movement.
Definition at line 89 of file cameracontroller.h.
|
protected |
A pointer to the angle limits for rotations on the Z axis.
Definition at line 101 of file cameracontroller.h.
|
protected |
The current rotation of the camera on the Z axis.
Definition at line 113 of file cameracontroller.h.
|
protected |
A pointer to the angle limits for rotations on the Y axis.
Definition at line 95 of file cameracontroller.h.
|
protected |
The current rotation of the camera on the Y axis.
Definition at line 107 of file cameracontroller.h.