67 #ifndef _graphicsproceduralspheregenerator_cpp
68 #define _graphicsproceduralspheregenerator_cpp
70 #include "Graphics/Procedural/Mesh/spheregenerator.h"
72 #include "MathTools/mathtools.h"
84 NumSegCircle(SegCircle)
99 Real fDeltaRingAngle = ( MathTools::GetPi() / this->
NumRings );
112 Real x0 = r0 * sinf( Segment * fDeltaSegAngle );
113 Real z0 = r0 * cosf( Segment * fDeltaSegAngle );
117 Vector3(x0, y0, z0).GetNormal(),
120 if( Ring != this->NumRings ) {
121 if( Segment != this->NumSegCircle ) {
123 if( Ring != this->NumRings - 1 ) {
124 Buffer.
AddTriangle(Offset + this->NumSegCircle + 2, Offset, Offset + this->NumSegCircle + 1);
127 Buffer.
AddTriangle(Offset + this->NumSegCircle + 2, Offset + 1, Offset);
Real SphereRadius
The radius of the sphere.
A convenience buffer that stores vertices and indices of a mesh to be generated.
A generator class for a sphere mesh.
#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.
int Integer
A datatype used to represent any integer close to.
Whole NumSegCircle
The number of segments along the circumference of the rings.
This implements the exception hiearchy for Mezzanine.
SphereGenerator & SetRadius(const Real Radius)
Sets the radius of the sphere. the radius is set to 0 or less, a PARAMETERS_EXCEPTION will be thrown...
Whole NumRings
The number of rings controlling the resolution along the vertical axis.
SphereGenerator & SetNumSegCircle(const Whole SegCircle)
Sets the number of segments along the circumference of the rings. the number of segments is set to 0...
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.
virtual void AddToTriangleBuffer(TriangleBuffer &Buffer) const
Adds the vertices and indices as configured in this generator to a triangle buffer.
TriangleBuffer & AddTriangle(const Integer Index1, const Integer Index2, const Integer Index3)
Adds a triangle to the index buffer.
virtual ~SphereGenerator()
Class destructor.
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.
SphereGenerator & SetNumRings(const Whole Rings)
Sets the number of rings, the number of rings is set to 0, a PARAMETERS_EXCEPTION will be thrown...
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.
SphereGenerator(const Real Radius, const Whole Rings=16, const Whole SegCircle=16)
Class constuctor.