Untold Engine  Beta v0.0.12
API Documentation
U4DEngine::U4DRenderManager Class Reference

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

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

Public Member Functions

 U4DRenderManager ()
 Constructor for the U4DRenderManager. More...
 
virtual ~U4DRenderManager ()
 Destructor for the U4DRenderManager
More...
 
void loadRenderingInformation ()
 Sends attributes information to the GPU. More...
 
virtual void initMTLRenderLibrary ()
 Initializes the library shaders. More...
 
virtual void initMTLRenderPipeline ()
 Initializes the Rendering Pipeline. 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 loadMTLNormalMapTexture ()
 Loads Normal Map raw data. More...
 
virtual void updateSpaceUniforms ()
 Updates the space matrix of the entity. More...
 
virtual void updateShadowSpaceUniforms ()
 Updates the space matrix of the shadow. More...
 
virtual void updateRenderingInformation ()
 
virtual void modifyRenderingInformation ()
 
virtual void render (id< MTLRenderCommandEncoder > uRenderEncoder)
 Renders the current entity. More...
 
virtual void renderShadow (id< MTLRenderCommandEncoder > uRenderShadowEncoder, id< MTLTexture > uShadowTexture)
 Renders the shadow for a 3D entity. More...
 
virtual void createTextureObject ()
 Creates a texture object to be applied to an entity. More...
 
void createSamplerObject ()
 Creates a sampler object required for texturing. More...
 
virtual void createSecondaryTextureObject ()
 
void createNormalMapTextureObject ()
 Creates a Normal Map Texture. More...
 
void createNormalMapSamplerObject ()
 Creates a Normal Map Sampler. More...
 
virtual void setGeometryLineColor (U4DVector4n &uGeometryLineColor)
 Set line color for geometric entities. More...
 
void decodeImage (std::string uTexture)
 Decodes the image texture. More...
 
std::vector< unsigned char > decodeImage (const char *uTexture)
 Decodes the image texture. 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...
 
virtual void setDiffuseTexture (const char *uTexture)
 Sets the diffuse texture data. More...
 
virtual void setAmbientTexture (const char *uTexture)
 Sets the ambient texture data
More...
 
void addTexturesToSkyboxContainer (const char *uTextures)
 Loads textures into skybox container. More...
 
std::vector< const char * > getSkyboxTexturesContainer ()
 Returns skybox textures. More...
 
virtual U4DDualQuaternion getEntitySpace ()
 Method which returns the absolute space of the entity. More...
 
virtual U4DDualQuaternion getEntityLocalSpace ()
 Method which returns the local space of the entity. More...
 
virtual U4DVector3n getEntityAbsolutePosition ()
 Method which returns the absolute position of the entity. More...
 
virtual U4DVector3n getEntityLocalPosition ()
 Method which returns the local position of the entity. More...
 
matrix_float4x4 convertToSIMD (U4DEngine::U4DMatrix4n &uMatrix)
 Converts 4x4 matrix to SIMD format. More...
 
matrix_float3x3 convertToSIMD (U4DEngine::U4DMatrix3n &uMatrix)
 Converts 3x3 matrix to SIMD format. More...
 
vector_float4 convertToSIMD (U4DEngine::U4DVector4n &uVector)
 Converts vector of 4 dimensions into SIMD format. More...
 
vector_float3 convertToSIMD (U4DEngine::U4DVector3n &uVector)
 Converts vector of 3 dimensions into SIMD format. More...
 
vector_float2 convertToSIMD (U4DEngine::U4DVector2n &uVector)
 Converts vector of 2 dimensions into SIMD format. More...
 
void setIsWithinFrustum (bool uValue)
 Sets property used to determine if entity is within frustum. More...
 

Protected Attributes

id< MTLDevice > mtlDevice
 Pointer representing a Metal Device.
 
id< MTLRenderPipelineState > mtlRenderPipelineState
 Pointer representing the state of the render pipeline.
 
MTLRenderPipelineDescriptor * mtlRenderPipelineDescriptor
 Pointer for the rendering pipeline descriptor.
 
id< MTLDepthStencilState > depthStencilState
 Pointer for the depth stencil state.
 
id< MTLLibrary > mtlLibrary
 Pointer that holds the library of shaders.
 
id< MTLFunction > vertexProgram
 Pointer to the shader vertex program.
 
id< MTLFunction > fragmentProgram
 Pointer to the shader fragment program.
 
MTLVertexDescriptor * vertexDesc
 Pointer to the vertex descriptors.
 
MTLDepthStencilDescriptor * depthStencilDescriptor
 Pointer to the Depth Stencil descriptor.
 
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.
 
id< MTLBuffer > uniformModelRenderFlagsBuffer
 Pointer to the Uniform that holds the several rendering flags.
 
id< MTLTexture > textureObject
 Pointer that represents the texture object.
 
id< MTLTexture > normalMapTextureObject
 Pointer to the Normal Map texture.
 
id< MTLSamplerState > samplerStateObject
 Pointer to the Sampler State object.
 
id< MTLSamplerState > samplerNormalMapStateObject
 Pointer to the Normal Map Sampler.
 
MTLSamplerDescriptor * samplerDescriptor
 Pointer to the Sampler descriptor.
 
id< MTLTexture > secondaryTextureObject
 Pointer for second Texture object.
 
id< MTLBuffer > lightPositionUniform
 Uniform for the Light Position.
 
id< MTLBuffer > lightColorUniform
 Uniform for the light color.
 
id< MTLBuffer > uniformParticleSystemPropertyBuffer
 Uniform for the Particle System property.
 
id< MTLBuffer > uniformParticlePropertyBuffer
 Uniform for the Particle Property.
 
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::vector< const char * > skyboxTexturesContainer
 Buffer for the skybox raw data.
 
bool eligibleToRender
 Variable to determine if object should be rendered.
 
bool isWithinFrustum
 Variable to determine if the 3D object is within the frustum.
 

Detailed Description

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

Constructor & Destructor Documentation

◆ U4DRenderManager()

U4DEngine::U4DRenderManager::U4DRenderManager ( )

Constructor for the U4DRenderManager.

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

◆ ~U4DRenderManager()

U4DEngine::U4DRenderManager::~U4DRenderManager ( )
virtual

Destructor for the U4DRenderManager

Sets all descriptors and pipeline states to NULL

Member Function Documentation

◆ addTexturesToSkyboxContainer()

void U4DEngine::U4DRenderManager::addTexturesToSkyboxContainer ( const char *  uTextures)

Loads textures into skybox container.

Loads all six textures into the skybox container

Parameters
uTexturesSkybox textures

◆ clearModelAttributeData()

virtual void U4DEngine::U4DRenderManager::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::U4DRenderSkybox, U4DEngine::U4DRenderGeometry, U4DEngine::U4DRenderWorld, U4DEngine::U4DRenderLights, and U4DEngine::U4DRenderFont.

◆ clearRawImageData()

void U4DEngine::U4DRenderManager::clearRawImageData ( )

Clear the raw image data.

Clears the decode image data used for texturing

◆ convertToSIMD() [1/5]

matrix_float4x4 U4DEngine::U4DRenderManager::convertToSIMD ( U4DEngine::U4DMatrix4n uMatrix)

Converts 4x4 matrix to SIMD format.

Converts 4x4 matrix to SIMD format used by the GPU shaders

Parameters
uMatrix3x3 Matrix
Returns
Matrix in SIMD format

◆ convertToSIMD() [2/5]

matrix_float3x3 U4DEngine::U4DRenderManager::convertToSIMD ( U4DEngine::U4DMatrix3n uMatrix)

Converts 3x3 matrix to SIMD format.

Converts 3x3 matrix to SIMD format used by the GPU shaders

Parameters
uMatrix3x3 Matrix
Returns
Matrix in SIMD format

◆ convertToSIMD() [3/5]

vector_float4 U4DEngine::U4DRenderManager::convertToSIMD ( U4DEngine::U4DVector4n uVector)

Converts vector of 4 dimensions into SIMD format.

Converts vector of 4n dimentsions into SIMD format

Parameters
uVector4n vector dimension
Returns
vector in SIMD format

◆ convertToSIMD() [4/5]

vector_float3 U4DEngine::U4DRenderManager::convertToSIMD ( U4DEngine::U4DVector3n uVector)

Converts vector of 3 dimensions into SIMD format.

Converts vector of 3n dimentsions into SIMD format

Parameters
uVector3n vector dimension
Returns
vector in SIMD format

◆ convertToSIMD() [5/5]

vector_float2 U4DEngine::U4DRenderManager::convertToSIMD ( U4DEngine::U4DVector2n uVector)

Converts vector of 2 dimensions into SIMD format.

Converts vector of 2n dimentsions into SIMD format

Parameters
uVector2n vector dimension
Returns
vector in SIMD format

◆ createNormalMapSamplerObject()

void U4DEngine::U4DRenderManager::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::U4DRenderManager::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.

◆ createSamplerObject()

void U4DEngine::U4DRenderManager::createSamplerObject ( )

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::U4DRenderManager::createTextureObject ( )
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.

◆ decodeImage() [1/2]

void U4DEngine::U4DRenderManager::decodeImage ( std::string  uTexture)

Decodes the image texture.

Decodes the texture using the lodepng library. It flips and inverts the image.

Parameters
uTextureThe image representing the texture

◆ decodeImage() [2/2]

std::vector< unsigned char > U4DEngine::U4DRenderManager::decodeImage ( const char *  uTexture)

Decodes the image texture.

Decodes the texture using the lodepng library. It flips and inverts the image.

Parameters
uTextureThe image representing the texture
Returns
Buffer containing the raw image data

◆ getEntityAbsolutePosition()

virtual U4DVector3n U4DEngine::U4DRenderManager::getEntityAbsolutePosition ( )
inlinevirtual

Method which returns the absolute position of the entity.

Returns
Returns the entity absolute position

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

◆ getEntityLocalPosition()

virtual U4DVector3n U4DEngine::U4DRenderManager::getEntityLocalPosition ( )
inlinevirtual

Method which returns the local position of the entity.

Returns
Returns the entity local position

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

◆ getEntityLocalSpace()

virtual U4DDualQuaternion U4DEngine::U4DRenderManager::getEntityLocalSpace ( )
inlinevirtual

Method which returns the local space of the entity.

Returns
Returns the entity local space-Orientation and Position

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

◆ getEntitySpace()

virtual U4DDualQuaternion U4DEngine::U4DRenderManager::getEntitySpace ( )
inlinevirtual

Method which returns the absolute space of the entity.

Returns
Returns the entity absolure space-Orientation and Position

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

◆ getSkyboxTexturesContainer()

std::vector< const char * > U4DEngine::U4DRenderManager::getSkyboxTexturesContainer ( )

Returns skybox textures.

Returns a vector containing all six skybox textures

Returns
skybox textures

◆ initMTLRenderLibrary()

virtual void U4DEngine::U4DRenderManager::initMTLRenderLibrary ( )
inlinevirtual

Initializes the library shaders.

It initializes the vertex and fragment shaders for the entity

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

◆ initMTLRenderPipeline()

virtual void U4DEngine::U4DRenderManager::initMTLRenderPipeline ( )
inlinevirtual

Initializes the Rendering Pipeline.

It prepares the rendering descriptor with the appropriate color attachment, depth attachment, shaders and attributes

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

◆ initTextureSamplerObjectNull()

virtual void U4DEngine::U4DRenderManager::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, and U4DEngine::U4DRenderParticleSystem.

◆ loadMTLAdditionalInformation()

virtual void U4DEngine::U4DRenderManager::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::U4DRenderParticleSystem, U4DEngine::U4DRenderGeometry, U4DEngine::U4DRenderMultiImage, and U4DEngine::U4DRenderSprite.

◆ loadMTLBuffer()

virtual bool U4DEngine::U4DRenderManager::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::U4DRenderGeometry, U4DEngine::U4DRenderLights, U4DEngine::U4DRenderWorld, U4DEngine::U4DRenderImage, and U4DEngine::U4DRenderSkybox.

◆ loadMTLNormalMapTexture()

virtual void U4DEngine::U4DRenderManager::loadMTLNormalMapTexture ( )
inlinevirtual

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

Reimplemented in U4DEngine::U4DRender3DModel.

◆ loadMTLTexture()

virtual void U4DEngine::U4DRenderManager::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::U4DRenderSkybox, and U4DEngine::U4DRenderMultiImage.

◆ loadRenderingInformation()

void U4DEngine::U4DRenderManager::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::U4DRenderManager::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::U4DRenderGeometry, U4DEngine::U4DRenderImage, U4DEngine::U4DRenderSkybox, U4DEngine::U4DRenderLights, U4DEngine::U4DRenderWorld, U4DEngine::U4DRenderMultiImage, U4DEngine::U4DRenderSprite, and U4DEngine::U4DRenderFont.

◆ renderShadow()

virtual void U4DEngine::U4DRenderManager::renderShadow ( id< MTLRenderCommandEncoder >  uRenderShadowEncoder,
id< MTLTexture >  uShadowTexture 
)
inlinevirtual

Renders the shadow for a 3D entity.

Updates the shadow space matrix, any rendering flags. It also sends the attributes and space uniforms to the GPU

Parameters
uRenderShadowEncoderMetal encoder object for the current entity
uShadowTextureTexture shadow for the current entity

Reimplemented in U4DEngine::U4DRender3DModel.

◆ setAmbientTexture()

virtual void U4DEngine::U4DRenderManager::setAmbientTexture ( const char *  uTexture)
inlinevirtual

Sets the ambient texture data

The ambient texture is the secondary texture used for entities

Parameters
uTextureAmbient texture

Reimplemented in U4DEngine::U4DRenderMultiImage.

◆ setDiffuseTexture()

virtual void U4DEngine::U4DRenderManager::setDiffuseTexture ( const char *  uTexture)
inlinevirtual

Sets the diffuse texture data.

The diffuse texture is the main texture used for entities

Parameters
uTextureDiffuse texture

Reimplemented in U4DEngine::U4DRenderParticleSystem, U4DEngine::U4DRenderSkybox, U4DEngine::U4DRenderImage, and U4DEngine::U4DRenderMultiImage.

◆ setGeometryLineColor()

virtual void U4DEngine::U4DRenderManager::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::U4DRenderManager::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

◆ updateShadowSpaceUniforms()

virtual void U4DEngine::U4DRenderManager::updateShadowSpaceUniforms ( )
inlinevirtual

Updates the space matrix of the shadow.

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

Reimplemented in U4DEngine::U4DRender3DModel.

◆ updateSpaceUniforms()

virtual void U4DEngine::U4DRenderManager::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::U4DRenderSkybox, U4DEngine::U4DRenderGeometry, U4DEngine::U4DRenderLights, and U4DEngine::U4DRenderWorld.