Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Divide::Camera Class Referencefinal

#include <Camera.h>

+ Inheritance diagram for Divide::Camera:

Public Types

enum class  Mode : U8 {
  FREE_FLY = 0 , STATIC , FIRST_PERSON , THIRD_PERSON ,
  ORBIT , SCRIPTED , COUNT
}
 
enum class  UtilityCamera : U8 {
  _2D = 0 , _2D_FLIP_Y , DEFAULT , CUBE ,
  DUAL_PARABOLOID , COUNT
}
 

Public Member Functions

 Camera (const std::string_view name, Mode mode, const vec3< F32 > &eye=VECTOR3_ZERO)
 
void fromCamera (const Camera &camera)
 Copies all of the internal data from the specified camera to the current one.
 
void fromSnapshot (const CameraSnapshot &snapshot)
 Sets the internal snapshot data (eye, orientation, etc) to match the specified value.
 
bool updateLookAt ()
 Return true if the cached camera state wasn't up-to-date.
 
void setReflection (const Plane< F32 > &reflectionPlane) noexcept
 Specify a reflection plane that alters the final view matrix to be a mirror of the internal lookAt matrix.
 
void clearReflection () noexcept
 Clears the reflection plane specified (if any)
 
void setGlobalRotation (F32 yaw, F32 pitch, F32 roll=0.0f) noexcept
 Global rotations are applied relative to the world axis, not the camera's.
 
void setGlobalRotation (const vec3< Angle::DEGREES< F32 > > &euler) noexcept
 Global rotations are applied relative to the world axis, not the camera's.
 
const mat4< F32 > & lookAt (const mat4< F32 > &viewMatrix)
 Sets the camera's view matrix to specify the specified value by extracting the eye position, orientation and other data from it.
 
const mat4< F32 > & lookAt (const vec3< F32 > &eye, const vec3< F32 > &target, const vec3< F32 > &up)
 Sets the camera's position, target and up directions.
 
const mat4< F32 > & lookAt (const vec3< F32 > &target)
 Sets the camera to point at the specified target point.
 
const mat4< F32 > & lookAt (const vec3< F32 > &eye, const vec3< F32 > &target)
 Sets the camera to point at the specified target point from the specified eye position.
 
void setYaw (const Angle::DEGREES< F32 > angle) noexcept
 
void setPitch (const Angle::DEGREES< F32 > angle) noexcept
 Sets the camera's Pitch angle. Yaw and Roll are previous extracted values.
 
void setRoll (const Angle::DEGREES< F32 > angle) noexcept
 Sets the camera's Roll angle. Yaw and Pitch are previous extracted values.
 
void setGlobalYaw (const Angle::DEGREES< F32 > angle) noexcept
 
void setGlobalPitch (const Angle::DEGREES< F32 > angle) noexcept
 Sets the camera's Pitch angle. Yaw and Roll are previous extracted values.
 
void setGlobalRoll (const Angle::DEGREES< F32 > angle) noexcept
 Sets the camera's Roll angle. Yaw and Pitch are previous extracted values.
 
void setEye (const F32 x, const F32 y, const F32 z) noexcept
 Sets the camera's eye position.
 
void setEye (const vec3< F32 > &position) noexcept
 Sets the camera's eye position.
 
void setRotation (const Quaternion< F32 > &q) noexcept
 Sets the camera's orientation.
 
void setRotation (const Angle::DEGREES< F32 > yaw, const Angle::DEGREES< F32 > pitch, const Angle::DEGREES< F32 > roll=0.0f) noexcept
 Sets the camera's orientation.
 
void rotate (const Quaternion< F32 > &q)
 Rotates the camera (changes its orientation) by the specified quaternion (_orientation *= q)
 
void rotate (Angle::DEGREES< F32 > yaw, Angle::DEGREES< F32 > pitch, Angle::DEGREES< F32 > roll) noexcept
 
void rotate (const vec3< F32 > &axis, const Angle::DEGREES< F32 > angle)
 Creates a quaternion based on the specified axis-angle and calls "rotate" to change the orientation.
 
void rotateYaw (Angle::DEGREES< F32 > angle)
 
void rotateRoll (Angle::DEGREES< F32 > angle)
 Change camera's roll.
 
void rotatePitch (Angle::DEGREES< F32 > angle)
 Change camera's pitch.
 
void move (F32 dx, F32 dy, F32 dz) noexcept
 Moves the camera by the specified offsets in each direction.
 
void moveForward (const F32 factor) noexcept
 Moves the camera forward or backwards.
 
void moveStrafe (const F32 factor) noexcept
 Moves the camera left or right.
 
void moveUp (const F32 factor) noexcept
 Moves the camera up or down.
 
void setFixedYawAxis (const bool useFixed, const vec3< F32 > &fixedAxis=WORLD_Y_AXIS) noexcept
 Exactly as in Ogre3D: locks the yaw movement to the specified axis.
 
bool moveRelative (const vec3< F32 > &relMovement)
 
bool rotateRelative (const vec3< F32 > &relRotation)
 
bool zoom (F32 zoomFactor) noexcept
 
void setEuler (const vec3< Angle::DEGREES< F32 > > &euler) noexcept
 Set the camera's rotation to match the specified euler angles.
 
void setEuler (const Angle::DEGREES< F32 > &pitch, const Angle::DEGREES< F32 > &yaw, const Angle::DEGREES< F32 > &roll) noexcept
 Set the camera's rotation to match the specified euler angles.
 
void setAspectRatio (F32 ratio) noexcept
 
void setVerticalFoV (Angle::DEGREES< F32 > verticalFoV) noexcept
 
void setHorizontalFoV (Angle::DEGREES< F32 > horizontalFoV) noexcept
 
const mat4< F32 > & setProjection (vec2< F32 > zPlanes)
 
const mat4< F32 > & setProjection (F32 verticalFoV, vec2< F32 > zPlanes)
 
const mat4< F32 > & setProjection (F32 aspectRatio, F32 verticalFoV, vec2< F32 > zPlanes)
 
const mat4< F32 > & setProjection (const vec4< F32 > &rect, vec2< F32 > zPlanes)
 
const mat4< F32 > & setProjection (const mat4< F32 > &projection, vec2< F32 > zPlanes, bool isOrtho) noexcept
 
void setTarget (TransformComponent *tComp, const vec3< F32 > &offsetDirection=VECTOR3_ZERO) noexcept
 Offset direction is a (eventually normalized) vector that is scaled by curRadius and applied to the camera's eye position.
 
bool moveFromPlayerState (const SceneStatePerPlayer &playerState)
 
void saveToXML (boost::property_tree::ptree &pt, std::string prefix="") const
 
void loadFromXML (const boost::property_tree::ptree &pt, std::string prefix="")
 
vec3< F32unProject (F32 winCoordsX, F32 winCoordsY, const Rect< I32 > &viewport) const noexcept
 
vec3< F32unProject (const vec3< F32 > &winCoords, const Rect< I32 > &viewport) const noexcept
 
vec2< F32project (const vec3< F32 > &worldCoords, const Rect< I32 > &viewport) const noexcept
 
bool removeUpdateListener (U32 id)
 
U32 addUpdateListener (const CameraListener &f)
 
const CameraSnapshotsnapshot () const noexcept
 Returns the internal camera snapshot data (eye, orientation, etc)
 
Angle::DEGREES< F32getHorizontalFoV () const noexcept
 Returns the horizontal field of view, calculated from the vertical FoV and aspect ratio.
 
const mat4< F32 > & viewMatrix () const noexcept
 Returns the most recent/up-to-date view matrix.
 
const mat4< F32 > & viewMatrix () noexcept
 Updates the view matrix and returns the result.
 
const mat4< F32 > & projectionMatrix () const noexcept
 Returns the most recent/up-to-date projection matrix.
 
const mat4< F32 > & projectionMatrix () noexcept
 Updates the projection matrix and returns the result.
 
const mat4< F32 > & viewProjectionMatrix () const noexcept
 Returns the most recent/up-to-date viewProjection matrix.
 
const mat4< F32 > & viewProjectionMatrix () noexcept
 Updates the viewProjection matrix and returns the result.
 
const mat4< F32 > & worldMatrix () const noexcept
 Returns the most recent/up-to-date inverse of the view matrix.
 
const mat4< F32 > & worldMatrix () noexcept
 Updates the view matrix and returns its inverse as the worldMatrix.
 
const FrustumgetFrustum () const noexcept
 Returns the most recent/up-to-date frustum.
 
FrustumgetFrustum () noexcept
 Updates the frustum and returns the result.
 
 PROPERTY_R_IW (vec4< F32 >, orthoRect, VECTOR4_UNIT)
 
 PROPERTY_R_IW (vec3< Angle::DEGREES< F32 > >, euler, VECTOR3_ZERO)
 
 PROPERTY_RW (vec3< F32 >, speedFactor, { 5.f })
 
 PROPERTY_RW (F32, maxRadius, 10.f)
 
 PROPERTY_RW (F32, minRadius, 0.1f)
 
 PROPERTY_RW (F32, curRadius, 8.f)
 
 PROPERTY_RW (Mode, mode, Mode::COUNT)
 
 PROPERTY_RW (bool, frustumLocked, false)
 
 PROPERTY_RW (bool, rotationLocked, false)
 
 PROPERTY_RW (bool, movementLocked, false)
 
 PROPERTY_R_IW (bool, reflectionActive, false)
 
- Public Member Functions inherited from Divide::Resource
 Resource (std::string_view resourceName, std::string_view typeName)
 
ResourceState getState () const noexcept
 
 PROPERTY_R (Str< 32 >, typeName)
 
 PROPERTY_R (Str< 256 >, resourceName)
 
- Public Member Functions inherited from Divide::GUIDWrapper
 GUIDWrapper () noexcept
 
 GUIDWrapper (const GUIDWrapper &old) noexcept
 
 GUIDWrapper (GUIDWrapper &&old) noexcept
 
virtual ~GUIDWrapper ()=default
 
FORCE_INLINE I64 getGUID () const noexcept
 
GUIDWrapperoperator= (const GUIDWrapper &old)=delete
 
GUIDWrapperoperator= (GUIDWrapper &&other)=delete
 

Static Public Member Functions

static mat4< F32LookAt (const vec3< F32 > &eye, const vec3< F32 > &target, const vec3< F32 > &up) noexcept
 
template<bool zeroToOneDepth = true>
static mat4< F32Ortho (F32 left, F32 right, F32 bottom, F32 top, F32 zNear, F32 zFar) noexcept
 
template<bool zeroToOneDepth = true>
static mat4< F32Perspective (Angle::DEGREES< F32 > fovyRad, F32 aspect, F32 zNear, F32 zFar) noexcept
 
template<bool zeroToOneDepth = true>
static mat4< F32FrustumMatrix (F32 left, F32 right, F32 bottom, F32 top, F32 nearVal, F32 farVal) noexcept
 
static void Update (U64 deltaTimeUS)
 
static void InitPool ()
 
static void DestroyPool ()
 
static bool DestroyCamera (Camera *&camera)
 
static CameraGetUtilityCamera (const UtilityCamera type)
 
static CameraCreateCamera (const Str< 256 > &cameraName, Mode cameraMode)
 
static CameraFindCamera (const U64 nameHash)
 
static bool RemoveChangeListener (U32 id)
 
static U32 AddChangeListener (const CameraListener &f)
 
- Static Public Member Functions inherited from Divide::GUIDWrapper
static I64 generateGUID () noexcept
 

Static Public Attributes

static constexpr F32 DEFAULT_CAMERA_MOVE_SPEED = 20.f
 
static constexpr F32 DEFAULT_CAMERA_TURN_SPEED = 20.f
 
static constexpr F32 MAX_CAMERA_MOVE_SPEED = 20.f
 
static constexpr F32 MAX_CAMERA_TURN_SPEED = 20.f
 
static constexpr F32 s_minNearZ = 0.1f
 

Protected Member Functions

bool updateFrustum ()
 Extract the frustum associated with our current PoV.
 
bool updateViewMatrix () noexcept
 
bool updateProjection () noexcept
 
void update () noexcept
 
- Protected Member Functions inherited from Divide::Resource
virtual void setState (ResourceState currentState)
 

Static Protected Member Functions

static CameraEntryFindCameraEntry (const U64 nameHash)
 
static CameraEntryFindCameraEntryLocked (const U64 nameHash)
 

Protected Attributes

CameraListenerMap _updateCameraListeners
 
CameraSnapshot _data
 
Frustum _frustum
 
TransformComponent_targetTransform { nullptr }
 
mat4< F32_viewProjectionMatrix
 
Plane< F32_reflectionPlane
 
vec3< Angle::RADIANS< F32 > > _cameraRotation { VECTOR3_ZERO }
 
vec3< F32_fixedYawAxis { WORLD_Y_AXIS }
 
vec3< F32_offsetDir { WORLD_Z_AXIS }
 
Angle::DEGREES< F32_accumPitchDegrees { 0.0f }
 
F32 _currentRotationX { 0.0f }
 
F32 _currentRotationY { 0.0f }
 
U32 _updateCameraId { 0u }
 
bool _projectionDirty { true }
 
bool _viewMatrixDirty { false }
 
bool _frustumDirty { true }
 
bool _yawFixed { false }
 
bool _rotationDirty { true }
 
- Protected Attributes inherited from Divide::Resource
std::atomic< ResourceState_resourceState
 
- Protected Attributes inherited from Divide::GUIDWrapper
const I64 _guid
 

Detailed Description

Definition at line 88 of file Camera.h.

Member Enumeration Documentation

◆ Mode

enum class Divide::Camera::Mode : U8
strong
Enumerator
FREE_FLY 
STATIC 
FIRST_PERSON 
THIRD_PERSON 
ORBIT 
SCRIPTED 
COUNT 

Definition at line 97 of file Camera.h.

◆ UtilityCamera

enum class Divide::Camera::UtilityCamera : U8
strong
Enumerator
_2D 
_2D_FLIP_Y 
DEFAULT 
CUBE 
DUAL_PARABOLOID 
COUNT 

Definition at line 108 of file Camera.h.

Constructor & Destructor Documentation

◆ Camera()

Divide::Camera::Camera ( const std::string_view  name,
Mode  mode,
const vec3< F32 > &  eye = VECTOR3_ZERO 
)
explicit

Definition at line 257 of file Camera.cpp.

Member Function Documentation

◆ AddChangeListener()

U32 Divide::Camera::AddChangeListener ( const CameraListener f)
static

Definition at line 249 of file Camera.cpp.

◆ addUpdateListener()

U32 Divide::Camera::addUpdateListener ( const CameraListener f)

Definition at line 464 of file Camera.cpp.

◆ clearReflection()

void Divide::Camera::clearReflection ( )
noexcept

Clears the reflection plane specified (if any)

Definition at line 479 of file Camera.cpp.

◆ CreateCamera()

Camera * Divide::Camera::CreateCamera ( const Str< 256 > &  cameraName,
const Camera::Mode  mode 
)
static

Definition at line 147 of file Camera.cpp.

◆ DestroyCamera()

bool Divide::Camera::DestroyCamera ( Camera *&  camera)
static

Definition at line 175 of file Camera.cpp.

◆ DestroyPool()

void Divide::Camera::DestroyPool ( )
static

Definition at line 139 of file Camera.cpp.

◆ FindCamera()

Camera * Divide::Camera::FindCamera ( const U64  nameHash)
static

Definition at line 224 of file Camera.cpp.

◆ FindCameraEntry()

CameraEntry * Divide::Camera::FindCameraEntry ( const U64  nameHash)
staticprotected

Definition at line 200 of file Camera.cpp.

◆ FindCameraEntryLocked()

CameraEntry * Divide::Camera::FindCameraEntryLocked ( const U64  nameHash)
staticprotected

Definition at line 208 of file Camera.cpp.

◆ fromCamera()

void Divide::Camera::fromCamera ( const Camera camera)

Copies all of the internal data from the specified camera to the current one.

Definition at line 272 of file Camera.cpp.

◆ fromSnapshot()

void Divide::Camera::fromSnapshot ( const CameraSnapshot snapshot)

Sets the internal snapshot data (eye, orientation, etc) to match the specified value.

Definition at line 297 of file Camera.cpp.

◆ FrustumMatrix()

template<bool zeroToOneDepth>
mat4< F32 > Divide::Camera::FrustumMatrix ( F32  left,
F32  right,
F32  bottom,
F32  top,
F32  nearVal,
F32  farVal 
)
staticnoexcept

Definition at line 273 of file Camera.inl.

◆ getFrustum() [1/2]

const Frustum & Divide::Camera::getFrustum ( ) const
inlinenoexcept

Returns the most recent/up-to-date frustum.

Definition at line 202 of file Camera.inl.

◆ getFrustum() [2/2]

Frustum & Divide::Camera::getFrustum ( )
inlinenoexcept

Updates the frustum and returns the result.

Definition at line 207 of file Camera.inl.

◆ getHorizontalFoV()

Angle::DEGREES< F32 > Divide::Camera::getHorizontalFoV ( ) const
noexcept

Returns the horizontal field of view, calculated from the vertical FoV and aspect ratio.

Definition at line 586 of file Camera.cpp.

◆ GetUtilityCamera()

Camera * Divide::Camera::GetUtilityCamera ( const UtilityCamera  type)
static

Definition at line 120 of file Camera.cpp.

◆ InitPool()

void Divide::Camera::InitPool ( )
static

Definition at line 130 of file Camera.cpp.

◆ loadFromXML()

void Divide::Camera::loadFromXML ( const boost::property_tree::ptree &  pt,
std::string  prefix = "" 
)

Definition at line 1017 of file Camera.cpp.

◆ lookAt() [1/4]

const mat4< F32 > & Divide::Camera::lookAt ( const mat4< F32 > &  viewMatrix)

Sets the camera's view matrix to specify the specified value by extracting the eye position, orientation and other data from it.

Definition at line 354 of file Camera.cpp.

◆ lookAt() [2/4]

const mat4< F32 > & Divide::Camera::lookAt ( const vec3< F32 > &  eye,
const vec3< F32 > &  target 
)
inline

Sets the camera to point at the specified target point from the specified eye position.

Definition at line 59 of file Camera.inl.

◆ lookAt() [3/4]

const mat4< F32 > & Divide::Camera::lookAt ( const vec3< F32 > &  eye,
const vec3< F32 > &  target,
const vec3< F32 > &  up 
)

Sets the camera's position, target and up directions.

Definition at line 367 of file Camera.cpp.

◆ LookAt()

mat4< F32 > Divide::Camera::LookAt ( const vec3< F32 > &  eye,
const vec3< F32 > &  target,
const vec3< F32 > &  up 
)
staticnoexcept

Definition at line 938 of file Camera.cpp.

◆ lookAt() [4/4]

const mat4< F32 > & Divide::Camera::lookAt ( const vec3< F32 > &  target)
inline

Sets the camera to point at the specified target point.

Definition at line 54 of file Camera.inl.

◆ move()

void Divide::Camera::move ( F32  dx,
F32  dy,
F32  dz 
)
noexcept

Moves the camera by the specified offsets in each direction.

Definition at line 668 of file Camera.cpp.

◆ moveForward()

void Divide::Camera::moveForward ( const F32  factor)
inlinenoexcept

Moves the camera forward or backwards.

Definition at line 123 of file Camera.inl.

◆ moveFromPlayerState()

bool Divide::Camera::moveFromPlayerState ( const SceneStatePerPlayer playerState)

Definition at line 704 of file Camera.cpp.

◆ moveRelative()

bool Divide::Camera::moveRelative ( const vec3< F32 > &  relMovement)

Definition at line 737 of file Camera.cpp.

◆ moveStrafe()

void Divide::Camera::moveStrafe ( const F32  factor)
inlinenoexcept

Moves the camera left or right.

Definition at line 129 of file Camera.inl.

◆ moveUp()

void Divide::Camera::moveUp ( const F32  factor)
inlinenoexcept

Moves the camera up or down.

Definition at line 135 of file Camera.inl.

◆ Ortho()

template<bool zeroToOneDepth>
mat4< F32 > Divide::Camera::Ortho ( F32  left,
F32  right,
F32  bottom,
F32  top,
F32  zNear,
F32  zFar 
)
staticnoexcept

Definition at line 219 of file Camera.inl.

◆ Perspective()

template<bool zeroToOneDepth>
mat4< F32 > Divide::Camera::Perspective ( Angle::DEGREES< F32 fovyRad,
F32  aspect,
F32  zNear,
F32  zFar 
)
staticnoexcept

Definition at line 245 of file Camera.inl.

◆ project()

vec2< F32 > Divide::Camera::project ( const vec3< F32 > &  worldCoords,
const Rect< I32 > &  viewport 
) const
noexcept

Definition at line 917 of file Camera.cpp.

◆ projectionMatrix() [1/2]

const mat4< F32 > & Divide::Camera::projectionMatrix ( ) const
inlinenoexcept

Returns the most recent/up-to-date projection matrix.

Definition at line 168 of file Camera.inl.

◆ projectionMatrix() [2/2]

const mat4< F32 > & Divide::Camera::projectionMatrix ( )
inlinenoexcept

Updates the projection matrix and returns the result.

Definition at line 173 of file Camera.inl.

◆ PROPERTY_R_IW() [1/3]

Divide::Camera::PROPERTY_R_IW ( bool  ,
reflectionActive  ,
false   
)

◆ PROPERTY_R_IW() [2/3]

Divide::Camera::PROPERTY_R_IW ( vec3< Angle::DEGREES< F32 > >  ,
euler  ,
VECTOR3_ZERO   
)

◆ PROPERTY_R_IW() [3/3]

Divide::Camera::PROPERTY_R_IW ( vec4< F32 ,
orthoRect  ,
VECTOR4_UNIT   
)

◆ PROPERTY_RW() [1/8]

Divide::Camera::PROPERTY_RW ( bool  ,
frustumLocked  ,
false   
)

◆ PROPERTY_RW() [2/8]

Divide::Camera::PROPERTY_RW ( bool  ,
movementLocked  ,
false   
)

◆ PROPERTY_RW() [3/8]

Divide::Camera::PROPERTY_RW ( bool  ,
rotationLocked  ,
false   
)

◆ PROPERTY_RW() [4/8]

Divide::Camera::PROPERTY_RW ( F32  ,
curRadius  ,
8.  f 
)

◆ PROPERTY_RW() [5/8]

Divide::Camera::PROPERTY_RW ( F32  ,
maxRadius  ,
10.  f 
)

◆ PROPERTY_RW() [6/8]

Divide::Camera::PROPERTY_RW ( F32  ,
minRadius  ,
0.  1f 
)

◆ PROPERTY_RW() [7/8]

Divide::Camera::PROPERTY_RW ( Mode  ,
mode  ,
Mode::COUNT   
)

◆ PROPERTY_RW() [8/8]

Divide::Camera::PROPERTY_RW ( vec3< F32 ,
speedFactor  ,
{ 5.f }   
)

◆ RemoveChangeListener()

bool Divide::Camera::RemoveChangeListener ( U32  id)
static

Definition at line 235 of file Camera.cpp.

◆ removeUpdateListener()

bool Divide::Camera::removeUpdateListener ( U32  id)

Definition at line 450 of file Camera.cpp.

◆ rotate() [1/3]

void Divide::Camera::rotate ( Angle::DEGREES< F32 yaw,
Angle::DEGREES< F32 pitch,
Angle::DEGREES< F32 roll 
)
noexcept

Sets the camera's orientation to match the specified yaw, pitch and roll values; Creates a quaternion based on the specified Euler angles and calls "rotate" to change the orientation

Definition at line 597 of file Camera.cpp.

◆ rotate() [2/3]

void Divide::Camera::rotate ( const Quaternion< F32 > &  q)

Rotates the camera (changes its orientation) by the specified quaternion (_orientation *= q)

Definition at line 427 of file Camera.cpp.

◆ rotate() [3/3]

void Divide::Camera::rotate ( const vec3< F32 > &  axis,
const Angle::DEGREES< F32 angle 
)
inline

Creates a quaternion based on the specified axis-angle and calls "rotate" to change the orientation.

Definition at line 118 of file Camera.inl.

◆ rotatePitch()

void Divide::Camera::rotatePitch ( Angle::DEGREES< F32 angle)

Change camera's pitch.

Definition at line 663 of file Camera.cpp.

◆ rotateRelative()

bool Divide::Camera::rotateRelative ( const vec3< F32 > &  relRotation)

Definition at line 748 of file Camera.cpp.

◆ rotateRoll()

void Divide::Camera::rotateRoll ( Angle::DEGREES< F32 angle)

Change camera's roll.

Definition at line 658 of file Camera.cpp.

◆ rotateYaw()

void Divide::Camera::rotateYaw ( Angle::DEGREES< F32 angle)

Yaw, Pitch and Roll call "rotate" with a appropriate quaternion for each rotation. Because the camera is facing the -Z axis, a positive angle will create a positive Yaw behind the camera and a negative one in front of the camera (so we invert the angle - left will turn left when facing -Z)

Definition at line 653 of file Camera.cpp.

◆ saveToXML()

void Divide::Camera::saveToXML ( boost::property_tree::ptree &  pt,
std::string  prefix = "" 
) const

Definition at line 969 of file Camera.cpp.

◆ setAspectRatio()

void Divide::Camera::setAspectRatio ( F32  ratio)
noexcept

Definition at line 568 of file Camera.cpp.

◆ setEuler() [1/2]

void Divide::Camera::setEuler ( const Angle::DEGREES< F32 > &  pitch,
const Angle::DEGREES< F32 > &  yaw,
const Angle::DEGREES< F32 > &  roll 
)
inlinenoexcept

Set the camera's rotation to match the specified euler angles.

Definition at line 152 of file Camera.inl.

◆ setEuler() [2/2]

void Divide::Camera::setEuler ( const vec3< Angle::DEGREES< F32 > > &  euler)
inlinenoexcept

Set the camera's rotation to match the specified euler angles.

Definition at line 147 of file Camera.inl.

◆ setEye() [1/2]

void Divide::Camera::setEye ( const F32  x,
const F32  y,
const F32  z 
)
inlinenoexcept

Sets the camera's eye position.

Definition at line 100 of file Camera.inl.

◆ setEye() [2/2]

void Divide::Camera::setEye ( const vec3< F32 > &  position)
inlinenoexcept

Sets the camera's eye position.

Definition at line 106 of file Camera.inl.

◆ setFixedYawAxis()

void Divide::Camera::setFixedYawAxis ( const bool  useFixed,
const vec3< F32 > &  fixedAxis = WORLD_Y_AXIS 
)
inlinenoexcept

Exactly as in Ogre3D: locks the yaw movement to the specified axis.

Definition at line 141 of file Camera.inl.

◆ setGlobalPitch()

void Divide::Camera::setGlobalPitch ( const Angle::DEGREES< F32 angle)
inlinenoexcept

Sets the camera's Pitch angle. Yaw and Roll are previous extracted values.

Definition at line 89 of file Camera.inl.

◆ setGlobalRoll()

void Divide::Camera::setGlobalRoll ( const Angle::DEGREES< F32 angle)
inlinenoexcept

Sets the camera's Roll angle. Yaw and Pitch are previous extracted values.

Definition at line 95 of file Camera.inl.

◆ setGlobalRotation() [1/2]

void Divide::Camera::setGlobalRotation ( const vec3< Angle::DEGREES< F32 > > &  euler)
inlinenoexcept

Global rotations are applied relative to the world axis, not the camera's.

Definition at line 48 of file Camera.inl.

◆ setGlobalRotation() [2/2]

void Divide::Camera::setGlobalRotation ( F32  yaw,
F32  pitch,
F32  roll = 0.0f 
)
noexcept

Global rotations are applied relative to the world axis, not the camera's.

Definition at line 405 of file Camera.cpp.

◆ setGlobalYaw()

void Divide::Camera::setGlobalYaw ( const Angle::DEGREES< F32 angle)
inlinenoexcept

Sets the camera's Yaw angle. This creates a new orientation quaternion for the camera and extracts the Euler angles

Definition at line 83 of file Camera.inl.

◆ setHorizontalFoV()

void Divide::Camera::setHorizontalFoV ( Angle::DEGREES< F32 horizontalFoV)
noexcept

Definition at line 580 of file Camera.cpp.

◆ setPitch()

void Divide::Camera::setPitch ( const Angle::DEGREES< F32 angle)
inlinenoexcept

Sets the camera's Pitch angle. Yaw and Roll are previous extracted values.

Definition at line 70 of file Camera.inl.

◆ setProjection() [1/5]

const mat4< F32 > & Divide::Camera::setProjection ( const mat4< F32 > &  projection,
vec2< F32 zPlanes,
bool  isOrtho 
)
noexcept

Definition at line 554 of file Camera.cpp.

◆ setProjection() [2/5]

const mat4< F32 > & Divide::Camera::setProjection ( const vec4< F32 > &  rect,
vec2< F32 zPlanes 
)

Definition at line 541 of file Camera.cpp.

◆ setProjection() [3/5]

const mat4< F32 > & Divide::Camera::setProjection ( F32  aspectRatio,
F32  verticalFoV,
vec2< F32 zPlanes 
)

Definition at line 526 of file Camera.cpp.

◆ setProjection() [4/5]

const mat4< F32 > & Divide::Camera::setProjection ( F32  verticalFoV,
vec2< F32 zPlanes 
)

Definition at line 521 of file Camera.cpp.

◆ setProjection() [5/5]

const mat4< F32 > & Divide::Camera::setProjection ( vec2< F32 zPlanes)

Definition at line 516 of file Camera.cpp.

◆ setReflection()

void Divide::Camera::setReflection ( const Plane< F32 > &  reflectionPlane)
noexcept

Specify a reflection plane that alters the final view matrix to be a mirror of the internal lookAt matrix.

Definition at line 472 of file Camera.cpp.

◆ setRoll()

void Divide::Camera::setRoll ( const Angle::DEGREES< F32 angle)
inlinenoexcept

Sets the camera's Roll angle. Yaw and Pitch are previous extracted values.

Definition at line 76 of file Camera.inl.

◆ setRotation() [1/2]

void Divide::Camera::setRotation ( const Angle::DEGREES< F32 yaw,
const Angle::DEGREES< F32 pitch,
const Angle::DEGREES< F32 roll = 0.0f 
)
noexcept

Sets the camera's orientation.

Definition at line 592 of file Camera.cpp.

◆ setRotation() [2/2]

void Divide::Camera::setRotation ( const Quaternion< F32 > &  q)
inlinenoexcept

Sets the camera's orientation.

Definition at line 111 of file Camera.inl.

◆ setTarget()

void Divide::Camera::setTarget ( TransformComponent tComp,
const vec3< F32 > &  offsetDirection = VECTOR3_ZERO 
)
noexcept

Offset direction is a (eventually normalized) vector that is scaled by curRadius and applied to the camera's eye position.

Definition at line 348 of file Camera.cpp.

◆ setVerticalFoV()

void Divide::Camera::setVerticalFoV ( Angle::DEGREES< F32 verticalFoV)
noexcept

Definition at line 574 of file Camera.cpp.

◆ setYaw()

void Divide::Camera::setYaw ( const Angle::DEGREES< F32 angle)
inlinenoexcept

Sets the camera's Yaw angle. This creates a new orientation quaternion for the camera and extracts the Euler angles

Definition at line 64 of file Camera.inl.

◆ snapshot()

const CameraSnapshot & Divide::Camera::snapshot ( ) const
inlinenoexcept

Returns the internal camera snapshot data (eye, orientation, etc)

Definition at line 43 of file Camera.inl.

◆ unProject() [1/2]

vec3< F32 > Divide::Camera::unProject ( const vec3< F32 > &  winCoords,
const Rect< I32 > &  viewport 
) const
inlinenoexcept

Definition at line 213 of file Camera.inl.

◆ unProject() [2/2]

vec3< F32 > Divide::Camera::unProject ( F32  winCoordsX,
F32  winCoordsY,
const Rect< I32 > &  viewport 
) const
noexcept

Returns the world space direction for the specified winCoords for this camera Use snapshot()._eye + unProject(...) * distance for a world-space position

Definition at line 879 of file Camera.cpp.

◆ update()

void Divide::Camera::update ( )
protectednoexcept

Definition at line 317 of file Camera.cpp.

◆ Update()

void Divide::Camera::Update ( U64  deltaTimeUS)
static

Definition at line 107 of file Camera.cpp.

◆ updateFrustum()

bool Divide::Camera::updateFrustum ( )
protected

Extract the frustum associated with our current PoV.

Definition at line 856 of file Camera.cpp.

◆ updateLookAt()

bool Divide::Camera::updateLookAt ( )

Return true if the cached camera state wasn't up-to-date.

Tell the rendering API to set up our desired PoV.

Definition at line 384 of file Camera.cpp.

◆ updateProjection()

bool Divide::Camera::updateProjection ( )
protectednoexcept

Definition at line 485 of file Camera.cpp.

◆ updateViewMatrix()

bool Divide::Camera::updateViewMatrix ( )
protectednoexcept

Definition at line 818 of file Camera.cpp.

◆ viewMatrix() [1/2]

const mat4< F32 > & Divide::Camera::viewMatrix ( ) const
inlinenoexcept

Returns the most recent/up-to-date view matrix.

Definition at line 157 of file Camera.inl.

◆ viewMatrix() [2/2]

const mat4< F32 > & Divide::Camera::viewMatrix ( )
inlinenoexcept

Updates the view matrix and returns the result.

Definition at line 162 of file Camera.inl.

◆ viewProjectionMatrix() [1/2]

const mat4< F32 > & Divide::Camera::viewProjectionMatrix ( ) const
inlinenoexcept

Returns the most recent/up-to-date viewProjection matrix.

Definition at line 186 of file Camera.inl.

◆ viewProjectionMatrix() [2/2]

const mat4< F32 > & Divide::Camera::viewProjectionMatrix ( )
inlinenoexcept

Updates the viewProjection matrix and returns the result.

Definition at line 179 of file Camera.inl.

◆ worldMatrix() [1/2]

const mat4< F32 > & Divide::Camera::worldMatrix ( ) const
inlinenoexcept

Returns the most recent/up-to-date inverse of the view matrix.

Definition at line 197 of file Camera.inl.

◆ worldMatrix() [2/2]

const mat4< F32 > & Divide::Camera::worldMatrix ( )
inlinenoexcept

Updates the view matrix and returns its inverse as the worldMatrix.

Definition at line 191 of file Camera.inl.

◆ zoom()

bool Divide::Camera::zoom ( F32  zoomFactor)
noexcept

Definition at line 806 of file Camera.cpp.

Member Data Documentation

◆ _accumPitchDegrees

Angle::DEGREES<F32> Divide::Camera::_accumPitchDegrees { 0.0f }
protected

Definition at line 286 of file Camera.h.

◆ _cameraRotation

vec3<Angle::RADIANS<F32> > Divide::Camera::_cameraRotation { VECTOR3_ZERO }
protected

Definition at line 283 of file Camera.h.

◆ _currentRotationX

F32 Divide::Camera::_currentRotationX { 0.0f }
protected

Definition at line 287 of file Camera.h.

◆ _currentRotationY

F32 Divide::Camera::_currentRotationY { 0.0f }
protected

Definition at line 288 of file Camera.h.

◆ _data

CameraSnapshot Divide::Camera::_data
protected

Definition at line 278 of file Camera.h.

◆ _fixedYawAxis

vec3<F32> Divide::Camera::_fixedYawAxis { WORLD_Y_AXIS }
protected

Definition at line 284 of file Camera.h.

◆ _frustum

Frustum Divide::Camera::_frustum
protected

Definition at line 279 of file Camera.h.

◆ _frustumDirty

bool Divide::Camera::_frustumDirty { true }
protected

Definition at line 292 of file Camera.h.

◆ _offsetDir

vec3<F32> Divide::Camera::_offsetDir { WORLD_Z_AXIS }
protected

Definition at line 285 of file Camera.h.

◆ _projectionDirty

bool Divide::Camera::_projectionDirty { true }
protected

Definition at line 290 of file Camera.h.

◆ _reflectionPlane

Plane<F32> Divide::Camera::_reflectionPlane
protected

Definition at line 282 of file Camera.h.

◆ _rotationDirty

bool Divide::Camera::_rotationDirty { true }
protected

Definition at line 294 of file Camera.h.

◆ _targetTransform

TransformComponent* Divide::Camera::_targetTransform { nullptr }
protected

Definition at line 280 of file Camera.h.

◆ _updateCameraId

U32 Divide::Camera::_updateCameraId { 0u }
protected

Definition at line 289 of file Camera.h.

◆ _updateCameraListeners

CameraListenerMap Divide::Camera::_updateCameraListeners
protected

Definition at line 277 of file Camera.h.

◆ _viewMatrixDirty

bool Divide::Camera::_viewMatrixDirty { false }
protected

Definition at line 291 of file Camera.h.

◆ _viewProjectionMatrix

mat4<F32> Divide::Camera::_viewProjectionMatrix
protected

Definition at line 281 of file Camera.h.

◆ _yawFixed

bool Divide::Camera::_yawFixed { false }
protected

Definition at line 293 of file Camera.h.

◆ DEFAULT_CAMERA_MOVE_SPEED

constexpr F32 Divide::Camera::DEFAULT_CAMERA_MOVE_SPEED = 20.f
staticconstexpr

Definition at line 91 of file Camera.h.

◆ DEFAULT_CAMERA_TURN_SPEED

constexpr F32 Divide::Camera::DEFAULT_CAMERA_TURN_SPEED = 20.f
staticconstexpr

Definition at line 92 of file Camera.h.

◆ MAX_CAMERA_MOVE_SPEED

constexpr F32 Divide::Camera::MAX_CAMERA_MOVE_SPEED = 20.f
staticconstexpr

Definition at line 93 of file Camera.h.

◆ MAX_CAMERA_TURN_SPEED

constexpr F32 Divide::Camera::MAX_CAMERA_TURN_SPEED = 20.f
staticconstexpr

Definition at line 94 of file Camera.h.

◆ s_minNearZ

constexpr F32 Divide::Camera::s_minNearZ = 0.1f
staticconstexpr

Definition at line 95 of file Camera.h.


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