NGL
6.5
The NCCA Graphics Library
|
Generic Bezier Curve Class allowing the user to generate basic curves using a number of different constriction methods, such as array of Vectors, array of numbers etc The class can automatically generate knot vectors as well or the user can specify their own. More...
#include <BezierCurve.h>
Public Member Functions | |
BezierCurve () noexcept | |
default ctor sets initial values for Curve to be used with AddPoint , AddKnot etc More... | |
BezierCurve (const Vec3 *_p, unsigned int _nPoints, const Real *_k, unsigned int _nKnots) noexcept | |
Ctor passing in an Array of CP's and and Array of knots. More... | |
BezierCurve (const Real *_p, unsigned int _nPoints) noexcept | |
ctor passing in an array of points, note the knot vector will be automatically calculated as an open vector using a call to create knots More... | |
BezierCurve (const BezierCurve &_c) noexcept | |
copy ctor More... | |
~BezierCurve () noexcept | |
destructor More... | |
void | draw () const noexcept |
Draw method to draw the curve Note this will be slow as it calls the CoxDeBoor function to calculate each time it is much quicker to create a display list and use this. More... | |
void | drawControlPoints () const noexcept |
draw the control points More... | |
void | drawHull () const noexcept |
Draw the control hull. More... | |
Vec3 | getPointOnCurve (Real _value) const noexcept |
get a point on the curve in the range of 0 - 1 based on the control points More... | |
void | addPoint (const Vec3 &_p) noexcept |
add a control point to the Curve More... | |
void | addPoint (Real _x, Real _y, Real _z) noexcept |
add a point to the curve using x,y,z values More... | |
void | addKnot (Real _k) noexcept |
add a knot value to the curve More... | |
void | createKnots () noexcept |
create a knot vector array based as an Open Vector (half 0.0 half 1.0) More... | |
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 modified to make it work with the class. NOTE, this is a recursive function More... | |
void | setLOD (int _lod) noexcept |
set the Level of Detail for Drawing More... | |
void | createVAO () noexcept |
set the Level of Detail for Drawing More... | |
Protected Attributes | |
GLuint | m_listIndex |
the display list index created from glCreateLists More... | |
unsigned int | m_order |
The Order of the Curve = Degree +1. More... | |
unsigned int | m_lod |
The level of detail used to calculate how much detail to draw. More... | |
unsigned int | m_numCP |
The ammount of Control Points in the Curve. More... | |
unsigned int | m_degree |
The degree of the curve, Calculated from the Number of Control Points. More... | |
unsigned int | m_numKnots |
The knot vector always has as many values as the numer of verts (cp) + the degree. More... | |
std::vector< Vec3 > | m_cp |
the contol points for the curve More... | |
std::vector< Real > | m_knots |
the knot vector for the curve More... | |
AbstractVAO * | m_vaoCurve |
a vertex array object for our curve drawing More... | |
AbstractVAO * | m_vaoPoints |
a vertex array object for our point drawing More... | |
Generic Bezier Curve Class allowing the user to generate basic curves using a number of different constriction methods, such as array of Vectors, array of numbers etc The class can automatically generate knot vectors as well or the user can specify their own.
Definition at line 45 of file BezierCurve.h.
|
noexcept |
default ctor sets initial values for Curve to be used with AddPoint , AddKnot etc
Definition at line 26 of file BezierCurve.cpp.
References m_degree, m_listIndex, m_lod, m_numCP, m_numKnots, m_order, m_vaoCurve, and m_vaoPoints.
|
noexcept |
Ctor passing in an Array of CP's and and Array of knots.
[in] | _p | an array of Vector objects which are the control |
[in] | _nPoints | the size of the Point Array |
[in] | _k | and array of knot values |
[in] | _nKnots | the size of the knot array |
ctor passing in an array of points, note the knot vector will be automatically calculated as an open vector using a call to create knots
[in] | _p | the array of CP values expressed as groups of 3 float x,y,z values |
[in] | _nPoints | the size of the array *p (note this is the total size of the array) |
|
noexcept |
copy ctor
_c | the curve to copy |
Definition at line 47 of file BezierCurve.cpp.
References BezierCurve(), createKnots(), m_cp, m_degree, m_knots, m_lod, m_numCP, m_numKnots, m_order, m_vaoCurve, and m_vaoPoints.
|
noexcept |
destructor
Definition at line 100 of file BezierCurve.cpp.
References m_cp, m_knots, m_vaoCurve, m_vaoPoints, ngl::AbstractVAO::removeVAO(), and ngl::AbstractVAO::unbind().
add a knot value to the curve
[in] | _k | the value of the knot (note this is added to the end of the curve |
Definition at line 220 of file BezierCurve.cpp.
References m_knots, m_numCP, m_numKnots, and m_order.
add a control point to the Curve
[in] | &_p | the point to add |
Definition at line 194 of file BezierCurve.cpp.
References m_cp, m_degree, m_numCP, m_numKnots, and m_order.
add a point to the curve using x,y,z values
[in] | _x | x value of point |
[in] | _y | y value of point |
[in] | _z | z value of point |
Definition at line 207 of file BezierCurve.cpp.
References m_cp, m_degree, m_numCP, m_numKnots, and m_order.
|
noexcept |
implementation of the CoxDeBoor algorithm for Bezier Curves borrowed from Rob Bateman's example and modified to make it work with the class. NOTE, this is a recursive function
[in] | _u | |
[in] | _i | |
[in] | _k | |
[in] | _knots | the array of knots for the curve |
Definition at line 114 of file BezierCurve.cpp.
References coxDeBoor().
|
noexcept |
create a knot vector array based as an Open Vector (half 0.0 half 1.0)
Definition at line 38 of file BezierCurve.cpp.
References m_knots, and m_numKnots.
|
noexcept |
set the Level of Detail for Drawing
Definition at line 226 of file BezierCurve.cpp.
References ngl::AbstractVAO::bind(), ngl::VAOFactory::createVAO(), getPointOnCurve(), GL_FLOAT, GL_LINE_STRIP, GL_POINTS, m_cp, m_knots, m_lod, m_numCP, m_numKnots, m_vaoCurve, m_vaoPoints, ngl::AbstractVAO::removeVAO(), ngl::AbstractVAO::setData(), ngl::AbstractVAO::setNumIndices(), ngl::AbstractVAO::setVertexAttributePointer(), and ngl::AbstractVAO::unbind().
|
noexcept |
Draw method to draw the curve Note this will be slow as it calls the CoxDeBoor function to calculate each time it is much quicker to create a display list and use this.
Definition at line 160 of file BezierCurve.cpp.
References ngl::AbstractVAO::bind(), ngl::AbstractVAO::draw(), m_vaoCurve, and ngl::AbstractVAO::unbind().
|
noexcept |
draw the control points
Definition at line 140 of file BezierCurve.cpp.
References ngl::AbstractVAO::bind(), ngl::AbstractVAO::draw(), GL_POINTS, m_vaoPoints, ngl::AbstractVAO::setMode(), and ngl::AbstractVAO::unbind().
|
noexcept |
Draw the control hull.
Definition at line 151 of file BezierCurve.cpp.
References ngl::AbstractVAO::bind(), ngl::AbstractVAO::draw(), GL_LINE_STRIP, m_vaoPoints, ngl::AbstractVAO::setMode(), and ngl::AbstractVAO::unbind().
get a point on the curve in the range of 0 - 1 based on the control points
[in] | _value | the point to evaluate between 0 and 1 |
Definition at line 168 of file BezierCurve.cpp.
References coxDeBoor(), m_cp, m_degree, m_knots, and m_numCP.
set the Level of Detail for Drawing
[in] | _lod | the level of detail to use when creating the display list for drawing the higher the number the finer the drawing |
Definition at line 138 of file BezierCurve.h.
|
protected |
the contol points for the curve
Definition at line 172 of file BezierCurve.h.
|
protected |
The degree of the curve, Calculated from the Number of Control Points.
Definition at line 164 of file BezierCurve.h.
|
protected |
the knot vector for the curve
Definition at line 176 of file BezierCurve.h.
|
protected |
the display list index created from glCreateLists
Definition at line 148 of file BezierCurve.h.
|
protected |
The level of detail used to calculate how much detail to draw.
Definition at line 156 of file BezierCurve.h.
|
protected |
The ammount of Control Points in the Curve.
Definition at line 160 of file BezierCurve.h.
|
protected |
The knot vector always has as many values as the numer of verts (cp) + the degree.
Definition at line 168 of file BezierCurve.h.
|
protected |
The Order of the Curve = Degree +1.
Definition at line 152 of file BezierCurve.h.
|
protected |
a vertex array object for our curve drawing
Definition at line 180 of file BezierCurve.h.
|
protected |
a vertex array object for our point drawing
Definition at line 184 of file BezierCurve.h.