67 #ifndef _graphicsproceduraltrianglebuffer_cpp
68 #define _graphicsproceduraltrianglebuffer_cpp
70 #include "Graphics/Procedural/Mesh/trianglebuffer.h"
72 #include "Graphics/meshmanager.h"
84 EstimatedVertexCount(0),
85 EstimatedIndexCount(0),
102 { this->
Vertices.push_back( *VertIt ); }
114 Ogre::ManualObject* TempMan =
new Ogre::ManualObject(
"TempMan");
116 #if OGRE_VERSION >= ((2 << 16) | (0 << 8) | 0)
117 Ogre::Vector3 aabb_min = Ogre::Vector3::ZERO;
118 Ogre::Vector3 aabb_max = Ogre::Vector3::ZERO;
123 TempMan->begin( (*SectIt).MaterialName, Ogre::RenderOperation::OT_TRIANGLE_LIST, (*SectIt).MaterialGroup );
127 TempMan->position( VertIt->Position.GetOgreVector3() );
128 TempMan->textureCoord( VertIt->UV.GetOgreVector2() );
129 TempMan->normal( VertIt->Normal.GetOgreVector3() );
130 #if OGRE_VERSION >= ((2 << 16) | (0 << 8) | 0)
131 if( VertIt->Position.X < aabb_min.X ) aabb_min.X = it->Position.X;
132 if( VertIt->Position.Y < aabb_min.Y ) aabb_min.Y = it->Position.Y;
133 if( VertIt->Position.Z < aabb_min.Z ) aabb_min.Z = it->Position.Z;
134 if( VertIt->Position.X > aabb_max.X ) aabb_max.X = it->Position.X;
135 if( VertIt->Position.Y > aabb_max.Y ) aabb_max.Y = it->Position.Y;
136 if( VertIt->Position.Z > aabb_max.Z ) aabb_max.z = it->Position.Z;
141 { TempMan->index( *IndicIt ); }
145 TempMan->begin(MatName,Ogre::RenderOperation::OT_TRIANGLE_LIST,MatGroup);
148 TempMan->position( VertIt->Position.GetOgreVector3() );
149 TempMan->textureCoord( VertIt->UV.GetOgreVector2() );
150 TempMan->normal( VertIt->Normal.GetOgreVector3() );
151 #if OGRE_VERSION >= ((2 << 16) | (0 << 8) | 0)
152 if( VertIt->Position.X < aabb_min.X ) aabb_min.X = it->Position.X;
153 if( VertIt->Position.Y < aabb_min.Y ) aabb_min.Y = it->Position.Y;
154 if( VertIt->Position.Z < aabb_min.Z ) aabb_min.Z = it->Position.Z;
155 if( VertIt->Position.X > aabb_max.X ) aabb_max.X = it->Position.X;
156 if( VertIt->Position.Y > aabb_max.Y ) aabb_max.Y = it->Position.Y;
157 if( VertIt->Position.Z > aabb_max.Z ) aabb_max.z = it->Position.Z;
161 { TempMan->index( *IndIt ); }
164 #if OGRE_VERSION >= ((2 << 16) | (0 << 8) | 0)
165 TempMan->setLocalAabb( Ogre::Aabb::newFromExtents(aabb_min,aabb_max) );
310 VertIt->Position = Mat * VertIt->Position;
311 VertIt->Normal = Mat * VertIt->Normal;
312 VertIt->Normal.Normalize();
321 VertIt->Position = VertIt->Position + Trans;
335 VertIt->Position = Rot * VertIt->Position;
336 VertIt->Normal = Rot * VertIt->Normal;
346 VertIt->Position = Scale * VertIt->Position;
360 VertIt->Normal = -(VertIt->Normal);
362 for(
Whole Index = 0 ; Index < this->
Indices.size() ; ++Index )
364 if( Index % 3 == 1 ) {
IndexContainer::const_iterator ConstIndexIterator
Const Iterator type for a IndexContainer.
std::vector< Vertex > VertexContainer
Basic container type for Vertex storage.
IndexContainer & GetIndices()
Gets a modifiable reference to Indices.
Whole LastIndex
The end indicy of this section in the parent buffer.
~TriangleBuffer()
Class destructor.
bool Boole
Generally acts a single bit, true or false.
IndexContainer Indices
Container storing all of the Indices in this buffer.
VertexContainer::iterator VertexIterator
Iterator type for Vertex instances in a VertexContainer.
BufferSection CurrentSection
Temporary storage for the current section being worked on.
A convenience buffer that stores vertices and indices of a mesh to be generated.
TriangleBuffer & SetTextureCoord(const Real U, const Real V)
Sets the texture coordinates of the current vertex.
TriangleBuffer()
Class constructor.
This class is used to check and modify the properties of a graphics mesh.
TriangleBuffer & RotateVertices(const Quaternion &Rot)
Applies the rotation immediately to all the points contained in this triangle buffer.
TriangleBuffer & ApplyTransform(const Matrix4x4 &Mat)
Applies a matrix to transform all vertices inside this triangle buffer.
void EstimateIndexCount(const Whole IndexCount)
Gives an estimation of the number of indices needed for this triangle buffer.
void RebaseOffset()
Rebase index offset.
int Integer
A datatype used to represent any integer close to.
A simple definition for a Vertex to be used when procedurally generating meshes.
void AppendBuffer(const TriangleBuffer &Other)
Appends the contents of another buffer to this buffer.
A 4x4 matrix math class for the representation of full transforms.
TriangleBuffer & SetNormal(const Vector3 &Norm)
Sets the normal of the current vertex.
Integer EstimatedIndexCount
The user estimated Index count for this buffer.
Mesh * GenerateMesh(const String &MeshName, const String &MeshGroup, const String &MatName="", const String &MatGroup="") const
Builds a Mesh from this buffer.
Quaternion & Normalize()
Normalizes this Quaternion.
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...
String MaterialGroup
The asset group where the material can be found.
VertexContainer & GetVertices()
Gets a modifiable reference to Vertices.
Whole LastVertex
The end vertex of this section in the parent buffer.
Vector3 Position
The position of the vertex in local space.
float Real
A Datatype used to represent a real floating point number.
void Clear()
Clears all the data on this BufferSection back to a blank initialization.
Integer EstimatedVertexCount
The user estimated Vertex count for this buffer.
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.
std::vector< BufferSection > SectionContainer
Basic container type for Section storage in this class.
std::vector< Integer > IndexContainer
A container of Integers used to represent the indicies of a shape.
VertexContainer Vertices
Container storing all of the Vertices in this buffer.
Vector2 UV
The UV coordinate for applying textures.
Whole FirstIndex
The start indicy of this section in the parent buffer.
String MaterialName
The name of the material to be used with this section.
static MeshManager * GetSingletonPtr()
Fetches a pointer to the singleton.
SectionContainer::const_iterator ConstSectionIterator
Const Iterator type for Section instances stored in this class.
TriangleBuffer & TranslateVertices(const Vector3 &Trans)
Applies the translation immediately to all the points contained in this triangle buffer.
void EstimateVertexCount(const Whole VertexCount)
Gives an estimation of the number of vertices need for this triangle buffer.
This is used to represent a point on a 2 dimentional area, such as a screen.
SectionContainer & GetSections()
Gets a modifiable reference to Sections.
TriangleBuffer & AddTriangle(const Integer Index1, const Integer Index2, const Integer Index3)
Adds a triangle to the index buffer.
Boole IsWorkingOnSection() const
Gets whether or not a section has been started and not yet closed.
void SetValues(const Real &x, const Real &y)
Sets the X and Y values of this vector2.
void SetValues(const Real &X, const Real &Y, const Real &Z)
Manually sets all the members of this vector3.
void EndSection()
Sets a BufferSection as the end section of this buffer.
Vertex * CurrentVertex
Convenience pointer to the Vertex currently being manipulated.
Integer GlobalOffset
Offset used to set where buffer/mesh appends begin.
Whole RenderOp
The render operation to be used for the section. See Graphics::RenderOperation enum for more info...
Boole IsUsingSections() const
Gets whether or not this buffer is divided into sections.
TriangleBuffer & ScaleVertices(const Vector3 &Scale)
Applies an immediate scale operation to this triangle buffer.
TriangleBuffer & AddIndex(const Integer Index)
Adds an index to the index buffer.
This is used to represent a point in space, or a vector through space.
VertexContainer::const_iterator ConstVertexIterator
Const Iterator type for Vertex instances in a VertexContainer.
The bulk of the engine components go in this namspace.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Vector3 Normal
The facing direction of the vertex in local space.
TriangleBuffer & InvertNormals()
Applies normal inversion on this triangle buffer.
This is used to store information about rotation in 3d space.
SectionContainer Sections
Container storing all of the sections of this buffer.
Whole FirstVertex
The start vertex of this section in the parent buffer.
std::string String
A datatype used to a series of characters.
Vertices form triangles. Each triangle has it's own distinct set of Vertices. Vertices are not expect...
TriangleBuffer & AddVertex(const Vertex &Vert)
Adds a premade Vertex to the buffer.