VoxelEngine
 
Loading...
Searching...
No Matches
engine::Camera Class Reference
Inheritance diagram for engine::Camera:
engine::EngineEventSite engine::EventSite

Public Types

enum class  ProjectionType { Perspective , Orthographic }
 

Public Member Functions

 Camera (OrthoOptions opts)
 
 Camera (PerspectiveOptions opts)
 
void windowResizeEvent (ResizeEvent *ev) override
 
void position (const glm::vec3 &pos)
 
const glm::vec3 & position () const
 
const glm::vec3 & lookDirection () const
 
glm::quat rotation (bool ignorePitch) const
 Returns the camera's rotation as a quaternion.
 
void lookAt (const glm::vec3 &target)
 
void lookDirection (const glm::vec3 &direction)
 
void rotate (float dx, float dy, bool constrainPitch=true)
 
void resize (int width, int height)
 
glm::mat4 getView () const
 
glm::mat4 getProjection () const
 
float farPlane () const
 
float nearPlane () const
 
float fov () const
 
float aspectRatio () const
 
std::array< Plane, 6 > getFrustum () const
 Returns the camera's frustum in world space.
 
std::array< glm::vec3, 8 > getFrustumCorners () const
 Returns the camera's frustum corners in world space.
 

Static Public Member Functions

static std::array< glm::vec3, 8 > getFrustumCorners (const glm::mat4 &projection, const glm::mat4 &view)
 

Protected Member Functions

void updateVectors ()
 

Protected Attributes

glm::vec3 m_worldUp = UP
 
float m_yaw
 
float m_pitch
 
glm::vec3 m_position
 
glm::vec3 m_front
 
glm::vec3 m_up
 
glm::vec3 m_right
 
glm::mat4 m_projection
 
ProjectionType m_type
 
float m_fov = 0.0f
 
float m_zNear = 0.1f
 
float m_zFar = 1200.0f
 
float m_aspectRatio = 1.0f
 

Member Function Documentation

◆ getFrustum()

std::array< Plane, 6 > Camera::getFrustum ( ) const

Returns the camera's frustum in world space.

Note
Order of the planes is: left, right, top, bottom, near, far.

◆ getFrustumCorners()

std::array< glm::vec3, 8 > Camera::getFrustumCorners ( ) const

Returns the camera's frustum corners in world space.

Note
Order of the corners is: [0] near bottom right, [1] near bottom left, [2] near top right, [3] near top left, [4] far bottom right, [5] far bottom left, [6] far top right, [7] far top left.

◆ rotation()

glm::quat Camera::rotation ( bool  ignorePitch) const

Returns the camera's rotation as a quaternion.

Parameters
ignorePitchIf true, the pitch (up/down rotation) is ignored. Good if you want to move on XZ plane only.
Returns
Quaternion representing the camera's rotation.

◆ windowResizeEvent()

void Camera::windowResizeEvent ( ResizeEvent ev)
overridevirtual

Reimplemented from engine::EngineEventSite.


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