1 | |
---|
2 | /*! |
---|
3 | \file curve.h |
---|
4 | \brief A basic 3D curve framework |
---|
5 | |
---|
6 | Contains classes to handle curves |
---|
7 | */ |
---|
8 | |
---|
9 | #ifndef _CURVE_H |
---|
10 | #define _CURVE_H |
---|
11 | |
---|
12 | #include "vector.h" |
---|
13 | |
---|
14 | |
---|
15 | //! An abstract class to handle curves. |
---|
16 | class Curve |
---|
17 | { |
---|
18 | protected: |
---|
19 | int nodeCount; //!< The count of nodes the Curve has. |
---|
20 | Vector curvePoint; //!< The point on the Cureve at a local Time. |
---|
21 | float localTime; //!< If the time of one point is asked more than once the programm will not calculate it again. |
---|
22 | Curve* dirCurve; //!< The derivation-curve of this Curve. |
---|
23 | int derivation; //!< Which derivation of a Curve is this. |
---|
24 | |
---|
25 | //! Handles the curve-points (dynamic List) |
---|
26 | struct PathNode |
---|
27 | { |
---|
28 | int number; //!< The N-th node of this curve. |
---|
29 | float factor; //!< Curve specific multiplier factor. |
---|
30 | Vector position; //!< Vector Pointung to this curve-point. |
---|
31 | PathNode* next; //!< Pointer to the next Node. |
---|
32 | }; |
---|
33 | |
---|
34 | PathNode* firstNode; //!< First node of the curve. |
---|
35 | PathNode* currentNode; //!< The node we are working with (the Last node). |
---|
36 | |
---|
37 | private: |
---|
38 | virtual void rebuild(void) = 0; |
---|
39 | public: |
---|
40 | void addNode (const Vector& newNode); |
---|
41 | |
---|
42 | virtual Vector calcPos(float t) = 0; |
---|
43 | virtual Vector calcDir(float t) = 0; |
---|
44 | virtual Quaternion calcQuat(float t) = 0; |
---|
45 | |
---|
46 | }; |
---|
47 | |
---|
48 | //! Bezier Curve |
---|
49 | /** |
---|
50 | Class to handle bezier curves in 3-dimesnsional space |
---|
51 | |
---|
52 | needed for the Tracking system in OrxOnoX. |
---|
53 | */ |
---|
54 | class BezierCurve : public Curve |
---|
55 | { |
---|
56 | private: |
---|
57 | void rebuild(void); |
---|
58 | public: |
---|
59 | BezierCurve(void); |
---|
60 | BezierCurve(int derivation); |
---|
61 | ~BezierCurve(void); |
---|
62 | void init(void); |
---|
63 | |
---|
64 | Vector calcPos(float t); |
---|
65 | Vector calcDir(float t); |
---|
66 | Quaternion calcQuat(float t); |
---|
67 | |
---|
68 | |
---|
69 | Vector getPos(void) const; |
---|
70 | }; |
---|
71 | |
---|
72 | |
---|
73 | //! B-Spline |
---|
74 | /** |
---|
75 | class to handle b-spline in 3d space |
---|
76 | */ |
---|
77 | class BSplieCurve : public Curve |
---|
78 | { |
---|
79 | |
---|
80 | |
---|
81 | }; |
---|
82 | |
---|
83 | |
---|
84 | #endif /* _CURVE_H */ |
---|