| [3311] | 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 |  | 
|---|
| [3330] | 14 | //! An Enumerator that defines what sort of Curves are availible | 
|---|
| [3331] | 15 | enum CurveType {BEZIERCURVE, UPOINTCURVE}; | 
|---|
| [3018] | 16 |  | 
|---|
| [3330] | 17 |  | 
|---|
| [3327] | 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. | 
|---|
| [3321] | 25 |   Curve* dirCurve;       //!< The derivation-curve of this Curve. | 
|---|
 | 26 |   int derivation;        //!< Which derivation of a Curve is this. | 
|---|
| [3019] | 27 |  | 
|---|
| [3217] | 28 |   //! Handles the curve-points (dynamic List) | 
|---|
| [3018] | 29 |   struct PathNode | 
|---|
 | 30 |   { | 
|---|
| [3217] | 31 |     int number;          //!< The N-th node of this curve. | 
|---|
| [3320] | 32 |     float factor;        //!< Curve specific multiplier factor. | 
|---|
| [3327] | 33 |     Vector vFactor;      //!< A Vector-factor for multipliing. | 
|---|
| [3217] | 34 |     Vector position;     //!< Vector Pointung to this curve-point. | 
|---|
 | 35 |     PathNode* next;      //!< Pointer to the next Node. | 
|---|
| [3018] | 36 |   }; | 
|---|
 | 37 |  | 
|---|
| [3217] | 38 |   PathNode* firstNode;   //!< First node of the curve. | 
|---|
 | 39 |   PathNode* currentNode; //!< The node we are working with (the Last node). | 
|---|
| [3018] | 40 |  | 
|---|
| [3320] | 41 |  private: | 
|---|
 | 42 |   virtual void rebuild(void) = 0; | 
|---|
| [3019] | 43 |  public: | 
|---|
 | 44 |   void addNode (const Vector& newNode); | 
|---|
 | 45 |  | 
|---|
| [3322] | 46 |   virtual Vector calcPos(float t) = 0; | 
|---|
 | 47 |   virtual Vector calcDir(float t) = 0; | 
|---|
 | 48 |   virtual Quaternion calcQuat(float t) = 0; | 
|---|
 | 49 |   | 
|---|
| [3019] | 50 | }; | 
|---|
 | 51 |  | 
|---|
| [3327] | 52 | //!    Class to handle bezier curves in 3-dimesnsional space | 
|---|
| [3019] | 53 | /** | 
|---|
| [3327] | 54 |    This Curve is good, for Fast Interaction. If you want to change it during the game, go on. | 
|---|
 | 55 |    !!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] | 56 | */ | 
|---|
 | 57 | class BezierCurve : public Curve | 
|---|
 | 58 | { | 
|---|
 | 59 |  private: | 
|---|
| [3320] | 60 |   void rebuild(void); | 
|---|
| [3018] | 61 |  public: | 
|---|
| [3320] | 62 |   BezierCurve(void); | 
|---|
| [3321] | 63 |   BezierCurve(int derivation); | 
|---|
| [3320] | 64 |   ~BezierCurve(void); | 
|---|
| [3321] | 65 |   void init(void); | 
|---|
| [3320] | 66 |  | 
|---|
 | 67 |   Vector calcPos(float t); | 
|---|
 | 68 |   Vector calcDir(float t); | 
|---|
 | 69 |   Quaternion calcQuat(float t); | 
|---|
| [3018] | 70 |    | 
|---|
| [3028] | 71 |    | 
|---|
| [3319] | 72 |   Vector getPos(void) const; | 
|---|
| [3018] | 73 | }; | 
|---|
 | 74 |  | 
|---|
| [3311] | 75 |  | 
|---|
 | 76 | //! B-Spline | 
|---|
 | 77 | /** | 
|---|
 | 78 |    class to handle b-spline in 3d space | 
|---|
 | 79 | */ | 
|---|
 | 80 | class BSplieCurve : public Curve | 
|---|
 | 81 | { | 
|---|
 | 82 |  | 
|---|
 | 83 |  | 
|---|
 | 84 | }; | 
|---|
 | 85 |  | 
|---|
| [3327] | 86 | //! Uniform Point Curve-class | 
|---|
 | 87 | /** | 
|---|
 | 88 |    A UPoint Curve is a A Curve, that flows through all the nodes given it. | 
|---|
 | 89 |    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. | 
|---|
| [3311] | 90 |  | 
|---|
| [3327] | 91 |    This Curve is very erattic, so i do not recommend to use it. | 
|---|
 | 92 | */ | 
|---|
 | 93 | class UPointCurve : public Curve | 
|---|
 | 94 | { | 
|---|
 | 95 |  private: | 
|---|
 | 96 |   void rebuild(void); | 
|---|
 | 97 |  public: | 
|---|
 | 98 |   UPointCurve(void); | 
|---|
 | 99 |   UPointCurve(int derivation); | 
|---|
 | 100 |   ~UPointCurve(void); | 
|---|
 | 101 |   void init(void); | 
|---|
 | 102 |  | 
|---|
 | 103 |   Vector calcPos(float t); | 
|---|
 | 104 |   Vector calcDir(float t); | 
|---|
 | 105 |   Quaternion calcQuat(float t); | 
|---|
 | 106 |    | 
|---|
 | 107 |   Vector getPos(void) const; | 
|---|
 | 108 | }; | 
|---|
 | 109 |  | 
|---|
| [3018] | 110 | #endif /* _CURVE_H */ | 
|---|