| 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 | //! An Enumerator that defines what sort of Curves are availible | 
|---|
| 15 | enum CurveType {CURVE_BEZIER}; | 
|---|
| 16 |  | 
|---|
| 17 |  | 
|---|
| 18 | //! An abstract class to handle curves. Needed for the Tracking system in orxonox. | 
|---|
| 19 | class Curve | 
|---|
| 20 | { | 
|---|
| 21 |  protected: | 
|---|
| 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. | 
|---|
| 25 |   int derivation;        //!< Which derivation of a Curve is this. | 
|---|
| 26 |  | 
|---|
| 27 |   //! Handles the curve-points (dynamic List) | 
|---|
| 28 |   struct PathNode | 
|---|
| 29 |   { | 
|---|
| 30 |     int number;          //!< The N-th node of this curve. | 
|---|
| 31 |     float factor;        //!< Curve specific multiplier factor. | 
|---|
| 32 |     Vector vFactor;      //!< A Vector-factor for multipliing. | 
|---|
| 33 |     Vector position;     //!< Vector Pointung to this curve-point. | 
|---|
| 34 |     PathNode* next;      //!< Pointer to the next Node. | 
|---|
| 35 |   }; | 
|---|
| 36 |  | 
|---|
| 37 |   PathNode* firstNode;   //!< First node of the curve. | 
|---|
| 38 |   PathNode* currentNode; //!< The node we are working with (the Last node). | 
|---|
| 39 |  | 
|---|
| 40 |  | 
|---|
| 41 |  private: | 
|---|
| 42 |   virtual void rebuild(void) = 0; | 
|---|
| 43 |  public: | 
|---|
| 44 |   Curve(void); | 
|---|
| 45 |  | 
|---|
| 46 |   Curve* dirCurve;       //!< The derivation-curve of this Curve. | 
|---|
| 47 |   void addNode(const Vector& newNode); | 
|---|
| 48 |   void addNode(const Vector& newNode, unsigned int insertPosition); | 
|---|
| 49 |   Vector getNode(unsigned int nodeToFind); | 
|---|
| 50 |   inline int getNodeCount(void) { return this->nodeCount;} | 
|---|
| 51 |  | 
|---|
| 52 |   virtual Vector calcPos(float t) = 0; | 
|---|
| 53 |   virtual Vector calcDir(float t) = 0; | 
|---|
| 54 |   virtual Vector calcAcc(float t) = 0; | 
|---|
| 55 |   virtual Quaternion calcQuat(float t) = 0; | 
|---|
| 56 |   | 
|---|
| 57 |   // DEBUG | 
|---|
| 58 |   void debug(void); | 
|---|
| 59 | }; | 
|---|
| 60 |  | 
|---|
| 61 | //!    Class to handle bezier curves in 3-dimesnsional space | 
|---|
| 62 | /** | 
|---|
| 63 |    This Curve is good, for Fast Interaction. If you want to change it during the game, go on. | 
|---|
| 64 |    !!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. | 
|---|
| 65 | */ | 
|---|
| 66 | class BezierCurve : public Curve | 
|---|
| 67 | { | 
|---|
| 68 |  private: | 
|---|
| 69 |   void rebuild(void); | 
|---|
| 70 |  public: | 
|---|
| 71 |   BezierCurve(void); | 
|---|
| 72 |   BezierCurve(int derivation); | 
|---|
| 73 |   virtual ~BezierCurve(void); | 
|---|
| 74 |  | 
|---|
| 75 |   Vector calcPos(float t); | 
|---|
| 76 |   Vector calcDir(float t); | 
|---|
| 77 |   Vector calcAcc(float t); | 
|---|
| 78 |   Quaternion calcQuat(float t); | 
|---|
| 79 |    | 
|---|
| 80 |    | 
|---|
| 81 |   Vector getPos(void) const; | 
|---|
| 82 | }; | 
|---|
| 83 |  | 
|---|
| 84 |  | 
|---|
| 85 | //! B-Spline | 
|---|
| 86 | /** | 
|---|
| 87 |    class to handle b-spline in 3d space | 
|---|
| 88 | */ | 
|---|
| 89 | class BSplieCurve : public Curve | 
|---|
| 90 | { | 
|---|
| 91 |  | 
|---|
| 92 |  | 
|---|
| 93 | }; | 
|---|
| 94 |  | 
|---|
| 95 | #endif /* _CURVE_H */ | 
|---|