67 #ifndef _graphicsproceduralboxcornergenerator_cpp
68 #define _graphicsproceduralboxcornergenerator_cpp
70 #include "Graphics/Procedural/Mesh/boxcornergenerator.h"
106 Real FirstSizeCheck = Half .
X < Half .
Y ? Half .
X : Half .
Y;
107 Real Smallest = FirstSizeCheck < Half .
Z ? FirstSizeCheck : Half .
Z;
108 if( Smallest * 2 <= FirstSizeCheck ) {
109 Length = Smallest * 0.5;
111 Length = Smallest * 0.25;
118 std::vector<Procedural::Vertex> BoxVertices;
144 BoxVertices.push_back(
Vertex(
Vector3(-Half.
X + this->BoxThick,Half.
Y - this->BoxThick,Half.
Z - this->BoxThick),
Vector3(0,0,-1),
Vector2(1 - (this->
BoxThick / Full.
X),this->BoxThick / Full.
Y) ) );
150 BoxVertices.push_back(
Vertex(
Vector3(-Half.
X + this->BoxThick,Half.
Y - this->BoxThick,Half.
Z - this->BoxThick),
Vector3(0,0,-1),
Vector2(1 - (this->
BoxThick / Full.
X),this->BoxThick / Full.
Y) ) );
182 std::vector<Vector3> Flips;
183 Flips.push_back(
Vector3(1,1,1) );
184 Flips.push_back(
Vector3(1,1,-1) );
185 Flips.push_back(
Vector3(1,-1,1) );
186 Flips.push_back(
Vector3(-1,1,1) );
187 Flips.push_back(
Vector3(1,-1,-1) );
188 Flips.push_back(
Vector3(-1,1,-1) );
189 Flips.push_back(
Vector3(-1,-1,1) );
190 Flips.push_back(
Vector3(-1,-1,-1) );
193 for( std::vector<Vector3>::iterator CurrentFlip = Flips.begin() ; CurrentFlip != Flips.end() ; ++CurrentFlip )
195 for( std::vector<Procedural::Vertex>::iterator CurrentVertex = BoxVertices.begin() ; CurrentVertex != BoxVertices.end() ; ++CurrentVertex )
198 (*CurrentVertex).Position * (*CurrentFlip),
199 (*CurrentVertex).Normal * (*CurrentFlip),
200 (*CurrentVertex).UV );
205 for(
Whole FlipCount = 0 ; FlipCount<Flips.size() ; ++FlipCount )
207 Whole ShapeIndex = FlipCount * BoxVertices.size();
210 if( 1 == Flips.at(FlipCount).Z ) {
212 Buffer.
AddTriangle( 0 + ShapeIndex, 1 + ShapeIndex, 2 + ShapeIndex );
213 Buffer.
AddTriangle( 0 + ShapeIndex, 2 + ShapeIndex, 3 + ShapeIndex );
214 Buffer.
AddTriangle( 0 + ShapeIndex, 3 + ShapeIndex, 4 + ShapeIndex );
215 Buffer.
AddTriangle( 0 + ShapeIndex, 4 + ShapeIndex, 5 + ShapeIndex );
217 Buffer.
AddTriangle( 18 + ShapeIndex, 19 + ShapeIndex, 20 + ShapeIndex );
218 Buffer.
AddTriangle( 18 + ShapeIndex, 20 + ShapeIndex, 21 + ShapeIndex );
219 Buffer.
AddTriangle( 22 + ShapeIndex, 23 + ShapeIndex, 24 + ShapeIndex );
220 Buffer.
AddTriangle( 22 + ShapeIndex, 24 + ShapeIndex, 25 + ShapeIndex );
221 Buffer.
AddTriangle( 26 + ShapeIndex, 27 + ShapeIndex, 28 + ShapeIndex );
222 Buffer.
AddTriangle( 26 + ShapeIndex, 28 + ShapeIndex, 29 + ShapeIndex );
225 Buffer.
AddTriangle( 0 + ShapeIndex, 1 + ShapeIndex, 2 + ShapeIndex );
226 Buffer.
AddTriangle( 0 + ShapeIndex, 3 + ShapeIndex, 4 + ShapeIndex );
227 Buffer.
AddTriangle( 0 + ShapeIndex, 2 + ShapeIndex, 3 + ShapeIndex );
228 Buffer.
AddTriangle( 0 + ShapeIndex, 4 + ShapeIndex, 5 + ShapeIndex );
230 Buffer.
AddTriangle( 26 + ShapeIndex, 28 + ShapeIndex, 29 + ShapeIndex );
231 Buffer.
AddTriangle( 26 + ShapeIndex, 27 + ShapeIndex, 28 + ShapeIndex );
232 Buffer.
AddTriangle( 22 + ShapeIndex, 24 + ShapeIndex, 25 + ShapeIndex );
233 Buffer.
AddTriangle( 22 + ShapeIndex, 23 + ShapeIndex, 24 + ShapeIndex );
234 Buffer.
AddTriangle( 18 + ShapeIndex, 20 + ShapeIndex, 21 + ShapeIndex );
235 Buffer.
AddTriangle( 18 + ShapeIndex, 19 + ShapeIndex, 20 + ShapeIndex );
238 if( 1 == Flips.at(FlipCount).Y ) {
240 Buffer.
AddTriangle( 6 + ShapeIndex, 7 + ShapeIndex, 8 + ShapeIndex );
241 Buffer.
AddTriangle( 6 + ShapeIndex, 8 + ShapeIndex, 9 + ShapeIndex );
242 Buffer.
AddTriangle( 6 + ShapeIndex, 9 + ShapeIndex, 10 + ShapeIndex );
243 Buffer.
AddTriangle( 6 + ShapeIndex, 10 + ShapeIndex, 11 + ShapeIndex );
245 Buffer.
AddTriangle( 30 + ShapeIndex, 31 + ShapeIndex, 32 + ShapeIndex );
246 Buffer.
AddTriangle( 30 + ShapeIndex, 32 + ShapeIndex, 33 + ShapeIndex );
247 Buffer.
AddTriangle( 34 + ShapeIndex, 35 + ShapeIndex, 36 + ShapeIndex );
248 Buffer.
AddTriangle( 34 + ShapeIndex, 36 + ShapeIndex, 37 + ShapeIndex );
249 Buffer.
AddTriangle( 38 + ShapeIndex, 39 + ShapeIndex, 40 + ShapeIndex );
250 Buffer.
AddTriangle( 38 + ShapeIndex, 40 + ShapeIndex, 41 + ShapeIndex );
253 Buffer.
AddTriangle( 6 + ShapeIndex, 10 + ShapeIndex, 11 + ShapeIndex );
254 Buffer.
AddTriangle( 6 + ShapeIndex, 9 + ShapeIndex, 10 + ShapeIndex );
255 Buffer.
AddTriangle( 6 + ShapeIndex, 8 + ShapeIndex, 9 + ShapeIndex );
256 Buffer.
AddTriangle( 6 + ShapeIndex, 7 + ShapeIndex, 8 + ShapeIndex );
258 Buffer.
AddTriangle( 38 + ShapeIndex, 40 + ShapeIndex, 41 + ShapeIndex );
259 Buffer.
AddTriangle( 38 + ShapeIndex, 39 + ShapeIndex, 40 + ShapeIndex );
260 Buffer.
AddTriangle( 34 + ShapeIndex, 36 + ShapeIndex, 37 + ShapeIndex );
261 Buffer.
AddTriangle( 34 + ShapeIndex, 35 + ShapeIndex, 36 + ShapeIndex );
262 Buffer.
AddTriangle( 30 + ShapeIndex, 32 + ShapeIndex, 33 + ShapeIndex );
263 Buffer.
AddTriangle( 30 + ShapeIndex, 31 + ShapeIndex, 32 + ShapeIndex );
266 if( 1 == Flips.at(FlipCount).X ) {
268 Buffer.
AddTriangle( 12 + ShapeIndex, 13 + ShapeIndex, 14 + ShapeIndex );
269 Buffer.
AddTriangle( 12 + ShapeIndex, 14 + ShapeIndex, 15 + ShapeIndex );
270 Buffer.
AddTriangle( 12 + ShapeIndex, 15 + ShapeIndex, 16 + ShapeIndex );
271 Buffer.
AddTriangle( 12 + ShapeIndex, 16 + ShapeIndex, 17 + ShapeIndex );
273 Buffer.
AddTriangle( 42 + ShapeIndex, 43 + ShapeIndex, 44 + ShapeIndex );
274 Buffer.
AddTriangle( 42 + ShapeIndex, 44 + ShapeIndex, 45 + ShapeIndex );
275 Buffer.
AddTriangle( 46 + ShapeIndex, 47 + ShapeIndex, 48 + ShapeIndex );
276 Buffer.
AddTriangle( 46 + ShapeIndex, 48 + ShapeIndex, 49 + ShapeIndex );
277 Buffer.
AddTriangle( 50 + ShapeIndex, 51 + ShapeIndex, 52 + ShapeIndex );
278 Buffer.
AddTriangle( 50 + ShapeIndex, 52 + ShapeIndex, 53 + ShapeIndex );
281 Buffer.
AddTriangle( 12 +ShapeIndex, 16 + ShapeIndex, 17 + ShapeIndex );
282 Buffer.
AddTriangle( 12 +ShapeIndex, 15 + ShapeIndex, 16 + ShapeIndex );
283 Buffer.
AddTriangle( 12 +ShapeIndex, 14 + ShapeIndex, 15 + ShapeIndex );
284 Buffer.
AddTriangle( 12 +ShapeIndex, 13 + ShapeIndex, 14 + ShapeIndex );
286 Buffer.
AddTriangle( 50 + ShapeIndex, 52 + ShapeIndex, 53 + ShapeIndex );
287 Buffer.
AddTriangle( 50 + ShapeIndex, 51 + ShapeIndex, 52 + ShapeIndex );
288 Buffer.
AddTriangle( 46 + ShapeIndex, 48 + ShapeIndex, 49 + ShapeIndex );
289 Buffer.
AddTriangle( 46 + ShapeIndex, 47 + ShapeIndex, 48 + ShapeIndex );
290 Buffer.
AddTriangle( 42 + ShapeIndex, 44 + ShapeIndex, 45 + ShapeIndex );
291 Buffer.
AddTriangle( 42 + ShapeIndex, 43 + ShapeIndex, 44 + ShapeIndex );
301 if( HalfSizeX <= 0.0 )
310 if( HalfSizeY <= 0.0 )
319 if( HalfSizeZ <= 0.0 )
336 if( CornerThickness == 0 )
BoxCornerGenerator & SetCornerThickness(const Real CornerThickness)
Sets how far into the box from the edge for each axis the corner component will be sized for...
Real BoxThick
The thickness of boxes that will be generated in each corner for each axis.
Real X
Coordinate on the X vector.
Real Z
Coordinate on the Z vector.
BoxCornerGenerator & SetHalfSizeZ(const Real HalfSizeZ)
Sets the half size along the Z axis. the size is set to 0 or less, a PARAMETERS_EXCEPTION will be thr...
A convenience buffer that stores vertices and indices of a mesh to be generated.
A generator class for a mesh composed of boxes that outline the corner edges of a larger box...
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
void EstimateIndexCount(const Whole IndexCount)
Gives an estimation of the number of indices needed for this triangle buffer.
void RebaseOffset()
Rebase index offset.
A simple definition for a Vertex to be used when procedurally generating meshes.
Vector3 BoxHalf
The size of the box to generate.
virtual ~BoxCornerGenerator()
Class destructor.
This implements the exception hiearchy for Mezzanine.
float Real
A Datatype used to represent a real floating point number.
BoxCornerGenerator & SetHalfExtents(const Vector3 &HalfExtents)
Sets the half size of the box.
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.
TriangleBuffer & AddTriangle(const Integer Index1, const Integer Index2, const Integer Index3)
Adds a triangle to the index buffer.
Real Y
Coordinate on the Y vector.
BoxCornerGenerator & SetHalfSizeX(const Real HalfSizeX)
Sets the half size along the X axis. the size is set to 0 or less, a PARAMETERS_EXCEPTION will be thr...
void AddPoint(TriangleBuffer &Buffer, const Vector3 &Loc, const Vector3 &Norm, const Vector2 &UV) const
Adds a new point to a triangle buffer, using the format defined for that MeshGenerator.
Thrown when parameters are checked at runtime and found invalid.
This is used to represent a point in space, or a vector through space.
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.
BoxCornerGenerator(const Vector3 &HalfExtents, const Real CornerThickness)
Vector constructor.
virtual void AddToTriangleBuffer(TriangleBuffer &Buffer) const
Adds the vertices and indices as configured in this generator to a triangle buffer.
BoxCornerGenerator & SetHalfSizeY(const Real HalfSizeY)
Sets the half size along the Y axis. the size is set to 0 or less, a PARAMETERS_EXCEPTION will be thr...