Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: removing some initialisation-stuff… i hope this works

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