Spinning Topp Logo BlackTopp Studios
inc
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Mezzanine::CameraController Class Reference

This is a simplified controller class for use with cameras. More...

#include <cameracontroller.h>

+ Collaboration diagram for Mezzanine::CameraController:

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::CameraProxyGetControlledCamera () 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::CameraProxyControlled
 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...
 
AngleLimitsPitchLimits
 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...
 
AngleLimitsRollLimits
 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...
 
AngleLimitsYawLimits
 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...
 

Detailed Description

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.

Member Enumeration Documentation

Possible options for determining how the camera should move relative to the world.

Enumerator
CCM_Fly 

CCM_Fly: This is the default option for every Camera Controller. Allows the camera unrestrained movement throughout the scene.

CCM_Walk 

CCM_Walk: This forces the camera to be only a certain distance above the terrain.

Definition at line 81 of file cameracontroller.h.

Constructor & Destructor Documentation

Mezzanine::CameraController::CameraController ( Graphics::CameraProxy ToBeControlled)

Camera constructor.

Parameters
ToBeControlledThe camera this controller is controlling.

Definition at line 68 of file cameracontroller.cpp.

Member Function Documentation

void Mezzanine::CameraController::CheckAllAngles ( )
protected

Calls CheckAngleLimits() and CheckAngleRollover(Real).

Definition at line 119 of file cameracontroller.cpp.

void Mezzanine::CameraController::CheckAngleLimits ( )
protected

Clamps all current rotation values to their set limits.

Definition at line 97 of file cameracontroller.cpp.

void Mezzanine::CameraController::CheckAngleRollover ( Real  Angle)
protected

Wraps an angle value if it goes outside the range of [-pi,+pi].

Parameters
AngleThe angle to be checked.

Definition at line 87 of file cameracontroller.cpp.

void Mezzanine::CameraController::CheckHeight ( )
protected

Ensures the camera position is at the desired height above any world terrain.

Definition at line 127 of file cameracontroller.cpp.

Real Mezzanine::CameraController::FindDistanceToGround ( )
protected

Performs a raycast to get the distance to any terrain beneath the camera.

Returns
Returns the distance from the camera to terrain in world units.

Definition at line 138 of file cameracontroller.cpp.

Graphics::CameraProxy * Mezzanine::CameraController::GetControlledCamera ( ) const

Gets the camera this controller is controlling.

Returns
Returns a camera pointer for the camera this controller is applied to.

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.

Returns
Returns a Real represening the distance above terrain the camera is to hover, in world units.

Definition at line 174 of file cameracontroller.cpp.

CameraController::MovementMode Mezzanine::CameraController::GetMovementMode ( ) const

Gets the currently set movement mode.

Returns
Returns an enum value representing the current movement mode. See MovementMode enum for more info.

Definition at line 168 of file cameracontroller.cpp.

void Mezzanine::CameraController::MoveBackward ( Real  Units)

Moves the camera backward.

Parameters
UnitsThe 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.

Parameters
UnitsThe distance to be moved in world units.

Definition at line 228 of file cameracontroller.cpp.

void Mezzanine::CameraController::Rotate ( Real  Yaw,
Real  Pitch,
Real  Roll 
)

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.

Parameters
YawThe amount to rotate the camera on it's local Y axis in Radians.
PitchThe amount to rotate the camera on it's local X axis in Radians.
RollThe amount to rotate the camera on it's local Z axis in Radians.

Definition at line 260 of file cameracontroller.cpp.

void Mezzanine::CameraController::Rotate6DOF ( Real  Yaw,
Real  Pitch,
Real  Roll 
)

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.

Parameters
YawThe amount to rotate the camera on it's local Y axis in Radians.
PitchThe amount to rotate the camera on it's local X axis in Radians.
RollThe 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.

Parameters
ToBeControlledThe 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.

Parameters
HoverThe 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.

Parameters
MoveModeThe 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.

Parameters
UpperLimitThe allowed upper rotation limit in radians.
LowerLimitThe 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.

Parameters
UpperLimitThe allowed upper rotation limit in radians.
LowerLimitThe allowed upper rotation limit in radians.

Definition at line 209 of file cameracontroller.cpp.

void Mezzanine::CameraController::SetYawLimits ( const Real UpperLimit,
const Real LowerLimit 
)

Sets rotational limits on the Y axis.

The rotation range is from -Pi to Pi.

Parameters
UpperLimitThe allowed upper rotation limit in radians.
LowerLimitThe 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.

Parameters
UnitsThe 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.

Parameters
UnitsThe distance to be moved in world units.

Definition at line 252 of file cameracontroller.cpp.

Member Data Documentation

Graphics::CameraProxy* Mezzanine::CameraController::Controlled
protected

A pointer to the Camera being controlled.

Definition at line 92 of file cameracontroller.h.

MovementMode Mezzanine::CameraController::CurrentMMode
protected

The mode with which the camera should move around the scene.

Definition at line 116 of file cameracontroller.h.

Real Mezzanine::CameraController::HoverHeight
protected

The height at which the camera is to remain above the terrain.

Definition at line 104 of file cameracontroller.h.

AngleLimits* Mezzanine::CameraController::PitchLimits
protected

A pointer to the angle limits for rotations on the X axis.

Definition at line 98 of file cameracontroller.h.

Real Mezzanine::CameraController::PitchRad
protected

The current rotation of the camera on the X axis.

Definition at line 110 of file cameracontroller.h.

RayQueryTool Mezzanine::CameraController::RayCaster
protected

A ray casting tool used to determine surrounding geometry to limit movement.

Definition at line 89 of file cameracontroller.h.

AngleLimits* Mezzanine::CameraController::RollLimits
protected

A pointer to the angle limits for rotations on the Z axis.

Definition at line 101 of file cameracontroller.h.

Real Mezzanine::CameraController::RollRad
protected

The current rotation of the camera on the Z axis.

Definition at line 113 of file cameracontroller.h.

AngleLimits* Mezzanine::CameraController::YawLimits
protected

A pointer to the angle limits for rotations on the Y axis.

Definition at line 95 of file cameracontroller.h.

Real Mezzanine::CameraController::YawRad
protected

The current rotation of the camera on the Y axis.

Definition at line 107 of file cameracontroller.h.


The documentation for this class was generated from the following files: