Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/cleanup/src/lib/math/curve.h @ 10581

Last change on this file since 10581 was 10581, checked in by bensch, 17 years ago

changed the animation3D and t_animation to match the new list structure… but i think it breaks workability… they are strange anyways

also removed the track, as it seems quite hacked in.
Here i uncommented everything for later reinjection

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