Spinning Topp Logo BlackTopp Studios
inc
Public Types | Public Member Functions | Protected Attributes | List of all members
Mezzanine::Graphics::Procedural::TriangleBuffer Class Reference

A convenience buffer that stores vertices and indices of a mesh to be generated. More...

#include <trianglebuffer.h>

+ Collaboration diagram for Mezzanine::Graphics::Procedural::TriangleBuffer:

Public Types

typedef SectionContainer::const_iterator ConstSectionIterator
 Const Iterator type for Section instances stored in this class.
 
typedef std::vector< BufferSectionSectionContainer
 Basic container type for Section storage in this class.
 
typedef SectionContainer::iterator SectionIterator
 Iterator type for Section instances stored in this class.
 

Public Member Functions

 TriangleBuffer ()
 Class constructor.
 
 ~TriangleBuffer ()
 Class destructor.
 
TriangleBufferAddIndex (const Integer Index)
 Adds an index to the index buffer. More...
 
TriangleBufferAddTriangle (const Integer Index1, const Integer Index2, const Integer Index3)
 Adds a triangle to the index buffer. More...
 
TriangleBufferAddVertex (const Vertex &Vert)
 Adds a premade Vertex to the buffer. More...
 
TriangleBufferAddVertex (const Vector3 &Loc, const Vector3 &Norm, const Vector2 &UV)
 Adds a new vertex to the buffer. More...
 
TriangleBufferAddVertex (const Vector3 &Loc)
 Adds a new vertex to the buffer. More...
 
TriangleBufferAddVertex (const Real X, const Real Y, const Real Z)
 Adds a new vertex to the buffer. More...
 
void AppendBuffer (const TriangleBuffer &Other)
 Appends the contents of another buffer to this buffer. More...
 
void AppendBufferAsSection (const TriangleBuffer &Other, const String &MatName="", const String &MatGroup="", const Whole RenderOp=Graphics::RO_TriangleList)
 Appends the contents of another buffer to this buffer as a separate section of the Mesh. More...
 
TriangleBufferApplyTransform (const Matrix4x4 &Mat)
 Applies a matrix to transform all vertices inside this triangle buffer. More...
 
void BeginSection (const String &MatName="", const String &MatGroup="", const Whole RenderOp=Graphics::RO_TriangleList)
 Gets a BufferSection that can be appended to the end of this buffer. More...
 
void EndSection ()
 Sets a BufferSection as the end section of this buffer. More...
 
void EstimateIndexCount (const Whole IndexCount)
 Gives an estimation of the number of indices needed for this triangle buffer. More...
 
void EstimateVertexCount (const Whole VertexCount)
 Gives an estimation of the number of vertices need for this triangle buffer. More...
 
MeshGenerateMesh (const String &MeshName, const String &MeshGroup, const String &MatName="", const String &MatGroup="") const
 Builds a Mesh from this buffer. More...
 
IndexContainerGetIndices ()
 Gets a modifiable reference to Indices. More...
 
const IndexContainerGetIndices () const
 Gets a non-modifiable reference to Indices. More...
 
SectionContainerGetSections ()
 Gets a modifiable reference to Sections. More...
 
const SectionContainerGetSections () const
 Gets a non-modifiable reference to Sections. More...
 
VertexContainerGetVertices ()
 Gets a modifiable reference to Vertices. More...
 
const VertexContainerGetVertices () const
 Gets a non-modifiable reference to Vertices. More...
 
TriangleBufferInvertNormals ()
 Applies normal inversion on this triangle buffer. More...
 
Boole IsUsingSections () const
 Gets whether or not this buffer is divided into sections. More...
 
Boole IsWorkingOnSection () const
 Gets whether or not a section has been started and not yet closed. More...
 
void RebaseOffset ()
 Rebase index offset. More...
 
TriangleBufferRotateVertices (const Quaternion &Rot)
 Applies the rotation immediately to all the points contained in this triangle buffer. More...
 
TriangleBufferScaleVertices (const Vector3 &Scale)
 Applies an immediate scale operation to this triangle buffer. More...
 
TriangleBufferScaleVertices (const Real X, const Real Y, const Real Z)
 Applies an immediate scale operation to this triangle buffer. More...
 
TriangleBufferSetNormal (const Vector3 &Norm)
 Sets the normal of the current vertex. More...
 
TriangleBufferSetTextureCoord (const Real U, const Real V)
 Sets the texture coordinates of the current vertex. More...
 
TriangleBufferSetTextureCoord (const Vector2 &UV)
 Sets the texture coordinates of the current vertex. More...
 
TriangleBufferTranslateVertices (const Vector3 &Trans)
 Applies the translation immediately to all the points contained in this triangle buffer. More...
 
TriangleBufferTranslateVertices (const Real X, const Real Y, const Real Z)
 Applies the translation immediately to all the points contained in this triangle buffer. More...
 

Protected Attributes

BufferSection CurrentSection
 Temporary storage for the current section being worked on. More...
 
VertexCurrentVertex
 Convenience pointer to the Vertex currently being manipulated. More...
 
Integer EstimatedIndexCount
 The user estimated Index count for this buffer. More...
 
Integer EstimatedVertexCount
 The user estimated Vertex count for this buffer. More...
 
Integer GlobalOffset
 Offset used to set where buffer/mesh appends begin. More...
 
IndexContainer Indices
 Container storing all of the Indices in this buffer. More...
 
SectionContainer Sections
 Container storing all of the sections of this buffer. More...
 
VertexContainer Vertices
 Container storing all of the Vertices in this buffer. More...
 

Detailed Description

A convenience buffer that stores vertices and indices of a mesh to be generated.

This buffer is different from native Graphics buffers in that it both has a combined API for the manipulation of vertices and indices and it doesn't create a cooresponding buffer in video card memory. This buffer exists solely in system memory and nothing is allocated on the video card until a mesh is generated.

Definition at line 197 of file trianglebuffer.h.

Member Function Documentation

TriangleBuffer & Mezzanine::Graphics::Procedural::TriangleBuffer::AddIndex ( const Integer  Index)

Adds an index to the index buffer.

Note
Index is relative to the latest call to RebaseOffset().
Parameters
IndexThe Index to be added.
Returns
Returns a reference to this.

Definition at line 374 of file trianglebuffer.cpp.

TriangleBuffer & Mezzanine::Graphics::Procedural::TriangleBuffer::AddTriangle ( const Integer  Index1,
const Integer  Index2,
const Integer  Index3 
)

Adds a triangle to the index buffer.

Note
Index is relative to the latest call to RebaseOffset().
Parameters
Index1The first point of the triangle to be added.
Index2The second point of the triangle to be added.
Index3The third point of the triangle to be added.
Returns
Returns a reference to this.

Definition at line 380 of file trianglebuffer.cpp.

TriangleBuffer & Mezzanine::Graphics::Procedural::TriangleBuffer::AddVertex ( const Vertex Vert)

Adds a premade Vertex to the buffer.

Parameters
VertThe premade Vertex to be appended to this buffer.
Returns
Returns a reference to this.

Definition at line 252 of file trianglebuffer.cpp.

TriangleBuffer & Mezzanine::Graphics::Procedural::TriangleBuffer::AddVertex ( const Vector3 Loc,
const Vector3 Norm,
const Vector2 UV 
)

Adds a new vertex to the buffer.

Parameters
LocThe location to set the new Vertex at, in local space.
NormThe facing direction of the new Vertex, in local space.
UVThe texture coordinate to set for the new Vertex.
Returns
Returns a reference to this.

Definition at line 259 of file trianglebuffer.cpp.

TriangleBuffer & Mezzanine::Graphics::Procedural::TriangleBuffer::AddVertex ( const Vector3 Loc)

Adds a new vertex to the buffer.

Parameters
LocThe location to set the new Vertex at, in local space.
Returns
Returns a reference to this.

Definition at line 270 of file trianglebuffer.cpp.

TriangleBuffer & Mezzanine::Graphics::Procedural::TriangleBuffer::AddVertex ( const Real  X,
const Real  Y,
const Real  Z 
)

Adds a new vertex to the buffer.

Parameters
XThe location of the new Vertex on the X axis, in local space.
YThe location of the new Vertex on the Y axis, in local space.
ZThe location of the new Vertex on the Z axis, in local space.
Returns
Returns a reference to this.

Definition at line 279 of file trianglebuffer.cpp.

void Mezzanine::Graphics::Procedural::TriangleBuffer::AppendBuffer ( const TriangleBuffer Other)

Appends the contents of another buffer to this buffer.

Parameters
OtherThe other TriangleBuffer to append to this.

Definition at line 95 of file trianglebuffer.cpp.

void Mezzanine::Graphics::Procedural::TriangleBuffer::AppendBufferAsSection ( const TriangleBuffer Other,
const String MatName = "",
const String MatGroup = "",
const Whole  RenderOp = Graphics::RO_TriangleList 
)

Appends the contents of another buffer to this buffer as a separate section of the Mesh.

Parameters
OtherThe other TriangleBuffer to append to this.
MatNameThe name of the material to be used with this section.
MatGroupThe asset group where the Material can be found.
RenderOpThe render operation describing how the Vertices should be treated for assembling the Mesh. See Graphics::RenderOperation enum for more information.

Definition at line 105 of file trianglebuffer.cpp.

TriangleBuffer & Mezzanine::Graphics::Procedural::TriangleBuffer::ApplyTransform ( const Matrix4x4 Mat)

Applies a matrix to transform all vertices inside this triangle buffer.

Parameters
MatA full transform to be applied to each Vertex in this buffer.
Returns
Returns a reference to this.

Definition at line 306 of file trianglebuffer.cpp.

void Mezzanine::Graphics::Procedural::TriangleBuffer::BeginSection ( const String MatName = "",
const String MatGroup = "",
const Whole  RenderOp = Graphics::RO_TriangleList 
)

Gets a BufferSection that can be appended to the end of this buffer.

Remarks
Sections are a useful tool for if and when you want to generate a Mesh with multiple SubMeshes. The usefulness of multiple SubMeshes is being able to assign more than one material to a mesh for whatever reason (there are plenty). When you start a Section if you have already added some vertex data to the mesh then all data input thus far will become a section and a new, second section will be started. Likewise, if a section is in progress and you call BeginSection then the previous section will be ended.
Section names and their materials are optional. However if you do not assign a material to a completed mesh prior to rendered it will render as just white (probably not what you are going for). So while setting a material name is optional at this stage it is a good idea to get around to.
Parameters
MatNameThe name of the material to be used with this section.
MatGroupThe asset group where the Material can be found.
RenderOpThe render operation describing how the Vertices should be treated for assembling the Mesh. See Graphics::RenderOperation enum for more information.

Definition at line 208 of file trianglebuffer.cpp.

void Mezzanine::Graphics::Procedural::TriangleBuffer::EndSection ( )

Sets a BufferSection as the end section of this buffer.

Parameters
SectThe BufferSection to set as the end of the buffer.

Definition at line 232 of file trianglebuffer.cpp.

void Mezzanine::Graphics::Procedural::TriangleBuffer::EstimateIndexCount ( const Whole  IndexCount)

Gives an estimation of the number of indices needed for this triangle buffer.

Remarks
If this function is called several times, it means an extra indices count, not an absolute measure.
Parameters
IndexCountThe amount of additional Indexes to allocate for.

Definition at line 178 of file trianglebuffer.cpp.

void Mezzanine::Graphics::Procedural::TriangleBuffer::EstimateVertexCount ( const Whole  VertexCount)

Gives an estimation of the number of vertices need for this triangle buffer.

Remarks
If this function is called several times, it means an extra vertices count, not an absolute measure.
Parameters
VertexCountThe amount of additional Vertices to allocate for.

Definition at line 172 of file trianglebuffer.cpp.

Mesh * Mezzanine::Graphics::Procedural::TriangleBuffer::GenerateMesh ( const String MeshName,
const String MeshGroup,
const String MatName = "",
const String MatGroup = "" 
) const

Builds a Mesh from this buffer.

Note
The returned mesh will need a Material applied to it for proper rendering.
Parameters
MeshNameThe name to give to the generated Mesh.
MeshGroupThe asset group to place the mesh in.
MatNameThe name of the Material to apply to the Mesh. This is only used if the buffer isn't using sections.
MatGroupThe asset group where the Material can be found. This is only used if the buffer isn't using sections.
Returns
Returns a pointer to the created Mesh.

Definition at line 112 of file trianglebuffer.cpp.

IndexContainer & Mezzanine::Graphics::Procedural::TriangleBuffer::GetIndices ( )

Gets a modifiable reference to Indices.

Returns
Returns a reference to the container storing the Indices of this buffer.

Definition at line 199 of file trianglebuffer.cpp.

const IndexContainer & Mezzanine::Graphics::Procedural::TriangleBuffer::GetIndices ( ) const

Gets a non-modifiable reference to Indices.

Returns
Returns a const reference to the container storing the Indices of this buffer.

Definition at line 202 of file trianglebuffer.cpp.

TriangleBuffer::SectionContainer & Mezzanine::Graphics::Procedural::TriangleBuffer::GetSections ( )

Gets a modifiable reference to Sections.

Returns
Returns a reference to the container storing the Sections of this buffer.

Definition at line 187 of file trianglebuffer.cpp.

const TriangleBuffer::SectionContainer & Mezzanine::Graphics::Procedural::TriangleBuffer::GetSections ( ) const

Gets a non-modifiable reference to Sections.

Returns
Returns a const reference to the container storing the Sections of this buffer.

Definition at line 190 of file trianglebuffer.cpp.

VertexContainer & Mezzanine::Graphics::Procedural::TriangleBuffer::GetVertices ( )

Gets a modifiable reference to Vertices.

Returns
Returns a reference to the container storing the Vertices of this buffer.

Definition at line 193 of file trianglebuffer.cpp.

const VertexContainer & Mezzanine::Graphics::Procedural::TriangleBuffer::GetVertices ( ) const

Gets a non-modifiable reference to Vertices.

Returns
Returns a const reference to the container storing the Vertices of this buffer.

Definition at line 196 of file trianglebuffer.cpp.

TriangleBuffer & Mezzanine::Graphics::Procedural::TriangleBuffer::InvertNormals ( )

Applies normal inversion on this triangle buffer.

Returns
Returns a reference to this.

Definition at line 356 of file trianglebuffer.cpp.

Boole Mezzanine::Graphics::Procedural::TriangleBuffer::IsUsingSections ( ) const

Gets whether or not this buffer is divided into sections.

Returns
Returns true if this buffer will generate multiple SubMeshes when it makes a Mesh, false otherwise.

Definition at line 243 of file trianglebuffer.cpp.

Boole Mezzanine::Graphics::Procedural::TriangleBuffer::IsWorkingOnSection ( ) const

Gets whether or not a section has been started and not yet closed.

Returns
Returns true if this buffer has an open section that is not yet ended, false otherwise.

Definition at line 246 of file trianglebuffer.cpp.

void Mezzanine::Graphics::Procedural::TriangleBuffer::RebaseOffset ( )

Rebase index offset.

Remarks
Call this function before you add a new mesh to the triangle buffer.

Definition at line 184 of file trianglebuffer.cpp.

TriangleBuffer & Mezzanine::Graphics::Procedural::TriangleBuffer::RotateVertices ( const Quaternion Rot)

Applies the rotation immediately to all the points contained in this triangle buffer.

Parameters
RotThe amount of rotation to be applied to each Vertex.
Returns
Returns a reference to this.

Definition at line 331 of file trianglebuffer.cpp.

TriangleBuffer & Mezzanine::Graphics::Procedural::TriangleBuffer::ScaleVertices ( const Vector3 Scale)

Applies an immediate scale operation to this triangle buffer.

Parameters
ScaleThe amount of scaling to be applied to each Vertex.
Returns
Returns a reference to this.

Definition at line 342 of file trianglebuffer.cpp.

TriangleBuffer & Mezzanine::Graphics::Procedural::TriangleBuffer::ScaleVertices ( const Real  X,
const Real  Y,
const Real  Z 
)

Applies an immediate scale operation to this triangle buffer.

Parameters
XThe amount to scale the contents of this buffer on the X axis.
YThe amount to scale the contents of this buffer on the Y axis.
ZThe amount to scale the contents of this buffer on the Z axis.
Returns
Returns a reference to this.

Definition at line 351 of file trianglebuffer.cpp.

TriangleBuffer & Mezzanine::Graphics::Procedural::TriangleBuffer::SetNormal ( const Vector3 Norm)

Sets the normal of the current vertex.

Parameters
NormThe facing direction to set for the current Vertex.
Returns
Returns a reference to this.

Definition at line 288 of file trianglebuffer.cpp.

TriangleBuffer & Mezzanine::Graphics::Procedural::TriangleBuffer::SetTextureCoord ( const Real  U,
const Real  V 
)

Sets the texture coordinates of the current vertex.

Parameters
UThe U component of texture UV component to set for the current Vertex.
VThe V component of texture UV component to set for the current Vertex.
Returns
Returns a reference to this.

Definition at line 294 of file trianglebuffer.cpp.

TriangleBuffer & Mezzanine::Graphics::Procedural::TriangleBuffer::SetTextureCoord ( const Vector2 UV)

Sets the texture coordinates of the current vertex.

Parameters
UVThe texture coordinate to set for the current Vertex.
Returns
Returns a reference to this.

Definition at line 300 of file trianglebuffer.cpp.

TriangleBuffer & Mezzanine::Graphics::Procedural::TriangleBuffer::TranslateVertices ( const Vector3 Trans)

Applies the translation immediately to all the points contained in this triangle buffer.

Parameters
TransThe amount of movement to be applied on each axis.
Returns
Returns a reference to this.

Definition at line 317 of file trianglebuffer.cpp.

TriangleBuffer & Mezzanine::Graphics::Procedural::TriangleBuffer::TranslateVertices ( const Real  X,
const Real  Y,
const Real  Z 
)

Applies the translation immediately to all the points contained in this triangle buffer.

Parameters
XThe amount of movement to be applied to each Vertex in this buffer on the X axis.
YThe amount of movement to be applied to each Vertex in this buffer on the Y axis.
ZThe amount of movement to be applied to each Vertex in this buffer on the Z axis.
Returns
Returns a reference to this.

Definition at line 326 of file trianglebuffer.cpp.

Member Data Documentation

BufferSection Mezzanine::Graphics::Procedural::TriangleBuffer::CurrentSection
protected

Temporary storage for the current section being worked on.

Definition at line 218 of file trianglebuffer.h.

Vertex* Mezzanine::Graphics::Procedural::TriangleBuffer::CurrentVertex
protected

Convenience pointer to the Vertex currently being manipulated.

Definition at line 221 of file trianglebuffer.h.

Integer Mezzanine::Graphics::Procedural::TriangleBuffer::EstimatedIndexCount
protected

The user estimated Index count for this buffer.

Definition at line 227 of file trianglebuffer.h.

Integer Mezzanine::Graphics::Procedural::TriangleBuffer::EstimatedVertexCount
protected

The user estimated Vertex count for this buffer.

Definition at line 224 of file trianglebuffer.h.

Integer Mezzanine::Graphics::Procedural::TriangleBuffer::GlobalOffset
protected

Offset used to set where buffer/mesh appends begin.

Definition at line 230 of file trianglebuffer.h.

IndexContainer Mezzanine::Graphics::Procedural::TriangleBuffer::Indices
protected

Container storing all of the Indices in this buffer.

Definition at line 215 of file trianglebuffer.h.

SectionContainer Mezzanine::Graphics::Procedural::TriangleBuffer::Sections
protected

Container storing all of the sections of this buffer.

Definition at line 209 of file trianglebuffer.h.

VertexContainer Mezzanine::Graphics::Procedural::TriangleBuffer::Vertices
protected

Container storing all of the Vertices in this buffer.

Definition at line 212 of file trianglebuffer.h.


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