Oxygen Engine
Modern C++ 3D Engine using OpenGL
Loading...
Searching...
No Matches
oe::scene::Camera Class Reference

The "eye of the scene". More...

#include <OxygenEngine/scene/camera.h>

Inheritance diagram for oe::scene::Camera:
[legend]
Collaboration diagram for oe::scene::Camera:
[legend]

Public Member Functions

template<CameraProjection ProjectionSettings>
 Camera (const ProjectionSettings &projection_settings)
 Constructor.
 
template<CameraProjection ProjectionSettings>
void setProjectionSettings (const ProjectionSettings &projection_settings)
 Update the camera's projection matrix by recomputing it based on the provided settings.
 
void lookAt (const glm::vec3 &target)
 Orient the camera to stare at a specified target.
 
bool isInFrustum (const glm::vec3 &point) const
 Check if a point is visible from the camera point of view.
 
bool isInFrustum (const glm::vec3 &center, const float &radius) const
 Check if a sphere is visible from the camera point of view.
 
bool isInFrustum (const AABB &box) const
 Check if a AABB is visible from the camera point of view.
 
const glm::mat4 & getView () const
 Get the view matrix of the camera.
 
const glm::mat4 & getProjection () const
 Get the projection matrix of the camera.
 
const glm::mat4 & getInverseView () const
 
const glm::mat4 & getInverseProjection () const
 
const glm::mat4 & getTransform () const noexcept
 Get the transformation matrix of the camera.
 
const glm::mat4 & getInverseTransform () const noexcept
 
float getPitch () const noexcept
 
float getYaw () const noexcept
 
float getRoll () const noexcept
 
void setPitch (const float pitch)
 
void setYaw (const float yaw)
 
void setRoll (const float roll)
 
bool isDirty () const
 
- Public Member Functions inherited from oe::scene::Transform
 Transform (const glm::vec3 &translation=glm::vec3(0.f), const glm::quat &rotation=glm::quat(1.f, 0.f, 0.f, 0.f), const glm::vec3 &scale=glm::vec3(1.f), const glm::vec3 &skew=glm::vec3(0.f), const glm::vec4 &perspective=glm::vec4(glm::vec3(0.f), 1.f))
 Generate Transform from its translation, rotation, scale values.
 
 Transform (const glm::mat4 &model)
 Generate Transform from a model matrix.
 
const glm::vec3 & getTranslation () const
 Get Translation component value of the transform.
 
const glm::vec3 & getPosition () const
 Get Translation component value of the transform.
 
const glm::quat & getRotation () const
 Get Rotation component value of the transform.
 
const glm::vec3 & getScale () const
 Get Scaling component value of the transform.
 
const glm::vec3 & getSkew () const
 Get Skew component value of the transform.
 
const glm::vec4 & getPerspective () const
 get Perspective component value of the transform
 
void setTranslation (const float x, const float y, const float z)
 Translate to the specified position, filled component wise.
 
void setPosition (const glm::vec3 &position)
 Translate to the specified position.
 
void setPosition (const float x, const float y, const float z)
 Translate to the specified position.
 
void setRotation (const float x, const float y, const float z)
 Set rotation from Euler angles.
 
void setRotation (const lit::Angle &x, const lit::Angle &y, const lit::Angle &z)
 Relatively rotate the transform using a lit::Angle triad.
 
void setScale (const float x, const float y, const float z)
 Set scaling.
 
void relativeTranslate (const glm::vec3 &translation)
 Translate the transform from current position.
 
void relativeTranslate (const float x, const float y, const float z)
 Translate the transform from current position, component wise.
 
void loadFromModel (const glm::mat4 &model)
 Fill the transform from a model matrix.
 
void relativeMove (const glm::vec3 &translation)
 Move the transform relative to current translation.
 
void relativeRotate (const glm::quat &quaternion)
 Rotate the transform relative to current rotation.
 
void relativeRotate (const float x, const float y, const float z)
 Rotate the transform from Euler angles (component wise)
 
void relativeRotate (const lit::Angle &x, const lit::Angle &y, const lit::Angle &z)
 Relatively rotate the transform using a lit::Angle triad.
 
void relativeScale (const glm::vec3 &scale)
 Multiply current scale by the new one.
 
void setSkew (const glm::vec3 &skew)
 Set skew of the transform.
 
void setPerspective (const glm::vec4 &perspective)
 Set perspective effect of the transform.
 
void interpolateWith (const float ratio, const Transform &target)
 Interpolate this transform with another one.
 
void fillFrom (const Transform &transform)
 Fill current values from another transform.
 
template<TranslationType T>
void setTranslation (const T &translation)
 Translate to the specified position.
 
template<RotationType R>
void setRotation (const R &rotation)
 Get rotation quaternion from a generic type.
 
template<ScaleType S>
void setScale (const S &scale)
 Set scale vector from a generic type.
 
template<TranslationType T>
void getTranslationAs (T &result) const
 Get translation vector and fill in generic type.
 
template<RotationType R>
void getRotationAs (R &result) const
 Get rotation quaternion and fill in generic type.
 
template<ScaleType S>
void getScaleAs (S &result) const
 Get scale vector and fill in generic type.
 
glm::mat4 getModelMatrix () const
 Generate a Model matrix from the transform.
 
bool isDirty () const
 Check if something modified this transform.
 

Additional Inherited Members

- Protected Member Functions inherited from oe::scene::Transform
void forceDirty (const bool is_dirty) const
 Set custom dirty status.
 

Detailed Description

The "eye of the scene".

Standalone Camera with a custom projection

Here is how to use it (example for a perspective Camera)

oe::scene::Camera camera(oe::scene::PerspectiveProjection(90.f, 1.33f, 0.1f, 100.0f));
The "eye of the scene".
Definition camera.h:33
Realistic projection where distant objects appear smaller than closer objects.
Definition camera_projections.h:21
See also
oe::render::Shader::fillFromCamera to understand which properties are automatically sent to shaders
PerspectiveProjection, OrthographicProjection and FrustumProjection for available projections, you can also use your custom one satisfying the CameraProjection concept

Constructor & Destructor Documentation

◆ Camera()

template<CameraProjection ProjectionSettings>
oe::scene::Camera::Camera ( const ProjectionSettings &  projection_settings)
inline

Constructor.

Parameters
projection_settingsProjection settings to use

Member Function Documentation

◆ getProjection()

const glm::mat4 & oe::scene::Camera::getProjection ( ) const

Get the projection matrix of the camera.

Returns
Mat4 matrix that can directly be sent to shaders

◆ getTransform()

const glm::mat4 & oe::scene::Camera::getTransform ( ) const
noexcept

Get the transformation matrix of the camera.

Transformation matrix is computed by applying the view then the projection

Returns
Mat4 matrix that can directly be sent to shaders

◆ getView()

const glm::mat4 & oe::scene::Camera::getView ( ) const

Get the view matrix of the camera.

Returns
Mat4 matrix that can directly be sent to shaders

◆ isInFrustum() [1/3]

bool oe::scene::Camera::isInFrustum ( const AABB box) const

Check if a AABB is visible from the camera point of view.

Parameters
boxBounding box
Returns
true if at least a part of the box is visible

◆ isInFrustum() [2/3]

bool oe::scene::Camera::isInFrustum ( const glm::vec3 &  center,
const float &  radius 
) const

Check if a sphere is visible from the camera point of view.

Parameters
centerAbsolute coordinates of the center of the sphere
radiusSphere radius
Returns
true if at least a part of the sphere is visible

◆ isInFrustum() [3/3]

bool oe::scene::Camera::isInFrustum ( const glm::vec3 &  point) const

Check if a point is visible from the camera point of view.

Parameters
pointAbsolute coordinates of the point to check
Returns
true if the point is visible

◆ lookAt()

void oe::scene::Camera::lookAt ( const glm::vec3 &  target)

Orient the camera to stare at a specified target.

Parameters
targetAbsolute coordinates of the point to look

◆ setProjectionSettings()

template<CameraProjection ProjectionSettings>
void oe::scene::Camera::setProjectionSettings ( const ProjectionSettings &  projection_settings)
inline

Update the camera's projection matrix by recomputing it based on the provided settings.

Parameters
projection_settingsSettings instance, can be anything as long it provides a glm::mat4 getProjectionMatrix() method

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