42 m_knots.push_back( (i<(m_numKnots/2)) ? 0.0
f : 1.0
f);
64 for(
unsigned int i=0; i<_nPoints; i+=3)
66 m_cp.push_back(
Vec3(_p[i],_p[i+1],_p[i+2]));
87 for(
unsigned int i=0; i<
m_numCP; ++i)
91 for(
unsigned int i=0; i<_nKnots; ++i)
118 if( _knots[_i] <= _u && _u <= _knots[_i+1] )
124 Real Den1 = _knots[_i+_k-1] - _knots[_i];
125 Real Den2 = _knots[_i+_k] - _knots[_i+1];
129 Eq1 = ((_u-_knots[_i]) / Den1) *
coxDeBoor(_u,_i,_k-1,_knots);
133 Eq2 = (_knots[_i+_k]-_u) / Den2 *
coxDeBoor(_u,_i+1,_k-1,_knots);
175 for(
unsigned int i=0;i!=
m_numCP;++i)
241 std::vector <Vec3>
points(size);
242 for(
size_t i=0;i<
size;++i)
244 points[i].set(
m_cp[i]);
255 std::vector <Vec3> lines(
m_lod);
256 for(
unsigned int i=0;i!=
m_lod;++i)
Generic Bezier Curve Class allowing the user to generate basic curves using a number of different con...
static AbstractVAO * createVAO(const std::string &_type, GLenum _mode=GL_TRIANGLES)
void drawHull() const noexcept
Draw the control hull.
unsigned int m_lod
The level of detail used to calculate how much detail to draw.
std::vector< Vec3 > m_cp
the contol points for the curve
GLuint const GLfloat * val
void createVAO() noexcept
set the Level of Detail for Drawing
simple Vec3 encapsulates a 3 float object like glsl vec3 but not maths use the Vec3 class for maths a...
implementation files for RibExport class
void setVertexAttributePointer(GLuint _id, GLint _size, GLenum _type, GLsizei _stride, unsigned int _dataOffset, bool _normalise=false)
set the generic vertex attribute pointer data usually this method will do however the user may occasi...
void addKnot(Real _k) noexcept
add a knot value to the curve
virtual void removeVAO()=0
this will clean up the VAO and associated data, it is the users responsibility to do this usually thi...
PRECISION Real
create a variable called Real which is the main data type we use (GLfloat for most cases) ...
Vec3 getPointOnCurve(Real _value) const noexcept
get a point on the curve in the range of 0 - 1 based on the control points
BezierCurve() noexcept
default ctor sets initial values for Curve to be used with AddPoint , AddKnot etc ...
std::vector< Real > m_knots
the knot vector for the curve
void setMode(const GLenum &_mode)
set the draw mode
void createKnots() noexcept
create a knot vector array based as an Open Vector (half 0.0 half 1.0)
void setNumIndices(size_t _s)
the number of indices to draw in the array. It may be that the draw routine can overide this at anoth...
void unbind()
unbind the VAO by binding default 0
void bind()
bind the VAO so it can be used.
unsigned int m_degree
The degree of the curve, Calculated from the Number of Control Points.
virtual void setData(const VertexData &_data)=0
this method is used to set the data in the VAO, we have a base data type of VertexData above...
GLuint GLdouble GLdouble GLint GLint const GLdouble * points
unsigned int m_numCP
The ammount of Control Points in the Curve.
unsigned int m_order
The Order of the Curve = Degree +1.
GLuint m_listIndex
the display list index created from glCreateLists
void draw() const noexcept
Draw method to draw the curve Note this will be slow as it calls the CoxDeBoor function to calculate ...
AbstractVAO * m_vaoPoints
a vertex array object for our point drawing
~BezierCurve() noexcept
destructor
virtual void draw() const =0
this is the draw method for the VAO the user must implement this per VAO data, usually this will be a...
unsigned int m_numKnots
The knot vector always has as many values as the numer of verts (cp) + the degree.
Real coxDeBoor(Real _u, unsigned int _i, unsigned int _k, const std::vector< Real > &_knots) const noexcept
implementation of the CoxDeBoor algorithm for Bezier Curves borrowed from Rob Bateman's example and m...
void drawControlPoints() const noexcept
draw the control points
void addPoint(const Vec3 &_p) noexcept
add a control point to the Curve
AbstractVAO * m_vaoCurve
a vertex array object for our curve drawing
basic BezierCurve using CoxDeBoor algorithm