Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: curve doxygen, and redesign

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