Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/math/curve.h @ 10585

Last change on this file since 10585 was 10368, checked in by patrick, 18 years ago

merged the branche playability into the trunk

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  float getLength();
50
51  /** @param t the value on the curve [0-1] @returns Vector to the position */
52  virtual Vector calcPos(float t) = 0;
53  /** @param t the value on the curve [0-1] @returns the direction */
54  virtual Vector calcDir(float t) = 0;
55  /** @param t the value on the curve [0-1] @returns the acceleration */
56  virtual Vector calcAcc(float t) = 0;
57  /** @param t the value on the curve [0-1] @returns quaternion of the rotation */
58  virtual Quaternion calcQuat(float t) = 0;
59
60  // DEBUG
61  void debug();
62
63 private:
64  /** \brief rebuilds the curve */
65  virtual void rebuild() = 0;
66
67 protected:
68  int                   nodeCount;       //!< The count of nodes the Curve has.
69  Vector                curvePoint;      //!< The point on the Cureve at a local Time.
70  float                 localTime;       //!< If the time of one point is asked more than once the programm will not calculate it again.
71  int                   derivation;      //!< Which derivation of a Curve is this.
72
73  Curve*                dirCurve;        //!< The derivation-curve of this Curve.
74
75  tList<PathNode>*      nodeList;        //!< A list of all the Nodes of a Curve.
76  tIterator<PathNode>*  nodeIterator;    //!< An iterator that should point to the current Node
77  PathNode*             firstNode;       //!< First node of the curve.
78  PathNode*             currentNode;     //!< The node we are working with (the Last node).
79
80};
81
82//!    Class to handle bezier curves in 3-dimesnsional space
83/**
84   This Curve is good, for Fast Interaction. If you want to change it during the game, go on.
85   !!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.
86*/
87class BezierCurve : public Curve
88{
89 public:
90  BezierCurve();
91  BezierCurve(int derivation);
92  virtual ~BezierCurve();
93
94  virtual Vector calcPos(float t);
95  virtual Vector calcDir(float t);
96  virtual Vector calcAcc(float t);
97  virtual Quaternion calcQuat(float t);
98
99
100  Vector getPos() const;
101
102 private:
103  void rebuild();
104};
105
106
107//! B-Spline
108/**
109   class to handle b-spline in 3d space
110*/
111class BSplieCurve : public Curve
112{
113
114
115};
116
117#endif /* _CURVE_H */
Note: See TracBrowser for help on using the repository browser.