Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3588 was 3588, checked in by bensch, 20 years ago

orxonox/trunk: name-fix for TrackManager and minor fix in Curve.
There has also been a little fix in the light-class: light is a BaseObject not a World-Entity

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 {BEZIERCURVE, UPOINTCURVE};
16
17
18//! An abstract class to handle curves. Needed for the Tracking system in orxonox.
19class Curve
20{
21 protected:
22  int nodeCount;         //!< The count of nodes the Curve has.
23  Vector curvePoint;     //!< The point on the Cureve at a local Time.
24  float localTime;       //!< If the time of one point is asked more than once the programm will not calculate it again.
25  int derivation;        //!< Which derivation of a Curve is this.
26
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  PathNode* firstNode;   //!< First node of the curve.
38  PathNode* currentNode; //!< The node we are working with (the Last node).
39
40
41 private:
42  virtual void rebuild(void) = 0;
43 public:
44  Curve(void);
45
46  Curve* dirCurve;       //!< The derivation-curve of this Curve.
47  void addNode(const Vector& newNode);
48  void addNode(const Vector& newNode, unsigned int insertPosition);
49  Vector getNode(unsigned int nodeToFind);
50  inline int getNodeCount(void) { return this->nodeCount;}
51
52  virtual Vector calcPos(float t) = 0;
53  virtual Vector calcDir(float t) = 0;
54  virtual Vector calcAcc(float t) = 0;
55  virtual Quaternion calcQuat(float t) = 0;
56 
57  // DEBUG
58  void debug(void);
59};
60
61//!    Class to handle bezier curves in 3-dimesnsional space
62/**
63   This Curve is good, for Fast Interaction. If you want to change it during the game, go on.
64   !!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.
65*/
66class BezierCurve : public Curve
67{
68 private:
69  void rebuild(void);
70 public:
71  BezierCurve(void);
72  BezierCurve(int derivation);
73  virtual ~BezierCurve(void);
74
75  Vector calcPos(float t);
76  Vector calcDir(float t);
77  Vector calcAcc(float t);
78  Quaternion calcQuat(float t);
79 
80 
81  Vector getPos(void) const;
82};
83
84
85//! B-Spline
86/**
87   class to handle b-spline in 3d space
88*/
89class BSplieCurve : public Curve
90{
91
92
93};
94
95//! Uniform Point Curve-class
96/**
97   A UPoint Curve is a A Curve, that flows through all the nodes given it.
98   The Algorithm to buid the curve is rather slow, but Painting and tracing along the curve has high speed, so do not change this curve during the Game.
99
100   This Curve is very erattic, so i do not recommend to use it.
101*/
102class UPointCurve : public Curve
103{
104 private:
105  void rebuild(void);
106 public:
107  UPointCurve(void);
108  UPointCurve(int derivation);
109  ~UPointCurve(void);
110
111  Vector calcPos(float t);
112  Vector calcDir(float t);
113  Vector calcAcc(float t);
114  Quaternion calcQuat(float t);
115 
116  Vector getPos(void) const;
117};
118
119#endif /* _CURVE_H */
Note: See TracBrowser for help on using the repository browser.