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
float getNearClippingPlane () const
float getFarClippingPlane () const
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
- 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
PerpCameraProperties mProperties
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...


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

Inheritance diagram for PerspCameraComponentInstance:
Collaboration diagram for PerspCameraComponentInstance:

Constructor & Destructor Documentation

◆ PerspCameraComponentInstance()

PerspCameraComponentInstance ( EntityInstance entity,
Component resource 

Member Function Documentation

◆ getFarClippingPlane()

float getFarClippingPlane ( ) const
camera far clipping plane

◆ getFieldOfView()

float getFieldOfView ( ) const
camera field of view

◆ getNearClippingPlane()

float getNearClippingPlane ( ) const
camera near clipping plane

◆ getProjectionMatrix()

virtual const glm::mat4& getProjectionMatrix ( ) const

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.

camera projection matrix

Implements CameraComponentInstance.

◆ getRenderProjectionMatrix()

virtual const glm::mat4& getRenderProjectionMatrix ( ) const

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

the projection matrix used by the renderer

Implements CameraComponentInstance.

◆ getViewMatrix()

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

Implements CameraComponentInstance.

◆ init()

virtual bool init ( utility::ErrorState errorState)

Checks whether a transform component is available.

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

Reimplemented from ComponentInstance.

◆ setFieldOfView()

void setFieldOfView ( float  fov)

Sets the fov parameter

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.

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.

◆ setRenderTargetSize()

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

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

sizeThe size of the render target in pixel coordinates.

Reimplemented from CameraComponentInstance.

Member Data Documentation

◆ mDirty

bool mDirty = true

◆ mPerpendicularRenderProjection

bool mPerpendicularRenderProjection = true

◆ mProjectionMatrix

glm::mat4x4 mProjectionMatrix

◆ mProperties

PerpCameraProperties mProperties

◆ mRenderProjectionMatrix

glm::mat4x4 mRenderProjectionMatrix

◆ mTransformComponent

TransformComponentInstance* mTransformComponent