67 #ifndef _graphicsproceduralcapsulegenerator_cpp
68 #define _graphicsproceduralcapsulegenerator_cpp
70 #include "Graphics/Procedural/Mesh/capsulegenerator.h"
72 #include "MathTools/mathtools.h"
82 CapsuleRadius(Radius),
83 CapsuleHeight(Height),
85 NumSegCircle(SegCircle),
86 NumSegHeight(SegHeight)
101 Real fDeltaRingAngle = ( MathTools::GetHalfPi() / this->
NumRings );
118 Real x0 = r0 * cosf( seg * fDeltaSegAngle );
119 Real z0 = r0 * sinf( seg * fDeltaSegAngle );
123 Vector3( x0, y0, z0 ).GetNormal(),
127 Buffer.
AddIndex( Offset + this->NumSegCircle + 1 );
128 Buffer.
AddIndex( Offset + this->NumSegCircle );
130 Buffer.
AddIndex( Offset + this->NumSegCircle + 1 );
150 Vector3( x0, 0, z0 ).GetNormal(),
153 Buffer.
AddIndex( Offset + this->NumSegCircle + 1 );
154 Buffer.
AddIndex( Offset + this->NumSegCircle );
156 Buffer.
AddIndex( Offset + this->NumSegCircle + 1 );
168 Real r0 = this->
CapsuleRadius * sinf( MathTools::GetHalfPi() + ring * fDeltaRingAngle );
169 Real y0 = this->
CapsuleRadius * cosf( MathTools::GetHalfPi() + ring * fDeltaRingAngle );
174 Real x0 = r0 * cosf( seg * fDeltaSegAngle );
175 Real z0 = r0 * sinf( seg * fDeltaSegAngle );
179 Vector3( x0, y0, z0 ).GetNormal(),
184 Buffer.
AddIndex( Offset + this->NumSegCircle + 1 );
185 Buffer.
AddIndex( Offset + this->NumSegCircle );
187 Buffer.
AddIndex( Offset + this->NumSegCircle + 1 );
virtual void AddToTriangleBuffer(TriangleBuffer &Buffer) const
Adds the vertices and indices as configured in this generator to a triangle buffer.
CapsuleGenerator & SetNumSegCircle(const Whole SegCircle)
Sets the number of segments when rotating around the cylinder. the number of segments is set to 0...
CapsuleGenerator & SetNumSegHeight(const Whole SegHeight)
Sets the number of segments along the axis of the cylinder. the number of segments is set to 0...
A convenience buffer that stores vertices and indices of a mesh to be generated.
Whole NumRings
The resolution of both hemispheres at the end of the capsule.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
Real CapsuleRadius
The radius of the capsule main body.
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.
CapsuleGenerator & SetNumRings(const Whole Rings)
Sets the number of segments of the sphere part. the number of rings is set to 0, a PARAMETERS_EXCEPTI...
This implements the exception hiearchy for Mezzanine.
virtual ~CapsuleGenerator()
Class destructor.
Whole NumSegHeight
The number of segments in the capsules body length.
float Real
A Datatype used to represent a real floating point number.
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.
CapsuleGenerator & SetHeight(const Real Height)
Sets the height of the main body part of the capsule. the height is set to 0 or less, a PARAMETERS_EXCEPTION will be thrown.
A generator class for a capsule mesh with rounded ends.
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.
CapsuleGenerator & SetRadius(const Real Radius)
Sets the radius of the main body part of the capsule. the radius is set to 0 or less, a PARAMETERS_EXCEPTION will be thrown.
Whole NumSegCircle
The resolution of the circular component of the capsule.
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.
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.
CapsuleGenerator(const Real Radius, const Real Height, const Whole Rings=8, const Whole SegCircle=16, const Whole SegHeight=1)
Class constructor.
Real CapsuleHeight
The total height of the capsule main body.