2 This file is part of the graphics core library.
4 Copyright (c) 2004, 2005 John Tsiombikas <nuclear@siggraph.org>
6 the graphics core library is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 the graphics core library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with the graphics core library; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * author: John Tsiombikas 2003
25 * John Tsiombikas 2004, 2005
26 * Mihalis Georgoulopoulos 2004
33 #include "vmath/vmath.h"
34 #include "linkedlist.h"
39 LinkedList<Vector3> control_points;
40 Vector2 *samples; // used for parametrizing by arc length
44 Curve *ease_curve; // ease in/out curve (1D, x&z discarded)
45 int ease_sample_count, ease_step;
47 void sample_arc_lengths();
48 scalar_t parametrize(scalar_t t) const;
49 scalar_t ease(scalar_t t) const;
56 virtual void add_control_point(const Vector3 &cp);
57 virtual void remove_control_point(int index);
58 virtual Vector3 *get_control_point(int index);
60 virtual int get_point_count() const;
61 virtual int get_segment_count() const = 0;
62 virtual void set_arc_parametrization(bool state);
63 virtual void set_ease_curve(Curve *curve);
64 virtual void set_ease_sample_count(int count);
66 virtual Vector3 interpolate(scalar_t t) const = 0;
67 virtual Vector3 operator ()(scalar_t t) const;
69 friend bool save_curve(const char *fname, const Curve *curve);
72 class BSplineCurve : public Curve {
74 virtual int get_segment_count() const;
75 virtual Vector3 interpolate(scalar_t t) const;
78 class CatmullRomSplineCurve : public Curve {
80 virtual int get_segment_count() const;
81 virtual Vector3 interpolate(scalar_t t) const;
84 class BezierSpline : public Curve {
86 virtual int get_segment_count() const;
87 virtual Vector3 interpolate(scalar_t t) const;
89 Vector3 get_control_point(int i) const;
90 Vector3 get_tangent(scalar_t t);
93 bool save_curve(const char *fname, const Curve *curve);
94 Curve *load_curve(const char *fname);
96 #endif // _CURVES_HPP_