[3365] | 1 | |
---|
[3018] | 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 | |
---|
[3365] | 14 | //! An Enumerator that defines what sort of Curves are availible |
---|
| 15 | enum CurveType {BEZIERCURVE, UPOINTCURVE}; |
---|
[3018] | 16 | |
---|
[3365] | 17 | |
---|
| 18 | //! An abstract class to handle curves. Needed for the Tracking system in orxonox. |
---|
[3019] | 19 | class Curve |
---|
[3018] | 20 | { |
---|
[3019] | 21 | protected: |
---|
[3217] | 22 | int nodeCount; //!< The count of nodes the Curve has. |
---|
| 23 | Vector curvePoint; //!< The point on the Cureve at a local Time. |
---|
| 24 | float localTime; //!< If the time of one point is asked more than once the programm will not calculate it again. |
---|
[3365] | 25 | int derivation; //!< Which derivation of a Curve is this. |
---|
[3019] | 26 | |
---|
[3217] | 27 | //! Handles the curve-points (dynamic List) |
---|
[3018] | 28 | struct PathNode |
---|
| 29 | { |
---|
[3217] | 30 | int number; //!< The N-th node of this curve. |
---|
[3365] | 31 | float factor; //!< Curve specific multiplier factor. |
---|
| 32 | Vector vFactor; //!< A Vector-factor for multipliing. |
---|
[3217] | 33 | Vector position; //!< Vector Pointung to this curve-point. |
---|
| 34 | PathNode* next; //!< Pointer to the next Node. |
---|
[3018] | 35 | }; |
---|
| 36 | |
---|
[3217] | 37 | PathNode* firstNode; //!< First node of the curve. |
---|
| 38 | PathNode* currentNode; //!< The node we are working with (the Last node). |
---|
[3018] | 39 | |
---|
[3365] | 40 | private: |
---|
| 41 | virtual void rebuild(void) = 0; |
---|
[3019] | 42 | public: |
---|
[3433] | 43 | Curve* dirCurve; //!< The derivation-curve of this Curve. |
---|
[3365] | 44 | void addNode(const Vector& newNode); |
---|
[3433] | 45 | void addNode(const Vector& newNode, unsigned int insertPosition); |
---|
[3365] | 46 | Vector getNode(unsigned int nodeToFind); |
---|
| 47 | inline int getNodeCount(void) { return this->nodeCount;} |
---|
[3019] | 48 | |
---|
[3365] | 49 | virtual Vector calcPos(float t) = 0; |
---|
| 50 | virtual Vector calcDir(float t) = 0; |
---|
[3433] | 51 | virtual Vector calcAcc(float t) = 0; |
---|
[3365] | 52 | virtual Quaternion calcQuat(float t) = 0; |
---|
| 53 | |
---|
[3433] | 54 | // DEBUG |
---|
| 55 | void debug(void); |
---|
[3019] | 56 | }; |
---|
| 57 | |
---|
[3365] | 58 | //! Class to handle bezier curves in 3-dimesnsional space |
---|
[3019] | 59 | /** |
---|
[3365] | 60 | This Curve is good, for Fast Interaction. If you want to change it during the game, go on. |
---|
| 61 | !!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. |
---|
[3019] | 62 | */ |
---|
| 63 | class BezierCurve : public Curve |
---|
| 64 | { |
---|
| 65 | private: |
---|
[3365] | 66 | void rebuild(void); |
---|
[3018] | 67 | public: |
---|
[3365] | 68 | BezierCurve(void); |
---|
| 69 | BezierCurve(int derivation); |
---|
| 70 | ~BezierCurve(void); |
---|
| 71 | void init(void); |
---|
| 72 | |
---|
| 73 | Vector calcPos(float t); |
---|
| 74 | Vector calcDir(float t); |
---|
[3433] | 75 | Vector calcAcc(float t); |
---|
[3365] | 76 | Quaternion calcQuat(float t); |
---|
[3018] | 77 | |
---|
[3028] | 78 | |
---|
[3365] | 79 | Vector getPos(void) const; |
---|
[3018] | 80 | }; |
---|
| 81 | |
---|
| 82 | |
---|
[3365] | 83 | //! B-Spline |
---|
| 84 | /** |
---|
| 85 | class to handle b-spline in 3d space |
---|
| 86 | */ |
---|
| 87 | class BSplieCurve : public Curve |
---|
| 88 | { |
---|
[3018] | 89 | |
---|
[3365] | 90 | |
---|
| 91 | }; |
---|
| 92 | |
---|
| 93 | //! Uniform Point Curve-class |
---|
| 94 | /** |
---|
| 95 | A UPoint Curve is a A Curve, that flows through all the nodes given it. |
---|
| 96 | 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. |
---|
| 97 | |
---|
| 98 | This Curve is very erattic, so i do not recommend to use it. |
---|
| 99 | */ |
---|
| 100 | class UPointCurve : public Curve |
---|
| 101 | { |
---|
| 102 | private: |
---|
| 103 | void rebuild(void); |
---|
| 104 | public: |
---|
| 105 | UPointCurve(void); |
---|
| 106 | UPointCurve(int derivation); |
---|
| 107 | ~UPointCurve(void); |
---|
| 108 | void init(void); |
---|
| 109 | |
---|
| 110 | Vector calcPos(float t); |
---|
| 111 | Vector calcDir(float t); |
---|
[3433] | 112 | Vector calcAcc(float t); |
---|
[3365] | 113 | Quaternion calcQuat(float t); |
---|
| 114 | |
---|
| 115 | Vector getPos(void) const; |
---|
| 116 | }; |
---|
| 117 | |
---|
[3018] | 118 | #endif /* _CURVE_H */ |
---|