Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/heathaze/src/lib/math/curve.h @ 10656

Last change on this file since 10656 was 6616, checked in by bensch, 19 years ago

orxonox/trunk: taken the quaternion outside of Vector.cc to quaternion.cc/h

File size: 3.4 KB
Line 
1
2/*!
3 * @file curve.h
4  *  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#include "quaternion.h"
14
15template<class T> class tList;
16template<class T> class tIterator;
17
18//! An Enumerator that defines what sort of Curves are availible
19enum CurveType {
20  CURVE_BEZIER
21};
22
23
24//! An abstract class to handle curves. Needed for the Tracking system in orxonox.
25class Curve
26{
27 protected:
28  //! Handles the curve-points (dynamic List)
29  struct PathNode
30  {
31    int          number;       //!< The N-th node of this curve.
32    float        factor;       //!< Curve specific multiplier factor.
33    Vector       vFactor;      //!< A Vector-factor for multipliing.
34    Vector       position;     //!< Vector Pointung to this curve-point.
35    PathNode*    next;         //!< Pointer to the next Node.
36  };
37
38 public:
39  Curve();
40  virtual ~Curve();
41
42  void addNode(const Vector& newNode);
43  void addNode(const Vector& newNode, unsigned int insertPosition);
44  Vector getNode(unsigned int nodeToFind);
45  /** @returns the count of nodes in this curve */
46  inline int getNodeCount() const { return this->nodeCount; };
47  /** @returns the directional Curve */
48  Curve* getDirCurve() const { return this->dirCurve; };
49
50  /** @param t the value on the curve [0-1] @returns Vector to the position */
51  virtual Vector calcPos(float t) = 0;
52  /** @param t the value on the curve [0-1] @returns the direction */
53  virtual Vector calcDir(float t) = 0;
54  /** @param t the value on the curve [0-1] @returns the acceleration */
55  virtual Vector calcAcc(float t) = 0;
56  /** @param t the value on the curve [0-1] @returns quaternion of the rotation */
57  virtual Quaternion calcQuat(float t) = 0;
58
59  // DEBUG
60  void debug();
61
62 private:
63  /** \brief rebuilds the curve */
64  virtual void rebuild() = 0;
65
66 protected:
67  int                   nodeCount;       //!< The count of nodes the Curve has.
68  Vector                curvePoint;      //!< The point on the Cureve at a local Time.
69  float                 localTime;       //!< If the time of one point is asked more than once the programm will not calculate it again.
70  int                   derivation;      //!< Which derivation of a Curve is this.
71
72  Curve*                dirCurve;        //!< The derivation-curve of this Curve.
73
74  tList<PathNode>*      nodeList;        //!< A list of all the Nodes of a Curve.
75  tIterator<PathNode>*  nodeIterator;    //!< An iterator that should point to the current Node
76  PathNode*             firstNode;       //!< First node of the curve.
77  PathNode*             currentNode;     //!< The node we are working with (the Last node).
78
79};
80
81//!    Class to handle bezier curves in 3-dimesnsional space
82/**
83   This Curve is good, for Fast Interaction. If you want to change it during the game, go on.
84   !!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.
85*/
86class BezierCurve : public Curve
87{
88 public:
89  BezierCurve();
90  BezierCurve(int derivation);
91  virtual ~BezierCurve();
92
93  virtual Vector calcPos(float t);
94  virtual Vector calcDir(float t);
95  virtual Vector calcAcc(float t);
96  virtual Quaternion calcQuat(float t);
97
98
99  Vector getPos() const;
100
101 private:
102  void rebuild();
103};
104
105
106//! B-Spline
107/**
108   class to handle b-spline in 3d space
109*/
110class BSplieCurve : public Curve
111{
112
113
114};
115
116#endif /* _CURVE_H */
Note: See TracBrowser for help on using the repository browser.