PixelLightAPI  .
Public Member Functions
PLMesh::MeshHandler Class Reference

Mesh handler. More...

#include <MeshHandler.h>

Inheritance diagram for PLMesh::MeshHandler:
Inheritance graph
[legend]

List of all members.

Public Member Functions

PLMESH_API MeshHandler ()
 Constructor.
virtual PLMESH_API ~MeshHandler ()
 Destructor.
PLMESH_API PLRenderer::RendererGetRenderer () const
 Returns the used renderer.
PLMESH_API void MeshUpdateRequired ()
 Whenever you manipulated mesh data "from outside" you need to call this function to set a "dirty"-flag.
PLMESH_API MeshGetMesh () const
 Returns the used mesh.
PLMESH_API bool SetMesh (Mesh *pMesh=nullptr)
 Sets the used mesh.
PLMESH_API void Update (float fTimeDifference, PLCore::uint32 nLODLevel=0)
 Updates the mesh handler.
PLMESH_API void Draw (bool bBlend=false, bool bUseMaterials=true) const
 Draws the mesh.
PLMESH_API void DrawVertices (const PLGraphics::Color4 &cColor) const
 Draws the vertices of the mesh (for debugging)
PLMESH_API void DrawNormals (const PLGraphics::Color4 &cColor, const PLMath::Matrix4x4 &mWorldViewProjection, float fScale=1.0f, float fLineWidth=1.0f) const
 Draws the normals of the mesh (for debugging)
PLMESH_API void DrawTangents (const PLGraphics::Color4 &cColor, const PLMath::Matrix4x4 &mWorldViewProjection, float fScale=1.0f, float fLineWidth=1.0f) const
 Draws the tangents of the mesh (for debugging)
PLMESH_API void DrawBinormals (const PLGraphics::Color4 &cColor, const PLMath::Matrix4x4 &mWorldViewProjection, float fScale=1.0f, float fLineWidth=1.0f) const
 Draws the binormals of the mesh (for debugging)
PLMESH_API void DrawVertexNumbers (PLRenderer::Font &cFont, const PLGraphics::Color4 &cColor, const PLMath::Matrix4x4 &mWorldViewProjection) const
 Draws the vertex numbers of the mesh (for debugging)
PLMESH_API void DrawAnchorPoints (PLRenderer::Font &cFont, const PLGraphics::Color4 &cColor, const PLMath::Matrix4x4 &mWorldViewProjection) const
 Draws the anchor points of the mesh (for debugging)
PLMESH_API PLCore::uint32 GetNumOfMaterials () const
 Returns the number of materials.
PLMESH_API PLRenderer::MaterialGetMaterial (PLCore::uint32 nMaterial=0) const
 Gets one of the mesh handler's materials.
PLMESH_API bool SetMaterial (PLCore::uint32 nMaterial, PLRenderer::Material *pMaterial)
 Sets one of the mesh handler's materials.
PLMESH_API PLCore::Array< float > & GetBaseMorphTargetWeights ()
 Returns an array holding the the base weight of each morph target.
PLMESH_API const PLCore::Array
< float > & 
GetBaseMorphTargetWeights () const
PLMESH_API PLCore::Array< float > & GetMorphTargetWeights ()
 Returns an array holding the the current weight of each morph target.
PLMESH_API const PLCore::Array
< float > & 
GetMorphTargetWeights () const
PLMESH_API SkeletonHandlerGetSkeletonHandler () const
 Returns the skeleton handler.
PLMESH_API MeshAnimationManagerGetMeshAnimationManager () const
 Returns the mesh animation manager.
PLMESH_API MeshAnimationManagerCreateMeshAnimationManager (const PLCore::String &sName="PLMesh::MeshAnimationManagerSoftware")
 Creates the mesh animation manager.
PLMESH_API void GetAnimationsList (PLCore::Array< PLCore::String > &lstAnimations) const
 Returns a list of all currently available animations.
PLMESH_API
PLRenderer::AnimationInfo
GetAnimationInfo (const PLCore::String &sName, int nLogMessage=1) const
 Returns a pointer to the requested animation information.
PLMESH_API JointHandlerGetJointHandler (const PLCore::String &sJointName) const
 Returns a current joint handler.
PLMESH_API JointHandlerGetBaseJointHandler (const PLCore::String &sJointName) const
 Returns a base joint handler.
PLMESH_API void UpdateVisibility (const PLMath::PlaneSet &cPlaneSet, bool bFirst=true)
 Updates the mesh visibility.
PLMESH_API PLCore::BitsetGetGeometryVisibility ()
 Returns the bit set holding the geometry visibility state.
PLMESH_API PLCore::uint32 GetNumOfLODLevels () const
 Returns the number of mesh LOD levels.
PLMESH_API PLCore::uint32 GetLODLevelIndex () const
 Returns the current used mesh LOD level index.
PLMESH_API MeshLODLevelGetLODLevel () const
 Returns the current used mesh LOD level.
PLMESH_API bool CalculateJointBoundingBox (PLMath::AABoundingBox &cAAB) const
 Calculates the current axis aligned joint bounding box.
PLMESH_API
PLRenderer::VertexBuffer
GetVertexBuffer () const
 Returns the current used vertex buffer of the mesh.
PLMESH_API PLCore::uint32 GetNumOfTriangles () const
 Returns the total number of current triangles.
PLMESH_API bool FindTriangle (const PLMath::Vector3 &vLineStartPos, const PLMath::Vector3 &vLineEndPos, PLCore::uint32 &nTriangle, PLCore::uint32 *pnGeometry=nullptr, PLMath::Vector3 *pvCollisionPoint=nullptr, PLCore::Array< PLCore::uint32 > *plstGeometries=nullptr) const
 Returns the first mesh triangle intersecting the line.
PLMESH_API PLCore::uint32 FindGeometries (const PLMath::PlaneSet &cPlaneSet, PLCore::uint32 **ppnGeometries=nullptr, PLMath::Vector3 *pvCamDir=nullptr) const
 Returns a list of mesh geometries intersecting the plane set.
PLMESH_API PLCore::Array
< MeshTriangle > * 
GetTriangleList ()
 Gets the triangle list.
PLMESH_API PLCore::Array
< MeshEdge > * 
GetEdgeList ()
 Gets the edge list.
PLMESH_API void BuildTrianglePlaneList ()
 Builds the current triangle planes.
PLMESH_API PLCore::Array
< PLMath::Plane > * 
GetTrianglePlaneList ()
 Gets the triangle plane list.

Detailed Description

Mesh handler.

Remarks:
A mesh handler will use a mesh and is able to use own materials and an own vertex buffer for e.g. animations. Whenever working with meshes you should use a mesh handler!
Animation example
pMH->CreateMeshAnimationManager(); // Create a mesh animation manager first!
Animation *pAnimation = pMH->GetMeshAnimationManager()->Create("attack");
pAnimation->Start(pMH->GetAnimationInfo(pAnimation->GetName()));
Note:
  • Whenever you manipulated mesh data "from outside" you need to call "MeshUpdateRequired()" to set a "dirty"-flag
  • Animation frame changes automatically set the internal 'mesh update required'-flag

Constructor & Destructor Documentation

Constructor.

virtual PLMESH_API PLMesh::MeshHandler::~MeshHandler ( ) [virtual]

Destructor.


Member Function Documentation

Returns the used renderer.

Returns:
Pointer to the renderer that is used, can be a null pointer

Whenever you manipulated mesh data "from outside" you need to call this function to set a "dirty"-flag.

PLMESH_API Mesh* PLMesh::MeshHandler::GetMesh ( ) const

Returns the used mesh.

Returns:
Pointer to the used mesh, can be a null pointer
Note:
  • Call "MeshUpdateRequired()" to set a "dirty"-flag if you manipulated the mesh
PLMESH_API bool PLMesh::MeshHandler::SetMesh ( Mesh pMesh = nullptr)

Sets the used mesh.

Parameters:
[in]pMeshPointer to the mesh which should be used, can be a null pointer
Returns:
'true' if all went fine, else 'false'
Note:
  • The mesh handler materials are set to the mesh materials, therefore first load/setup a mesh and then use this function!
  • After a mesh itself was manipulated, for instance the material list was changed you should reset the mesh in your mesh handler!
PLMESH_API void PLMesh::MeshHandler::Update ( float  fTimeDifference,
PLCore::uint32  nLODLevel = 0 
)

Updates the mesh handler.

Parameters:
[in]fTimeDifferencePast time since last frame (use e.g. PLCore::Timing::GetInstance()->GetTimeDifference())
[in]nLODLevelLOD level to use
Remarks:
This function for instance updates the animations but will also setup individual mesh data required for drawing the mesh the mesh handler is using.
PLMESH_API void PLMesh::MeshHandler::Draw ( bool  bBlend = false,
bool  bUseMaterials = true 
) const

Draws the mesh.

Parameters:
[in]bBlendDraw only mesh parts which use a blended material?
[in]bUseMaterialsUse the mesh materials? If 'false' no material is bound.
Note:
  • Update() must have been called before the mesh can be drawn because this function setup the individual mesh data
PLMESH_API void PLMesh::MeshHandler::DrawVertices ( const PLGraphics::Color4 cColor) const

Draws the vertices of the mesh (for debugging)

Parameters:
[in]cColorColor to use
Note:
  • Ensure that correct render states are set...
PLMESH_API void PLMesh::MeshHandler::DrawNormals ( const PLGraphics::Color4 cColor,
const PLMath::Matrix4x4 mWorldViewProjection,
float  fScale = 1.0f,
float  fLineWidth = 1.0f 
) const

Draws the normals of the mesh (for debugging)

Parameters:
[in]cColorColor to use
[in]mWorldViewProjectionWorld view projection matrix to use
[in]fScaleNormal scale
[in]fLineWidthLine width
See also:
PLMESH_API void PLMesh::MeshHandler::DrawTangents ( const PLGraphics::Color4 cColor,
const PLMath::Matrix4x4 mWorldViewProjection,
float  fScale = 1.0f,
float  fLineWidth = 1.0f 
) const

Draws the tangents of the mesh (for debugging)

Parameters:
[in]cColorColor to use
[in]mWorldViewProjectionWorld view projection matrix to use
[in]fScaleTangent scale
[in]fLineWidthLine width
See also:
PLMESH_API void PLMesh::MeshHandler::DrawBinormals ( const PLGraphics::Color4 cColor,
const PLMath::Matrix4x4 mWorldViewProjection,
float  fScale = 1.0f,
float  fLineWidth = 1.0f 
) const

Draws the binormals of the mesh (for debugging)

Parameters:
[in]cColorColor to use
[in]mWorldViewProjectionWorld view projection matrix to use
[in]fScaleBinormals scale
[in]fLineWidthLine width
See also:
PLMESH_API void PLMesh::MeshHandler::DrawVertexNumbers ( PLRenderer::Font cFont,
const PLGraphics::Color4 cColor,
const PLMath::Matrix4x4 mWorldViewProjection 
) const

Draws the vertex numbers of the mesh (for debugging)

Parameters:
[in]cFontFont to use
[in]cColorColor to use
[in]mWorldViewProjectionWorld view projection matrix to use
See also:
PLMESH_API void PLMesh::MeshHandler::DrawAnchorPoints ( PLRenderer::Font cFont,
const PLGraphics::Color4 cColor,
const PLMath::Matrix4x4 mWorldViewProjection 
) const

Draws the anchor points of the mesh (for debugging)

Parameters:
[in]cFontFont to use
[in]cColorColor to use
[in]mWorldViewProjectionWorld view projection matrix to use
See also:
PLMESH_API PLCore::uint32 PLMesh::MeshHandler::GetNumOfMaterials ( ) const

Returns the number of materials.

Returns:
Number of materials
PLMESH_API PLRenderer::Material* PLMesh::MeshHandler::GetMaterial ( PLCore::uint32  nMaterial = 0) const

Gets one of the mesh handler's materials.

Parameters:
[in]nMaterialNumber of the material to get
Returns:
Pointer to the material, or a null pointer
PLMESH_API bool PLMesh::MeshHandler::SetMaterial ( PLCore::uint32  nMaterial,
PLRenderer::Material pMaterial 
)

Sets one of the mesh handler's materials.

Parameters:
[in]nMaterialNumber of the material to set
[in]pMaterialPointer to the material to set, can be a null pointer
Returns:
'true' if all went fine, else 'false'

Returns an array holding the the base weight of each morph target.

Returns:
Morph target base weights
See also:
  • Have a look at the mesh class Mesh for more morph target stuff
Note:
  • Use whenever possible the 'const' version of this function (performance)
  • The none 'const' version automatically sets the internal 'mesh update required'-flag

Returns an array holding the the current weight of each morph target.

Returns:
Current morph target weights
Note:
  • This current weights are changed automatically through animations, use the base weights to set the 'general' base weight
See also:
Note:
  • Use whenever possible the 'const' version of this function (performance)
  • The none 'const' version automatically sets the internal 'mesh update required'-flag
PLMESH_API const PLCore::Array<float>& PLMesh::MeshHandler::GetMorphTargetWeights ( ) const

Returns the skeleton handler.

Returns:
The mesh handlers skeleton handler, a null pointer if there's no such handler
Note:
  • Call "MeshUpdateRequired()" to set a "dirty"-flag if you manipulated the skeleton

Returns the mesh animation manager.

Returns:
The mesh handlers animation manager, a null pointer if there's no such manager
Note:
PLMESH_API MeshAnimationManager* PLMesh::MeshHandler::CreateMeshAnimationManager ( const PLCore::String sName = "PLMesh::MeshAnimationManagerSoftware")

Creates the mesh animation manager.

Parameters:
[in]sNameName of the mesh animation manager class to use, empty to destroy the actual manager without creating a new one
Returns:
The created mesh handlers animation manager, a null pointer on error (maybe unknown class or the class is not derived from 'PLMesh::MeshAnimationManager')
PLMESH_API void PLMesh::MeshHandler::GetAnimationsList ( PLCore::Array< PLCore::String > &  lstAnimations) const

Returns a list of all currently available animations.

Parameters:
[out]lstAnimationsReceives a list of all currently available animations (list is cleared automatically before it's filled)
See also:
PLMESH_API PLRenderer::AnimationInfo* PLMesh::MeshHandler::GetAnimationInfo ( const PLCore::String sName,
int  nLogMessage = 1 
) const

Returns a pointer to the requested animation information.

Parameters:
[in]sNameName of the animation information
[in]nLogMessageShould a warning message be written into the log if the requested animation information wasn't found? If < 0, write no log message, else the integer indicates the debug mode where the message should be written.
Returns:
Pointer to the requested animation information, a null pointer if there was an error
Remarks:
Using this function you are e.g. able to backup pointers to the animation information
in a quit comfortable way for instance in an scene node:
m_pStandAnimation = GetMeshHandler()->GetAnimationInfo("Stand");
Note:
  • This function will search for the requested animation information within the skeleton manager and the morph targets of the mesh the mesh handler is using.
PLMESH_API JointHandler* PLMesh::MeshHandler::GetJointHandler ( const PLCore::String sJointName) const

Returns a current joint handler.

Parameters:
[in]sJointNameName of the joint
Returns:
The requested current joint handler, a null pointer on error
Note:
  • Call "MeshUpdateRequired()" to set a "dirty"-flag if you manipulated the skeleton
PLMESH_API JointHandler* PLMesh::MeshHandler::GetBaseJointHandler ( const PLCore::String sJointName) const

Returns a base joint handler.

Parameters:
[in]sJointNameName of the joint
Returns:
The requested base joint handler, a null pointer on error
Note:
  • Using this base joint handler you can for instance change the initial joint settings
  • Call "MeshUpdateRequired()" to set a "dirty"-flag if you manipulated the skeleton
PLMESH_API void PLMesh::MeshHandler::UpdateVisibility ( const PLMath::PlaneSet cPlaneSet,
bool  bFirst = true 
)

Updates the mesh visibility.

Parameters:
[in]cPlaneSetPlane set we want to check against - the planes must be in the object space
[in]bFirstFirst visibility determination or add visible things?
Note:

Returns the bit set holding the geometry visibility state.

Returns:
Bitset holding the geometry visibility state
Note:
PLMESH_API PLCore::uint32 PLMesh::MeshHandler::GetNumOfLODLevels ( ) const

Returns the number of mesh LOD levels.

Returns:
The number of mesh LOD levels
See also:
PLMESH_API PLCore::uint32 PLMesh::MeshHandler::GetLODLevelIndex ( ) const

Returns the current used mesh LOD level index.

Returns:
The current used LOD level index
See also:

Returns the current used mesh LOD level.

Returns:
The current used LOD level, a null pointer on error
Note:
  • Don't manipulate the LOD level!
See also:

Calculates the current axis aligned joint bounding box.

Parameters:
[out]cAABWill receive the current axis aligned joint bounding box
Returns:
'true' if all went fine, else 'false'

Returns the current used vertex buffer of the mesh.

Returns:
Current used vertex buffer of the mesh, can be a null pointer
Note:
  • You shouldn't manipulate this vertex buffer - use it for read only! Internally the mesh handler will use the meshes vertex buffer directly whenever possible, but if there are e.g. animations the mesh handler has it's own vertex buffer with the current individual data.
See also:
PLMESH_API PLCore::uint32 PLMesh::MeshHandler::GetNumOfTriangles ( ) const

Returns the total number of current triangles.

Returns:
Total number of current triangles
PLMESH_API bool PLMesh::MeshHandler::FindTriangle ( const PLMath::Vector3 vLineStartPos,
const PLMath::Vector3 vLineEndPos,
PLCore::uint32 &  nTriangle,
PLCore::uint32 *  pnGeometry = nullptr,
PLMath::Vector3 pvCollisionPoint = nullptr,
PLCore::Array< PLCore::uint32 > *  plstGeometries = nullptr 
) const

Returns the first mesh triangle intersecting the line.

Parameters:
[in]vLineStartPosLine start position
[in]vLineEndPosLine end position
[out]nTriangleWill receive the ID of the found triangle
[out]pnGeometryReceives the owner geometry ID of the found triangle if not a null pointer
[out]pvCollisionPointWill receive the collision point if not a null pointer
[in]plstGeometriesList of geometry indices to use, if a null pointer all geometries are used
Returns:
'true' if a triangle was found, else 'false'
Note:
  • The line is assumed to be in the object space of the mesh handlers mesh
PLMESH_API PLCore::uint32 PLMesh::MeshHandler::FindGeometries ( const PLMath::PlaneSet cPlaneSet,
PLCore::uint32 **  ppnGeometries = nullptr,
PLMath::Vector3 pvCamDir = nullptr 
) const

Returns a list of mesh geometries intersecting the plane set.

Parameters:
[in]cPlaneSetPlane set we want to check against
[out]ppnGeometriesIf not a null pointer, receives the geometries intersecting the plane set. You have to delete this list by self after usage! (delete [] ...)
[in]pvCamDirCamera direction vector, if not null faces where the normal is facing away from the given camera direction are ignored
Returns:
Number of found geometries if all went fine, else 0
Note:
  • The the planes must be in the object space

Gets the triangle list.

Returns:
Triangle list, a null pointer on error
See also:

Gets the edge list.

Returns:
Edge list, a null pointer on error
See also:

Builds the current triangle planes.

Note:
  • The triangle planes must be updated after manipulating geometries or vertices!
  • If the triangle list is available (MeshLODLevel::GetTriangleList()) it will be used for faster triangle plane calculation, else the slower GetTriangle() is used instead.

Gets the triangle plane list.

Returns:
Triangle plane list, a null pointer on error
Note:
  • If the mesh handler currently is using the original morph target vertex data the triangle planes of this morph target will be returned. But if the mesh handler is using an animated mesh it will need it's individual triangle planes!
See also:

The documentation for this class was generated from the following file:


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:21
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported