Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: TrackManager: nicer fuctionality… more to come

File size: 2.4 KB
RevLine 
[3365]1
[3018]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
[3365]14//! An Enumerator that defines what sort of Curves are availible
[3836]15enum CurveType {CURVE_BEZIER};
[3018]16
[3365]17
18//! An abstract class to handle curves. Needed for the Tracking system in orxonox.
[3019]19class Curve
[3018]20{
[3019]21 protected:
[3217]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.
[3365]25  int derivation;        //!< Which derivation of a Curve is this.
[3019]26
[3217]27  //! Handles the curve-points (dynamic List)
[3018]28  struct PathNode
29  {
[3217]30    int number;          //!< The N-th node of this curve.
[3365]31    float factor;        //!< Curve specific multiplier factor.
32    Vector vFactor;      //!< A Vector-factor for multipliing.
[3217]33    Vector position;     //!< Vector Pointung to this curve-point.
34    PathNode* next;      //!< Pointer to the next Node.
[3018]35  };
36
[3217]37  PathNode* firstNode;   //!< First node of the curve.
38  PathNode* currentNode; //!< The node we are working with (the Last node).
[3018]39
[3588]40
[3365]41 private:
42  virtual void rebuild(void) = 0;
[3019]43 public:
[3588]44  Curve(void);
45
[3433]46  Curve* dirCurve;       //!< The derivation-curve of this Curve.
[3365]47  void addNode(const Vector& newNode);
[3433]48  void addNode(const Vector& newNode, unsigned int insertPosition);
[3365]49  Vector getNode(unsigned int nodeToFind);
50  inline int getNodeCount(void) { return this->nodeCount;}
[3019]51
[3365]52  virtual Vector calcPos(float t) = 0;
53  virtual Vector calcDir(float t) = 0;
[3433]54  virtual Vector calcAcc(float t) = 0;
[3365]55  virtual Quaternion calcQuat(float t) = 0;
56 
[3433]57  // DEBUG
58  void debug(void);
[3019]59};
60
[3365]61//!    Class to handle bezier curves in 3-dimesnsional space
[3019]62/**
[3365]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.
[3019]65*/
66class BezierCurve : public Curve
67{
68 private:
[3365]69  void rebuild(void);
[3018]70 public:
[3365]71  BezierCurve(void);
72  BezierCurve(int derivation);
[3588]73  virtual ~BezierCurve(void);
[3365]74
75  Vector calcPos(float t);
76  Vector calcDir(float t);
[3433]77  Vector calcAcc(float t);
[3365]78  Quaternion calcQuat(float t);
[3018]79 
[3028]80 
[3365]81  Vector getPos(void) const;
[3018]82};
83
84
[3365]85//! B-Spline
86/**
87   class to handle b-spline in 3d space
88*/
89class BSplieCurve : public Curve
90{
[3018]91
[3365]92
93};
94
[3018]95#endif /* _CURVE_H */
Note: See TracBrowser for help on using the repository browser.