NAP
Public Member Functions | Static Public Member Functions | List of all members
OrthoCameraComponentInstance Class Reference

#include <orthocameracomponent.h>

Public Member Functions

 OrthoCameraComponentInstance (EntityInstance &entity, Component &resource)
 
virtual bool init (utility::ErrorState &errorState) override
 
virtual void setRenderTargetSize (const glm::ivec2 &size) override
 
virtual const glm::mat4 & getProjectionMatrix () const override
 
virtual const glm::mat4 getViewMatrix () const override
 
const OrthoCameraPropertiesgetProperties () const
 
void setProperties (const OrthoCameraProperties &properties)
 
void setMode (EOrthoCameraMode mode)
 
void setClipRect (const math::Rect &clipRect)
 
void restoreClipRect ()
 
virtual float getNearClippingPlane () const override
 
virtual float getFarClippingPlane () const override
 
virtual const glm::mat4 & getRenderProjectionMatrix () const override
 
- Public Member Functions inherited from CameraComponentInstance
 CameraComponentInstance (EntityInstance &entity, Component &resource)
 
glm::vec3 screenToWorld (const glm::vec3 &screenPos, const math::Rect &viewport)
 
glm::vec3 worldToScreen (const glm::vec3 &worldPos, const math::Rect &viewport)
 
glm::vec3 rayFromScreen (const glm::vec2 &screenPos, const math::Rect &viewport)
 
const glm::ivec2 & getRenderTargetSize () const
 
- Public Member Functions inherited from ComponentInstance
 ComponentInstance (EntityInstance &entity, Component &resource)
 
virtual void update (double deltaTime)
 
nap::EntityInstancegetEntityInstance () const
 
nap::ComponentgetComponent () const
 
template<typename T >
T * getComponent () const
 
virtual bool init (utility::ErrorState &errorState)
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Static Public Member Functions

static glm::mat4 createRenderProjectionMatrix (float left, float right, float bottom, float top, float zNear, float zFar)
 
static glm::mat4 createRenderProjectionMatrix (float left, float right, float bottom, float top)
 
- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 

Additional Inherited Members

- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Description

An orthographic camera. The space that the camera is operating depends on the mode that is set. By default this camera operates in pixel space. Use setMode to change the space that the camera is operating in. The transform to calculate the view matrix is retrieved from the transform component.

Inheritance diagram for OrthoCameraComponentInstance:
[legend]
Collaboration diagram for OrthoCameraComponentInstance:
[legend]

Constructor & Destructor Documentation

◆ OrthoCameraComponentInstance()

OrthoCameraComponentInstance ( EntityInstance entity,
Component resource 
)

Member Function Documentation

◆ createRenderProjectionMatrix() [1/2]

static glm::mat4 createRenderProjectionMatrix ( float  left,
float  right,
float  bottom,
float  top 
)
static

Creates a Vulkan compatible orthographic projection matrix without having to specify near and far coordinates. Use this matrix, instead of glm::ortho(), when drawing geometry and an ortographic projection matrix is required as shader input. For all regular (CPU) related orthographic calculations, use glm::ortho().

Returns
Vulkan compatible orthographic matrix.

◆ createRenderProjectionMatrix() [2/2]

static glm::mat4 createRenderProjectionMatrix ( float  left,
float  right,
float  bottom,
float  top,
float  zNear,
float  zFar 
)
static

Creates a Vulkan compatible orthographic projection matrix, use this matrix instead of glm::ortho when interfacing with the renderer. Use this matrix, instead of glm::ortho(), when drawing geometry and an ortographic projection matrix is required as shader input. For all regular (CPU) related orthographic calculations, use glm::ortho().

Returns
Vulkan compatible orthographic matrix.

◆ getFarClippingPlane()

virtual float getFarClippingPlane ( ) const
overridevirtual
Returns
camera far clipping plane

Implements CameraComponentInstance.

◆ getNearClippingPlane()

virtual float getNearClippingPlane ( ) const
overridevirtual
Returns
camera near clipping plane

Implements CameraComponentInstance.

◆ getProjectionMatrix()

virtual const glm::mat4& getProjectionMatrix ( ) const
overridevirtual

Returns the matrix that is used to transform a 3d scene into a 2d projection. Use this matrix for all regular CPU side projection calculations. Use the matrix returned by getRenderProjectionMatrix() as shader input only.

Returns
camera projection matrix

Implements CameraComponentInstance.

◆ getProperties()

const OrthoCameraProperties& getProperties ( ) const
Returns
The planes for this orthographic camera.

◆ getRenderProjectionMatrix()

virtual const glm::mat4& getRenderProjectionMatrix ( ) const
overridevirtual

Returns the matrix that is used to transform a 3d scene in to a 2d projection by the renderer. Vulkan uses a coordinate system where (-1, -1) is in the top left quadrant, instead of the bottom left quadrant. Use this matrix, instead of the one returned by getProjectionMatrix(), when an ortographic projection matrix is required as shader input. For all regular (CPU) related orthographic calculations, use getProjectionMatrix().

Returns
the projection matrix used by the renderer

Implements CameraComponentInstance.

◆ getViewMatrix()

virtual const glm::mat4 getViewMatrix ( ) const
overridevirtual
Returns
The populated view matrix.

Implements CameraComponentInstance.

◆ init()

virtual bool init ( utility::ErrorState errorState)
overridevirtual

Initialize this component from its resource

Parameters
errorStatecontains the error if initialization fails.

Reimplemented from ComponentInstance.

◆ restoreClipRect()

void restoreClipRect ( )

Restores the clip rectangle to a unit rectangle, disabling clipping

◆ setClipRect()

void setClipRect ( const math::Rect clipRect)

Sets the normalized clip rectangle used to clip/crop the camera view

Parameters
clipRectThe clip rectangle.

◆ setMode()

void setMode ( EOrthoCameraMode  mode)

Sets the mode (the physical space) in which the orthographic camera is operating.

Parameters
modeThe view mode to operate in.

◆ setProperties()

void setProperties ( const OrthoCameraProperties properties)

Sets the orthographic camera properties.

Parameters
propertiesThe new camera properties

◆ setRenderTargetSize()

virtual void setRenderTargetSize ( const glm::ivec2 &  size)
overridevirtual

This implementation extracts the size in pixels of the render target to make sure that the orthographic camera acts in pixel coordinates.

Parameters
sizeThe size of the render target in pixel coordinates.

Reimplemented from CameraComponentInstance.