PURE API 0.5
PR00F's Ultimate Rendering Engine full documentation
Loading...
Searching...
No Matches
PureMesh3D Class Reference

3D Mesh class. More...

Detailed Description

3D Mesh class.

Mesh objects are 2-level entities:

  • first level (parent) has no geometry, owns submeshes,
  • second level meshes own geometry. This is why a Mesh is both a Managed and a Manager too: it is owned by Mesh3DManager but it owns its submeshes.

Definition at line 48 of file PureMesh3DManager.h.

#include <PureMesh3DManager.h>

+ Inheritance diagram for PureMesh3D:

Classes

class  PureMesh3DImpl
 

Public Member Functions

virtual ~PureMesh3D ()
 
CConsole & getManagedConsole () const
 Returns access to console preset with logger module name as this class.
 
virtual TPureBool isLevel1 () const
 Tells if the mesh is a level-1 parent mesh.
 
virtual TPureBool isLevel2 () const
 Tells if the mesh is a level-2 submesh.
 
virtual TPURE_PRIMITIVE_FORMAT getPrimitiveFormat () const
 Gets the primitives' format.
 
virtual TPureUInt getVerticesCount () const
 Gets the number of total vertices.
 
virtual const TXYZgetVertices (TPureBool implicitAccessSubobject=true) const
 Gets the pointer to vertices.
 
virtual TXYZgetVertices (TPureBool implicitAccessSubobject=true)
 Gets the pointer to vertices.
 
virtual TPureUInt getVertexIndicesCount () const
 Gets the number of total vertex indices.
 
virtual const void * getVertexIndices (TPureBool implicitAccessSubobject=true) const
 Gets the pointer to vertex indices.
 
virtual unsigned int getVertexIndicesType (TPureBool implicitAccessSubobject=true) const
 Gets the type of the indices.
 
virtual TPureUInt getMinVertexIndex (TPureBool implicitAccessSubobject=true) const
 Gets the smallest index in the vertex indices array.
 
virtual TPureUInt getMaxVertexIndex (TPureBool implicitAccessSubobject=true) const
 Gets the greatest index in the vertex indices array.
 
virtual TPureUInt getVertexIndex (TPureUInt index, TPureBool implicitAccessSubobject=true) const
 Gets an index value from the vertex indices array.
 
virtual const TXYZgetNormals (TPureBool implicitAccessSubobject=true) const
 Gets the pointer to normals.
 
virtual TPureUInt getFaceCount () const
 Gets the number of faces/polygons formed by the vertices.
 
virtual TPureUInt getTriangleCount () const
 Gets the number of triangles formed by the vertices.
 
PureVectorgetPosVec ()
 Gets the position.
 
const PureVectorgetPosVec () const
 Gets the position.
 
virtual const PureVectorgetRelPosVec () const
 Gets the mesh-local relative position.
 
virtual const PureVectorgetSizeVec () const
 Gets the base sizes.
 
void RecalculateSize ()
 Recalculates the sizes.
 
const PureMaterialgetMaterial (TPureBool implicitAccessSubobject=true) const
 Gets the material.
 
PureMaterialgetMaterial (TPureBool implicitAccessSubobject=true)
 Gets the material.
 
virtual TPureUInt getUsedSystemMemory () const
 Gets the amount of allocated system memory.
 
- Public Member Functions inherited from PureFiledManaged
 PureFiledManaged ()
 
virtual ~PureFiledManaged ()
 
CConsole & getManagedConsole () const
 Returns access to console preset with logger module name as this class.
 
const std::string & getFilename () const
 Gets the filename.
 
- Public Member Functions inherited from PureManaged
 PureManaged ()
 
virtual ~PureManaged ()
 
CConsole & getManagedConsole () const
 Returns access to console preset with logger module name as this class.
 
const PureManagedgetUtiliser () const
 Returns the managed that utilizes this managed.
 
PureManagedgetUtiliser ()
 Returns the managed that utilizes this managed.
 
void SetUtiliser (PureManaged *pUtiliser)
 Sets the managed that utilizes this managed.
 
void DetachFrom ()
 Removes the managed from its manager.
 
PureManagergetManager () const
 Gets the manager of the managed.
 
const std::string & getName () const
 Gets the name.
 
void SetName (const std::string &name)
 Sets the name.
 
virtual void FlushResources ()
 This can be used if the specialized managed object has some resources that may be released from memory when not needed anymore.
 
- Public Member Functions inherited from PureFiledManager
 PureFiledManager ()
 
virtual ~PureFiledManager ()
 
CConsole & getConsole () const
 Returns access to console preset with logger module name as this class.
 
PureFiledManagedgetByFilename (const char *filename) const
 Gets the FiledManaged by the specified filename.
 
virtual PureFiledManagedcreateFromFile (const char *filename)
 Should create a new managed from the given file.
 
void WriteList () const
 From PureManager, adding logging file names.
 
- Public Member Functions inherited from PureManager
 PureManager ()
 
virtual ~PureManager ()
 
CConsole & getConsole () const
 Returns access to console preset with logger module name as this class.
 
TPureInt getCount () const
 Gets the number of managed objects.
 
TPureBool isEmpty () const
 Is the number of manageds 0?
 
TPureInt getSize () const
 Gets the number of allocated slots for managed objects; getSize() >= getCount().
 
PureManagedgetAttachedAt (TPureInt ind) const
 Gets the pointer to the managed at the given index.
 
TPureInt getAttachedIndex (const PureManaged &m) const
 Gets the index of the given managed.
 
void PreAlloc (TPureInt count)
 Allocates count free slots for manageds.
 
TPureBool hasAttached (const PureManaged &m) const
 Gets whether the given managed is managed by this manager.
 
virtual void Attach (PureManaged &m)
 Adds the given managed to the manager, if the managed has no manager yet.
 
virtual void Detach (PureManaged &m)
 Removes the given managed from the manager, so the managed will have no manager.
 
void DeleteAttachedInstance (PureManaged &m)
 Removes the given managed from the manager and destructs it.
 
void DeleteAll ()
 Removes and destructs every managed element in the manager.
 
virtual void HandleManagedPropertyChanged (PureManaged &m)
 Should be invoked when a managed's property got changed from a different kind of manager or managed.
 

Static Public Member Functions

static const char * getLoggerModuleName ()
 Returns the logger module name of this class.
 
- Static Public Member Functions inherited from PureFiledManaged
static const char * getLoggerModuleName ()
 Returns the logger module name of this class.
 
- Static Public Member Functions inherited from PureManaged
static const char * getLoggerModuleName ()
 Returns the logger module name of this class.
 
- Static Public Member Functions inherited from PureFiledManager
static const char * getLoggerModuleName ()
 Returns the logger module name of this class.
 
- Static Public Member Functions inherited from PureManager
static const char * getLoggerModuleName ()
 Returns the logger module name of this class.
 

Protected Member Functions

 PureMesh3D (TPURE_PRIMITIVE_FORMAT prfmt=PURE_PM_TRIANGLES)
 Only PureMesh3DManager creates it.
 
 PureMesh3D (const PureMesh3D &)
 
PureMesh3Doperator= (const PureMesh3D &)
 
- Protected Member Functions inherited from PureFiledManaged
 PureFiledManaged (const PureFiledManaged &other)
 
PureFiledManagedoperator= (const PureFiledManaged &other)
 
void SetFilename (const std::string &filename)
 Sets the filename.
 
- Protected Member Functions inherited from PureManaged
 PureManaged (const PureManaged &other)
 
PureManagedoperator= (const PureManaged &other)
 
- Protected Member Functions inherited from PureFiledManager
 PureFiledManager (const PureFiledManager &)
 
PureFiledManageroperator= (const PureFiledManager &)
 
virtual void WriteListCallback (const PureManaged &mngd) const
 From PureManager, printing filename.
 
- Protected Member Functions inherited from PureManager
 PureManager (const PureManager &other)
 
PureManageroperator= (const PureManager &)
 

Private Attributes

PureMesh3DImplpImpl
 

Friends

class PureMesh3DManager
 
class PureObject3DManager
 
class SampleManagerForDescendantFromVertexTransfer
 

Constructor & Destructor Documentation

◆ ~PureMesh3D()

PureMesh3D::~PureMesh3D ( )
virtual

Definition at line 565 of file PureMesh3D.cpp.

◆ PureMesh3D() [1/2]

PureMesh3D::PureMesh3D ( TPURE_PRIMITIVE_FORMAT prfmt = PURE_PM_TRIANGLES)
protected

Only PureMesh3DManager creates it.

Only PureObject3DManager creates it.

Exceptions
std::bad_alloc- This class or its ancestor dynamically allocates memory with operator new, in case of failure the exception is not handled but propagated to caller.

Definition at line 954 of file PureMesh3D.cpp.

◆ PureMesh3D() [2/2]

PureMesh3D::PureMesh3D ( const PureMesh3D & mesh)
protected

Definition at line 960 of file PureMesh3D.cpp.

Member Function Documentation

◆ getFaceCount()

TPureUInt PureMesh3D::getFaceCount ( ) const
virtual

Gets the number of faces/polygons formed by the vertices.

Gets the number of faces/polygons/primitives formed by the vertices.

Face count doesn't only depend on vertex or vertex index count but also on the primitive format (see: getPrimitiveFormat()). Note that face count is not necessarily equal to getTriangleCount() because e.q. if primitive format is quads/quadrilaterals, then obviously face count will be smaller than triangle count. Even if primitive format indicates quads/quadrilaterals, they are split into triangles at some point when transferred through the graphics pipeline.

Returns
Number of faces/polygons/primitives formed by the vertices.

Reimplemented in PureObject3D.

Definition at line 812 of file PureMesh3D.cpp.

◆ getLoggerModuleName()

const char * PureMesh3D::getLoggerModuleName ( )
static

Returns the logger module name of this class.

Intentionally not virtual, so derived class should hide this instead of overriding. Not even private, so user can also access this from outside, for any reason like controlling log filtering per logger module name.

Returns
The logger module name of this class.

Definition at line 591 of file PureMesh3D.cpp.

◆ getManagedConsole()

CConsole & PureMesh3D::getManagedConsole ( ) const

Returns access to console preset with logger module name as this class.

Intentionally not virtual, so the getConsole() in derived class should hide this instead of overriding.

Returns
Console instance used by this class.

Definition at line 578 of file PureMesh3D.cpp.

◆ getMaterial() [1/2]

PureMaterial & PureMesh3D::getMaterial ( TPureBool implicitAccessSubobject = true)

Gets the material.

Note that some properties of a level-1 mesh are irrelevant because renderer doesn't even access them, e.g. texture, because they are fetched from the level-2 meshes. Some other material properties of level-2 meshes are irrelevant because they are inherited from the material of their parent level-1 mesh, e.g. texture environment color. Thus make sure you are careful when you specify the argument as described below.

Parameters
implicitAccessSubobjectIf true (default), and this mesh has exactly 1 submesh, the accessed value will be that submesh's value. If false, the accessed value will be this mesh's value.
Returns
Material. If the object's own vertex count is 0 but it has exactly 1 subobject, the returned material is the subobject's material. This implicit behavior is for convenience for objects storing only 1 subobject like internally created objects.

Definition at line 918 of file PureMesh3D.cpp.

◆ getMaterial() [2/2]

const PureMaterial & PureMesh3D::getMaterial ( TPureBool implicitAccessSubobject = true) const

Gets the material.

Note that some properties of a level-1 mesh are irrelevant because renderer doesn't even access them, e.g. texture, because they are fetched from the level-2 meshes. Some other material properties of level-2 meshes are irrelevant because they are inherited from the material of their parent level-1 mesh, e.g. texture environment color. Thus make sure you are careful when you specify the argument as described below.

Parameters
implicitAccessSubobjectIf true (default), and this mesh has exactly 1 submesh, the accessed value will be that submesh's value. If false, the accessed value will be this mesh's value.
Returns
Material. If the object's own vertex count is 0 but it has exactly 1 subobject, the returned material is the subobject's material. This implicit behavior is for convenience for objects storing only 1 subobject like internally created objects.

Definition at line 899 of file PureMesh3D.cpp.

◆ getMaxVertexIndex()

TPureUInt PureMesh3D::getMaxVertexIndex ( TPureBool implicitAccessSubobject = true) const
virtual

Gets the greatest index in the vertex indices array.

This value is irrelevant for a level-1 mesh since the geometry is owned by its level-2 submeshes and it is unique for each submesh. Still the returned value for a level-1 mesh can be a positive value, see below.

Parameters
implicitAccessSubobjectIf true (default), and this mesh has exactly 1 submesh, the accessed value will be that submesh's value. If false, the accessed value will be this mesh's value.
Returns
The greatest index in the vertex index array. If the object's own vertex count is 0 but it has exactly 1 subobject, the returned index is the subobject's greatest index. This implicit behavior is for convenience for objects storing only 1 subobject like internally created objects.

Reimplemented in PureObject3D.

Definition at line 757 of file PureMesh3D.cpp.

◆ getMinVertexIndex()

TPureUInt PureMesh3D::getMinVertexIndex ( TPureBool implicitAccessSubobject = true) const
virtual

Gets the smallest index in the vertex indices array.

This value is irrelevant for a level-1 mesh since the geometry is owned by its level-2 submeshes and it is unique for each submesh. Still the returned value for a level-1 mesh can be a positive value, see below.

Parameters
implicitAccessSubobjectIf true (default), and this mesh has exactly 1 submesh, the accessed value will be that submesh's value. If false, the accessed value will be this mesh's value.
Returns
The smallest index in the vertex index array. If the object's own vertex count is 0 but it has exactly 1 subobject, the returned index is the subobject's smallest index. This implicit behavior is for convenience for objects storing only 1 subobject like internally created objects.

Reimplemented in PureObject3D.

Definition at line 740 of file PureMesh3D.cpp.

◆ getNormals()

const TXYZ * PureMesh3D::getNormals ( TPureBool implicitAccessSubobject = true) const
virtual

Gets the pointer to normals.

Pointer to normals is NULL for a level-1 mesh since the geometry is owned by its level-2 submeshes. Note: in special case this returns non-NULL value even for a level-1 mesh, see below.

In indexed vertex referencing mode, the vertex indices can be used to reference normals in the array, same way as how vertices can be referenced.

Parameters
implicitAccessSubobjectIf true (default), and this mesh has exactly 1 submesh, the accessed value will be that submesh's value. If false, the accessed value will be this mesh's value.
Returns
Pointer to normals. If the object's own vertex count is 0 but it has exactly 1 subobject, the returned pointer is the subobject's normals pointer. This implicit behavior is for convenience for objects storing only 1 subobject like internally created objects.

Reimplemented in PureObject3D.

Definition at line 797 of file PureMesh3D.cpp.

◆ getPosVec() [1/2]

PureVector & PureMesh3D::getPosVec ( )

Gets the position.

For a level-1 mesh object, this vector is always zero. It can be utilized by a descendant class though. For a level-2 (sub)mesh object, this vector represents the position of the submesh relative to the position of its parent mesh object.

Returns
Position vector.

Definition at line 838 of file PureMesh3D.cpp.

◆ getPosVec() [2/2]

const PureVector & PureMesh3D::getPosVec ( ) const

Gets the position.

For a level-1 mesh object, this vector is always zero. It can be utilized by a descendant class though. For a level-2 (sub)mesh object, this vector represents the position of the submesh relative to the position of its parent mesh object.

Returns
Position vector.

Definition at line 850 of file PureMesh3D.cpp.

◆ getPrimitiveFormat()

TPURE_PRIMITIVE_FORMAT PureMesh3D::getPrimitiveFormat ( ) const
virtual

Gets the primitives' format.

Primitive format is the same for the mesh and its submeshes.

Reimplemented in PureObject3D.

Definition at line 626 of file PureMesh3D.cpp.

◆ getRelPosVec()

const PureVector & PureMesh3D::getRelPosVec ( ) const
virtual

Gets the mesh-local relative position.

This position tells the offset of the vertex positions relative to the center of the mesh [0,0,0]. For level-2 (sub)mesh, this vector is always expected to be [0,0,0] since the position of submeshes is calculated with vertex positions and size.

Returns
Mesh-local relative position vector.

Reimplemented in PureObject3D.

Definition at line 862 of file PureMesh3D.cpp.

◆ getSizeVec()

const PureVector & PureMesh3D::getSizeVec ( ) const
virtual

Gets the base sizes.

Returns
Base sizes vector.

Reimplemented in PureObject3D.

Definition at line 871 of file PureMesh3D.cpp.

◆ getTriangleCount()

TPureUInt PureMesh3D::getTriangleCount ( ) const
virtual

Gets the number of triangles formed by the vertices.

Triangle count doesn't only depend on vertex or vertex index count but also on the primitive format (see: getPrimitiveFormat()). Note that triangle count is not necessarily equal to getFaceCount() because e.q. if primitive format is quads/quadrilaterals, then obviously triangle count will be greater than face count. Even if primitive format indicates quads/quadrilaterals, they are split into triangles at some point when transferred through the graphics pipeline.

Returns
Number of triangles formed by the vertices.

Reimplemented in PureObject3D.

Definition at line 826 of file PureMesh3D.cpp.

◆ getUsedSystemMemory()

TPureUInt PureMesh3D::getUsedSystemMemory ( ) const
virtual

Gets the amount of allocated system memory.

It includes the allocated Material size as well (getMaterial()). Level-1 (parent) meshes summarize the memory usage of their level-2 submeshes and include it in the returned value.

Returns
Amount of allocated system memory in Bytes.

Reimplemented from PureFiledManaged.

Reimplemented in PureObject3D, and PureVertexTransfer.

Definition at line 931 of file PureMesh3D.cpp.

◆ getVertexIndex()

TPureUInt PureMesh3D::getVertexIndex ( TPureUInt index,
TPureBool implicitAccessSubobject = true ) const
virtual

Gets an index value from the vertex indices array.

This function is highly recommended to be used for reading indices from the index array since the type of indices can vary from subobject to subobject and this function considers the index type. This function is irrelevant for a level-1 mesh since the geometry is owned by its level-2 submeshes. Still the returned value for a level-1 mesh can be a valid value, see below.

Parameters
implicitAccessSubobjectIf true (default), and this mesh has exactly 1 submesh, the accessed value will be that submesh's value. If false, the accessed value will be this mesh's value.
Returns
An index read from the given array. If the object's own vertex count is 0 but it has exactly 1 subobject, the returned index is the subobject's index. This implicit behavior is for convenience for objects storing only 1 subobject like internally created objects.

Reimplemented in PureObject3D.

Definition at line 776 of file PureMesh3D.cpp.

◆ getVertexIndices()

const void * PureMesh3D::getVertexIndices ( TPureBool implicitAccessSubobject = true) const
virtual

Gets the pointer to vertex indices.

Pointer to vertex indices is NULL for a level-1 mesh since the geometry is owned by its level-2 submeshes. Note: in special case this returns non-NULL value even for a level-1 mesh, see below.

Parameters
implicitAccessSubobjectIf true (default), and this mesh has exactly 1 submesh, the accessed value will be that submesh's value. If false, the accessed value will be this mesh's value.
Returns
Pointer to vertex indices. If the object's own vertex count is 0 but it has exactly 1 subobject, the returned pointer is the subobject's vertex indices pointer. This implicit behavior is for convenience for objects storing only 1 subobject like internally created objects.

Reimplemented in PureObject3D.

Definition at line 704 of file PureMesh3D.cpp.

◆ getVertexIndicesCount()

TPureUInt PureMesh3D::getVertexIndicesCount ( ) const
virtual

Gets the number of total vertex indices.

Number of total vertex indices for a level-1 mesh is the sum of number of vertex indices of its level-2 submeshes.

Returns
Number of total vertex indices.

Reimplemented in PureObject3D.

Definition at line 686 of file PureMesh3D.cpp.

◆ getVertexIndicesType()

unsigned int PureMesh3D::getVertexIndicesType ( TPureBool implicitAccessSubobject = true) const
virtual

Gets the type of the indices.

Index type is irrelevant for a level-1 mesh since the geometry is owned by its level-2 submeshes and it is unique for each submesh.

Parameters
implicitAccessSubobjectIf true (default), and this mesh has exactly 1 submesh, the accessed value will be that submesh's value. If false, the accessed value will be this mesh's value.
Returns
Vertex index type. If the object's own vertex count is 0 but it has exactly 1 subobject, the returned type is the subobject's vertex index type. This implicit behavior is for convenience for objects storing only 1 subobject like internally created objects.

Reimplemented in PureObject3D.

Definition at line 722 of file PureMesh3D.cpp.

◆ getVertices() [1/2]

TXYZ * PureMesh3D::getVertices ( TPureBool implicitAccessSubobject = true)
virtual

Gets the pointer to vertices.

Pointer to vertices is NULL for a level-1 mesh since the geometry is owned by its level-2 submeshes. Note: in special case this returns non-NULL value even for a level-1 mesh, see below.

Parameters
implicitAccessSubobjectIf true (default), and this mesh has exactly 1 submesh, the accessed value will be that submesh's value. If false, the accessed value will be this mesh's value.
Returns
Pointer to vertices. If the object's own vertex count is 0 but it has exactly 1 subobject, the returned pointer is the subobject's vertices pointer. This implicit behavior is for convenience for objects storing only 1 subobject like internally created objects.

Reimplemented in PureObject3D.

Definition at line 674 of file PureMesh3D.cpp.

◆ getVertices() [2/2]

const TXYZ * PureMesh3D::getVertices ( TPureBool implicitAccessSubobject = true) const
virtual

Gets the pointer to vertices.

Pointer to vertices is NULL for a level-1 mesh since the geometry is owned by its level-2 submeshes. Note: in special case this returns non-NULL value even for a level-1 mesh, see below.

Parameters
implicitAccessSubobjectIf true (default), and this mesh has exactly 1 submesh, the accessed value will be that submesh's value. If false, the accessed value will be this mesh's value.
Returns
Pointer to vertices. If the object's own vertex count is 0 but it has exactly 1 subobject, the returned pointer is the subobject's vertices pointer. This implicit behavior is for convenience for objects storing only 1 subobject like internally created objects.

Reimplemented in PureObject3D.

Definition at line 656 of file PureMesh3D.cpp.

◆ getVerticesCount()

TPureUInt PureMesh3D::getVerticesCount ( ) const
virtual

Gets the number of total vertices.

Number of total vertices for a level-1 mesh is the sum of number of vertices of its level-2 submeshes.

Returns
Number of total vertices.

Reimplemented in PureObject3D.

Definition at line 638 of file PureMesh3D.cpp.

◆ isLevel1()

TPureBool PureMesh3D::isLevel1 ( ) const
virtual

Tells if the mesh is a level-1 parent mesh.

A mesh cannot be both level-1 and level-2 at the same time. A level-1 mesh does not have vertex data on its own, but its level-2 submeshes own vertex data.

Returns
True if the mesh is a level-1 parent mesh i.e. it has at least 1 submesh, false otherwise.

Reimplemented in PureObject3D.

Definition at line 604 of file PureMesh3D.cpp.

◆ isLevel2()

TPureBool PureMesh3D::isLevel2 ( ) const
virtual

Tells if the mesh is a level-2 submesh.

A mesh cannot be both level-1 and level-2 at the same time. A level-1 mesh does not have vertex data on its own, but its level-2 submeshes own vertex data.

Returns
True if the mesh is a level-2 submesh i.e. it doesn't have any submesh, false otherwise.

Reimplemented in PureObject3D.

Definition at line 616 of file PureMesh3D.cpp.

◆ operator=()

PureMesh3D & PureMesh3D::operator= ( const PureMesh3D & )
protected

Definition at line 966 of file PureMesh3D.cpp.

◆ RecalculateSize()

void PureMesh3D::RecalculateSize ( )

Recalculates the sizes.

Definition at line 880 of file PureMesh3D.cpp.

Friends And Related Symbol Documentation

◆ PureMesh3DManager

friend class PureMesh3DManager
friend

Definition at line 116 of file PureMesh3DManager.h.

◆ PureObject3DManager

friend class PureObject3DManager
friend

Definition at line 117 of file PureMesh3DManager.h.

◆ SampleManagerForDescendantFromVertexTransfer

friend class SampleManagerForDescendantFromVertexTransfer
friend

Definition at line 118 of file PureMesh3DManager.h.

Member Data Documentation

◆ pImpl

PureMesh3DImpl* PureMesh3D::pImpl
private

Definition at line 114 of file PureMesh3DManager.h.


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