Keos::CMesh Class Reference

Resource holding data about 3D mesh. More...

#include <KeosMesh.h>

Inheritance diagram for Keos::CMesh:

Inheritance graph
[legend]
List of all members.

Public Types

typedef std::vector< CMaterial * > TMaterialList

Public Member Functions

 CMesh ()
 Default constructor.
virtual ~CMesh ()
 Destructor.
void Render () const
 Render the model.
uint GetTrianglesCount (void)
 Return the number of triangles/faces in the Mesh.
void CreateSharedVertexBuffer (const CMeshGeom::TVertex *pVertices, ulong nVerticesCount)
 Create the shared vertex buffer.
void ComputeNormals ()
 Compute the normals for each vertex.
void AddMeshGeom (CMeshGeom *pMeshGeom)
 Add a new MeshGeom.
void AddMeshGeom (CMeshGeom *pMeshGeom, const String &strName)
 Add a new MeshGeom and gives it a name.
void NameMeshGeom (const String &strName, ushort nIndex)
 Gives a name to a MeshGeom.
ushort GetNumMeshGeom (void) const
 Gets the number of MeshGeom which comprise this Mesh.
CMeshGeomGetMeshGeom (ushort nIndex) const
 Gets a pointer to the MeshGeom indicated by the index.
CMeshGeomGetMeshGeom (const String &strName) const
 Gets a MeshGeom by name.
ushort _GetMeshGeomIndex (const String &strName) const
 Gets the index of a MeshGeom with a given name.
TMaterialListGetMaterialList ()
 Gets the material list.
CMaterialGetMaterial (ushort nIndex)
 Gets a pointer to the Material indicated by the index.
size_t GetLastAddedMaterialIndex (void)
 Gets the last added material index.
size_t GetMaterialsCount (void)
 Gets the number of materials.
void AddMaterial (CMaterial *pMaterial)
 Add a material.
void AddMaterial (CMaterial *pMaterial, ushort nMeshGeomIndex)
 Add a material and assign it to the MeshGeom specified by the index.

Protected Types

typedef std::vector< CMeshGeom * > TMeshGeomList
 A list of MeshGeom which make up this mesh.
typedef std::map< String,
ushort
TMeshGeomNameMap
 A hashmap used to store optional MeshGeom names.

Protected Attributes

CBuffer< CMeshGeom::TVertexm_SharedVertexBuffer
 Shared vertex buffer.
TMaterialList m_MaterialList
 List of materials.
TMeshGeomList m_MeshGeomList
TMeshGeomNameMap m_MeshGeomNameMap

Friends

class CMeshGeom

Detailed Description

Resource holding data about 3D mesh.

A CMesh is a collection of some MeshGeoms (CMeshGeom) and a list of materials.

Definition at line 35 of file KeosMesh.h.


Member Typedef Documentation

typedef std::vector<CMaterial*> Keos::CMesh::TMaterialList

Definition at line 113 of file KeosMesh.h.

typedef std::vector<CMeshGeom*> Keos::CMesh::TMeshGeomList [protected]

A list of MeshGeom which make up this mesh.

Each mesh is made up of 1 or more MeshGeom, which are each based on a single material and can have their own vertex data or they can share vertex data from the Mesh).

Definition at line 176 of file KeosMesh.h.

typedef std::map<String, ushort> Keos::CMesh::TMeshGeomNameMap [protected]

A hashmap used to store optional MeshGeom names.

Translates a name into MeshGeom index

Definition at line 182 of file KeosMesh.h.


Constructor & Destructor Documentation

Keos::CMesh::CMesh (  ) 

Default constructor.

Definition at line 38 of file KeosMesh.cpp.

Keos::CMesh::~CMesh (  )  [virtual]

Destructor.

Definition at line 42 of file KeosMesh.cpp.

References m_MaterialList, and m_MeshGeomList.


Member Function Documentation

void Keos::CMesh::Render (  )  const

Render the model.

Definition at line 49 of file KeosMesh.cpp.

References Keos::CMeshGeom::GetMaterialIndex(), Keos::CMeshGeom::m_bUseSharedVertexBuffer, Keos::CMeshGeom::m_IndexBuffer, m_MaterialList, m_MeshGeomList, Keos::CMeshGeom::m_nPrimitivesCount, Keos::CMeshGeom::m_pDeclaration, Keos::CMeshGeom::m_PrimitiveType, m_SharedVertexBuffer, Keos::CMeshGeom::m_VertexBuffer, and Renderer.

Referenced by Keos::CAnimatedMeshKF::Animate().

uint Keos::CMesh::GetTrianglesCount ( void   ) 

Return the number of triangles/faces in the Mesh.

Definition at line 77 of file KeosMesh.cpp.

References m_MeshGeomList.

void Keos::CMesh::CreateSharedVertexBuffer ( const CMeshGeom::TVertex pVertices,
ulong  nVerticesCount 
)

Create the shared vertex buffer.

Parameters:
pVertices Pointer on vertex array.
nVerticesCount Number of vertices.

Definition at line 89 of file KeosMesh.cpp.

References Assert, m_SharedVertexBuffer, and Renderer.

void Keos::CMesh::ComputeNormals (  ) 

Compute the normals for each vertex.

Todo:
Check that the normals compute is correct for all primitives types
  • TRIANGLELIST --> OK
  • TRIANGLESTRIP --> ?????

Definition at line 96 of file KeosMesh.cpp.

References Keos::CMeshGeom::GetTrianglesCount(), Keos::CVector3< T >::LengthSq(), Keos::LOCK_READONLY, Keos::LOCK_WRITEONLY, Keos::CMeshGeom::m_bUseSharedVertexBuffer, Keos::CMeshGeom::m_IndexBuffer, m_MeshGeomList, m_SharedVertexBuffer, Keos::CMeshGeom::m_VertexBuffer, Keos::CMeshGeom::TVertex::Normal, Keos::CVector3< T >::Normalize(), Keos::CMeshGeom::TVertex::Position, Keos::VectorBetweenTwoPoints(), and Keos::VectorCross().

Referenced by Keos::C3DSLoader::LoadFromFile(), and Keos::CMeshGen::MakeCube().

void Keos::CMesh::AddMeshGeom ( CMeshGeom pMeshGeom  )  [inline]

Add a new MeshGeom.

Definition at line 71 of file KeosMesh.h.

References Keos::CMeshGeom::m_pParentMesh.

Referenced by Keos::CMDLQ1Loader::LoadFromFile(), Keos::CMDLQ1AnimatedLoader::LoadFromFile(), Keos::CMD2Loader::LoadFromFile(), Keos::CMD2AnimatedLoader::LoadFromFile(), Keos::CMeshGen::MakeCube(), and Keos::CMeshGen::MakeSphere().

void Keos::CMesh::AddMeshGeom ( CMeshGeom pMeshGeom,
const String strName 
) [inline]

Add a new MeshGeom and gives it a name.

Definition at line 79 of file KeosMesh.h.

void Keos::CMesh::NameMeshGeom ( const String strName,
ushort  nIndex 
) [inline]

Gives a name to a MeshGeom.

Definition at line 87 of file KeosMesh.h.

ushort Keos::CMesh::GetNumMeshGeom ( void   )  const [inline]

Gets the number of MeshGeom which comprise this Mesh.

Definition at line 94 of file KeosMesh.h.

CMeshGeom * Keos::CMesh::GetMeshGeom ( ushort  nIndex  )  const

Gets a pointer to the MeshGeom indicated by the index.

Definition at line 204 of file KeosMesh.cpp.

References m_MeshGeomList.

Referenced by GetMeshGeom().

CMeshGeom * Keos::CMesh::GetMeshGeom ( const String strName  )  const

Gets a MeshGeom by name.

Definition at line 197 of file KeosMesh.cpp.

References _GetMeshGeomIndex(), and GetMeshGeom().

ushort Keos::CMesh::_GetMeshGeomIndex ( const String strName  )  const

Gets the index of a MeshGeom with a given name.

Definition at line 211 of file KeosMesh.cpp.

References m_MeshGeomNameMap.

Referenced by GetMeshGeom().

TMaterialList& Keos::CMesh::GetMaterialList (  )  [inline]

Gets the material list.

Definition at line 117 of file KeosMesh.h.

CMaterial* Keos::CMesh::GetMaterial ( ushort  nIndex  )  [inline]

Gets a pointer to the Material indicated by the index.

Definition at line 124 of file KeosMesh.h.

Referenced by Keos::CMeshGeom::AssignMaterialColor().

size_t Keos::CMesh::GetLastAddedMaterialIndex ( void   )  [inline]

Gets the last added material index.

Definition at line 131 of file KeosMesh.h.

size_t Keos::CMesh::GetMaterialsCount ( void   )  [inline]

Gets the number of materials.

Definition at line 138 of file KeosMesh.h.

Referenced by Keos::CMeshGeom::AssignMaterialColor().

void Keos::CMesh::AddMaterial ( CMaterial pMaterial  )  [inline]

Add a material.

Parameters:
pMaterial Pointer on the material.

Definition at line 146 of file KeosMesh.h.

Referenced by Keos::CMDLQ1Loader::LoadFromFile(), Keos::CMDLQ1AnimatedLoader::LoadFromFile(), Keos::CMD2Loader::LoadFromFile(), Keos::CMD2AnimatedLoader::LoadFromFile(), Keos::CMeshGen::MakeCube(), and Keos::CMeshGen::MakeSphere().

void Keos::CMesh::AddMaterial ( CMaterial pMaterial,
ushort  nMeshGeomIndex 
) [inline]

Add a material and assign it to the MeshGeom specified by the index.

Parameters:
pMaterial Pointer on the material.
nMeshGeomIndex Index of MeshGeom.

Definition at line 155 of file KeosMesh.h.


Friends And Related Function Documentation

friend class CMeshGeom [friend]

Definition at line 37 of file KeosMesh.h.


Member Data Documentation

CBuffer<CMeshGeom::TVertex> Keos::CMesh::m_SharedVertexBuffer [protected]

Shared vertex buffer.

Definition at line 165 of file KeosMesh.h.

Referenced by Keos::CMeshGeom::AssignColor(), ComputeNormals(), CreateSharedVertexBuffer(), and Render().

TMaterialList Keos::CMesh::m_MaterialList [protected]

List of materials.

Definition at line 168 of file KeosMesh.h.

Referenced by Render(), and ~CMesh().

TMeshGeomList Keos::CMesh::m_MeshGeomList [protected]

Definition at line 177 of file KeosMesh.h.

Referenced by ComputeNormals(), GetMeshGeom(), GetTrianglesCount(), Render(), and ~CMesh().

TMeshGeomNameMap Keos::CMesh::m_MeshGeomNameMap [protected]

Definition at line 183 of file KeosMesh.h.

Referenced by _GetMeshGeomIndex().


The documentation for this class was generated from the following files:
Generated on Fri Mar 9 14:29:26 2007 for Keos by  doxygen 1.5.1-p1