NAP
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
RenderableComponentInstance Class Referenceabstract

#include <rendercomponent.h>

Public Member Functions

 RenderableComponentInstance (EntityInstance &entity, Component &resource)
 
virtual bool init (utility::ErrorState &errorState) override
 
void draw (IRenderTarget &renderTarget, VkCommandBuffer commandBuffer, const glm::mat4 &viewMatrix, const glm::mat4 &projectionMatrix)
 
void setVisible (bool visible)
 
bool isVisible () const
 
const std::vector< ResourcePtr< RenderTag > > & getTags () const
 
RenderMask getMask () const
 
bool includesMask (RenderMask otherMask)
 
int getRank () const
 
const RenderLayergetLayer () const
 
virtual bool isSupported (nap::CameraComponentInstance &camera) 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 Member Functions

virtual void onDraw (IRenderTarget &renderTarget, VkCommandBuffer commandBuffer, const glm::mat4 &viewMatrix, const glm::mat4 &projectionMatrix)=0
 

Protected Attributes

RenderServicemRenderService = nullptr
 

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

Represents an object that can be rendered to screen or any other type of render target. This is the base class for all render-able types. Override the draw call to implement custom draw behavior.

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

Constructor & Destructor Documentation

◆ RenderableComponentInstance()

RenderableComponentInstance ( EntityInstance entity,
Component resource 
)

Member Function Documentation

◆ draw()

void draw ( IRenderTarget renderTarget,
VkCommandBuffer  commandBuffer,
const glm::mat4 &  viewMatrix,
const glm::mat4 &  projectionMatrix 
)

Called by the render service, calls onDraw() if visible. Renders the object to the given render target using the provided command buffer, view and projection matrix.

Parameters
renderTargettarget to render to
commandBufferactive command buffer
viewMatrixoften the camera world space location.
projectionMatrixoften the camera projection matrix.

◆ getLayer()

const RenderLayer* getLayer ( ) const

Returns the layer assigned to this component. Every layer is assigned a rank which controls the order in which components are rendered, where 0 is the front and the last index is the back.

Returns
the render layer, nullptr if no layer is given

◆ getMask()

RenderMask getMask ( ) const
Returns
the render mask

◆ getRank()

int getRank ( ) const

Returns the rank of this component in the render chain, defaults to 0 (front) if no layer is assigned. The rank controls the order in which components are rendered, where 0 is the front and the last index is the back.

Returns
the rank index in the render chain, 0 (front) if no layer is assigned

◆ getTags()

const std::vector<ResourcePtr<RenderTag> >& getTags ( ) const
Returns
the list of tags

◆ includesMask()

bool includesMask ( RenderMask  otherMask)

Returns if this component can be rendered with (includes) the given mask. The component can be rendered when included in the other mask or when no mask is provided.

Parameters
otherMaskthe inclusion mask
Returns
if this component can be rendered with (includes) the given mask.

◆ init()

virtual bool init ( utility::ErrorState errorState)
overridevirtual

◆ isSupported()

virtual bool isSupported ( nap::CameraComponentInstance camera) const
virtual

Called by the Render Service. By default every camera type is supported If your renderable component doesn't support a specific camera return false In that case the object won't be rendered.

Returns
if the object can be rendered with the given camera

Reimplemented in Renderable2DTextComponentInstance, RenderToTextureComponentInstance, RenderFrustumComponentInstance, RenderVideoComponentInstance, and RenderGnomonComponentInstance.

◆ isVisible()

bool isVisible ( ) const
Returns
if the mesh is visible or not, default = true

◆ onDraw()

virtual void onDraw ( IRenderTarget renderTarget,
VkCommandBuffer  commandBuffer,
const glm::mat4 &  viewMatrix,
const glm::mat4 &  projectionMatrix 
)
protectedpure virtual

Called by the render service. Override this method to implement your own custom draw behavior. This method won't be called if the mesh isn't visible.

Parameters
renderTargetcurrently bound render target
commandBufferactive command buffer
viewMatrixthe camera world space location
projectionMatrixthe camera projection matrix

Implemented in Renderable2DTextComponentInstance, RenderableMeshComponentInstance, RenderToTextureComponentInstance, Renderable3DTextComponentInstance, RenderSkyBoxComponentInstance, RenderFaderComponentInstance, RenderVideoComponentInstance, RenderBloomComponentInstance, RenderFrustumComponentInstance, and RenderGnomonComponentInstance.

◆ setVisible()

void setVisible ( bool  visible)

Toggles visibility.

Parameters
visibleif this object should be drawn or not

Member Data Documentation

◆ mRenderService

RenderService* mRenderService = nullptr
protected