NAP
Public Member Functions | Protected Attributes | List of all members
PerspCameraComponentInstance Class Reference

#include <perspcameracomponent.h>

Public Member Functions

 PerspCameraComponentInstance (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
 
void setGridDimensions (int numRows, int numColumns)
 
void setGridLocation (int row, int column)
 
void setFieldOfView (float fov)
 
float getFieldOfView () const
 
virtual float getNearClippingPlane () const override
 
virtual float getFarClippingPlane () const override
 
virtual const glm::mat4 & getRenderProjectionMatrix () const override
 
PerspCameraProperties getProperties () const
 
void setProperties (const PerspCameraProperties &props)
 
- 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
 

Protected Attributes

glm::mat4x4 mProjectionMatrix
 
glm::mat4x4 mRenderProjectionMatrix
 
bool mDirty = true
 
PerspCameraProperties mProperties
 
TransformComponentInstancemTransformComponent
 
bool mPerpendicularRenderProjection = true
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Description

Implementation of the perspective camera. The view matrix is calculated using the transform attached to the entity.

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

Constructor & Destructor Documentation

◆ PerspCameraComponentInstance()

PerspCameraComponentInstance ( EntityInstance entity,
Component resource 
)

Member Function Documentation

◆ getFarClippingPlane()

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

Implements CameraComponentInstance.

◆ getFieldOfView()

float getFieldOfView ( ) const
Returns
camera field of view

◆ 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()

PerspCameraProperties getProperties ( ) const
Returns
the perspective camera properties

◆ 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

Checks whether a transform component is available.

Parameters
errorStatecontains the error if the camera can't be initialized properly.
Returns
if the camera initialized properly.

Reimplemented from ComponentInstance.

◆ setFieldOfView()

void setFieldOfView ( float  fov)

Sets the fov parameter

Parameters
fovthe new field of view

◆ setGridDimensions()

void setGridDimensions ( int  numRows,
int  numColumns 
)

Use this function to split the projection into a regular grid. This can be used to render to multiple screens with a single camera. Use setGridLocation to set the horizontal and vertical index into this grid.

Parameters
numRowsthe number of cells in the horizontal
numColumnsthe number of cells in the vertical direction.

◆ setGridLocation()

void setGridLocation ( int  row,
int  column 
)

Sets the horizontal and vertical index into the projection grid as set by setGridDimensions.

◆ setProperties()

void setProperties ( const PerspCameraProperties props)

Sets the camera instance properties

◆ setRenderTargetSize()

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

Extracts the size in pixels of the render target. The dimensions are used to calculate the correct projection matrix.

Parameters
sizeThe size of the render target in pixel coordinates.

Reimplemented from CameraComponentInstance.

Member Data Documentation

◆ mDirty

bool mDirty = true
mutableprotected

◆ mPerpendicularRenderProjection

bool mPerpendicularRenderProjection = true
protected

◆ mProjectionMatrix

glm::mat4x4 mProjectionMatrix
mutableprotected

◆ mProperties

PerspCameraProperties mProperties
protected

◆ mRenderProjectionMatrix

glm::mat4x4 mRenderProjectionMatrix
mutableprotected

◆ mTransformComponent

TransformComponentInstance* mTransformComponent
protected