The LARC Game Engine
A Simple Game Engine from the Laboratory for Recreational Computing
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
LBaseCamera Class Reference

The base camera. More...

#include <BaseCamera.h>

Inheritance diagram for LBaseCamera:
LCameraCommon

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

Vector3 m_vPos = Vector3::Zero
 Position.
 
Vector3 m_vVel = Vector3::Zero
 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_frustum
 View frustum for frustum clipping.
 

Additional Inherited Members

- Static Protected Attributes inherited from LCameraCommon
static XMFLOAT4X4 m_orient
 Orientation matrix.
 
static XMFLOAT4X4 m_view
 View matrix.
 
static XMFLOAT4X4 m_projection
 Projection matrix.
 

Detailed Description

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

Constructor & Destructor Documentation

◆ LBaseCamera()

LBaseCamera::LBaseCamera ( )

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

Member Function Documentation

◆ AddToPitch()

void LBaseCamera::AddToPitch ( float  angle)

Add angle to pitch.

Parameters
angleAngle to be added to pitch, in radians.

◆ AddToPos()

void LBaseCamera::AddToPos ( const Vector3 &  delta)

Add to the camera position.

Parameters
deltaChange in position.

◆ AddToRoll()

void LBaseCamera::AddToRoll ( float  angle)

Add angle to roll.

Parameters
angleAngle to be added to roll, in radians.

◆ AddToYaw()

void LBaseCamera::AddToYaw ( float  angle)

Add angle to yaw.

Parameters
angleAngle to be added to yaw, in radians.

◆ BoxInFrustum()

bool LBaseCamera::BoxInFrustum ( const BoundingBox &  box)

Box in frustum test.

Parameters
boxAn AABB.
Returns
true if the AABB intersects the view frustum.

◆ BuildViewFrustum()

void LBaseCamera::BuildViewFrustum ( )
protected

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

◆ GetFrustum()

const BoundingFrustum & LBaseCamera::GetFrustum ( ) const

Reader function for the view frustum.

Returns
The view frustum.

◆ GetPitch()

const float LBaseCamera::GetPitch ( ) const

Reader function for the pitch.

Returns
angle Pitch in radians.

◆ GetPos()

const Vector3 & LBaseCamera::GetPos ( ) const

Reader function for the camera position.

Returns
Camera position.

◆ GetRoll()

const float LBaseCamera::GetRoll ( ) const

Reader function for the roll.

Returns
angle Roll in radians.

◆ GetUpVector()

const Vector3 & LBaseCamera::GetUpVector ( ) const

Reader function for the up vector.

Returns
The up vector.

◆ GetViewVector()

const Vector3 & LBaseCamera::GetViewVector ( ) const

Reader function for the view vector.

Returns
The view vector.

◆ GetYaw()

const float LBaseCamera::GetYaw ( ) const

Reader function for the yaw.

Returns
angle Yaw in radians.

◆ Move()

void LBaseCamera::Move ( float  t)
virtual

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

Parameters
tFrame time in seconds.

◆ MoveTo()

void LBaseCamera::MoveTo ( const Vector3 &  p)

Move camera to a new position.

Parameters
pNew position.

◆ RotateToFaceCamera()

void LBaseCamera::RotateToFaceCamera ( LSpriteDesc3D sd)

Rotate a sprite descriptor to face the camera.

Parameters
sd[in, out] 3D sprite descriptor

◆ SetOrthographic()

void LBaseCamera::SetOrthographic ( float  width,
float  ht,
float  nearz,
float  farz 
)

Set renderer to orthographic projection.

Parameters
widthWindow width in pixels.
htWindow height in pixels.
nearzZ coordinate of the near clipping plane.
farzZ coordinate of the far clipping plane.

◆ SetPerspective()

void LBaseCamera::SetPerspective ( float  aspectratio,
float  hfov,
float  nearz,
float  farz 
)

Set renderer to perspective projection.

Parameters
aspectratioWindow aspect ratio.
hfovHorizontal field of view angle
nearzZ coordinate of the near clipping plane.
farzZ coordinate of the far clipping plane.

◆ SetPitch()

void LBaseCamera::SetPitch ( float  angle)

Set pitch angle.

Parameters
angleNew pitch angle, in radians.

◆ SetRoll()

void LBaseCamera::SetRoll ( float  angle)

Set roll angle.

Parameters
angleNew roll angle, in radians.

◆ SetVel()

void LBaseCamera::SetVel ( const Vector3 &  p)

Set camera velocity.

Parameters
pThe new velocity vector.

◆ SetYaw()

void LBaseCamera::SetYaw ( float  angle)

Set yaw angle.

Parameters
angleNew yaw angle, in radians.

◆ Update()

void LBaseCamera::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.