absence_thelab
diff src/common/curves.h @ 0:1cffe3409164
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 23 Oct 2014 01:46:07 +0300 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/common/curves.h Thu Oct 23 01:46:07 2014 +0300 1.3 @@ -0,0 +1,50 @@ 1.4 +#ifndef _CURVES_H_ 1.5 +#define _CURVES_H_ 1.6 + 1.7 +#include <string> 1.8 +#include "n3dmath.h" 1.9 +#include "linkedlist.h" 1.10 + 1.11 +class Curve { 1.12 +protected: 1.13 + LinkedList<Vector3> ControlPoints; 1.14 + Vector2 *Samples; // used for parametrizing by arc length 1.15 + int SampleCount; 1.16 + bool ArcParametrize; 1.17 + 1.18 + Curve *ease_curve; // ease in/out curve (1D, x&z discarded) 1.19 + int ease_sample_count, ease_step; 1.20 + 1.21 + void SampleArcLengths(); 1.22 + float Parametrize(float t); 1.23 + float Ease(float t); 1.24 + 1.25 +public: 1.26 + std::string name; 1.27 + 1.28 + Curve(); 1.29 + ~Curve(); 1.30 + virtual void AddControlPoint(const Vector3 &cp); 1.31 + 1.32 + virtual int GetSegmentCount() const = 0; 1.33 + virtual void SetArcParametrization(bool state); 1.34 + virtual void SetEaseCurve(Curve *curve); 1.35 + virtual void SetEaseSampleCount(int count); 1.36 + 1.37 + virtual Vector3 Interpolate(float t) = 0; 1.38 +}; 1.39 + 1.40 +class BSpline : public Curve { 1.41 +public: 1.42 + virtual int GetSegmentCount() const; 1.43 + virtual Vector3 Interpolate(float t); 1.44 +}; 1.45 + 1.46 +class CatmullRomSpline : public Curve { 1.47 +public: 1.48 + virtual int GetSegmentCount() const; 1.49 + virtual Vector3 Interpolate(float t); 1.50 +}; 1.51 + 1.52 + 1.53 +#endif // _CURVES_H_ 1.54 \ No newline at end of file