--- /dev/null
+#include "action.h"
+
+InterpolationAction::InterpolationAction(bool h):
+ hermite(h),
+ start_beat(0),
+ duration(0)
+{ }
+
+void InterpolationAction::start(float b, float d)
+{
+ start_beat = b;
+ duration = d;
+ interpolate(0.0f, 0.0f);
+}
+
+void InterpolationAction::tick(float b, float d)
+{
+ if(duration)
+ {
+ float t = (b-start_beat)/duration;
+ float dt = d/duration;
+ if(hermite)
+ {
+ dt = t-dt;
+ t = (3-2*t)*t*t;
+ dt = t-(3-2*dt)*dt*dt;
+ }
+ interpolate(t, dt);
+ }
+ else
+ interpolate(1.0f, 1.0f);
+}
+
+void InterpolationAction::end(float)
+{
+ interpolate(1.0f, 0.0f);
+}
--- /dev/null
+#ifndef MSP_DEMOSCENE_ACTION_H_
+#define MSP_DEMOSCENE_ACTION_H_
+
+class Action
+{
+protected:
+ Action() { }
+public:
+ virtual ~Action() { }
+
+ virtual void start(float, float) { }
+ virtual void beat(int) { }
+ virtual void tick(float, float) { }
+ virtual void end(float) { }
+};
+
+class InterpolationAction: public Action
+{
+protected:
+ bool hermite;
+ float start_beat;
+ float duration;
+
+ InterpolationAction(bool = false);
+
+public:
+ virtual void start(float, float);
+ virtual void tick(float, float);
+ virtual void end(float);
+ virtual void interpolate(float, float) { }
+};
+
+#endif
#include <msp/gl/objectinstance.h>
#include <msp/gl/renderable.h>
#include <msp/gl/text.h>
-#include "sequencer.h"
+#include "action.h"
-class BeatCounter: public Msp::GL::Renderable, public Sequencer::Action
+class BeatCounter: public Msp::GL::Renderable, public Action
{
private:
Msp::GL::Text text;
#include <msp/gl/animationplayer.h>
#include <msp/gl/camera.h>
-#include "sequencer.h"
+#include "action.h"
-class CameraControl: public Sequencer::Action
+class CameraControl: public Action
{
public:
- class SetCamera: public Sequencer::Action
+ class SetCamera: public Action
{
private:
CameraControl &control;
virtual void start(float, float);
};
- class AnimateCamera: public Sequencer::Action
+ class AnimateCamera: public Action
{
private:
CameraControl &control;
using namespace Msp;
ColorFadeAction::ColorFadeAction(const GL::Color &c):
- Sequencer::InterpolationAction(true),
+ InterpolationAction(true),
end_color(c)
{ }
#define MSP_DEMOSCENE_COLORFADE_H_
#include <msp/gl/color.h>
-#include "sequencer.h"
+#include "action.h"
-class ColorFadeAction: public Sequencer::InterpolationAction
+class ColorFadeAction: public InterpolationAction
{
protected:
Msp::GL::Color start_color;
#include <cmath>
#include <msp/core/algorithm.h>
+#include "action.h"
#include "sequencer.h"
using namespace std;
if(i->end_beat>beat)
next_event = min(next_event, i->end_beat);
}
-
-
-Sequencer::InterpolationAction::InterpolationAction(bool h):
- hermite(h),
- start_beat(0),
- duration(0)
-{ }
-
-void Sequencer::InterpolationAction::start(float b, float d)
-{
- start_beat = b;
- duration = d;
- interpolate(0.0f, 0.0f);
-}
-
-void Sequencer::InterpolationAction::tick(float b, float d)
-{
- if(duration)
- {
- float t = (b-start_beat)/duration;
- float dt = d/duration;
- if(hermite)
- {
- dt = t-dt;
- t = (3-2*t)*t*t;
- dt = t-(3-2*dt)*dt*dt;
- }
- interpolate(t, dt);
- }
- else
- interpolate(1.0f, 1.0f);
-}
-
-void Sequencer::InterpolationAction::end(float)
-{
- interpolate(1.0f, 0.0f);
-}
#include <msp/time/timedelta.h>
#include <msp/time/timestamp.h>
+class Action;
+
class Sequencer
{
-public:
- class Action
- {
- protected:
- Action() { }
- public:
- virtual ~Action() { }
-
- virtual void start(float, float) { }
- virtual void beat(int) { }
- virtual void tick(float, float) { }
- virtual void end(float) { }
- };
-
- class InterpolationAction: public Action
- {
- protected:
- bool hermite;
- float start_beat;
- float duration;
-
- InterpolationAction(bool = false);
-
- public:
- virtual void start(float, float);
- virtual void tick(float, float);
- virtual void end(float);
- virtual void interpolate(float, float) { }
- };
-
private:
struct Segment
{
#include <msp/gl/pipeline.h>
#include "cameracontrol.h"
-#include "sequencer.h"
+#include "action.h"
struct Stage
{
- class UseInView: public Sequencer::Action
+ class UseInView: public Action
{
private:
Msp::GL::View &view;