2 This file is part of the graphics core library.
4 Copyright (c) 2004, 2005 John Tsiombikas <nuclear@siggraph.org>
6 This program 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 This program 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 this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 /* motion controllers (part of the animation system)
23 * Author: John Tsiombikas 2004
26 #ifndef _CONTROLLER_HPP_
27 #define _CONTROLLER_HPP_
30 #include "timeline.hpp"
32 enum ControllerClass {CTRL_CURVE, CTRL_SIN, CTRL_COS, CTRL_LIN};
45 class MotionController {
49 // parameters for the sinusoidal controller
50 scalar_t freq, ampl, phase;
51 scalar_t (*freq_func)(scalar_t);
52 scalar_t (*ampl_func)(scalar_t);
54 // parameters for the linear controller
57 unsigned long start_time, end_time;
59 TimelineMode time_mode;
60 ControllerClass ctrl_type;
61 unsigned int axis_flags;
64 MotionController(ControllerClass ctype = CTRL_CURVE, TimelineMode mode = TIME_CLAMP);
65 MotionController(Curve *curve, unsigned long start, unsigned long end, TimelineMode mode = TIME_CLAMP);
67 void set_curve(Curve *curve);
68 void set_sin_func(scalar_t freq, scalar_t ampl, scalar_t phase = 0.0f);
69 void set_sin_func(scalar_t (*freq_func)(scalar_t), scalar_t(*ampl_func)(scalar_t));
71 void set_origin(scalar_t orig);
72 void set_origin(const Vector3 &orig_vec);
73 void set_slope(scalar_t slope);
74 void set_slope(const Vector3 &slope_vec);
76 void set_timing(unsigned long start, unsigned long end);
77 void set_timeline_mode(TimelineMode tmode);
78 void set_controller_type(ControllerClass ctype);
79 void set_control_axis(unsigned int axis_flags);
82 unsigned long get_start_time() const;
83 unsigned long get_end_time() const;
84 TimelineMode get_timeline_mode() const;
85 unsigned int get_control_axis() const;
87 Vector3 operator ()(unsigned long time) const;
91 #endif // _CONTROLLER_HPP_