From 1039fe7789a990eee6e00896cf85bc097e9009dc Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Fri, 6 Apr 2012 18:58:50 +0100 Subject: working track interpolation --- gaunt01/src/morphmesh.h | 62 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 13 deletions(-) (limited to 'gaunt01/src/morphmesh.h') diff --git a/gaunt01/src/morphmesh.h b/gaunt01/src/morphmesh.h index ca1231c..18463a8 100644 --- a/gaunt01/src/morphmesh.h +++ b/gaunt01/src/morphmesh.h @@ -34,15 +34,48 @@ behaviours are triggered by things like spotting people or avoiding the wall. These could be parameterised on top of the rest? */ +struct morphWeight +{ + string name; + float weight; +}; +struct key +{ + key(float _val,float _time) {value=_val;time=_time;} + float value; + float time; +}; + +class track +{ + //a single morph channel. keys a single morph target within a single sequence + public: + track(); + string target; + multimap keys; + float evaluate(float time); + +}; class sequence { - //stores a morph sequence: an animation cycle or transition + //tracks a morph sequence: an animation cycle or transition + //targets are named keys + //animation consists of time,value pairs for any number of named tracks + //the sequence knows the time (absolute seconds) it was started + //sequencer keeps track of playback time and start/stop of sequences + //tracks is a map of time,value pairs - built in interpolation via multimap public: sequence(); - virtual ~sequence(); - + map tracks; + vector evaluate(); + private: + float length; + float startTime; + float fadeinTime; + float fadeoutTime; + bool loop,active; }; @@ -50,18 +83,21 @@ class morphmesh : public ofMesh { public: morphmesh(); - morphmesh(string filename); - virtual ~morphmesh(); - bool loadMesh(string filename); - bool isLoaded(); - void draw(); - void draw(int target); - void draw(const vector& targets, const vector& weights); - int getNumTargets(); + morphmesh(string filename); + bool loadMesh(string filename); + bool loadSeqs(string filename); + bool isLoaded(); + void draw(); + void draw(int target); + void draw(string target); + void draw(const vector& targets, const vector& weights); + void drawAnimated(); //evaluates all active sequences via iterator and builds a collection of targets and weights for above + int getNumTargets(); + map< string,sequence > sequences; //public for direct access protected: private: - map< string,vector > morphs; - bool loaded; + map< string,vector > morphs; + bool loaded; }; #endif // MORPHMESH_H -- cgit v1.2.3