#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 { 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 { //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(); map tracks; vector evaluate(); private: float length; float startTime; float fadeinTime; float fadeoutTime; bool loop,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& 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; }; #endif // MORPHMESH_H