Ocular Engine
Ocular::Graphics::Mesh Class Reference

Combination of a VertexBuffer and IndexBuffer. More...

#include <Mesh.hpp>

Inheritance diagram for Ocular::Graphics::Mesh:
Ocular::Core::Resource Ocular::Graphics::MeshEmpty Ocular::Graphics::MeshMissing

Public Member Functions

virtual bool bind ()
 
virtual void unbind ()
 
virtual void unload () override
 
void setVertexBuffer (VertexBuffer *buffer, uint32_t submesh=0)
 
VertexBuffergetVertexBuffer (uint32_t submesh=0)
 
void setIndexBuffer (IndexBuffer *buffer, uint32_t submesh=0)
 
IndexBuffergetIndexBuffer (uint32_t submesh=0)
 
void calculateMinMaxPoints ()
 
void setMinMaxPoints (Math::Vector3f const &min, Math::Vector3f const &max)
 
Math::Vector3f const & getMinPoint () const
 
Math::Vector3f const & getMaxPoint () const
 
SubMeshgetSubMesh (uint32_t index) const
 
uint32_t addSubMesh (SubMesh *submesh=nullptr)
 
bool setSubMesh (SubMesh *submesh, uint32_t index)
 
bool removeSubMesh (uint32_t index)
 
uint32_t getNumSubMeshes () const
 
- Public Member Functions inherited from Ocular::Core::Resource
 Resource (File const &source)
 
virtual void forceLoad ()
 
File getSourceFile () const
 
void setSourceFile (File const &file)
 
void setIsInMemory (bool inMemory)
 
bool isInMemory () const
 
void setSize (uint64_t size)
 
uint64_t getSize () const
 
ResourceType getResourceType () const
 
void setName (std::string const &name)
 
std::string const & getName () const
 
std::string const & getMappingName () const
 
void setMappingName (std::string const &name)
 
ResourceMetadatagetMetadata () const
 
void setMetadata (ResourceMetadata *metadata)
 

Protected Attributes

Math::Vector3f m_MinPoint
 
Math::Vector3f m_MaxPoint
 
std::vector< SubMesh * > m_SubMeshes
 
- Protected Attributes inherited from Ocular::Core::Resource
ResourceType m_Type
 
ResourceMetadatam_Metadata
 
File m_SourceFile
 
bool m_IsInMemory
 
uint64_t m_SizeInMemory
 
std::string m_Name
 
std::string m_MappingName
 

Detailed Description

Combination of a VertexBuffer and IndexBuffer.

Member Function Documentation

uint32_t Ocular::Graphics::Mesh::addSubMesh ( SubMesh submesh = nullptr)

Adds a SubMesh to the Mesh.

If provided SubMesh is NULL, then a new SubMesh is created.

Note
The Mesh assumes ownership of the SubMesh and will delete it upon destruction or removal.
Parameters
[in]submesh
Returns
Index of the newly added SubMesh
bool Ocular::Graphics::Mesh::bind ( )
virtual

Does nothing.

See SubMesh::Bind to bind a vertex/index buffer pair.

Reimplemented in Ocular::Graphics::MeshEmpty, and Ocular::Graphics::MeshMissing.

void Ocular::Graphics::Mesh::calculateMinMaxPoints ( )

Calculates the minimum and maximum vertex spatial points within the mesh.

Note
Potentially slow on extremely large data sets.
IndexBuffer * Ocular::Graphics::Mesh::getIndexBuffer ( uint32_t  submesh = 0)
Note
Any changes made to the buffer will not take affect until IndexBuffer::build is called and the Mesh is rebound.
Parameters
[in]submeshThe index of the submesh whose buffer should be retrieved.
Returns
A pointer to the specified IndexBuffer. May be NULL.
Math::Vector3f const & Ocular::Graphics::Mesh::getMaxPoint ( ) const

Returns the maximum vertex spatial point along all 3 axis. This point does not necessarily correspond with an actual vertex position.

Note that this point is cached, and is thus retrieved in constant time. It is also the local point prior to any transformations that may be performed on the parent renderer/model/etc. (translate, scale, rotate).

Returns
Maximum point along all 3 local axis.
Math::Vector3f const & Ocular::Graphics::Mesh::getMinPoint ( ) const

Returns the minimum vertex spatial point along all 3 axis. This point does not necessarily correspond with an actual vertex position.

Note that this point is cached, and is thus retrieved in constant time. It is also the local point prior to any transformations that may be performed on the parent renderer/model/etc. (translate, scale, rotate).

Returns
Minimum point along all 3 local axis.
uint32_t Ocular::Graphics::Mesh::getNumSubMeshes ( ) const
Returns
Returns the number of SubMeshes that comprise this Mesh.
SubMesh * Ocular::Graphics::Mesh::getSubMesh ( uint32_t  index) const

Returns the SubMesh at the specified index.

Parameters
[in]index
Returns
Pointer to the requested SubMesh. Returns NULL if the specified index is out-of-bounds.
VertexBuffer * Ocular::Graphics::Mesh::getVertexBuffer ( uint32_t  submesh = 0)

Returns a pointer to the current vertex buffer of this mesh, which can then be modified.

After modifying vertex data, one should call either calculateMinMaxPoints() or setMinMaxPoints() so that bounding volumes, etc. based off of this mesh will be accurate.

Any changes made to the buffer will not take affect until VertexBuffer::build is called and the Mesh is rebound.

Parameters
[in]submeshThe index of the submesh whose buffer should be retrieved.
Returns
A pointer to the specified IndexBuffer. May be NULL.
bool Ocular::Graphics::Mesh::removeSubMesh ( uint32_t  index)

Destroys the SubMesh at the specified index.

Parameters
[in]index
Returns
Returns TRUE if the SubMesh was successfully destroyed. Returns FALSE if the specified index is invalid.
void Ocular::Graphics::Mesh::setIndexBuffer ( IndexBuffer buffer,
uint32_t  submesh = 0 
)

Sets the IndexBuffer for this Mesh.

Note
The Mesh takes ownership of the buffer and will delete it when it is no longer in use.
Parameters
[in]buffer
[in]submeshIndex of the submesh that should receive the new buffer.
void Ocular::Graphics::Mesh::setMinMaxPoints ( Math::Vector3f const &  min,
Math::Vector3f const &  max 
)

Sets the minimum and maximum vertex spatial points within the mesh data.

These should represent the extrema along each of the local axis, and do not necessarily correlate to an actual vertex within the mesh.

Parameters
[in]min
[in]max
bool Ocular::Graphics::Mesh::setSubMesh ( SubMesh submesh,
uint32_t  index 
)

Sets the SubMesh at the specified index.

The pre-existing SubMesh is deleted during this action.

Note
The Mesh assumes ownership of the SubMesh and will delete it upon destruction or removal.
Parameters
[in]submesh
[in]index
Returns
Returns TRUE if the SubMesh was correctly set. Returns FALSE if the specified index is invalid.
void Ocular::Graphics::Mesh::setVertexBuffer ( VertexBuffer buffer,
uint32_t  submesh = 0 
)

Sets the VertexBuffer for this Mesh.

After modifying vertex data, one should call either calculateMinMaxPoints() or setMinMaxPoints() so that bounding volumes, etc. based off of this mesh will be accurate.

The Mesh takes ownership of the buffer and will delete it when it is no longer in use.

Parameters
[in]buffer
[in]submeshIndex of the submesh that should receive the new buffer.
void Ocular::Graphics::Mesh::unbind ( )
virtual

Does nothing.

See SubMesh::Unind to unbind a vertex/index buffer pair.

Reimplemented in Ocular::Graphics::MeshEmpty, and Ocular::Graphics::MeshMissing.

void Ocular::Graphics::Mesh::unload ( )
overridevirtual

Unloads this Mesh from CPU and GPU memory

Reimplemented from Ocular::Core::Resource.

Reimplemented in Ocular::Graphics::MeshEmpty, and Ocular::Graphics::MeshMissing.


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