Castor3D  ..
Classes | Public Member Functions | Friends | List of all members
Castor3D::Submesh Class Reference

The submesh representation. More...

+ Inheritance diagram for Castor3D::Submesh:
+ Collaboration diagram for Castor3D::Submesh:

Classes

class  BinaryParser
 MovableObject loader. More...
 
class  TextLoader
 Submesh text loader. More...
 

Public Member Functions

C3D_API Submesh (Engine &p_engine, MeshRPtr p_mesh, uint32_t p_id=1)
 Constructor. More...
 
C3D_API ~Submesh ()
 Destructor. More...
 
C3D_API void Initialise ()
 Initialises the submesh. More...
 
C3D_API void Cleanup ()
 Cleans the submesh. More...
 
C3D_API void ComputeContainers ()
 Computes the containers (cube and sphere) More...
 
C3D_API uint32_t GetFaceCount () const
 
C3D_API uint32_t GetPointsCount () const
 
C3D_API int IsInMyPoints (Castor::Point3r const &p_vertex, double p_precision)
 Tests if the given Point3r is in mine. More...
 
C3D_API BufferElementGroupSPtr AddPoint (real x, real y, real z)
 Creates and adds a vertex to my list. More...
 
C3D_API BufferElementGroupSPtr AddPoint (Castor::Point3r const &p_v)
 Adds a vertex to my list. More...
 
C3D_API BufferElementGroupSPtr AddPoint (real *p_v)
 Creates and adds a vertex to my list. More...
 
C3D_API void AddPoints (stVERTEX_GROUP const &p_vertices)
 Adds a points list to my list. More...
 
C3D_API void AddBoneDatas (stVERTEX_BONE_DATA const *const p_boneDataBegin, stVERTEX_BONE_DATA const *const p_boneDataEnd)
 Adds bone datas. More...
 
void AddBoneDatas (stVERTEX_BONE_DATA const *const p_boneData, uint32_t p_count)
 Adds bone datas. More...
 
void AddBoneDatas (std::vector< stVERTEX_BONE_DATA > const &p_boneData)
 Adds bone datas. More...
 
template<uint32_t Count>
void AddBoneDatas (stVERTEX_BONE_DATA const (&p_boneData)[Count])
 Adds bone datas. More...
 
C3D_API void ClearFaces ()
 Clears this submesh's face array. More...
 
C3D_API Face AddFace (uint32_t a, uint32_t b, uint32_t c)
 Creates and adds a face to the submesh. More...
 
C3D_API void AddFaceGroup (stFACE_INDICES *p_faces, uint32_t p_count)
 Creates and adds faces to the submesh. More...
 
C3D_API void AddQuadFace (uint32_t a, uint32_t b, uint32_t c, uint32_t d, Castor::Point3r const &p_minUV=Castor::Point3r(), Castor::Point3r const &p_maxUV=Castor::Point3r(1, 1, 1))
 Creates and adds a quad face to the submesh. More...
 
C3D_API SubmeshSPtr Clone ()
 Clones the submesh and returns the clone. More...
 
C3D_API void ResetGpuBuffers ()
 Recreates the Vertex and Index buffers. More...
 
C3D_API void Draw (ShaderProgram const &p_program)
 Draws the submesh. More...
 
C3D_API void DrawInstanced (ShaderProgram const &p_program, uint32_t p_count)
 Draws the submesh. More...
 
C3D_API void ComputeFacesFromPolygonVertex ()
 Creates faces from the points. More...
 
C3D_API void ComputeNormals (bool p_reverted=false)
 Generates normals and tangents. More...
 
C3D_API void ComputeNormals (Face const &p_face)
 Computes normal and tangent for each vertex of the given face. More...
 
C3D_API void ComputeTangents (Face const &p_face)
 Computes tangent for each vertex of the given face. More...
 
C3D_API void ComputeTangentsFromNormals ()
 Computes tangent for each vertex of the submesh. More...
 
C3D_API void ComputeTangentsFromBitangents ()
 Computes tangent for each vertex of the submesh. More...
 
C3D_API void ComputeBitangents ()
 Computes bitangent for each vertex of the submesh. More...
 
C3D_API void SortFaces (Castor::Point3r const &p_cameraPosition)
 Sorts the face from farthest to nearest from the camera. More...
 
C3D_API void Ref (MaterialSPtr p_material)
 Increments instance count. More...
 
C3D_API void UnRef (MaterialSPtr p_material)
 Decrements instance count. More...
 
C3D_API uint32_t GetRefCount (MaterialSPtr p_material) const
 Retrieves the instances count. More...
 
C3D_API eTOPOLOGY GetTopology () const
 
C3D_API void SetTopology (eTOPOLOGY p_value)
 Sets the topology. More...
 
SkeletonSPtr GetSkeleton () const
 Retrieves the skeleton. More...
 
void SetDefaultMaterial (MaterialSPtr p_mat)
 Sets the material. More...
 
BufferElementGroupSPtr operator[] (uint32_t p_index) const
 Retrieves the point at given index. More...
 
BufferElementGroupSPtr GetPoint (uint32_t p_index) const
 Retrieves the point at given index. More...
 
MaterialSPtr GetDefaultMaterial () const
 Retrieves the material. More...
 
Castor::CubeBox const & GetCubeBox () const
 Retrieves the cube bounding box. More...
 
Castor::CubeBox & GetCubeBox ()
 Retrieves the cube bounding box. More...
 
Castor::SphereBox const & GetSphere () const
 Retrieves the sphere bounding box. More...
 
Castor::SphereBox & GetSphere ()
 Retrieves the sphere bounding box. More...
 
VertexPtrArray const & GetPoints () const
 Retrieves the points array. More...
 
VertexPtrArray & GetPoints ()
 Retrieves the points array. More...
 
Face const & GetFace (uint32_t p_index) const
 Retrieves the face at given index. More...
 
FaceArray const & GetFaces () const
 Retrieves the faces array. More...
 
FaceArray & GetFaces ()
 Retrieves the faces array. More...
 
bool HasVertexBuffer () const
 
bool HasIndexBuffer () const
 
bool HasBonesBuffer () const
 
bool HasMatrixBuffer () const
 
VertexBuffer const & GetVertexBuffer () const
 
VertexBufferGetVertexBuffer ()
 
IndexBuffer const & GetIndexBuffer () const
 
IndexBufferGetIndexBuffer ()
 
VertexBuffer const & GetBonesBuffer () const
 
VertexBufferGetBonesBuffer ()
 
VertexBuffer const & GetMatrixBuffer () const
 
VertexBufferGetMatrixBuffer ()
 
bool IsInitialised () const
 Retrieves the initialisation status. More...
 
MeshRPtr GetParent () const
 Retrieves the parent mesh. More...
 
uint32_t GetProgramFlags () const
 Retrieves the shader program flags. More...
 
template<uint32_t Count>
void AddFaceGroup (stFACE_INDICES(&p_faces)[Count])
 Creates and adds faces to the submesh. More...
 

Friends

class GeometryBuffers
 

Detailed Description

The submesh representation.

Author
Sylvain DOREMUS
Date
14/02/2010
Remarks
A submesh holds its buffers (vertex, normals and texture) and its combobox.

Constructor & Destructor Documentation

◆ Submesh()

C3D_API Castor3D::Submesh::Submesh ( Engine p_engine,
MeshRPtr  p_mesh,
uint32_t  p_id = 1 
)

Constructor.

Parameters
[in]p_meshThe parent mesh
[in]p_engineThe core engine
[in]p_idThe submesh ID

◆ ~Submesh()

C3D_API Castor3D::Submesh::~Submesh ( )

Destructor.

Member Function Documentation

◆ AddBoneDatas() [1/4]

C3D_API void Castor3D::Submesh::AddBoneDatas ( stVERTEX_BONE_DATA const *const  p_boneDataBegin,
stVERTEX_BONE_DATA const *const  p_boneDataEnd 
)

Adds bone datas.

Parameters
[in]p_boneDataBeginThe bone datas begin.
[in]p_boneDataEndThe bone datas end.

Referenced by AddBoneDatas().

+ Here is the caller graph for this function:

◆ AddBoneDatas() [2/4]

void Castor3D::Submesh::AddBoneDatas ( stVERTEX_BONE_DATA const *const  p_boneData,
uint32_t  p_count 
)
inline

Adds bone datas.

Parameters
[in]p_boneDataThe bone datas.
[in]p_countThe data count.

References AddBoneDatas().

+ Here is the call graph for this function:

◆ AddBoneDatas() [3/4]

void Castor3D::Submesh::AddBoneDatas ( std::vector< stVERTEX_BONE_DATA > const &  p_boneData)
inline

Adds bone datas.

Parameters
[in]p_boneDataThe bone datas.

References AddBoneDatas().

+ Here is the call graph for this function:

◆ AddBoneDatas() [4/4]

template<uint32_t Count>
void Castor3D::Submesh::AddBoneDatas ( stVERTEX_BONE_DATA const (&)  p_boneData[Count])
inline

Adds bone datas.

Parameters
[in]p_boneDataThe bone datas.

References AddBoneDatas().

+ Here is the call graph for this function:

◆ AddFace()

C3D_API Face Castor3D::Submesh::AddFace ( uint32_t  a,
uint32_t  b,
uint32_t  c 
)

Creates and adds a face to the submesh.

Parameters
[in]aThe first face's vertex index
[in]bThe second face's vertex index
[in]cThe third face's vertex index
Returns
The created face

◆ AddFaceGroup() [1/2]

C3D_API void Castor3D::Submesh::AddFaceGroup ( stFACE_INDICES p_faces,
uint32_t  p_count 
)

Creates and adds faces to the submesh.

Parameters
[in]p_facesThe faces
[in]p_countThe faces count

Referenced by AddFaceGroup().

+ Here is the caller graph for this function:

◆ AddFaceGroup() [2/2]

template<uint32_t Count>
void Castor3D::Submesh::AddFaceGroup ( stFACE_INDICES(&)  p_faces[Count])
inline

Creates and adds faces to the submesh.

Parameters
[in]p_facesThe faces

References AddFaceGroup().

+ Here is the call graph for this function:

◆ AddPoint() [1/3]

C3D_API BufferElementGroupSPtr Castor3D::Submesh::AddPoint ( real  x,
real  y,
real  z 
)

Creates and adds a vertex to my list.

Parameters
[in]xThe vertex X coordinate
[in]yThe vertex Y coordinate
[in]zThe vertex Z coordinate
Returns
The created vertex

◆ AddPoint() [2/3]

C3D_API BufferElementGroupSPtr Castor3D::Submesh::AddPoint ( Castor::Point3r const &  p_v)

Adds a vertex to my list.

Parameters
[in]p_vThe vertex to add
Returns
The vertex

◆ AddPoint() [3/3]

C3D_API BufferElementGroupSPtr Castor3D::Submesh::AddPoint ( real *  p_v)

Creates and adds a vertex to my list.

Parameters
[in]p_vThe vertex coordinates
Returns
The created vertex

◆ AddPoints()

C3D_API void Castor3D::Submesh::AddPoints ( stVERTEX_GROUP const &  p_vertices)

Adds a points list to my list.

Parameters
[in]p_verticesThe vertices

◆ AddQuadFace()

C3D_API void Castor3D::Submesh::AddQuadFace ( uint32_t  a,
uint32_t  b,
uint32_t  c,
uint32_t  d,
Castor::Point3r const &  p_minUV = Castor::Point3r(),
Castor::Point3r const &  p_maxUV = Castor::Point3r(1, 1, 1) 
)

Creates and adds a quad face to the submesh.

Parameters
[in]aThe first face's vertex index
[in]bThe second face's vertex index
[in]cThe third face's vertex index
[in]dThe fourth face's vertex index
[in]p_minUVThe UV of the bottom left corner
[in]p_maxUVThe UV of the top right corner
Returns
The created face

◆ Cleanup()

C3D_API void Castor3D::Submesh::Cleanup ( )

Cleans the submesh.

◆ ClearFaces()

C3D_API void Castor3D::Submesh::ClearFaces ( )

Clears this submesh's face array.

◆ Clone()

C3D_API SubmeshSPtr Castor3D::Submesh::Clone ( )

Clones the submesh and returns the clone.

Returns
The clone

◆ ComputeBitangents()

C3D_API void Castor3D::Submesh::ComputeBitangents ( )

Computes bitangent for each vertex of the submesh.

Remarks
This function supposes the tangents and normals are defined

◆ ComputeContainers()

C3D_API void Castor3D::Submesh::ComputeContainers ( )

Computes the containers (cube and sphere)

◆ ComputeFacesFromPolygonVertex()

C3D_API void Castor3D::Submesh::ComputeFacesFromPolygonVertex ( )

Creates faces from the points.

Remarks
This function assumes the points are sorted like triangles fan

◆ ComputeNormals() [1/2]

C3D_API void Castor3D::Submesh::ComputeNormals ( bool  p_reverted = false)

Generates normals and tangents.

◆ ComputeNormals() [2/2]

C3D_API void Castor3D::Submesh::ComputeNormals ( Face const &  p_face)

Computes normal and tangent for each vertex of the given face.

Parameters
[in]p_faceThe face

◆ ComputeTangents()

C3D_API void Castor3D::Submesh::ComputeTangents ( Face const &  p_face)

Computes tangent for each vertex of the given face.

Parameters
[in]p_faceThe face

◆ ComputeTangentsFromBitangents()

C3D_API void Castor3D::Submesh::ComputeTangentsFromBitangents ( )

Computes tangent for each vertex of the submesh.

Remarks
This function supposes bitangents and normals are defined

◆ ComputeTangentsFromNormals()

C3D_API void Castor3D::Submesh::ComputeTangentsFromNormals ( )

Computes tangent for each vertex of the submesh.

Remarks
This function supposes the normals are defined

◆ Draw()

C3D_API void Castor3D::Submesh::Draw ( ShaderProgram const &  p_program)

Draws the submesh.

Parameters
[in]p_programThe shader program.

◆ DrawInstanced()

C3D_API void Castor3D::Submesh::DrawInstanced ( ShaderProgram const &  p_program,
uint32_t  p_count 
)

Draws the submesh.

Parameters
[in]p_programThe shader program.
[in]p_countThe instances count.

◆ GetBonesBuffer() [1/2]

VertexBuffer const& Castor3D::Submesh::GetBonesBuffer ( ) const
inline
Returns
The bones VertexBuffer.

◆ GetBonesBuffer() [2/2]

VertexBuffer& Castor3D::Submesh::GetBonesBuffer ( )
inline
Returns
The bones VertexBuffer.

◆ GetCubeBox() [1/2]

Castor::CubeBox const& Castor3D::Submesh::GetCubeBox ( ) const
inline

Retrieves the cube bounding box.

Returns
The value

◆ GetCubeBox() [2/2]

Castor::CubeBox& Castor3D::Submesh::GetCubeBox ( )
inline

Retrieves the cube bounding box.

Returns
The value

◆ GetDefaultMaterial()

MaterialSPtr Castor3D::Submesh::GetDefaultMaterial ( ) const
inline

Retrieves the material.

Returns
The value

◆ GetFace()

Face const& Castor3D::Submesh::GetFace ( uint32_t  p_index) const
inline

Retrieves the face at given index.

Parameters
[in]p_indexThe index
Returns
The value

◆ GetFaceCount()

C3D_API uint32_t Castor3D::Submesh::GetFaceCount ( ) const
Returns
The faces number

◆ GetFaces() [1/2]

FaceArray const& Castor3D::Submesh::GetFaces ( ) const
inline

Retrieves the faces array.

Returns
The value

◆ GetFaces() [2/2]

FaceArray& Castor3D::Submesh::GetFaces ( )
inline

Retrieves the faces array.

Returns
The value

◆ GetIndexBuffer() [1/2]

IndexBuffer const& Castor3D::Submesh::GetIndexBuffer ( ) const
inline
Returns
The IndexBuffer.

◆ GetIndexBuffer() [2/2]

IndexBuffer& Castor3D::Submesh::GetIndexBuffer ( )
inline
Returns
The IndexBuffer.

◆ GetMatrixBuffer() [1/2]

VertexBuffer const& Castor3D::Submesh::GetMatrixBuffer ( ) const
inline
Returns
The instantiation VertexBuffer.

◆ GetMatrixBuffer() [2/2]

VertexBuffer& Castor3D::Submesh::GetMatrixBuffer ( )
inline
Returns
The instantiation VertexBuffer.

◆ GetParent()

MeshRPtr Castor3D::Submesh::GetParent ( ) const
inline

Retrieves the parent mesh.

Returns
The value

Referenced by GetSkeleton().

+ Here is the caller graph for this function:

◆ GetPoint()

BufferElementGroupSPtr Castor3D::Submesh::GetPoint ( uint32_t  p_index) const
inline

Retrieves the point at given index.

Parameters
[in]p_indexThe index
Returns
The value

◆ GetPoints() [1/2]

VertexPtrArray const& Castor3D::Submesh::GetPoints ( ) const
inline

Retrieves the points array.

Returns
The value

◆ GetPoints() [2/2]

VertexPtrArray& Castor3D::Submesh::GetPoints ( )
inline

Retrieves the points array.

Returns
The value

◆ GetPointsCount()

C3D_API uint32_t Castor3D::Submesh::GetPointsCount ( ) const
Returns
The points count

◆ GetProgramFlags()

uint32_t Castor3D::Submesh::GetProgramFlags ( ) const
inline

Retrieves the shader program flags.

Returns
The value

◆ GetRefCount()

C3D_API uint32_t Castor3D::Submesh::GetRefCount ( MaterialSPtr  p_material) const

Retrieves the instances count.

Parameters
[in]p_materialThe material for which the instance count is retrieved
Returns
The value

◆ GetSkeleton()

SkeletonSPtr Castor3D::Submesh::GetSkeleton ( ) const
inline

Retrieves the skeleton.

Returns
The value

References GetParent().

+ Here is the call graph for this function:

◆ GetSphere() [1/2]

Castor::SphereBox const& Castor3D::Submesh::GetSphere ( ) const
inline

Retrieves the sphere bounding box.

Returns
The value

◆ GetSphere() [2/2]

Castor::SphereBox& Castor3D::Submesh::GetSphere ( )
inline

Retrieves the sphere bounding box.

Returns
The value

◆ GetTopology()

C3D_API eTOPOLOGY Castor3D::Submesh::GetTopology ( ) const
Returns
The topology.

◆ GetVertexBuffer() [1/2]

VertexBuffer const& Castor3D::Submesh::GetVertexBuffer ( ) const
inline
Returns
The VertexBuffer.

◆ GetVertexBuffer() [2/2]

VertexBuffer& Castor3D::Submesh::GetVertexBuffer ( )
inline
Returns
The VertexBuffer.

◆ HasBonesBuffer()

bool Castor3D::Submesh::HasBonesBuffer ( ) const
inline
Returns
The bones VertexBuffer.

◆ HasIndexBuffer()

bool Castor3D::Submesh::HasIndexBuffer ( ) const
inline
Returns
The IndexBuffer.

◆ HasMatrixBuffer()

bool Castor3D::Submesh::HasMatrixBuffer ( ) const
inline
Returns
The instantiation VertexBuffer.

◆ HasVertexBuffer()

bool Castor3D::Submesh::HasVertexBuffer ( ) const
inline
Returns
The VertexBuffer.

◆ Initialise()

C3D_API void Castor3D::Submesh::Initialise ( )

Initialises the submesh.

◆ IsInitialised()

bool Castor3D::Submesh::IsInitialised ( ) const
inline

Retrieves the initialisation status.

Returns
true if initialised

◆ IsInMyPoints()

C3D_API int Castor3D::Submesh::IsInMyPoints ( Castor::Point3r const &  p_vertex,
double  p_precision 
)

Tests if the given Point3r is in mine.

Parameters
[in]p_vertexThe vertex to test
[in]p_precisionThe comparison precision
Returns
The index of the vertex equal to parameter, -1 if not found

◆ operator[]()

BufferElementGroupSPtr Castor3D::Submesh::operator[] ( uint32_t  p_index) const
inline

Retrieves the point at given index.

Parameters
[in]p_indexThe index
Returns
The value

◆ Ref()

C3D_API void Castor3D::Submesh::Ref ( MaterialSPtr  p_material)

Increments instance count.

Parameters
[in]p_materialThe material for which the instance count is incremented

◆ ResetGpuBuffers()

C3D_API void Castor3D::Submesh::ResetGpuBuffers ( )

Recreates the Vertex and Index buffers.

◆ SetDefaultMaterial()

void Castor3D::Submesh::SetDefaultMaterial ( MaterialSPtr  p_mat)
inline

Sets the material.

Parameters
[in]p_matThe new value

◆ SetTopology()

C3D_API void Castor3D::Submesh::SetTopology ( eTOPOLOGY  p_value)

Sets the topology.

Parameters
[in]p_valueThe new value.

◆ SortFaces()

C3D_API void Castor3D::Submesh::SortFaces ( Castor::Point3r const &  p_cameraPosition)

Sorts the face from farthest to nearest from the camera.

Parameters
[in]p_cameraPositionThe camera position, relative to submesh

◆ UnRef()

C3D_API void Castor3D::Submesh::UnRef ( MaterialSPtr  p_material)

Decrements instance count.

Parameters
[in]p_materialThe material for which the instance count is decremented

Friends And Related Function Documentation

◆ GeometryBuffers

friend class GeometryBuffers
friend

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