SAGE
A Simple Academic Game Engine
Loading...
Searching...
No Matches
Sage::CCamera Class Reference

A basic camera. More...

#include <SageCamera.h>

Inheritance diagram for Sage::CCamera:
Collaboration diagram for Sage::CCamera:

Public Member Functions

 CCamera ()
 Constructor.
 
void SetPerspective (float, float, float, float)
 Set perspective camera.
 
void SetOrthographic (float, float, float, float)
 Set orthographic camera.
 
virtual void Move (float)
 Move along velocity vector.
 
void MoveTo (const Vector3 &)
 Move to new position.
 
void AddToPos (const Vector3 &)
 Add to position.
 
void SetVel (const Vector3 &)
 Set velocity.
 
void AddToYaw (float)
 Add to yaw.
 
void AddToPitch (float)
 Add to pitch.
 
void AddToRoll (float)
 Add to roll.
 
void SetYaw (float)
 Set yaw.
 
void SetPitch (float)
 Set pitch.
 
void SetRoll (float)
 Set roll.
 
const float GetYaw () const
 Get yaw.
 
const float GetPitch () const
 Get pitch.
 
const float GetRoll () const
 Get roll.
 
void RotateToFaceCamera (CSpriteDesc3D &)
 Rotate to face camera.
 
bool BoxInFrustum (const BoundingBox &)
 Does the box overlap the view frustum?
 
const Vector3 & GetViewVector () const
 Get the view vector.
 
const Vector3 & GetUpVector () const
 Get the up vector.
 
const BoundingFrustum & GetFrustum () const
 Get the view frustum.
 
const Vector3 & GetPos () const
 Get position.
 

Protected Member Functions

void BuildViewFrustum ()
 Build the view frustum.
 
virtual void Update ()
 Update matrices and frustum.
 

Protected Attributes

Vector3 m_vPos
 Position.
 
Vector3 m_vVel
 Velocity.
 
float m_fYaw = 0.0f
 Yaw angle.
 
float m_fPitch = 0.0f
 Pitch angle.
 
float m_fRoll = 0.0f
 Roll angle.
 
Vector3 m_vView = Vector3::UnitZ
 View vector.
 
Vector3 m_vUp = Vector3::UnitY
 Up vector.
 
BoundingFrustum m_cFrustum
 View frustum for frustum clipping.
 

Additional Inherited Members

- Static Protected Attributes inherited from Sage::CCameraCommon
static XMFLOAT4X4 m_f4x4Orient
 Orientation matrix.
 
static XMFLOAT4X4 m_f4x4View
 View matrix.
 
static XMFLOAT4X4 m_f4x4Projection
 Projection matrix.
 

Detailed Description

Basic camera functionality including position, orientation, velocity, and frustum culling.

Constructor & Destructor Documentation

◆ CCamera()

CCamera::CCamera ( )

Set the orientation, view, and projection matrices to the identity matrix.

Member Function Documentation

◆ AddToPitch()

void CCamera::AddToPitch ( float angle)

Add angle to pitch.

Parameters
angleAngle to be added to pitch, in radians.
Here is the call graph for this function:

◆ AddToPos()

void CCamera::AddToPos ( const Vector3 & delta)

Add to the camera position.

Parameters
deltaChange in position.
Here is the call graph for this function:

◆ AddToRoll()

void CCamera::AddToRoll ( float angle)

Add angle to roll.

Parameters
angleAngle to be added to roll, in radians.
Here is the call graph for this function:

◆ AddToYaw()

void CCamera::AddToYaw ( float angle)

Add angle to yaw.

Parameters
angleAngle to be added to yaw, in radians.
Here is the call graph for this function:

◆ BoxInFrustum()

bool CCamera::BoxInFrustum ( const BoundingBox & box)

Box in frustum test.

Parameters
boxAn AABB.
Returns
true if the AABB intersects the view frustum.
Here is the caller graph for this function:

◆ BuildViewFrustum()

void CCamera::BuildViewFrustum ( )
protected

Compute the view frustum from the camera's projection and view matrices.

Here is the caller graph for this function:

◆ GetFrustum()

const BoundingFrustum & CCamera::GetFrustum ( ) const

Reader function for the view frustum.

Returns
The view frustum.

◆ GetPitch()

const float CCamera::GetPitch ( ) const

Reader function for the pitch.

Returns
angle Pitch in radians.

◆ GetPos()

const Vector3 & CCamera::GetPos ( ) const

Reader function for the camera position.

Returns
Camera position.
Here is the caller graph for this function:

◆ GetRoll()

const float CCamera::GetRoll ( ) const

Reader function for the roll.

Returns
angle Roll in radians.

◆ GetUpVector()

const Vector3 & CCamera::GetUpVector ( ) const

Reader function for the up vector.

Returns
The up vector.
Here is the caller graph for this function:

◆ GetViewVector()

const Vector3 & CCamera::GetViewVector ( ) const

Reader function for the view vector.

Returns
The view vector.
Here is the caller graph for this function:

◆ GetYaw()

const float CCamera::GetYaw ( ) const

Reader function for the yaw.

Returns
angle Yaw in radians.

◆ Move()

void CCamera::Move ( float t)
virtual

Move the camera along its velocity vector for a given amount of time.

Parameters
tFrame time in seconds.
Here is the call graph for this function:

◆ MoveTo()

void CCamera::MoveTo ( const Vector3 & p)

Move camera to a new position.

Parameters
pNew position.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RotateToFaceCamera()

void CCamera::RotateToFaceCamera ( CSpriteDesc3D & sd)

Rotate a sprite descriptor to face the camera.

Parameters
sd[in, out] 3D sprite descriptor
Here is the caller graph for this function:

◆ SetOrthographic()

void CCamera::SetOrthographic ( float w,
float h,
float nearz,
float farz )

Set renderer to orthographic projection.

Parameters
wWindow width in pixels.
hWindow height in pixels.
nearzZ coordinate of the near clipping plane.
farzZ coordinate of the far clipping plane.
Here is the caller graph for this function:

◆ SetPerspective()

void CCamera::SetPerspective ( float r,
float hfov,
float nearz,
float farz )

Set renderer to perspective projection.

Parameters
rWindow aspect ratio.
hfovHorizontal field of view angle
nearzZ coordinate of the near clipping plane.
farzZ coordinate of the far clipping plane.
Here is the caller graph for this function:

◆ SetPitch()

void CCamera::SetPitch ( float angle)

Set pitch angle.

Parameters
angleNew pitch angle, in radians.
Here is the call graph for this function:

◆ SetRoll()

void CCamera::SetRoll ( float angle)

Set roll angle.

Parameters
angleNew roll angle, in radians.
Here is the call graph for this function:

◆ SetVel()

void CCamera::SetVel ( const Vector3 & p)

Set camera velocity.

Parameters
pThe new velocity vector.

◆ SetYaw()

void CCamera::SetYaw ( float angle)

Set yaw angle.

Parameters
angleNew yaw angle, in radians.
Here is the call graph for this function:

◆ Update()

void CCamera::Update ( )
protectedvirtual

Update the camera's orientation matrix, view vector, up vector, view matrix, and view frustum from its current yaw, pitch, roll, and position.

Here is the call graph for this function:
Here is the caller graph for this function: