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

The U4DModel class represents a 3D model entity. More...

Inherits U4DEngine::U4DVisibleEntity.

Public Member Functions

 U4DModel ()
 Constructor for the class.
 
 ~U4DModel ()
 Destructor for the class.
 
 U4DModel (const U4DModel &value)
 Copy constructor for the class.
 
U4DModeloperator= (const U4DModel &value)
 Copy constructor for the class. More...
 
virtual void update (double dt)
 Method which updates the state of the 3D model. More...
 
void updateAllUniforms ()
 
void render (id< MTLRenderCommandEncoder > uRenderEncoder)
 Renders the current entity. More...
 
bool getBoneRestPose (std::string uBoneName, U4DMatrix4n &uBoneRestPoseMatrix)
 returns the rest pose of the bone. Note, an armature must be present More...
 
bool getBoneAnimationPose (std::string uBoneName, U4DAnimation *uAnimation, U4DMatrix4n &uBoneAnimationPoseMatrix)
 returns the animation pose of the bone. Note, an armature must be present and an animation must currently be playing. More...
 
bool loadModel (const char *uModelName)
 Method which loads Digital Asset data into the game character. Note, the mesh asset binary data must be loaded before calling this method. More...
 
bool loadAnimationToModel (U4DAnimation *uAnimation, const char *uAnimationName)
 Method which loads Animation data into the game character. Note, the animation asset binary data must be loaded before calling this method. More...
 
void loadIntoVisibilityManager (U4DEntityManager *uEntityManager)
 self load 3d model into the visibility manager More...
 
U4DVector3n getModelDimensions ()
 Get the 3D dimensions. More...
 
void setNormalMapTexture (std::string uTexture)
 sets the Normal Map texture used for the 3d model More...
 
void setEnableNormalMap (bool uValue)
 enable Normal Map rendering More...
 
bool getEnableNormalMap ()
 gets if Normal Map rendering is enabled More...
 
void setHasNormalMap (bool uValue)
 Informs the engine that the 3d model contains Normal Map texture. More...
 
bool getHasNormalMap ()
 returns true if the 3D model has Normal Map texture More...
 
void computeNormalMapTangent ()
 computes the Normal map tangent vectors More...
 
void setHasMaterial (bool uValue)
 Informs the engine that the 3D model contains material color information. More...
 
void setHasTexture (bool uValue)
 Informs the engine that the 3D model contains texture information. More...
 
void setHasAnimation (bool uValue)
 Method to inform the engine that the 3D model contains animation information. More...
 
void setHasArmature (bool uValue)
 Method to inform the engine that the 3D model contains armature information. More...
 
bool getHasMaterial ()
 Method which returns true if the 3D model has material color information. More...
 
bool getHasTexture ()
 Method which returns true if the 3D model has texture information. More...
 
bool getHasAnimation ()
 Method which returns true if the 3D model has animation information. More...
 
bool getHasArmature ()
 Method which returns true if the 3D model has armature information. More...
 
U4DVector3n getViewInDirection ()
 Method which returns a 3D vector representing the current view-direction of the 3D model. More...
 
void viewInDirection (U4DVector3n &uDestinationPoint)
 Method which sets the view-direction of the 3D model. More...
 
U4DDualQuaternion getBoneAnimationSpace (std::string uName)
 Gets the pose animation space of the bone. More...
 
void setModelVisibility (bool uValue)
 set if the model should be rendered or not depending if it lies within frustum
 
void initCullingBoundingVolume ()
 Method which initialized the boundary volume used for frustum culling. More...
 
void setCullingPhaseBoundingVolumeVisibility (bool uValue)
 Methods which sets the visibility of the Culling-Phase bounding volume. More...
 
void updateCullingPhaseBoundingVolumeSpace ()
 Method which updates the culling-phase bounding volume space.
 
U4DBoundingVolumegetCullingPhaseBoundingVolume ()
 Method which returns the culling-phase bounding volume. More...
 
bool getCullingPhaseBoundingVolumeVisibility ()
 Method which returns if the engine should render the culling-phase bounding volume. More...
 
void updateShaderParameterContainer (int uPosition, U4DVector4n &uParamater)
 
std::vector< U4DVector4ngetModelShaderParameterContainer ()
 
void setTexture0 (std::string uTexture0)
 
void setTexture1 (std::string uTexture1)
 
void setRawImageData (std::vector< unsigned char > uRawImageData)
 
void setImageWidth (unsigned int uImageWidth)
 
void setImageHeight (unsigned int uImageHeight)
 
void enableMeshManager (int uSubDivisions)
 Enables the mesh manager to build an octree. More...
 
U4DMeshOctreeManagergetMeshOctreeManager ()
 gets a pointer to the mesh manager in charge of building an octree
 
- Public Member Functions inherited from U4DEngine::U4DVisibleEntity
 U4DVisibleEntity ()
 Constructor for the class.
 
virtual ~U4DVisibleEntity ()
 Destructor for the class.
 
 U4DVisibleEntity (const U4DVisibleEntity &value)
 Copy constructor for the visible entity.
 
U4DVisibleEntityoperator= (const U4DVisibleEntity &value)
 Copy constructor for the visible entity. More...
 
void loadRenderingInformation ()
 Method which loads all rendering information for the entiy.
 
std::string getFragmentShader ()
 get the name of the fragment shader More...
 
U4DRenderEntitygetRenderEntity ()
 
void setPipelineForPass (std::string uPipelineName, int uRenderPassKey)
 
void setPipeline (std::string uPipelineName)
 sets the pipeline for the default final pass More...
 
- Public Member Functions inherited from U4DEngine::U4DEntity
 U4DEntity ()
 Entity Constructor. It creates the entity with the local orientation set to zero and local position set to the origin. The forwad vector is set to (0.0,0.0,-1.0). Parent and Next pointer set to null.
 
 ~U4DEntity ()
 Entity Destructor.
 
 U4DEntity (const U4DEntity &value)
 Entity Copy Constructor.
 
U4DEntityoperator= (const U4DEntity &value)
 Entity Copy Constructor. More...
 
void setName (std::string uName)
 Method which sets the name of the Entity. More...
 
std::string getName ()
 Method which returns the name of the Entity. More...
 
void setEntityType (ENTITYTYPE uType)
 Method which sets the type of the Entity. More...
 
ENTITYTYPE getEntityType ()
 Method which returns the type of the Entity. More...
 
void setLocalSpace (U4DDualQuaternion &uLocalSpace)
 Method which sets the local space of the Entity. More...
 
void setLocalSpace (U4DMatrix4n &uMatrix)
 Method which sets the local space of the Entity. More...
 
U4DDualQuaternion getLocalSpace ()
 
U4DDualQuaternion getAbsoluteSpace ()
 Method which returns the absolute space of the Entity. More...
 
U4DQuaternion getLocalSpaceOrientation ()
 Method which returns the local orientation space of the Entity. More...
 
U4DQuaternion getLocalSpacePosition ()
 Method which returns the local position space of the Entity. More...
 
U4DQuaternion getAbsoluteSpaceOrientation ()
 Method which returns the absolute orientation space of the Entity. More...
 
U4DQuaternion getAbsoluteSpacePosition ()
 Method which returns the absolute position space of the Entity. More...
 
void setLocalSpaceOrientation (U4DQuaternion &uOrientation)
 Method which sets the local space orientation of the Entity. More...
 
void setLocalSpacePosition (U4DQuaternion &uPosition)
 Method which sets the local space position of the Entity. More...
 
U4DVector3n getLocalOrientation ()
 Method which returns the Local orientation of the Entity. More...
 
U4DVector3n getLocalPosition ()
 Method which returns the local position of the Entity. More...
 
U4DVector3n getAbsoluteOrientation ()
 Method which returns the absolute orientation of the Entity. More...
 
U4DVector3n getAbsolutePosition ()
 Method which returns the absolute position of the Entity. More...
 
U4DVector3n getEntityForwardVector ()
 Method which returns the forwad vector of the Entity. More...
 
void setEntityForwardVector (U4DVector3n &uForwardVector)
 Method which sets the forward vectof of the Entity. The default value is (0.0,0.0,-1.0) More...
 
U4DMatrix3n getAbsoluteMatrixOrientation ()
 Method which returns the absolute orientation of the Entity. More...
 
U4DMatrix3n getLocalMatrixOrientation ()
 Method which returns the local orientation of the Entity. More...
 
void translateTo (U4DVector3n &translation)
 Method which translates entity to a new position. More...
 
void translateTo (float x, float y, float z)
 Method which translates entity to a new position. More...
 
void translateTo (U4DVector2n &translation)
 Method which translates entity to a new position. More...
 
void translateBy (float x, float y, float z)
 Method which translates entity by certain amount. More...
 
void translateBy (U4DVector3n &translation)
 Method which translates entity by a certain amount. More...
 
void rotateTo (U4DQuaternion &rotation)
 Method which rotates entity to a new orientation. More...
 
void rotateBy (U4DQuaternion &rotation)
 Method which rotates entity by a certain amount. More...
 
void rotateTo (float angle, U4DVector3n &axis)
 Method which rotates entity to a new orientation. More...
 
void rotateBy (float angle, U4DVector3n &axis)
 Method which rotates entity by certain amount. More...
 
void rotateTo (float angleX, float angleY, float angleZ)
 Method which rotates entity to a new orientation. More...
 
void rotateBy (float angleX, float angleY, float angleZ)
 Method which rotates entity by a certain amount. More...
 
void rotateAboutAxis (float angle, U4DVector3n &axisOrientation, U4DVector3n &axisPosition)
 Method which rotates entity about an axis. More...
 
void rotateAboutAxis (U4DQuaternion &uOrientation, U4DVector3n &axisPosition)
 Method which rotates entity about an axis. More...
 
void setZDepth (int uZDepth)
 Loads all rendering information for the entiy ‍/ virtual void loadRenderingInformation(){};. More...
 
int getZDepth ()
 Gets the z-depth value used for rendering ordering. More...
 
virtual bool changeState (INPUTELEMENTACTION uInputAction, U4DVector2n uPosition)
 
- Public Member Functions inherited from U4DEngine::U4DEntityNode< U4DEntity >
 U4DEntityNode ()
 Constructor for the class.
 
 U4DEntityNode (std::string uNodeName)
 
 ~U4DEntityNode ()
 Destructor for the class.
 
void addChild (U4DEntity *uChild)
 Method which adds a child node to a scenegraph. More...
 
void addChild (U4DEntity *uChild, U4DEntity *uNext)
 
void addChild (U4DEntity *uChild, int uZDepth)
 Method which adds a child entity to a scenegraph at a particular location. More...
 
void removeChild (U4DEntity *uChild)
 Method which removes a child node from the scenegraph. More...
 
void changeLastDescendant (U4DEntity *uNewLastDescendant)
 Method which changes the node's last descendant in the scenegraph. More...
 
U4DEntitygetFirstChild ()
 Method which returns the node's first child in the scenegraph. More...
 
U4DEntitygetLastChild ()
 Method which returns the node's last child in the scenegraph. More...
 
U4DEntitygetNextSibling ()
 Method which returns the node's next sibling in the scenegraph. More...
 
U4DEntitygetPrevSibling ()
 Method which returns the node's previous sibling in the scenegraph. More...
 
U4DEntityprevInPreOrderTraversal ()
 Method which returns the node's previous sibling in pre-order traversal order. More...
 
U4DEntitynextInPreOrderTraversal ()
 Method which returns the node's next pointer in pre-order traversal order. More...
 
bool isLeaf ()
 Method which returns true if the node represents a leaf node in the scenegraph. More...
 
bool isRoot ()
 Method which returns true if the node represents a root node in the scenegraph. More...
 
U4DEntitygetParent ()
 Gets the parent to the entity. More...
 
U4DEntitygetRootParent ()
 Gets the root parent (top parent in the scenegraph) of the entity. More...
 
U4DEntitysearchChild (std::string uName)
 

Public Attributes

U4DVertexData bodyCoordinates
 Object which contains attribute data such as vertices, normals, uv-coordinates, bone indices, bone weights, etc.
 
U4DMaterialData materialInformation
 Object which contains material color information.
 
U4DTextureData textureInformation
 Object which contains texture information.
 
U4DArmatureDataarmatureManager
 Pointer to an armature object representing an armature manager.
 
U4DPolygonData polygonInformation
 Object with polygon (vertices, edges and faces) information.
 
std::vector< U4DMatrix4narmatureBoneMatrix
 Container holding armature bone matrix data.
 
- Public Attributes inherited from U4DEngine::U4DVisibleEntity
U4DRenderEntityrenderEntity
 pointer to the rendering entity
 
- Public Attributes inherited from U4DEngine::U4DEntity
U4DDualQuaternion localSpace
 Local Space of the entity.
 
U4DDualQuaternion absoluteSpace
 Absolute Space of the entity.
 
U4DTransformationtransformation
 U4DTransformation object pointer in charge of translating/rotating the entity.
 
U4DVector3n entityForwardVector
 Forward vector of the entity. This is used to compute the view-direction vector.
 
int zDepth
 z-depth used for rendering ordering
 
- Public Attributes inherited from U4DEngine::U4DEntityNode< U4DEntity >
U4DEntityparent
 Tree parent pointer.
 
U4DEntityprevSibling
 Tree previous sibling pointer.
 
U4DEntitynext
 Tree next pointer.
 
U4DEntitylastDescendant
 Tree last descendant pointer.
 

Additional Inherited Members

- Protected Attributes inherited from U4DEngine::U4DEntity
U4DVector3n localOrientation
 Entity local orientation.
 
U4DVector3n localPosition
 Entity local position.
 
U4DVector3n absoluteOrientation
 Entity absolute orientation.
 
U4DVector3n absolutePosition
 Entity absolute position.
 

Detailed Description

The U4DModel class represents a 3D model entity.

Member Function Documentation

◆ computeNormalMapTangent()

void U4DEngine::U4DModel::computeNormalMapTangent ( )

computes the Normal map tangent vectors

the tangent vectors are used to properly shade the normal map texture

◆ enableMeshManager()

void U4DEngine::U4DModel::enableMeshManager ( int  uSubDivisions)

Enables the mesh manager to build an octree.

Builds an octree for the 3D model using AABB boxes

Parameters
uSubDivisionsThe subdivisions used for the octree. 1 subdivision=9 nodes, 2 subdivisions=73 node, 3 subdivisions=585 nodes

◆ getBoneAnimationPose()

bool U4DEngine::U4DModel::getBoneAnimationPose ( std::string  uBoneName,
U4DAnimation uAnimation,
U4DMatrix4n uBoneAnimationPoseMatrix 
)

returns the animation pose of the bone. Note, an armature must be present and an animation must currently be playing.

Parameters
uBoneNamename of the bone
uAnimationcurrent animation being played
uBoneAnimationPoseMatrixbone animation pose matrix
Returns
returns true along with the animation pose space of the bone. The uBoneAnimationPoseMatrix will contain the animation pose matrix.

◆ getBoneAnimationSpace()

U4DDualQuaternion U4DEngine::U4DModel::getBoneAnimationSpace ( std::string  uName)

Gets the pose animation space of the bone.

Returns
The pose space animation of the bone

◆ getBoneRestPose()

bool U4DEngine::U4DModel::getBoneRestPose ( std::string  uBoneName,
U4DMatrix4n uBoneRestPoseMatrix 
)

returns the rest pose of the bone. Note, an armature must be present

Parameters
uBoneNamename of the bone
uBoneRestPoseMatrixbone rest pose matrix
Returns
returns true if the rootbone rest pose exists. The uBoneRestPoseMatrix will contain the bone rest pose

◆ getCullingPhaseBoundingVolume()

U4DBoundingVolume * U4DEngine::U4DModel::getCullingPhaseBoundingVolume ( )

Method which returns the culling-phase bounding volume.

Returns
Returns the culling-phase bounding volume

◆ getCullingPhaseBoundingVolumeVisibility()

bool U4DEngine::U4DModel::getCullingPhaseBoundingVolumeVisibility ( )

Method which returns if the engine should render the culling-phase bounding volume.

Returns
Returns true if the engine should render the culling-phase bounding volume

◆ getEnableNormalMap()

bool U4DEngine::U4DModel::getEnableNormalMap ( )

gets if Normal Map rendering is enabled

Returns
true if Normal map rendering has been enable. False otherwise.

◆ getHasAnimation()

bool U4DEngine::U4DModel::getHasAnimation ( )

Method which returns true if the 3D model has animation information.

Returns
Returns true if 3D model has animation information

◆ getHasArmature()

bool U4DEngine::U4DModel::getHasArmature ( )

Method which returns true if the 3D model has armature information.

Returns
Returns true if 3D model has armature information

◆ getHasMaterial()

bool U4DEngine::U4DModel::getHasMaterial ( )

Method which returns true if the 3D model has material color information.

Returns
Returns true if 3D model has material color information

◆ getHasNormalMap()

bool U4DEngine::U4DModel::getHasNormalMap ( )

returns true if the 3D model has Normal Map texture

Returns
True if 3D model has Normal Map texture

◆ getHasTexture()

bool U4DEngine::U4DModel::getHasTexture ( )

Method which returns true if the 3D model has texture information.

Returns
Returns true if 3D model has texture information

◆ getModelDimensions()

U4DVector3n U4DEngine::U4DModel::getModelDimensions ( )

Get the 3D dimensions.

Gets the widht, length and depth dimensions of the 3D entity

Returns
vector with the dimensions

◆ getViewInDirection()

U4DVector3n U4DEngine::U4DModel::getViewInDirection ( )
virtual

Method which returns a 3D vector representing the current view-direction of the 3D model.

Returns
Returns 3D vector representing the view-direction of the 3D model

Reimplemented from U4DEngine::U4DEntity.

◆ initCullingBoundingVolume()

void U4DEngine::U4DModel::initCullingBoundingVolume ( )

Method which initialized the boundary volume used for frustum culling.

◆ loadAnimationToModel()

bool U4DEngine::U4DModel::loadAnimationToModel ( U4DAnimation uAnimation,
const char *  uAnimationName 
)

Method which loads Animation data into the game character. Note, the animation asset binary data must be loaded before calling this method.

Parameters
uAnimationPointer to the animation
uAnimationNameName of the animation
Returns
Returns true if the animation was successfully loaded

◆ loadIntoVisibilityManager()

void U4DEngine::U4DModel::loadIntoVisibilityManager ( U4DEntityManager uEntityManager)

self load 3d model into the visibility manager

Parameters
uEntityManagerpointer to the entity manager

◆ loadModel()

bool U4DEngine::U4DModel::loadModel ( const char *  uModelName)

Method which loads Digital Asset data into the game character. Note, the mesh asset binary data must be loaded before calling this method.

Parameters
uModelNameName of the model in the Digital Asset File
Returns
Returns true if the digital asset data was successfully loaded

◆ operator=()

U4DModel & U4DEngine::U4DModel::operator= ( const U4DModel value)

Copy constructor for the class.

Parameters
value3D model entity to copy to
Returns
Returns a copy of the 3D model

◆ render()

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

◆ setCullingPhaseBoundingVolumeVisibility()

void U4DEngine::U4DModel::setCullingPhaseBoundingVolumeVisibility ( bool  uValue)

Methods which sets the visibility of the Culling-Phase bounding volume.

Parameters
uValueThe engine will render the culling-phase bounding volume if set to true

◆ setEnableNormalMap()

void U4DEngine::U4DModel::setEnableNormalMap ( bool  uValue)

enable Normal Map rendering

Parameters
uValuetrue to enable Normal map rendering.

◆ setHasAnimation()

void U4DEngine::U4DModel::setHasAnimation ( bool  uValue)

Method to inform the engine that the 3D model contains animation information.

Parameters
uValueBoolean value (True states that the 3D model contains animation information)

◆ setHasArmature()

void U4DEngine::U4DModel::setHasArmature ( bool  uValue)

Method to inform the engine that the 3D model contains armature information.

Parameters
uValueBoolean value (True states that the 3D model contains armature information)

◆ setHasMaterial()

void U4DEngine::U4DModel::setHasMaterial ( bool  uValue)

Informs the engine that the 3D model contains material color information.

Parameters
uValueBoolean value (True states that the 3D model contains material color information)

◆ setHasNormalMap()

void U4DEngine::U4DModel::setHasNormalMap ( bool  uValue)

Informs the engine that the 3d model contains Normal Map texture.

Parameters
uValuetrue states that the 3d model contains a normal map

◆ setHasTexture()

void U4DEngine::U4DModel::setHasTexture ( bool  uValue)

Informs the engine that the 3D model contains texture information.

Parameters
uValueBoolean value (True states that the 3D model contains texture information)

◆ setNormalMapTexture()

void U4DEngine::U4DModel::setNormalMapTexture ( std::string  uTexture)

sets the Normal Map texture used for the 3d model

Parameters
uTexturename of the normal map

◆ update()

virtual void U4DEngine::U4DModel::update ( double  dt)
inlinevirtual

Method which updates the state of the 3D model.

Parameters
dtTime-step value

Reimplemented from U4DEngine::U4DVisibleEntity.

◆ updateAllUniforms()

void U4DEngine::U4DModel::updateAllUniforms ( )
virtual

Reimplemented from U4DEngine::U4DVisibleEntity.

◆ viewInDirection()

void U4DEngine::U4DModel::viewInDirection ( U4DVector3n uDestinationPoint)
virtual

Method which sets the view-direction of the 3D model.

Parameters
uDestinationPoint3D vector representing the destination point.

Reimplemented from U4DEngine::U4DEntity.