absence_thelab

view src/common/curves.h @ 1:4d5933c261c3

todo and .hgignore
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 23 Oct 2014 02:18:43 +0300
parents
children
line source
1 #ifndef _CURVES_H_
2 #define _CURVES_H_
4 #include <string>
5 #include "n3dmath.h"
6 #include "linkedlist.h"
8 class Curve {
9 protected:
10 LinkedList<Vector3> ControlPoints;
11 Vector2 *Samples; // used for parametrizing by arc length
12 int SampleCount;
13 bool ArcParametrize;
15 Curve *ease_curve; // ease in/out curve (1D, x&z discarded)
16 int ease_sample_count, ease_step;
18 void SampleArcLengths();
19 float Parametrize(float t);
20 float Ease(float t);
22 public:
23 std::string name;
25 Curve();
26 ~Curve();
27 virtual void AddControlPoint(const Vector3 &cp);
29 virtual int GetSegmentCount() const = 0;
30 virtual void SetArcParametrization(bool state);
31 virtual void SetEaseCurve(Curve *curve);
32 virtual void SetEaseSampleCount(int count);
34 virtual Vector3 Interpolate(float t) = 0;
35 };
37 class BSpline : public Curve {
38 public:
39 virtual int GetSegmentCount() const;
40 virtual Vector3 Interpolate(float t);
41 };
43 class CatmullRomSpline : public Curve {
44 public:
45 virtual int GetSegmentCount() const;
46 virtual Vector3 Interpolate(float t);
47 };
50 #endif // _CURVES_H_