-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBezierPath.h
More file actions
223 lines (187 loc) · 6.68 KB
/
BezierPath.h
File metadata and controls
223 lines (187 loc) · 6.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/*
Description: Bezier path and bezier curve motion objects
classes contained are:
class BezierCurve,
class AbstractCurveHead,
|
--------> class AbstractBezierPathParentStatic
| |
| -------> class AbstractBezierPathStatic,
| |
| -------> class BezierPathStatic,
|
|
|
|
--------> class AbstractBezierPathParentDynamic
|
-------> class AbstractBezierPathDynamic
|
---------> class BezierPathDynamic
============================================================================================================
WARNING: Use only CurveEditorUI, BezierPathDynamic,
BezierPathStatic classes and if you want BezierCurve
============================================================================================================
*/
#ifndef RX_BEZIER_PATH_H_
#define RX_BEZIER_PATH_H_
#include "CoreEngine.h"
#include "utils/AlignedObjectArray.h"
#include "utils/3DMATH.H"
//#include <vector>
#include "Client.h"
namespace DifferentialArts
{
/*
================================================
class BezierCurve
================================================
*/
/*! \class BezierCurve
\brief Bezier curve class
\author Rajesh Peter Douglas D'Monte
Basic bezier curve class. Used internally.
*/
class RX_API BezierCurve
{
public:
BezierCurve(void);//!<Constructor
BezierCurve(const Math::Vector3 &a, const Math::Vector3 &b = Math::Vector3(0, 0, 0), const Math::Vector3 &c = Math::Vector3(0, 0, 0), const Math::Vector3 &d = Math::Vector3(0, 0, 0));//!<Constructor with 4 control points
~BezierCurve(void);//!< Destructor
Math::Vector3 pointOnCurve(float t);//!< Returns a point on the curve
Math::Vector3 p1; //!< First control point for the bezier curve
Math::Vector3 p2; //!< Second control point for the bezier curve
Math::Vector3 p3; //!< Third control point for the bezier curve
Math::Vector3 p4; //!< Fourth control point for the bezier curve
void debugDrawCurve(float resolution = 0.04f, int secondaryColor = 0, int currentPoint = 0); //!< For debuggin purposes. Max 1, min approx 0
};
/*
================================================
class AbstractCurveHead
================================================
*/
/*! \class AbstractCurveHead
\brief Curve set
\author Rajesh Peter Douglas D'Monte
Basic bezier curve set with no curve information. Used internally.
*/
class RX_API AbstractCurveHead : public BaseMemoryInterface
{
public:
void SetHead(float t); //!< Sets the head of the curve play time
protected:
float time;
float maxTime;
GLuint curves;
};
/*
================================================
class AbstractBezierPathParentStatic
================================================
*/
/*! \class AbstractBezierPathParentStatic
\brief Static bezier curve path class
\author Rajesh Peter Douglas D'Monte
Static bezier curve path with a static list of curves. Used internally.
*/
class RX_API AbstractBezierPathParentStatic: public AbstractCurveHead
{
public:
BezierCurve* curveList; //!< Bezier curve list
};
/*
================================================
class AbstractBezierPathParentDynamic
================================================
*/
/*! \class AbstractBezierPathParentDynamic
\brief Dynamic bezier curve path class
\author Rajesh Peter Douglas D'Monte
Dynamic bezier curve path with a Dynamic vector of curves. Used internally.
*/
class RX_API AbstractBezierPathParentDynamic: public AbstractCurveHead
{
protected:
AlignedObjectArray<BezierCurve> curveList;//!< Bezier curve vector. Unaccessible.
};
/*
================================================
class AbstractBezierPathStatic
================================================
*/
/*! \class AbstractBezierPathStatic
\brief Static bezier curve path class
\author Rajesh Peter Douglas D'Monte
Static bezier curve path class with setable init properties. Used internally.
*/
class RX_API AbstractBezierPathStatic: public AbstractBezierPathParentStatic
{
public:
bool Initialize(GLuint bcurves); //!< Initialize the curve path
void Free(void);//!< Frees resources allocated to the curve path
};
/*
================================================
class AbstractBezierPathDynamic
================================================
*/
/*! \class AbstractBezierPathDynamic
\brief Dynamic bezier curve path class
\author Rajesh Peter Douglas D'Monte
Dynamic bezier curve path class with ability to add and remove curves. Used internally.
*/
class RX_API AbstractBezierPathDynamic: public AbstractBezierPathParentDynamic
{
public:
int AddCurve(const Math::Vector3 &a, const Math::Vector3 &b, const Math::Vector3 &c, const Math::Vector3 &d); //!< Add curves
int RemoveCurve(int i = -1); //!< Remove curves
};
/*
================================================
class BezierPathStatic
================================================
*/
/*! \class BezierPathStatic
\brief Static bezier curve path FINAL class
\author Rajesh Peter Douglas D'Monte
Static bezier curve path class with complete user control to play curves, load
and save curve set data etc.
*/
class RX_API BezierPathStatic: public AbstractBezierPathStatic
{
public:
BezierPathStatic(void);//!<Constructor
~BezierPathStatic(void); //!< Destructor
void debugDraw(float resolution = 0.04f, int currentCurve = -1, int currentPoint = 0);
//!< For debugging purposes. Draws the curve.
Math::Vector3 PlayNext(float dt); //!< Play the curve by an interval dt
Math::Vector3 PlayTillEnd(float dt); //!< Play the curve till the end by an interval dt
bool Load(const char* file); //!< Loads a curve set
bool Save(const char* file); //!< Saves a curve set
};
/*
================================================
class BezierPathDynamic
================================================
*/
/*! \class BezierPathDynamic
\brief Dynamic bezier curve path FINAL class
\author Rajesh Peter Douglas D'Monte
Dynamic bezier curve path class with complete user control to play curves, load
and save curve set data etc.
*/
class RX_API BezierPathDynamic: public AbstractBezierPathDynamic
{
public:
BezierPathDynamic(void);//!<Constructor
~BezierPathDynamic(void); //!< Destructor
void debugDraw(float resolution = 0.04f, int currentCurve = -1, int currentPoint = 0);
//!< For debugging purposes. Draws the curve.
Math::Vector3 PlayNext(float dt); //!< Play the curve by an interval dt
Math::Vector3 PlayTillEnd(float dt); //!< Play the curve till the end by an interval dt
bool Load(const char* file); //!< Loads a curve set
bool Save(const char* file); //!< Saves a curve set
friend class CurveEditorUI;
};
}
#endif