#ifndef MORPHMESH_H #define MORPHMESH_H #include #include #include #include /* Tim Redfern, March 2012 Loads meshes in Oak3D XML format Draws blended morph targets Multiple meshes are loaded as morph targets Coords are absolute --managing movement sequences --cycles can refer to targets by name --high level controller objects can refer to animation sequences by name --this makes it impossible for a re-odering to banjax everything cycles have a start time, and they either loop or act as a transition Working out the morphs is a question of: -working out which cycles are active based on behaviours -adding their morph targets into the current vector of targets behaviours are triggered by things like spotting people or avoiding the wall. These could be parameterised on top of the rest? */ struct morphWeight { morphWeight(string _name="",float _weight=1.0) {name=_name;weight=_weight;} 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(); map keys; float evaluate(float time); }; class sequence { //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(string _name="",float _length=1.0,float _fadeinTime=-2.0,float _fadeoutTime=-2.0); string name; map tracks; vector evaluate(float time); void reset(); void start(); void stop(); void startAt(float time); void stopAt(float time); void fadein(float time); void fadeout(float time); float length; float startTime; float stopTime; float fadeinTime; float fadeoutTime; bool active; }; class morphmesh : public ofMesh { public: morphmesh(); 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& weights); void drawAnimated(); //evaluates all active sequences via iterator and builds a collection of targets and weights for above int getNumTargets(); int getNumSequences(); map sequences; //public for direct access protected: private: map< string,vector > morphs; bool loaded; }; #endif // MORPHMESH_H