SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLCurveBezier.h
Go to the documentation of this file.
1 /**
2  * \file SLCurveBezier.h
3  * \date July 2014
4  * \authors Marcus Hudritsch
5  * \copyright http://opensource.org/licenses/GPL-3.0
6  * \remarks Please use clangformat to format the code. See more code style on
7  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
8 */
9 
10 #ifndef SLCURVEBEZIER_H
11 #define SLCURVEBEZIER_H
12 
13 #include <SLCurve.h>
14 #include <SLGLVertexArrayExt.h>
15 #include <SLMat4.h>
16 
17 //-----------------------------------------------------------------------------
18 //! The SLCurveBezier class implements a Bezier curve interpolation
19 /*!The SLCurveBezier class implements a Bezier curve interpolation. The math
20 is originally based on the implementation from the book:
21 "Essential Mathematics for Games and Interactive Applications" from
22 James M. Van Verth and Lars M. Bishop.
23 */
24 class SLCurveBezier : public SLCurve
25 {
26 public:
27  SLCurveBezier(const SLVVec4f& points);
28  SLCurveBezier(const SLVVec4f& points,
29  const SLVVec3f& controlPoints);
31 
32  void dispose();
33  void init(const SLVVec4f& points,
34  const SLVVec3f& controlPoints);
35  void draw(const SLMat4f& wm);
36  SLVec3f evaluate(const SLfloat t);
39 
41  SLfloat u1,
42  SLfloat u2);
43  SLfloat subdivideLength(const SLVec3f& P0, const SLVec3f& P1, const SLVec3f& P2, const SLVec3f& P3);
44  void subdivideRender(SLVVec3f& points,
45  const SLMat4f& wm,
46  SLfloat epsilon,
47  const SLVec3f& P0,
48  const SLVec3f& P1,
49  const SLVec3f& P2,
50  const SLVec3f& P3);
53 
54  // Getters
55  SLint numControlPoints() { return 2 * ((SLint)_points.size() - 1); }
56  SLVVec3f& controls() { return _controls; }
57 
58 protected:
59  SLVVec3f _controls; //!< Control points of Bezier curve
60  SLGLVertexArrayExt _vao; //!< Vertex array object for rendering
61 };
62 //-----------------------------------------------------------------------------
63 #endif
float SLfloat
Definition: SL.h:173
unsigned int SLuint
Definition: SL.h:171
int SLint
Definition: SL.h:170
Extension class with functions for quick line & point drawing.
vector< SLVec3f > SLVVec3f
Definition: SLVec3.h:325
vector< SLVec4f > SLVVec4f
Definition: SLVec4.h:239
The SLCurveBezier class implements a Bezier curve interpolation.
Definition: SLCurveBezier.h:25
void subdivideRender(SLVVec3f &points, const SLMat4f &wm, SLfloat epsilon, const SLVec3f &P0, const SLVec3f &P1, const SLVec3f &P2, const SLVec3f &P3)
SLVVec3f & controls()
Definition: SLCurveBezier.h:56
SLVVec3f _controls
Control points of Bezier curve.
Definition: SLCurveBezier.h:59
void init(const SLVVec4f &points, const SLVVec3f &controlPoints)
SLVec3f velocity(SLfloat t)
SLint numControlPoints()
Definition: SLCurveBezier.h:55
SLVec3f acceleration(SLfloat t)
SLGLVertexArrayExt _vao
Vertex array object for rendering.
Definition: SLCurveBezier.h:60
SLfloat arcLength(SLfloat t1, SLfloat t2)
SLCurveBezier(const SLVVec4f &points)
SLVec3f evaluate(const SLfloat t)
SLfloat segmentArcLength(SLuint i, SLfloat u1, SLfloat u2)
void draw(const SLMat4f &wm)
void dispose()
Deletes all curve arrays.
SLfloat subdivideLength(const SLVec3f &P0, const SLVec3f &P1, const SLVec3f &P2, const SLVec3f &P3)
SLfloat findParamByDist(SLfloat t1, SLfloat s)
Base class for curves defined by multiple 3D points.
Definition: SLCurve.h:24
SLVVec4f _points
Sample points (x,y,z) and time (w) of curve.
Definition: SLCurve.h:34
SLGLVertexArray adds Helper Functions for quick Line & Point Drawing.
The SLScene class represents the top level instance holding the scene structure.
Definition: SLScene.h:47