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

The U4DRender3DModel class manages the rendering of 3D models. More...

Inherits U4DEngine::U4DRenderEntity.

Public Member Functions

 U4DRender3DModel (U4DModel *uU4DModel)
 Constructor for class. More...
 
 ~U4DRender3DModel ()
 class destructor More...
 
bool loadMTLBuffer ()
 Loads the attributes and Uniform data. More...
 
void loadMTLTexture ()
 Loads image texture into GPU. More...
 
void loadMTLAdditionalInformation ()
 Loads additional information for the 3D model. More...
 
void loadMTLNormalMapTexture ()
 Loads Normal Map raw data. More...
 
void loadMTLMaterialInformation ()
 Loads material information for rendering into the GPU. More...
 
void updateSpaceUniforms ()
 Updates the space matrix of the 3D entity. More...
 
void updateBoneSpaceUniforms ()
 Updates the space matrix of each bone used in animation. More...
 
void updateModelRenderFlags ()
 Updates the rendering flags for the 3D model. More...
 
void updateAllUniforms ()
 
void render (id< MTLRenderCommandEncoder > uRenderEncoder)
 Renders the current entity. More...
 
void initTextureSamplerObjectNull ()
 Initializes a null texture sampler object. More...
 
void alignedAttributeData ()
 It aligns all attribute data. More...
 
void clearModelAttributeData ()
 clears all attributes containers More...
 
void updateModelShaderParametersUniform ()
 Update the users parameters used in the shader.
 
void createNormalMapTextureObject ()
 Creates a Normal Map Texture. More...
 
void createNormalMapSamplerObject ()
 Creates a Normal Map Sampler. More...
 
- Public Member Functions inherited from U4DEngine::U4DRenderEntity
 U4DRenderEntity ()
 Constructor for the U4DRenderEntity. More...
 
virtual ~U4DRenderEntity ()
 Destructor for the U4DRenderEntity. More...
 
void loadRenderingInformation ()
 Sends attributes information to the GPU. More...
 
virtual void updateRenderingInformation ()
 Updates the space matrix of the shadow. More...
 
virtual void modifyRenderingInformation ()
 
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...
 
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)
 

Additional Inherited Members

- Protected Attributes inherited from U4DEngine::U4DRenderEntity
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 U4DRender3DModel class manages the rendering of 3D models.

It manages the rendering of all 3D models such as game characters. It also manages shadows and animation rendering.

Constructor & Destructor Documentation

◆ U4DRender3DModel()

U4DEngine::U4DRender3DModel::U4DRender3DModel ( U4DModel uU4DModel)

Constructor for class.

It initializes the buffers and textures used for rendering

Parameters
uU4DModel3D entity which will be managed by the class

◆ ~U4DRender3DModel()

U4DEngine::U4DRender3DModel::~U4DRender3DModel ( )

class destructor

It releases the bone buffer, shadow buffer and sampler descriptor.

Member Function Documentation

◆ alignedAttributeData()

void U4DEngine::U4DRender3DModel::alignedAttributeData ( )

It aligns all attribute data.

Aligns vertices, normal vectors, uv, tangent, material data, vertex weights and bone indices. This is necessary when using Metal

◆ clearModelAttributeData()

void U4DEngine::U4DRender3DModel::clearModelAttributeData ( )
virtual

clears all attributes containers

clears attributes containers such as vertices, normal maps, uv, tangent, material data, vertex weights and bones

Reimplemented from U4DEngine::U4DRenderEntity.

◆ createNormalMapSamplerObject()

void U4DEngine::U4DRender3DModel::createNormalMapSamplerObject ( )

Creates a Normal Map Sampler.

Creates a sampler descriptor, sets the filtering and addressing setting and creates a sampler object using the sampler descriptor

◆ createNormalMapTextureObject()

void U4DEngine::U4DRender3DModel::createNormalMapTextureObject ( )

Creates a Normal Map Texture.

Creates a texture descriptor and a texture object. Copies the Normal Map raw image data into the texture object.

◆ initTextureSamplerObjectNull()

void U4DEngine::U4DRender3DModel::initTextureSamplerObjectNull ( )
virtual

Initializes a null texture sampler object.

It creates a null texture object, null normal map texture object, null shadow texture object and a null sampler object

Reimplemented from U4DEngine::U4DRenderEntity.

◆ loadMTLAdditionalInformation()

void U4DEngine::U4DRender3DModel::loadMTLAdditionalInformation ( )
virtual

Loads additional information for the 3D model.

It loads Normal Map texture, material and light information

Reimplemented from U4DEngine::U4DRenderEntity.

◆ loadMTLBuffer()

bool U4DEngine::U4DRender3DModel::loadMTLBuffer ( )
virtual

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 from U4DEngine::U4DRenderEntity.

◆ loadMTLMaterialInformation()

void U4DEngine::U4DRender3DModel::loadMTLMaterialInformation ( )

Loads material information for rendering into the GPU.

It loads information about the diffuse and specular material. As well, as their intensity. This information is used for lighting

◆ loadMTLNormalMapTexture()

void U4DEngine::U4DRender3DModel::loadMTLNormalMapTexture ( )

Loads Normal Map raw data.

It decodes the normal map texture data, creates a texture object, a texture sampler, and loads the normal map data into a buffer

◆ loadMTLTexture()

void U4DEngine::U4DRender3DModel::loadMTLTexture ( )
virtual

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 from U4DEngine::U4DRenderEntity.

◆ render()

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

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 from U4DEngine::U4DRenderEntity.

◆ updateAllUniforms()

void U4DEngine::U4DRender3DModel::updateAllUniforms ( )
virtual

Reimplemented from U4DEngine::U4DRenderEntity.

◆ updateBoneSpaceUniforms()

void U4DEngine::U4DRender3DModel::updateBoneSpaceUniforms ( )

Updates the space matrix of each bone used in animation.

It accesses the entity's armature and updates each bone space matrix

◆ updateModelRenderFlags()

void U4DEngine::U4DRender3DModel::updateModelRenderFlags ( )

Updates the rendering flags for the 3D model.

It updates flags such as if shadows, normal map texturing, armatures should be enabled or disabled

◆ updateSpaceUniforms()

void U4DEngine::U4DRender3DModel::updateSpaceUniforms ( )
virtual

Updates the space matrix of the 3D entity.

It updates the space matrix of the entity by using the current world and camera space matrix

Reimplemented from U4DEngine::U4DRenderEntity.