PixelLightAPI  .
Public Types | Public Member Functions
PLMesh::Mesh Class Reference

Mesh class. More...

#include <Mesh.h>

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

List of all members.

Public Types

enum  EFlags { DrawVertices = 1<<0, DrawNormals = 1<<1, DrawOctree = 1<<2 }
 Mesh draw flags. More...

Public Member Functions

virtual PLMESH_API ~Mesh ()
 Destructor.
PLMESH_API MeshManagerGetMeshManager () const
 Returns the owner mesh manager.
PLMESH_API SkeletonManagerGetSkeletonManager ()
 Returns the skeleton manager.
PLMESH_API PLRenderer::RendererGetRenderer () const
 Returns the used renderer.
PLMESH_API PLCore::uint32 GetMaxNumOfVertices () const
 Checks all LODs and returns the maximum number of vertices.
PLMESH_API PLCore::uint32 GetMaxNumOfGeometries () const
 Checks all LODs and returns the maximum number of geometries.
PLMESH_API PLCore::uint32 GetMaxNumOfTriangles () const
 Checks all LODs and returns the maximum number of triangles.
PLMESH_API void Draw (const PLMath::Matrix4x4 &mWorldViewProjection, bool bBlend=false, PLCore::uint32 nFlags=0, PLCore::uint32 nLODLevel=0, PLCore::uint32 nMorphTarget=0, bool bUseMaterials=true) const
 Draws the mesh.
PLMESH_API Meshoperator= (const Mesh &cSource)
 Copy operator.
PLMESH_API AnchorPointManagerGetAnchorPointManager ()
 Returns the anchor point manager.
PLMESH_API void ClearMorphTargets ()
 Clears all morph targets.
PLMESH_API PLCore::uint32 GetNumOfMorphTargets () const
 Returns the number of morph targets.
PLMESH_API MeshMorphTargetAddMorphTarget ()
 Adds a new morph target.
PLMESH_API MeshMorphTargetGetMorphTarget (PLCore::uint32 nMorphTarget=0) const
 Gets one of the mesh's morph targets by index.
PLMESH_API MeshMorphTargetGetMorphTarget (const PLCore::String &sName) const
 Gets one of the mesh's morph targets by name.
PLMESH_API int GetMorphTargetIndex (const PLCore::String &sName) const
 Returns the index of a given morph target.
PLMESH_API MorphTargetAniManagerGetMorphTargetAnimationManager ()
 Returns the morph target animation manager.
PLMESH_API bool AddMorphTargetAnimation (const PLCore::String &sFilename)
 Adds a morph target animation.
PLMESH_API void ClearLODLevels ()
 Clears all LOD levels.
PLMESH_API PLCore::uint32 GetNumOfLODLevels () const
 Returns the number of LOD levels.
PLMESH_API MeshLODLevelAddLODLevel ()
 Adds a new LOD level.
PLMESH_API MeshLODLevelGetLODLevel (PLCore::uint32 nLODLevel=0) const
 Gets one of the mesh's LOD levels.
PLMESH_API void ClearMaterials ()
 Clears all materials.
PLMESH_API PLCore::uint32 GetNumOfMaterials () const
 Returns the number of materials.
PLMESH_API PLRenderer::MaterialAddMaterial (PLRenderer::Material *pMaterial)
 Adds a new material.
PLMESH_API bool DeleteMaterial (PLCore::uint32 nMaterial)
 Deletes a material.
PLMESH_API PLCore::uint32 GetMaterialUsage (PLCore::uint32 nMaterial) const
 Returns the number of geometries using this material.
PLMESH_API PLRenderer::MaterialGetMaterial (PLCore::uint32 nMaterial=0) const
 Gets one of the mesh's materials.
PLMESH_API bool SetMaterial (PLCore::uint32 nMaterial, PLRenderer::Material *pMaterial)
 Sets one of the mesh's materials.
PLMESH_API void ClearSkeletonHandlers ()
 Clears the list of skeleton handlers.
PLMESH_API PLCore::Array
< SkeletonHandler * > & 
GetSkeletonHandlers ()
 Returns the list of skeleton handlers.
PLMESH_API PLCore::Array
< Weight > & 
GetWeights ()
 Returns the weights array.
PLMESH_API PLCore::Array
< VertexWeights > & 
GetVertexWeights ()
 Returns the vertex weights array.
PLMESH_API void BuildConnectivity ()
 Builds the connectivity information of all LOD levels.
PLMESH_API void BuildTrianglePlaneList ()
 Builds the current triangle planes of all morph targets.
PLMESH_API bool BuildLOD (PLCore::uint32 nNumLODLevels)
 Builds the LOD levels automatically.
PLMESH_API bool CalculateNormals ()
 Calculate the vertex normals of all morph targets of the mesh.
PLMESH_API bool CalculateTangentSpaceVectors (bool bTangent=true, bool bBinormal=true)
 Calculates all tangent space vectors of all morph targets of the mesh.
PLMESH_API void GetBoundingBox (PLMath::Vector3 &vMin, PLMath::Vector3 &vMax) const
 Returns the mesh bounding box.
PLMESH_API void SetBoundingBox (const PLMath::Vector3 &vMin, const PLMath::Vector3 &vMax)
 Set's the mesh bounding box.
PLMESH_API bool CalculateBoundingBox (PLMath::Vector3 &vMin, PLMath::Vector3 &vMax)
 Calculates the mesh bounding box.
PLMESH_API bool CalculateBoundingSphere (PLMath::Vector3 &vPos, float &fRadius)
 Calculates the mesh bounding sphere.
virtual PLMESH_API bool Unload () override
 Unloads the loadable.
virtual PLMESH_API PLCore::String GetLoadableTypeName () const override
 Returns the loadable type name.

Detailed Description

Mesh class.

Remarks:
A mesh defining a 3D mesh consists of several information:
Animations (list of predefined animations)
Anchor points (anchor points are in fact a kind of index to a vertex)
Morph targets (that contains the vertex data for every frame)
LOD levels (each of which can define the geometries and/or index data)
Skeleton (that defines a hierarchical structure on the mesh)
Materials (list of materials used by the mesh)

Member Enumeration Documentation

Mesh draw flags.

Enumerator:
DrawVertices 

Draw vertices

DrawNormals 

Draw normals

DrawOctree 

Draw (optional) octree


Constructor & Destructor Documentation

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

Destructor.


Member Function Documentation

Returns the owner mesh manager.

Returns:
Pointer to the owner mesh manager, a null pointer on error

Returns the skeleton manager.

Returns:
The skeleton manager

Returns the used renderer.

Returns:
Pointer to the renderer the mesh uses, can be a null pointer
PLMESH_API PLCore::uint32 PLMesh::Mesh::GetMaxNumOfVertices ( ) const

Checks all LODs and returns the maximum number of vertices.

Returns:
Maximum number of vertices
PLMESH_API PLCore::uint32 PLMesh::Mesh::GetMaxNumOfGeometries ( ) const

Checks all LODs and returns the maximum number of geometries.

Returns:
Maximum number of geometries
PLMESH_API PLCore::uint32 PLMesh::Mesh::GetMaxNumOfTriangles ( ) const

Checks all LODs and returns the maximum number of triangles.

Returns:
Maximum number of triangles
PLMESH_API void PLMesh::Mesh::Draw ( const PLMath::Matrix4x4 mWorldViewProjection,
bool  bBlend = false,
PLCore::uint32  nFlags = 0,
PLCore::uint32  nLODLevel = 0,
PLCore::uint32  nMorphTarget = 0,
bool  bUseMaterials = true 
) const

Draws the mesh.

Parameters:
[in]mWorldViewProjectionWorld view projection matrix to use
[in]bBlendDraw only mesh parts which use a blended material?
[in]nFlagsDraw flags (use EFlags)
[in]nLODLevelWhich LOD level to use
[in]nMorphTargetWhich morph target to use
[in]bUseMaterialsUse the mesh materials? If 'false' no material is bound.
Note:
  • Use this function only if you know that there's only one special usage of the mesh. (for instance you dynamically change it) Normally you should use a mesh handler to handle the mesh
PLMESH_API Mesh& PLMesh::Mesh::operator= ( const Mesh cSource)

Copy operator.

Parameters:
[in]cSourceSource to copy from
Returns:
This mesh

Returns the anchor point manager.

Returns:
The anchor point manager of the mesh
Remarks:
To add an anchor point to the manager you can e.g. do the following:
AnchorPoint *pAnchorPoint = new AnchorPoint("LeftHand", 0,
99, &pMyMesh->GetAnchorPointManager());
PLMESH_API void PLMesh::Mesh::ClearMorphTargets ( )

Clears all morph targets.

PLMESH_API PLCore::uint32 PLMesh::Mesh::GetNumOfMorphTargets ( ) const

Returns the number of morph targets.

Returns:
Number of morph targets the mesh contains

Adds a new morph target.

Returns:
Pointer to the new morph target, a null pointer on error
PLMESH_API MeshMorphTarget* PLMesh::Mesh::GetMorphTarget ( PLCore::uint32  nMorphTarget = 0) const

Gets one of the mesh's morph targets by index.

Parameters:
[in]nMorphTargetNumber of the morph target to get
Returns:
Pointer to the morph target, or a null pointer
PLMESH_API MeshMorphTarget* PLMesh::Mesh::GetMorphTarget ( const PLCore::String sName) const

Gets one of the mesh's morph targets by name.

Parameters:
[in]sNameName of the morph target to get
Returns:
Pointer to the morph target, or a null pointer
PLMESH_API int PLMesh::Mesh::GetMorphTargetIndex ( const PLCore::String sName) const

Returns the index of a given morph target.

Parameters:
[in]sNameName of the morph target the index should be returned
Returns:
The index of the given morph target, < 0 if the morph target wasn't found

Returns the morph target animation manager.

Returns:
The morph target animation manager
Remarks:
To add an morph target animation to the manager you can e.g. do the following:
MorphTargetAni *pAnimation = new MorphTargetAni(&pMyMesh->GetMorphTargetAnimationManager());
PLMESH_API bool PLMesh::Mesh::AddMorphTargetAnimation ( const PLCore::String sFilename)

Adds a morph target animation.

Parameters:
[in]sFilenameMorph target animation filename
Returns:
'true' if all went fine, else 'false'
PLMESH_API void PLMesh::Mesh::ClearLODLevels ( )

Clears all LOD levels.

PLMESH_API PLCore::uint32 PLMesh::Mesh::GetNumOfLODLevels ( ) const

Returns the number of LOD levels.

Returns:
Number of LOD levels the mesh contains

Adds a new LOD level.

Returns:
Pointer to the new LOD level, a null pointer on error
PLMESH_API MeshLODLevel* PLMesh::Mesh::GetLODLevel ( PLCore::uint32  nLODLevel = 0) const

Gets one of the mesh's LOD levels.

Parameters:
[in]nLODLevelNumber of the LOD level to get
Returns:
Pointer to the LOD level, or a null pointer
PLMESH_API void PLMesh::Mesh::ClearMaterials ( )

Clears all materials.

PLMESH_API PLCore::uint32 PLMesh::Mesh::GetNumOfMaterials ( ) const

Returns the number of materials.

Returns:
Number of materials

Adds a new material.

Parameters:
[in]pMaterialMaterial to add, if a null pointer, nothing happens
Returns:
Pointer to the added material, a null pointer on error
PLMESH_API bool PLMesh::Mesh::DeleteMaterial ( PLCore::uint32  nMaterial)

Deletes a material.

Parameters:
[in]nMaterialNumber of the material to delete
Returns:
'true' if all went fine else 'false'
Note:
  • If the deleted material was used by a geometry the geometry material index will be set to 0
  • The material index of the geometries will automatically corrected if the material index has changed
PLMESH_API PLCore::uint32 PLMesh::Mesh::GetMaterialUsage ( PLCore::uint32  nMaterial) const

Returns the number of geometries using this material.

Parameters:
[in]nMaterialNumber of the material to check
Returns:
Number of geometries using this material
Note:
  • Use this function for instance to find unused materials in order to delete them
PLMESH_API PLRenderer::Material* PLMesh::Mesh::GetMaterial ( PLCore::uint32  nMaterial = 0) const

Gets one of the mesh's materials.

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

Sets one of the mesh'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'

Clears the list of skeleton handlers.

Note:
  • The skeletons are managed by the global skeleton manager, the meshes only can have a list of skeletons 'assigned' to them. This skeletons for instance are saved/loaded directly within the mesh file.
  • By default the mesh has no skeleton assigned to it
  • The first skeleton is the base skeleton, all other are for instance additional animations assigned with this mesh
  • See MeshLODLevel::GetVertexWeights()

Returns the list of skeleton handlers.

Returns:
The list of skeleton handlers
See also:

Returns the weights array.

Returns:
Weights array
Note:
  • The weights are optional, but required for mesh skinning

Returns the vertex weights array.

Returns:
Vertex weights array
Note:
  • The number of vertices in this array should always be the same number as the number of vertices within the vertex buffer of this LOD level! (see MeshMorphTarget::GetVertexBuffer())
  • The vertex weights are optional, but required for mesh skinning
PLMESH_API void PLMesh::Mesh::BuildConnectivity ( )

Builds the connectivity information of all LOD levels.

Note:

Builds the current triangle planes of all morph targets.

Note:
PLMESH_API bool PLMesh::Mesh::BuildLOD ( PLCore::uint32  nNumLODLevels)

Builds the LOD levels automatically.

Parameters:
[in]nNumLODLevelsNumber of LOD levels to create (including the original)
Returns:
'true' if all went fine, else 'false'
Note:
  • The first LOD level and morph target must exist already
PLMESH_API bool PLMesh::Mesh::CalculateNormals ( )

Calculate the vertex normals of all morph targets of the mesh.

Returns:
'true' if all went fine, else 'false'
Note:
  • This function will add normals to the vertex buffer if there are no one allocated yet
PLMESH_API bool PLMesh::Mesh::CalculateTangentSpaceVectors ( bool  bTangent = true,
bool  bBinormal = true 
)

Calculates all tangent space vectors of all morph targets of the mesh.

Parameters:
[in]bTangentCreate tangent vectors?
[in]bBinormalCreate binormal vectors?
Returns:
'true' if all went fine, else 'false'
Note:
  • This function will add tangents and binormals to the vertex buffer if there are no one allocated yet
  • If there are no normals available they will be computed (see CalculateNormals())
  • To save memory one can only hold tangent vectors and compute the binormal for instance within a vertex shader using a cross product of the normal and tangent vector
PLMESH_API void PLMesh::Mesh::GetBoundingBox ( PLMath::Vector3 vMin,
PLMath::Vector3 vMax 
) const

Returns the mesh bounding box.

Parameters:
[out]vMinWill receive the minimum bounding box position
[out]vMaxWill receive the maximum bounding box position
Remarks:
This bounding box should enclose the whole mesh. If it is a 0-bounding box you can use CalculateBoundingBox() to calculate a valid bounding box.
PLMESH_API void PLMesh::Mesh::SetBoundingBox ( const PLMath::Vector3 vMin,
const PLMath::Vector3 vMax 
)

Set's the mesh bounding box.

Parameters:
[in]vMinThe minimum bounding box position
[in]vMaxThe maximum bounding box position
See also:
PLMESH_API bool PLMesh::Mesh::CalculateBoundingBox ( PLMath::Vector3 vMin,
PLMath::Vector3 vMax 
)

Calculates the mesh bounding box.

Parameters:
[out]vMinWill receive the minimum bounding box position
[out]vMaxWill receive the maximum bounding box position
Returns:
'true' if all went fine, else 'false'
Note:
  • This function will take all morph targets into account
  • The internal mesh bounding box is NOT manipulated!
PLMESH_API bool PLMesh::Mesh::CalculateBoundingSphere ( PLMath::Vector3 vPos,
float &  fRadius 
)

Calculates the mesh bounding sphere.

Parameters:
[out]vPosWill receive the bounding sphere position
[out]fRadiusWill receive the bounding sphere radius
Returns:
'true' if all went fine, else 'false'
Note:
  • This function will take all morph targets into account
virtual PLMESH_API bool PLMesh::Mesh::Unload ( ) [override, virtual]

Unloads the loadable.

Returns:
'true' if all went fine, else 'false'

Reimplemented from PLCore::Loadable.

virtual PLMESH_API PLCore::String PLMesh::Mesh::GetLoadableTypeName ( ) const [override, virtual]

Returns the loadable type name.

Returns:
The loadable type name

Reimplemented from PLCore::Loadable.


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


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:36
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported