Ocular Engine
Ocular::Core::Camera Class Reference
Inheritance diagram for Ocular::Core::Camera:
Ocular::Core::SceneObject Ocular::Core::AEventListener Ocular::Core::Object Ocular::Core::ObjectIO Ocular::Core::Exposable Ocular::Core::Buildable

Public Member Functions

 Camera (std::string const &name, SceneObject *parent=nullptr)
 
void setRenderTexture (Graphics::RenderTexture *renderTexture)
 
Graphics::RenderTexturegetRenderTexture ()
 
void setDepthTexture (Graphics::DepthTexture *depthTexture)
 
Graphics::DepthTexturegetDepthTexture ()
 
ProjectionType getProjectionType () const
 
PerspectiveProjection getPerspectiveProjection () const
 
OrthographicProjection getOrthographicProjection () const
 
void setProjectionOrthographic (float xMin, float xMax, float yMin, float yMax, float nearClip, float farClip)
 
void setProjectionOrthographic (OrthographicProjection const &projection)
 
void setProjectionPerspective (float fov, float aspectRatio, float nearClip, float farClip)
 
void setProjectionPerspective (PerspectiveProjection const &projection)
 
void setProjectionMatrix (Math::Matrix4x4 const &matrix)
 
Math::Matrix4x4 const & getViewMatrix ()
 
Math::Matrix4x4 const & getProjectionMatrix () const
 
Math::Frustum const & getFrustum (bool updateFrustum=true)
 
void setPriority (Priority priority)
 
Priority getPriority () const
 
void setViewport (float x, float y, float width, float height, float minDepth=0.0f, float maxDepth=1.0f, bool updateMatrix=true)
 
Graphics::ViewportgetViewport () const
 
void setFixedViewport (bool fixed)
 
bool getIsFixedViewport () const
 
void setFixedProjection (bool fixed)
 
bool getIsFixedProjection () const
 
void setClearColor (Core::Color const &color)
 
Color const & getClearColor () const
 
Math::Vector3f screenToWorld (Math::Vector2i const &screenPos)
 
Math::Vector2i worldToScreen (Math::Vector3f const &worldPos)
 
Math::Ray getPickRay (Math::Vector2i const &screenPos)
 
virtual bool onEvent (std::shared_ptr< AEvent > event) override
 
- Public Member Functions inherited from Ocular::Core::SceneObject
 SceneObject (std::string const &name, SceneObject *parent=nullptr, std::string const &type="SceneObject")
 
 SceneObject ()
 
virtual ~SceneObject ()
 
virtual void onVariableModified (std::string const &varName) override
 
Math::TransformgetTransform ()
 
void setActive (bool active)
 
bool isActive () const
 
void setVisible (bool visible)
 
bool isVisible () const
 
void setForcedVisible (bool forced)
 
bool isForcedVisible () const
 
void setStatic (bool isStatic)
 
bool isStatic () const
 
void setPersistent (bool persists)
 
bool isPersistent () const
 
Graphics::UniformPerObject const & getUniformData (Math::Matrix4x4 const &viewMatrix, Math::Matrix4x4 const &projMatrix)
 
void setPosition (float x, float y, float z)
 
void setPosition (Math::Vector3f const &position)
 
Math::Vector3f getPosition (bool local=true) const
 
void translate (Math::Vector3f const &translation, bool local=true)
 
void rotate (float angle, Math::Vector3f const &axis)
 
void rotate (Math::Quaternion const &rotation)
 
void setRotation (Math::Quaternion const &rotation)
 
void resetRotation ()
 
Math::Quaternion const & getRotation () const
 
void setScale (Math::Vector3f const &scale)
 
void setScale (float xScale, float yScale, float zScale)
 
Math::Vector3f getScale (bool local=true) const
 
void setTransform (Math::Transform const &transform)
 
void lookAt (Math::Vector3f const &point)
 
Math::Transform const & getTransform () const
 
virtual Math::Matrix4x4 getModelMatrix (bool local=true) const
 
void setParent (SceneObject *parent, bool maintainWorldPos=true)
 
SceneObjectgetParent () const
 
SceneObjectcreateChild (std::string const &name)
 
void addChild (SceneObject *child, bool maintainWorldPos=true)
 
SceneObjectfindChild (std::string const &name)
 
SceneObjectfindChild (UUID const &uuid)
 
SceneObjectremoveChild (std::string const &name)
 
SceneObjectremoveChild (UUID const &uuid)
 
SceneObjectremoveChild (SceneObject const *object)
 
uint32_t getNumChildren () const
 
std::vector< SceneObject * > const & getAllChildren () const
 
ARoutineaddRoutine (std::string const &name)
 
void addRoutine (ARoutine *routine)
 
template<class T >
T * addRoutine ()
 
bool removeRoutine (std::string const &name)
 
bool removeRoutine (ARoutine *routine, bool transferring=false)
 
void removeAllRoutines ()
 
ARoutinegetRoutine (std::string const &name)
 
std::vector< ARoutine * > const & getAllRoutines () const
 
uint32_t getNumRoutines () const
 
ARenderablesetRenderable (std::string const &name)
 
void setRenderable (ARenderable *renderable)
 
template<class T >
T * setRenderable ()
 
void removeRenderable (bool transferring=false)
 
ARenderablegetRenderable () const
 
virtual void onLoad (BuilderNode const *node) override
 
virtual void onSave (BuilderNode *node) const override
 
void forceBoundsRebuild ()
 
Math::BoundsSphere getBoundsSphere (bool local)
 
Math::BoundsAABB getBoundsAABB (bool local)
 
Math::BoundsOBB getBoundsOBB (bool local)
 
- Public Member Functions inherited from Ocular::Core::Object
 Object (std::string name, std::string className)
 Creates a new Object with the specified name and class. More...
 
 Object (std::string name)
 Creates a new Object with the specified name. More...
 
 Object ()
 Creates a new Object with the default name ('Name').
 
std::string const & getName () const
 
void setName (std::string name)
 Sets the name of the Object. More...
 
std::string const & getClass () const
 
void setUUID (std::string const &uuid)
 
UUID const & getUUID () const
 
int64_t getCreationTime () const
 
virtual std::string toString () const
 
template<class T >
bool isType ()
 
- Public Member Functions inherited from Ocular::Core::Exposable
void getAllExposedNames (std::vector< std::string > &names) const
 
bool getVariable (std::string const &name, ExposedVariable &var)
 
template<typename T >
bool getVariableValue (std::string const &name, T &var)
 
template<typename T >
bool setVariableValue (std::string const &name, T const &value)
 

Protected Member Functions

void onCreation ()
 
void exposeVariables ()
 
void updateViewport (float width, float height)
 
- Protected Member Functions inherited from Ocular::Core::SceneObject
void getModelMatrix (Math::Matrix4x4 &matrix)
 
virtual void updateBounds (uint32_t dirtyFlags)
 
- Protected Member Functions inherited from Ocular::Core::Exposable
void exposeVariable (std::string const &name, std::string const &type, bool isPointer, bool isExposed, void *data)
 

Protected Attributes

ProjectionType m_ProjType
 
PerspectiveProjection m_PerspectiveProj
 
OrthographicProjection m_OrthographicProj
 
Math::Matrix4x4 m_ViewMatrix
 
Math::Matrix4x4 m_ProjMatrix
 
Math::Frustum m_Frustum
 
Graphics::RenderTexturem_RenderTexture
 
Graphics::DepthTexturem_DepthTexture
 
Graphics::Viewportm_Viewport
 
Core::Color m_ClearColor
 
Priority m_Priority
 
bool m_IsFixedViewport
 
bool m_IsFixedProjection
 
bool m_IsFrustumDirty
 
- Protected Attributes inherited from Ocular::Core::SceneObject
SceneObjectm_Parent
 
uint32_t m_Layer
 The render layer this object is part of.
 
Graphics::UniformPerObject m_UniformData
 
Math::Transform m_Transform
 
Math::BoundsSphere m_BoundsSphereLocal
 
Math::BoundsAABB m_BoundsAABBLocal
 
Math::BoundsOBB m_BoundsOBBLocal
 
Math::BoundsSphere m_BoundsSphereWorld
 
Math::BoundsAABB m_BoundsAABBWorld
 
Math::BoundsOBB m_BoundsOBBWorld
 
- Protected Attributes inherited from Ocular::Core::Object
std::string m_Name
 
std::string m_Class
 
UUID m_UUID
 
const int64_t m_CreationTime
 
- Protected Attributes inherited from Ocular::Core::Exposable
std::unordered_map< std::string, ExposedVariablem_ExposedVariables
 

Constructor & Destructor Documentation

Ocular::Core::Camera::Camera ( std::string const &  name,
SceneObject parent = nullptr 
)
Parameters
[in]name
[in]parent

Member Function Documentation

Graphics::DepthTexture * Ocular::Core::Camera::getDepthTexture ( )
Returns
The current depth texture
Math::Frustum const & Ocular::Core::Camera::getFrustum ( bool  updateFrustum = true)
Parameters
[in]updateFrustumIf true, updates the frustum with the latest view/proj matrices.
Returns
The camera's frustum
bool Ocular::Core::Camera::getIsFixedProjection ( ) const
Returns
TRUE if the projection is fixed
bool Ocular::Core::Camera::getIsFixedViewport ( ) const
Returns
TRUE if the viewport is fixed
OrthographicProjection Ocular::Core::Camera::getOrthographicProjection ( ) const
Returns
The settings of the last set orthographic matrix.
PerspectiveProjection Ocular::Core::Camera::getPerspectiveProjection ( ) const
Returns
The settings of the last set perspective matrix.
Math::Ray Ocular::Core::Camera::getPickRay ( Math::Vector2i const &  screenPos)

Returns a ray projected from the camera at the given screen coordinates.

Parameters
[in]x
[in]y
Priority Ocular::Core::Camera::getPriority ( ) const
Returns
The camera's priority level.
Math::Matrix4x4 const & Ocular::Core::Camera::getProjectionMatrix ( ) const
Returns
The projection matrix
ProjectionType Ocular::Core::Camera::getProjectionType ( ) const
Returns
The type of projection matrix currently in use.
Graphics::RenderTexture * Ocular::Core::Camera::getRenderTexture ( )
Returns
The current render texture
Math::Matrix4x4 const & Ocular::Core::Camera::getViewMatrix ( )
Returns
The view matrix
Graphics::Viewport * Ocular::Core::Camera::getViewport ( ) const
Returns
Current viewport
bool Ocular::Core::Camera::onEvent ( std::shared_ptr< AEvent event)
overridevirtual

Handles WindowResizeEvent instances.

Upon a WindowResizeEvent, the viewport and projection (if perspective) will be updated according to the new window size.

The viewport and projection updating will not occur if they are set to fixed (setFixedProjection and setFixedViewport).

Implements Ocular::Core::AEventListener.

Math::Vector3f Ocular::Core::Camera::screenToWorld ( Math::Vector2i const &  screenPos)

Converts a given screen coordinate to a world-space position.

Parameters
[in]x
[in]y
void Ocular::Core::Camera::setDepthTexture ( Graphics::DepthTexture depthTexture)
Parameters
[in]depthTexture
void Ocular::Core::Camera::setFixedProjection ( bool  fixed)

Sets if the projection is fixed.

If the projection is fixed, it will not update and resize automatically with the window. By default, the projection is not fixed.

Parameters
[in]fixed
void Ocular::Core::Camera::setFixedViewport ( bool  fixed)

Sets if the viewport is fixed.

If the viewport is fixed, it will not update and resize automatically with the window. By default, the viewport is not fixed.

Parameters
[in]fixed
void Ocular::Core::Camera::setPriority ( Priority  priority)

Sets the camera's priority level

Parameters
[in]priority
void Ocular::Core::Camera::setProjectionMatrix ( Math::Matrix4x4 const &  matrix)

Sets a custom projection matrix.

Note
The projection will not be updated during a WindowResizeEvent. If the projection needs to be updated after a resize, then a custom event handler will need to be created.
Parameters
[in]matrix
void Ocular::Core::Camera::setProjectionOrthographic ( float  xMin,
float  xMax,
float  yMin,
float  yMax,
float  nearClip,
float  farClip 
)

Creates a new orthographic projection matrix and sets it as the projection matrix.

Parameters
[in]xMin
[in]xMax
[in]yMin
[in]yMax
[in]nearClip
[in]farClip
void Ocular::Core::Camera::setProjectionPerspective ( float  fov,
float  aspectRatio,
float  nearClip,
float  farClip 
)

Creates a new perspective projection matrix and sets it as the projection matrix.

Parameters
[in]fov
[in]aspectRatio
[in]nearClip
[in]farClip
void Ocular::Core::Camera::setRenderTexture ( Graphics::RenderTexture renderTexture)
Parameters
[in]renderTexture
void Ocular::Core::Camera::setViewport ( float  x,
float  y,
float  width,
float  height,
float  minDepth = 0.0f,
float  maxDepth = 1.0f,
bool  updateMatrix = true 
)

Sets the camera's viewport.

Parameters
[in]x
[in]y
[in]width
[in]height
[in]minDepth
[in]maxDepth
[in]updateMatrix
Math::Vector2i Ocular::Core::Camera::worldToScreen ( Math::Vector3f const &  worldPos)

Converts a given world space position to a screen-space coordinate.

Parameters
[in]pos

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