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. Needed for the Tracking system in orxonox. |
---|
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 vFactor; //!< A Vector-factor for multipliing. |
---|
31 | Vector position; //!< Vector Pointung to this curve-point. |
---|
32 | PathNode* next; //!< Pointer to the next Node. |
---|
33 | }; |
---|
34 | |
---|
35 | PathNode* firstNode; //!< First node of the curve. |
---|
36 | PathNode* currentNode; //!< The node we are working with (the Last node). |
---|
37 | |
---|
38 | private: |
---|
39 | virtual void rebuild(void) = 0; |
---|
40 | public: |
---|
41 | void addNode (const Vector& newNode); |
---|
42 | |
---|
43 | virtual Vector calcPos(float t) = 0; |
---|
44 | virtual Vector calcDir(float t) = 0; |
---|
45 | virtual Quaternion calcQuat(float t) = 0; |
---|
46 | |
---|
47 | }; |
---|
48 | |
---|
49 | //! Class to handle bezier curves in 3-dimesnsional space |
---|
50 | /** |
---|
51 | This Curve is good, for Fast Interaction. If you want to change it during the game, go on. |
---|
52 | !!be aware!! BezierCurves only flow through their first and last Node. Their Tangents at those Points a directed to the second and second-last Point. |
---|
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 | //! Uniform Point Curve-class |
---|
84 | /** |
---|
85 | A UPoint Curve is a A Curve, that flows through all the nodes given it. |
---|
86 | The Algorithm to buid the curve is rather slow, but Painting and tracing along the curve has high speed, so do not change this curve during the Game. |
---|
87 | |
---|
88 | This Curve is very erattic, so i do not recommend to use it. |
---|
89 | */ |
---|
90 | class UPointCurve : public Curve |
---|
91 | { |
---|
92 | private: |
---|
93 | void rebuild(void); |
---|
94 | public: |
---|
95 | UPointCurve(void); |
---|
96 | UPointCurve(int derivation); |
---|
97 | ~UPointCurve(void); |
---|
98 | void init(void); |
---|
99 | |
---|
100 | Vector calcPos(float t); |
---|
101 | Vector calcDir(float t); |
---|
102 | Quaternion calcQuat(float t); |
---|
103 | |
---|
104 | Vector getPos(void) const; |
---|
105 | }; |
---|
106 | |
---|
107 | #endif /* _CURVE_H */ |
---|