Ogre Procedural  0.3.0 unstable
Procedural Geometry & Textures for Ogre3D
Classes | Public Member Functions | Protected Attributes | List of all members
Procedural::TriangleBuffer Class Reference

This is ogre-procedural's temporary mesh buffer. More...

#include <ProceduralTriangleBuffer.h>

Classes

struct  Section
 
struct  Vertex
 

Public Member Functions

 TriangleBuffer ()
 
void append (const TriangleBuffer &other)
 
Section beginSection (std::string sectionName="")
 
void endSection (Section &section)
 
Section getFullSection ()
 
std::vector< Vertex > & getVertices ()
 Gets a modifiable reference to vertices. More...
 
const std::vector< Vertex > & getVertices () const
 Gets a non-modifiable reference to vertices. More...
 
std::vector< int > & getIndices ()
 Gets a modifiable reference to vertices. More...
 
const std::vector< int > & getIndices () const
 Gets a non-modifiable reference to indices. More...
 
void rebaseOffset ()
 Rebase index offset : call that function before you add a new mesh to the triangle buffer. More...
 
Ogre::MeshPtr transformToMesh (const std::string &name, const Ogre::String &group="General") const
 Builds an Ogre Mesh from this buffer. More...
 
TriangleBuffervertex (const Vertex &v)
 Adds a new vertex to the buffer. More...
 
TriangleBuffervertex (const Ogre::Vector3 &position, const Ogre::Vector3 &normal, const Ogre::Vector2 &uv)
 Adds a new vertex to the buffer. More...
 
TriangleBufferposition (const Ogre::Vector3 &pos)
 Adds a new vertex to the buffer. More...
 
TriangleBufferposition (Ogre::Real x, Ogre::Real y, Ogre::Real z)
 Adds a new vertex to the buffer. More...
 
TriangleBuffernormal (const Ogre::Vector3 &normal)
 Sets the normal of the current vertex. More...
 
TriangleBuffertextureCoord (float u, float v)
 Sets the texture coordinates of the current vertex. More...
 
TriangleBuffertextureCoord (const Ogre::Vector2 &vec)
 Sets the texture coordinates of the current vertex. More...
 
TriangleBufferindex (int i)
 Adds an index to the index buffer. More...
 
TriangleBuffertriangle (int i1, int i2, int i3)
 Adds a triangle to the index buffer. More...
 
TriangleBufferapplyTransform (const Ogre::Matrix4 &matrix)
 Applies a matrix to transform all vertices inside the triangle buffer. More...
 
TriangleBuffertranslate (const Ogre::Vector3 &amount)
 Applies the translation immediately to all the points contained in that triangle buffer. More...
 
TriangleBuffertranslate (Ogre::Real x, Ogre::Real y, Ogre::Real z)
 Applies the translation immediately to all the points contained in that triangle buffer. More...
 
TriangleBufferrotate (Ogre::Quaternion quat)
 Applies the rotation immediately to all the points contained in that triangle buffer. More...
 
TriangleBufferscale (const Ogre::Vector3 &scale)
 Applies an immediate scale operation to that triangle buffer. More...
 
TriangleBufferscale (Ogre::Real x, Ogre::Real y, Ogre::Real z)
 Applies an immediate scale operation to that triangle buffer. More...
 
TriangleBufferinvertNormals ()
 Applies normal inversion on the triangle buffer. More...
 
void estimateVertexCount (unsigned int vertexCount)
 Gives an estimation of the number of vertices need for this triangle buffer. More...
 
void estimateIndexCount (unsigned int indexCount)
 Gives an estimation of the number of indices needed for this triangle buffer. More...
 

Protected Attributes

std::vector< int > mIndices
 
std::vector< VertexmVertices
 
int globalOffset
 
int mEstimatedVertexCount
 
int mEstimatedIndexCount
 
VertexmCurrentVertex
 
std::map< std::string, SectionmSections
 

Detailed Description

This is ogre-procedural's temporary mesh buffer.

It stores all the info needed to build an Ogre Mesh, yet is intented to be more flexible, since there is no link towards hardware.

Constructor & Destructor Documentation

◆ TriangleBuffer()

Procedural::TriangleBuffer::TriangleBuffer ( )

Member Function Documentation

◆ append()

void Procedural::TriangleBuffer::append ( const TriangleBuffer other)

References mIndices, and mVertices.

◆ applyTransform()

TriangleBuffer& Procedural::TriangleBuffer::applyTransform ( const Ogre::Matrix4 matrix)

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

◆ beginSection()

Section Procedural::TriangleBuffer::beginSection ( std::string  sectionName = "")

◆ endSection()

void Procedural::TriangleBuffer::endSection ( Section section)

◆ estimateIndexCount()

void Procedural::TriangleBuffer::estimateIndexCount ( unsigned int  indexCount)

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

If this function is called several times, it means an extra indices count, not an absolute measure.

◆ estimateVertexCount()

void Procedural::TriangleBuffer::estimateVertexCount ( unsigned int  vertexCount)

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

If this function is called several times, it means an extra vertices count, not an absolute measure.

◆ getFullSection()

Section Procedural::TriangleBuffer::getFullSection ( )

◆ getIndices() [1/2]

std::vector<int>& Procedural::TriangleBuffer::getIndices ( )

Gets a modifiable reference to vertices.

◆ getIndices() [2/2]

const std::vector<int>& Procedural::TriangleBuffer::getIndices ( ) const

Gets a non-modifiable reference to indices.

◆ getVertices() [1/2]

std::vector<Vertex>& Procedural::TriangleBuffer::getVertices ( )

Gets a modifiable reference to vertices.

◆ getVertices() [2/2]

const std::vector<Vertex>& Procedural::TriangleBuffer::getVertices ( ) const

Gets a non-modifiable reference to vertices.

◆ index()

TriangleBuffer& Procedural::TriangleBuffer::index ( int  i)

Adds an index to the index buffer.

Index is relative to the latest rebaseOffset().

◆ invertNormals()

TriangleBuffer& Procedural::TriangleBuffer::invertNormals ( )

Applies normal inversion on the triangle buffer.

References std::swap().

◆ normal()

TriangleBuffer& Procedural::TriangleBuffer::normal ( const Ogre::Vector3 normal)

Sets the normal of the current vertex.

References Procedural::TriangleBuffer::Vertex::mNormal.

Referenced by Procedural::MeshGenerator< TorusGenerator >::addPoint().

◆ position() [1/2]

TriangleBuffer& Procedural::TriangleBuffer::position ( const Ogre::Vector3 pos)

Adds a new vertex to the buffer.

References v.

Referenced by Procedural::MeshGenerator< TorusGenerator >::addPoint().

◆ position() [2/2]

TriangleBuffer& Procedural::TriangleBuffer::position ( Ogre::Real  x,
Ogre::Real  y,
Ogre::Real  z 
)

Adds a new vertex to the buffer.

References v.

◆ rebaseOffset()

void Procedural::TriangleBuffer::rebaseOffset ( )

Rebase index offset : call that function before you add a new mesh to the triangle buffer.

◆ rotate()

TriangleBuffer& Procedural::TriangleBuffer::rotate ( Ogre::Quaternion  quat)

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

Parameters
quatthe rotation quaternion to apply

References Ogre::Quaternion::normalise().

◆ scale() [1/2]

TriangleBuffer& Procedural::TriangleBuffer::scale ( const Ogre::Vector3 scale)

Applies an immediate scale operation to that triangle buffer.

Parameters
scaleScale vector

◆ scale() [2/2]

TriangleBuffer& Procedural::TriangleBuffer::scale ( Ogre::Real  x,
Ogre::Real  y,
Ogre::Real  z 
)

Applies an immediate scale operation to that triangle buffer.

Parameters
xX scale component
yY scale component
zZ scale component

◆ textureCoord() [1/2]

TriangleBuffer& Procedural::TriangleBuffer::textureCoord ( const Ogre::Vector2 vec)

Sets the texture coordinates of the current vertex.

References Procedural::TriangleBuffer::Vertex::mUV.

◆ textureCoord() [2/2]

TriangleBuffer& Procedural::TriangleBuffer::textureCoord ( float  u,
float  v 
)

Sets the texture coordinates of the current vertex.

References Procedural::TriangleBuffer::Vertex::mUV, u, and v.

Referenced by Procedural::MeshGenerator< TorusGenerator >::addPoint().

◆ transformToMesh()

Ogre::MeshPtr Procedural::TriangleBuffer::transformToMesh ( const std::string &  name,
const Ogre::String group = "General" 
) const

Builds an Ogre Mesh from this buffer.

Referenced by Procedural::MeshGenerator< TorusGenerator >::realizeMesh().

◆ translate() [1/2]

TriangleBuffer& Procedural::TriangleBuffer::translate ( const Ogre::Vector3 amount)

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

Parameters
amounttranslation vector

◆ translate() [2/2]

TriangleBuffer& Procedural::TriangleBuffer::translate ( Ogre::Real  x,
Ogre::Real  y,
Ogre::Real  z 
)

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

References translate().

◆ triangle()

TriangleBuffer& Procedural::TriangleBuffer::triangle ( int  i1,
int  i2,
int  i3 
)

Adds a triangle to the index buffer.

Index is relative to the latest rebaseOffset().

◆ vertex() [1/2]

TriangleBuffer& Procedural::TriangleBuffer::vertex ( const Ogre::Vector3 position,
const Ogre::Vector3 normal,
const Ogre::Vector2 uv 
)

Adds a new vertex to the buffer.

References v.

◆ vertex() [2/2]

TriangleBuffer& Procedural::TriangleBuffer::vertex ( const Vertex v)

Adds a new vertex to the buffer.

References v.

Member Data Documentation

◆ globalOffset

int Procedural::TriangleBuffer::globalOffset
protected

◆ mCurrentVertex

Vertex* Procedural::TriangleBuffer::mCurrentVertex
protected

◆ mEstimatedIndexCount

int Procedural::TriangleBuffer::mEstimatedIndexCount
protected

◆ mEstimatedVertexCount

int Procedural::TriangleBuffer::mEstimatedVertexCount
protected

◆ mIndices

std::vector<int> Procedural::TriangleBuffer::mIndices
protected

Referenced by append().

◆ mSections

std::map<std::string, Section> Procedural::TriangleBuffer::mSections
protected

◆ mVertices

std::vector<Vertex> Procedural::TriangleBuffer::mVertices
protected

Referenced by append().


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