diff options
Diffstat (limited to 'pluginchooser/src/pluginpanel.h')
| -rw-r--r-- | pluginchooser/src/pluginpanel.h | 80 |
1 files changed, 58 insertions, 22 deletions
diff --git a/pluginchooser/src/pluginpanel.h b/pluginchooser/src/pluginpanel.h index 5757836..82c7e46 100644 --- a/pluginchooser/src/pluginpanel.h +++ b/pluginchooser/src/pluginpanel.h @@ -14,40 +14,78 @@ struct float_param { class loader { public: - loader(string _n,AChaosBase *_plugin,vector<float_param> _params={}){ + loader(string _n,AChaosBase *_plugin,int _dimension,int _input_index,vector<float_param> _params={}){ name=_n; plugin=_plugin; + dimension=_dimension; + input_index=_input_index; params=_params; + iv.resize(_params.size()+_dimension); } string name; AChaosBase *plugin; vector<float_param> params; - REAL iv[6]; + vector<REAL> iv; + int dimension; + int input_index; + void update(vector<ofParameter<float> > _params){ + int in=input_index==0?dimension:0; + for (int i=0;i<min(_params.size(),params.size());i++,in++){ + iv[in]=_params[i]; + params[i].val=_params[i]; + } + } ofVec2f calc(ofVec2f point){ - iv[0]=point.x; - iv[1]=point.y; + iv[input_index]=point.x; + iv[input_index+1]=point.y; plugin->set(iv); plugin->calc(); - return ofVec2f(plugin->nx,plugin->ny); + vector<REAL> ov=plugin->getVec(); + return ofVec2f(ov[0],ov[1]); } }; +/* +some plugins have more or less dimensions of input/output +params are ordered differently +some allow t/dt control + +-> tag the first input dimension index +-> tag the first param index +-> tag the number of params + +*/ + class pluginPanel : public ofxPanel { public: pluginPanel(){ ofRegisterKeyEvents(this, defaultEventsPriority); plugins={ - loader("baker",&baker), - loader("clifford",&clifford,{ - {"a",0.0f,-1.0f,1.0f}, - {"b",0.0f,-1.0f,1.0f}, - {"c",0.0f,-1.0f,1.0f}, - {"d",0.0f,-1.0f,1.0f} + //loader("baker",&baker), //2,1 + loader("clifford",&clifford, + 2,4, //number of dimensions and index + { //4,2 a b c d nx ny + {"a",-1.4f,-2.0f,2.0f}, + {"b",1.6f,-2.0f,2.0f}, + {"c",1.0f,-2.0f,2.0f}, + {"d",0.7f,-2.0f,2.0f} + } + ), + //loader("collatz",&collatz), //3,1 + //loader("duffing",&duffing,{ //7,2 a b w nx ny dt t time, could be real time or magnified + // } //seems perfect + //), + //loader("ginger",&ginger), //3,2 seed nx ny maybe + loader("henon",&henon, //4,2 a b nx ny perfect + 2,2, + { + {"a",1.4f,-0.0f,2.0f}, + {"b",0.3f,-1.0f,1.0f} } ) }; index=0; - update(); + select(); } bool mouseMoved(ofMouseEventArgs & args){ if (args.x>getPosition().x&& @@ -79,7 +117,7 @@ class pluginPanel : public ofxPanel { if (index<0){ index=plugins.size()-1; } - update(); + select(); break; } case 57358:{ //right @@ -87,7 +125,7 @@ class pluginPanel : public ofxPanel { if (index==plugins.size()){ index=0; } - update(); + select(); break; } default: @@ -99,7 +137,7 @@ class pluginPanel : public ofxPanel { bool keyReleased(ofKeyEventArgs & args){ //required in order to call ofRegisterKeyEvents } - void update(){ + void select(){ ofLog()<<"selected "<<plugins[index].name; clear(); add(label.setup(plugins[index].name)); @@ -118,13 +156,12 @@ class pluginPanel : public ofxPanel { params.push_back(param); } } - void update_params(){ - for (int i=0;i<params.size();i++){ - plugins[index].iv[i+2]=params[i]; - } + void update(){ + //push params to plugin + plugins[index].update(params); } ofVec2f calc(ofVec2f point){ - return plugins[index].plugin->calc(point); + return plugins[index].calc(point); } private: int index; @@ -134,7 +171,6 @@ private: ofParameter<bool> active; ofParameter<float> amount; vector<ofParameter<float> > params; - AChaosBaker baker; AChaosClifford clifford; - + AChaosHenon henon; };
\ No newline at end of file |
