Untold Engine  Beta v0.0.16
docs
U4DEngine::U4DRenderEntity Class Reference

The U4DRenderEntity class manages all rendering for 3D models, images, skyboxes, etc. More...

Inherited by U4DEngine::U4DRender3DModel, U4DEngine::U4DRenderGeometry, U4DEngine::U4DRenderImage, U4DEngine::U4DRenderParticleSystem, U4DEngine::U4DRenderShaderEntity, U4DEngine::U4DRenderSkybox, and U4DEngine::U4DRenderWorld.

Public Member Functions

 U4DRenderEntity ()
 Constructor for the U4DRenderEntity. More...
 
virtual ~U4DRenderEntity ()
 Destructor for the U4DRenderEntity. More...
 
void loadRenderingInformation ()
 Sends attributes information to the GPU. More...
 
virtual bool loadMTLBuffer ()
 Loads the attributes and Uniform data. More...
 
virtual void loadMTLTexture ()
 Loads image texture into GPU. More...
 
virtual void loadMTLAdditionalInformation ()
 Loads additional information for different types of entities. More...
 
virtual void updateSpaceUniforms ()
 Updates the space matrix of the entity. More...
 
virtual void updateAllUniforms ()
 
virtual void updateRenderingInformation ()
 Updates the space matrix of the shadow. More...
 
virtual void modifyRenderingInformation ()
 
virtual void render (id< MTLRenderCommandEncoder > uRenderEncoder)
 Renders the current entity. More...
 
virtual void createTextureObject (id< MTLTexture > &uTextureObject)
 Creates a texture object to be applied to an entity. More...
 
void createSamplerObject (id< MTLSamplerState > &uSamplerStateObject, MTLSamplerDescriptor *uSamplerDescriptor)
 Creates a sampler object required for texturing. More...
 
virtual void setGeometryLineColor (U4DVector4n &uGeometryLineColor)
 Set line color for geometric entities. More...
 
void clearRawImageData ()
 Clear the raw image data. More...
 
virtual void clearModelAttributeData ()
 Clears the attribute container. More...
 
virtual void initTextureSamplerObjectNull ()
 Initializes texture sampler object to null. More...
 
void setIsWithinFrustum (bool uValue)
 Sets property used to determine if entity is within frustum. More...
 
void setRawImageData (std::vector< unsigned char > uRawImageData)
 
void setImageWidth (unsigned int uImageWidth)
 
void setImageHeight (unsigned int uImageHeight)
 
bool createTextureAndSamplerObjects (id< MTLTexture > &uTextureObject, id< MTLSamplerState > &uSamplerStateObject, MTLSamplerDescriptor *uSamplerDescriptor, std::string uTextureName)
 
void setPipelineForPass (std::string uPipelineName, int uRenderPassKey)
 
void removePassPipelinePair (int uRenderPassKey)
 
U4DRenderPipelineInterfacegetPipeline (int uRenderPassKey)
 

Protected Attributes

id< MTLDevice > mtlDevice
 Pointer representing a Metal Device.
 
id< MTLBuffer > attributeBuffer
 Pointer to the attribute buffer.
 
id< MTLBuffer > indicesBuffer
 Pointer to the index buffer.
 
id< MTLBuffer > uniformSpaceBuffer
 Pointer to the Uniform that holds the Space matrix.
 
bool eligibleToRender
 Variable to determine if object should be rendered.
 
bool isWithinFrustum
 Variable to determine if the 3D object is within the frustum.
 
std::vector< unsigned char > rawImageData
 buffer for the raw image data of a texture
 
unsigned int imageWidth
 Width of the texture image.
 
unsigned int imageHeight
 Height of the texture image.
 
std::map< int, U4DRenderPipelineInterface * > renderPassPipelineMap
 

Detailed Description

The U4DRenderEntity class manages all rendering for 3D models, images, skyboxes, etc.

Constructor & Destructor Documentation

◆ U4DRenderEntity()

U4DEngine::U4DRenderEntity::U4DRenderEntity ( )

Constructor for the U4DRenderEntity.

The constructor initializes the Metal device and sets the descriptors and pipeline states to NULL

◆ ~U4DRenderEntity()

U4DEngine::U4DRenderEntity::~U4DRenderEntity ( )
virtual

Destructor for the U4DRenderEntity.

Sets all descriptors and pipeline states to NULL

Member Function Documentation

◆ clearModelAttributeData()

virtual void U4DEngine::U4DRenderEntity::clearModelAttributeData ( )
inlinevirtual

Clears the attribute container.

clears vertices, normals, uv, tangent,materials, bone and vertex weights containers

Reimplemented in U4DEngine::U4DRender3DModel, U4DEngine::U4DRenderParticleSystem, U4DEngine::U4DRenderImage, U4DEngine::U4DRenderShaderEntity, U4DEngine::U4DRenderGeometry, U4DEngine::U4DRenderSkybox, U4DEngine::U4DRenderWorld, and U4DEngine::U4DRenderFont.

◆ clearRawImageData()

void U4DEngine::U4DRenderEntity::clearRawImageData ( )

Clear the raw image data.

Clears the decode image data used for texturing

◆ createSamplerObject()

void U4DEngine::U4DRenderEntity::createSamplerObject ( id< MTLSamplerState > &  uSamplerStateObject,
MTLSamplerDescriptor *  uSamplerDescriptor 
)

Creates a sampler object required for texturing.

Creates a sampler descriptor and sets the filtering and addressing settings. Loads the sampler descriptor into a newly created sampler object.

◆ createTextureObject()

void U4DEngine::U4DRenderEntity::createTextureObject ( id< MTLTexture > &  uTextureObject)
virtual

Creates a texture object to be applied to an entity.

It creates a texture descriptor, and loads texture raw data into a newly created texture object

Reimplemented in U4DEngine::U4DRenderSkybox.

◆ initTextureSamplerObjectNull()

virtual void U4DEngine::U4DRenderEntity::initTextureSamplerObjectNull ( )
inlinevirtual

Initializes texture sampler object to null.

It initializes the sampler object to null. The object is later used to store sampler settings

Reimplemented in U4DEngine::U4DRender3DModel, U4DEngine::U4DRenderParticleSystem, and U4DEngine::U4DRenderImage.

◆ loadMTLAdditionalInformation()

virtual void U4DEngine::U4DRenderEntity::loadMTLAdditionalInformation ( )
inlinevirtual

Loads additional information for different types of entities.

Some entities requires additional information to be sent to the GPU. This methods allows for different information to be sent.

Reimplemented in U4DEngine::U4DRender3DModel, U4DEngine::U4DRenderShaderEntity, U4DEngine::U4DRenderParticleSystem, U4DEngine::U4DRenderGeometry, and U4DEngine::U4DRenderSprite.

◆ loadMTLBuffer()

virtual bool U4DEngine::U4DRenderEntity::loadMTLBuffer ( )
inlinevirtual

Loads the attributes and Uniform data.

It prepares the attribute data so that it is aligned. It then loads the attributes into a buffer. It also loads uniform data into a buffer

Returns
True if loading is successful

Reimplemented in U4DEngine::U4DRender3DModel, U4DEngine::U4DRenderParticleSystem, U4DEngine::U4DRenderImage, U4DEngine::U4DRenderShaderEntity, U4DEngine::U4DRenderSkybox, U4DEngine::U4DRenderGeometry, and U4DEngine::U4DRenderWorld.

◆ loadMTLTexture()

virtual void U4DEngine::U4DRenderEntity::loadMTLTexture ( )
inlinevirtual

Loads image texture into GPU.

It decodes the current texture image, creates a texture object, a texture sampler, and loads the raw data into a buffer

Reimplemented in U4DEngine::U4DRender3DModel, U4DEngine::U4DRenderParticleSystem, U4DEngine::U4DRenderImage, U4DEngine::U4DRenderShaderEntity, and U4DEngine::U4DRenderSkybox.

◆ loadRenderingInformation()

void U4DEngine::U4DRenderEntity::loadRenderingInformation ( )

Sends attributes information to the GPU.

It initializes the library and pipeline. It then loads vertices, normals, UV coordinates and animation data into the GPU

◆ render()

virtual void U4DEngine::U4DRenderEntity::render ( id< MTLRenderCommandEncoder >  uRenderEncoder)
inlinevirtual

Renders the current entity.

Updates the space matrix, any rendering flags, bones and shadows properties. It encodes the pipeline, buffers and issues the draw command

Parameters
uRenderEncoderMetal encoder object for the current entity

Reimplemented in U4DEngine::U4DRender3DModel, U4DEngine::U4DRenderParticleSystem, U4DEngine::U4DRenderImage, U4DEngine::U4DRenderShaderEntity, U4DEngine::U4DRenderSkybox, U4DEngine::U4DRenderGeometry, U4DEngine::U4DRenderWorld, U4DEngine::U4DRenderSprite, and U4DEngine::U4DRenderFont.

◆ setGeometryLineColor()

virtual void U4DEngine::U4DRenderEntity::setGeometryLineColor ( U4DVector4n uGeometryLineColor)
inlinevirtual

Set line color for geometric entities.

Geometric entities such as cubes, spheres etc are rendered only with lines. This method sets the particular color.

Parameters
uGeometryLineColorVector denoting the desired color

Reimplemented in U4DEngine::U4DRenderGeometry.

◆ setIsWithinFrustum()

void U4DEngine::U4DRenderEntity::setIsWithinFrustum ( bool  uValue)

Sets property used to determine if entity is within frustum.

If the property is set, the entity is rendered, else is ignored

Parameters
uValuetrue for is within the frustum, false if is not

◆ updateAllUniforms()

virtual void U4DEngine::U4DRenderEntity::updateAllUniforms ( )
inlinevirtual

Reimplemented in U4DEngine::U4DRender3DModel.

◆ updateRenderingInformation()

virtual void U4DEngine::U4DRenderEntity::updateRenderingInformation ( )
inlinevirtual

Updates the space matrix of the shadow.

Updates the current shadow matrix by computing the current light space projection matrix

Reimplemented in U4DEngine::U4DRenderGeometry, and U4DEngine::U4DRenderFont.

◆ updateSpaceUniforms()

virtual void U4DEngine::U4DRenderEntity::updateSpaceUniforms ( )
inlinevirtual

Updates the space matrix of the entity.

Updates the model space matrix of the entity by computing the world, view and perspective/orthogonal (depending on entity type) space matrix

Reimplemented in U4DEngine::U4DRender3DModel, U4DEngine::U4DRenderParticleSystem, U4DEngine::U4DRenderImage, U4DEngine::U4DRenderShaderEntity, U4DEngine::U4DRenderSkybox, U4DEngine::U4DRenderGeometry, and U4DEngine::U4DRenderWorld.