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
RevLine 
[3365]1
[4597]2/*!
[5039]3 * @file curve.h
[4836]4  *  A basic 3D curve framework
[4597]5
[3018]6    Contains classes to handle curves
[4597]7*/
[3018]8
9#ifndef _CURVE_H
10#define _CURVE_H
11
12#include "vector.h"
[6616]13#include "quaternion.h"
[3018]14
[5225]15template<class T> class tList;
16template<class T> class tIterator;
17
[3365]18//! An Enumerator that defines what sort of Curves are availible
[5225]19enum CurveType {
20  CURVE_BEZIER
21};
[3018]22
[3365]23
24//! An abstract class to handle curves. Needed for the Tracking system in orxonox.
[3019]25class Curve
[3018]26{
[3019]27 protected:
[3217]28  //! Handles the curve-points (dynamic List)
[3018]29  struct PathNode
30  {
[4472]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.
[3018]36  };
37
[3019]38 public:
[4746]39  Curve();
[5231]40  virtual ~Curve();
[3588]41
[3365]42  void addNode(const Vector& newNode);
[3433]43  void addNode(const Vector& newNode, unsigned int insertPosition);
[3365]44  Vector getNode(unsigned int nodeToFind);
[4836]45  /** @returns the count of nodes in this curve */
[4746]46  inline int getNodeCount() const { return this->nodeCount; };
[4836]47  /** @returns the directional Curve */
[4746]48  Curve* getDirCurve() const { return this->dirCurve; };
[10368]49  float getLength();
[3019]50
[4836]51  /** @param t the value on the curve [0-1] @returns Vector to the position */
[3365]52  virtual Vector calcPos(float t) = 0;
[4836]53  /** @param t the value on the curve [0-1] @returns the direction */
[3365]54  virtual Vector calcDir(float t) = 0;
[4836]55  /** @param t the value on the curve [0-1] @returns the acceleration */
[3433]56  virtual Vector calcAcc(float t) = 0;
[4836]57  /** @param t the value on the curve [0-1] @returns quaternion of the rotation */
[3365]58  virtual Quaternion calcQuat(float t) = 0;
[4597]59
[3433]60  // DEBUG
[4746]61  void debug();
[4472]62
63 private:
64  /** \brief rebuilds the curve */
[4746]65  virtual void rebuild() = 0;
[4472]66
67 protected:
[5225]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.
[4472]72
[5225]73  Curve*                dirCurve;        //!< The derivation-curve of this Curve.
[4472]74
[5225]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).
[4472]79
[3019]80};
81
[3365]82//!    Class to handle bezier curves in 3-dimesnsional space
[3019]83/**
[3365]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.
[3019]86*/
87class BezierCurve : public Curve
88{
[3018]89 public:
[4746]90  BezierCurve();
[3365]91  BezierCurve(int derivation);
[4746]92  virtual ~BezierCurve();
[3365]93
[4472]94  virtual Vector calcPos(float t);
95  virtual Vector calcDir(float t);
96  virtual Vector calcAcc(float t);
97  virtual Quaternion calcQuat(float t);
[4597]98
99
[4746]100  Vector getPos() const;
[4472]101
102 private:
[4746]103  void rebuild();
[3018]104};
105
106
[3365]107//! B-Spline
108/**
109   class to handle b-spline in 3d space
110*/
111class BSplieCurve : public Curve
112{
[3018]113
[3365]114
115};
116
[3018]117#endif /* _CURVE_H */
Note: See TracBrowser for help on using the repository browser.