67 #ifndef _graphicsproceduraltorusknotgenerator_cpp
68 #define _graphicsproceduraltorusknotgenerator_cpp
70 #include "Graphics/Procedural/Mesh/torusknotgenerator.h"
72 #include "MathTools/mathtools.h"
82 TorusPoloidalRadius(PoloidalRadius),
83 TorusToroidalRadius(ToroidalRadius),
86 NumPoloidalSeg(PoloidalSeg),
87 NumToroidalSeg(ToroidalSeg)
118 Vector3 direction( ( v1 - v0 ).GetNormal() );
131 if( i != this->NumPoloidalSeg * this->PParameter ) {
132 Buffer.
AddIndex( Offset + this->NumToroidalSeg + 1 );
133 Buffer.
AddIndex( Offset + this->NumToroidalSeg );
135 Buffer.
AddIndex( Offset + this->NumToroidalSeg + 1 );
149 if( PoloidalRadius <= 0.0 )
158 if( ToroidalRadius <= 0.0 )
185 if( PoloidalSeg < 3 )
194 if( ToroidalSeg < 3 )
TorusKnotGenerator(const Real PoloidalRadius, const Real ToroidalRadius, const Integer PParam=2, const Integer QParam=3, const Whole PoloidalSeg=16, const Whole ToroidalSeg=16)
Class constructor.
Vector3 GetNormal() const
This returns the normal for this relative to the origin.
TorusKnotGenerator & SetNumToroidalSeg(const Whole ToroidalSeg)
Sets the number of segments along the guiding circle. the number of segments is less than three...
A generator class for a torus knot mesh.
Real TorusPoloidalRadius
The radius of the primary ring of the torus.
A convenience buffer that stores vertices and indices of a mesh to be generated.
#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.
This implements the exception hiearchy for Mezzanine.
float Real
A Datatype used to represent a real floating point number.
TorusKnotGenerator & SetQParameter(const Integer QParam)
Sets the q parameter of the knot the paramter is set to 0, a PARAMETERS_EXCEPTION will be thrown...
Whole NumPoloidalSeg
The resolution of the Poloidal ring.
Integer PParameter
Controls how many times the knot is going around the torus.
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.
static Vector3 Unit_Y()
Gets a vector representing the Y unit of a Vector3.
TorusKnotGenerator & SetPParameter(const Integer PParam)
Sets the p parameter of the knot the paramter is set to 0, a PARAMETERS_EXCEPTION will be thrown...
Integer QParameter
Controls how many times the knot goes through the center of the torus.
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.
TorusKnotGenerator & SetPoloidalRadius(const Real PoloidalRadius)
Sets the radius of the torus. the radius is set to 0 or less, a PARAMETERS_EXCEPTION will be thrown...
Thrown when parameters are checked at runtime and found invalid.
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.
virtual ~TorusKnotGenerator()
Class destructor.
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.
Real TorusToroidalRadius
The radius of the secondary ring of the torus.
virtual void AddToTriangleBuffer(TriangleBuffer &Buffer) const
Adds the vertices and indices as configured in this generator to a triangle buffer.
TorusKnotGenerator & SetToroidalRadius(const Real ToroidalRadius)
Sets the radius of the torus ring. AKA it's thickness. the radius is set to 0 or less, a PARAMETERS_EXCEPTION will be thrown.
Whole NumToroidalSeg
The resolution of the Toroidal ring.
This is used to store information about rotation in 3d space.
TorusKnotGenerator & SetNumPoloidalSeg(const Whole PoloidalSeg)
Sets the number of segments on the Poloidal ring. the number of segments is less than three...