diff options
Diffstat (limited to 'liveengine')
| -rw-r--r-- | liveengine/bin/data/yoga.xml | 124 | ||||
| -rw-r--r-- | liveengine/liveengine.cbp | 2 | ||||
| -rw-r--r-- | liveengine/liveengine.layout | 19 | ||||
| -rwxr-xr-x | liveengine/src/layers.cpp | 20 | ||||
| -rwxr-xr-x | liveengine/src/layers.h | 17 | ||||
| -rwxr-xr-x[-rw-r--r--] | liveengine/src/playlist.cpp | 0 | ||||
| -rwxr-xr-x | liveengine/src/testApp.cpp | 116 | ||||
| -rwxr-xr-x | liveengine/src/testApp.h | 15 | ||||
| -rwxr-xr-x | liveengine/src/viewport.cpp | 107 | ||||
| -rwxr-xr-x | liveengine/src/viewport.h | 33 |
10 files changed, 316 insertions, 137 deletions
diff --git a/liveengine/bin/data/yoga.xml b/liveengine/bin/data/yoga.xml index fc9c103..5c26932 100644 --- a/liveengine/bin/data/yoga.xml +++ b/liveengine/bin/data/yoga.xml @@ -1,56 +1,68 @@ -<?xml version="1.0" encoding="UTF-8" ?>
-<playlist>
- <svglayer note="36" file="yoga/RD01004A.WMF.svg"/>
- <svglayer note="37" file="yoga/RD01005A.WMF.svg"/>
- <svglayer note="38" file="yoga/RD01006A.WMF.svg"/>
- <svglayer note="39" file="yoga/RD01007A.WMF.svg"/>
- <svglayer note="40" file="yoga/RD01008A.WMF.svg"/>
- <svglayer note="41" file="yoga/RD01009A.WMF.svg"/>
- <svglayer note="42" file="yoga/RD01010A.WMF.svg"/>
- <svglayer note="43" file="yoga/RD01011A.WMF.svg"/>
- <svglayer note="44" file="yoga/RD01012A.WMF.svg"/>
- <svglayer note="45" file="yoga/RD01013A.WMF.svg"/>
- <svglayer note="46" file="yoga/RD01014A.WMF.svg"/>
- <svglayer note="47" file="yoga/RD01015A.WMF.svg"/>
- <svglayer note="48" file="yoga/RD01016A.WMF.svg"/>
- <svglayer note="49" file="yoga/RD01017A.WMF.svg"/>
- <svglayer note="50" file="yoga/RD01029A.WMF.svg"/>
- <svglayer note="51" file="yoga/RD01030A.WMF.svg"/>
- <svglayer note="52" file="yoga/RD01031A.WMF.svg"/>
- <svglayer note="53" file="yoga/RD01032A.WMF.svg"/>
- <svglayer note="54" file="yoga/RD01033A.WMF.svg"/>
- <svglayer note="55" file="yoga/RD01034A.WMF.svg"/>
- <svglayer note="56" file="yoga/RD01035A.WMF.svg"/>
- <svglayer note="57" file="yoga/RD01036A.WMF.svg"/>
- <svglayer note="58" file="yoga/RD01037A.WMF.svg"/>
- <svglayer note="59" file="yoga/RD01038A.WMF.svg"/>
- <svglayer note="60" file="yoga/RD01039A.WMF.svg"/>
- <svglayer note="61" file="yoga/RD01040A.WMF.svg"/>
- <svglayer note="62" file="yoga/RD01041A.WMF.svg"/>
- <svglayer note="63" file="yoga/RD01042A.WMF.svg"/>
- <svglayer note="64" file="yoga/RD01043A.WMF.svg"/>
- <svglayer note="65" file="yoga/RD01044A.WMF.svg"/>
- <svglayer note="66" file="yoga/RD01045A.WMF.svg"/>
- <svglayer note="67" file="yoga/RD01046A.WMF.svg"/>
- <svglayer note="68" file="yoga/RD01047A.WMF.svg"/>
- <svglayer note="69" file="yoga/RD01048A.WMF.svg"/>
- <svglayer note="70" file="yoga/RD01049A.WMF.svg"/>
- <svglayer note="71" file="yoga/RD01050A.WMF.svg"/>
- <svglayer note="72" file="yoga/RD01051A.WMF.svg"/>
- <svglayer note="73" file="yoga/RD01052A.WMF.svg"/>
- <svglayer note="74" file="yoga/RD01053A.WMF.svg"/>
- <svglayer note="75" file="yoga/RD01054A.WMF.svg"/>
- <svglayer note="76" file="yoga/RD01055A.WMF.svg"/>
- <svglayer note="77" file="yoga/RD01056A.WMF.svg"/>
- <svglayer note="78" file="yoga/RD01057A.WMF.svg"/>
- <svglayer note="79" file="yoga/RD01058A.WMF.svg"/>
- <svglayer note="80" file="yoga/RD01059A.WMF.svg"/>
- <svglayer note="81" file="yoga/RD01060A.WMF.svg"/>
- <svglayer note="82" file="yoga/RD01061A.WMF.svg"/>
- <svglayer note="83" file="yoga/RD01063A.WMF.svg"/>
- <svglayer note="84" file="yoga/RD01064A.WMF.svg"/>
- <svglayer note="85" file="yoga/RD01065A.WMF.svg"/>
- <svglayer note="86" file="yoga/RD01066A.WMF.svg"/>
-
-</playlist>
- +<?xml version='1.0' encoding='utf-8'?> +<playlist> + <svglayer note="36" file="yoga/RD01004A.WMF.svg"/> + <svglayer note="37" file="yoga/RD01005A.WMF.svg"/> + <svglayer note="38" file="yoga/RD01006A.WMF.svg"/> + <svglayer note="39" file="yoga/RD01007A.WMF.svg"/> + <svglayer note="40" file="yoga/RD01008A.WMF.svg"/> + <svglayer note="41" file="yoga/RD01009A.WMF.svg"/> + <svglayer note="42" file="yoga/RD01010A.WMF.svg"/> + <svglayer note="43" file="yoga/RD01011A.WMF.svg"/> + <svglayer note="44" file="yoga/RD01012A.WMF.svg"/> + <svglayer note="45" file="yoga/RD01013A.WMF.svg"/> + <svglayer note="46" file="yoga/RD01014A.WMF.svg"/> + <svglayer note="47" file="yoga/RD01015A.WMF.svg"/> + <svglayer note="48" file="yoga/RD01016A.WMF.svg"/> + <svglayer note="49" file="yoga/RD01017A.WMF.svg"/> + <svglayer note="50" file="yoga/RD01029A.WMF.svg"/> + <svglayer note="51" file="yoga/RD01030A.WMF.svg"/> + <svglayer note="52" file="yoga/RD01031A.WMF.svg"/> + <svglayer note="53" file="yoga/RD01032A.WMF.svg"/> + <svglayer note="54" file="yoga/RD01033A.WMF.svg"/> + <svglayer note="55" file="yoga/RD01034A.WMF.svg"/> + <svglayer note="56" file="yoga/RD01035A.WMF.svg"/> + <svglayer note="57" file="yoga/RD01036A.WMF.svg"/> + <svglayer note="58" file="yoga/RD01037A.WMF.svg"/> + <svglayer note="59" file="yoga/RD01038A.WMF.svg"/> + <svglayer note="60" file="yoga/RD01039A.WMF.svg"/> + <svglayer note="61" file="yoga/RD01040A.WMF.svg"/> + <svglayer note="62" file="yoga/RD01041A.WMF.svg"/> + <svglayer note="63" file="yoga/RD01042A.WMF.svg"/> + <svglayer note="64" file="yoga/RD01043A.WMF.svg"/> + <svglayer note="65" file="yoga/RD01044A.WMF.svg"/> + <svglayer note="66" file="yoga/RD01045A.WMF.svg"/> + <svglayer note="67" file="yoga/RD01046A.WMF.svg"/> + <svglayer note="68" file="yoga/RD01047A.WMF.svg"/> + <svglayer note="69" file="yoga/RD01048A.WMF.svg"/> + <svglayer note="70" file="yoga/RD01049A.WMF.svg"/> + <svglayer note="71" file="yoga/RD01050A.WMF.svg"/> + <svglayer note="72" file="yoga/RD01051A.WMF.svg"/> + <svglayer note="73" file="yoga/RD01052A.WMF.svg"/> + <svglayer note="74" file="yoga/RD01053A.WMF.svg"/> + <svglayer note="75" file="yoga/RD01054A.WMF.svg"/> + <svglayer note="76" file="yoga/RD01055A.WMF.svg"/> + <svglayer note="77" file="yoga/RD01056A.WMF.svg"/> + <svglayer note="78" file="yoga/RD01057A.WMF.svg"/> + <svglayer note="79" file="yoga/RD01058A.WMF.svg"/> + <svglayer note="80" file="yoga/RD01059A.WMF.svg"/> + <svglayer note="81" file="yoga/RD01060A.WMF.svg"/> + <svglayer note="82" file="yoga/RD01061A.WMF.svg"/> + <svglayer note="83" file="yoga/RD01063A.WMF.svg"/> + <svglayer note="84" file="yoga/RD01064A.WMF.svg"/> + <svglayer note="85" file="yoga/RD01065A.WMF.svg"/> + <svglayer note="86" file="yoga/RD01066A.WMF.svg"/> + <svglayer note="87" file="yoga/RD01004A.WMF.svg"/> + <svglayer note="88" file="yoga/RD01005A.WMF.svg"/> + <svglayer note="89" file="yoga/RD01006A.WMF.svg"/> + <svglayer note="90" file="yoga/RD01007A.WMF.svg"/> + <svglayer note="91" file="yoga/RD01008A.WMF.svg"/> + <svglayer note="92" file="yoga/RD01009A.WMF.svg"/> + <svglayer note="93" file="yoga/RD01010A.WMF.svg"/> + <svglayer note="94" file="yoga/RD01011A.WMF.svg"/> + <svglayer note="95" file="yoga/RD01012A.WMF.svg"/> + <svglayer note="96" file="yoga/RD01013A.WMF.svg"/> + <svglayer note="97" file="yoga/RD01014A.WMF.svg"/> + <svglayer note="98" file="yoga/RD01015A.WMF.svg"/> + <svglayer note="99" file="yoga/RD01016A.WMF.svg"/> + <svglayer note="100" file="yoga/RD01017A.WMF.svg"/> +</playlist> diff --git a/liveengine/liveengine.cbp b/liveengine/liveengine.cbp index d657653..de55eca 100644 --- a/liveengine/liveengine.cbp +++ b/liveengine/liveengine.cbp @@ -64,6 +64,8 @@ <Unit filename="src/testApp.h"> <Option virtualFolder="src/" /> </Unit> + <Unit filename="src/viewport.cpp" /> + <Unit filename="src/viewport.h" /> <Extensions> <code_completion /> <envvars /> diff --git a/liveengine/liveengine.layout b/liveengine/liveengine.layout index 82581a6..c4d9071 100644 --- a/liveengine/liveengine.layout +++ b/liveengine/liveengine.layout @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <CodeBlocks_layout_file> - <ActiveTarget name="Release" /> + <ActiveTarget name="Debug" /> <File name="Makefile" open="1" top="0" tabpos="3"> <Cursor position="0" topLine="36" /> </File> @@ -17,18 +17,27 @@ <Cursor position="192" topLine="0" /> </File> <File name="src/layers.cpp" open="1" top="0" tabpos="2"> - <Cursor position="646" topLine="0" /> + <Cursor position="2259" topLine="58" /> </File> <File name="src/layers.h" open="1" top="0" tabpos="1"> - <Cursor position="42" topLine="0" /> + <Cursor position="995" topLine="10" /> </File> <File name="src/main.cpp" open="1" top="0" tabpos="5"> <Cursor position="42" topLine="0" /> </File> + <File name="src/playlist.cpp" open="1" top="0" tabpos="7"> + <Cursor position="985" topLine="2" /> + </File> <File name="src/testApp.cpp" open="1" top="0" tabpos="6"> - <Cursor position="5432" topLine="150" /> + <Cursor position="1874" topLine="38" /> </File> <File name="src/testApp.h" open="1" top="1" tabpos="4"> - <Cursor position="2322" topLine="61" /> + <Cursor position="2322" topLine="59" /> + </File> + <File name="src/viewport.cpp" open="1" top="0" tabpos="9"> + <Cursor position="926" topLine="6" /> + </File> + <File name="src/viewport.h" open="1" top="0" tabpos="8"> + <Cursor position="272" topLine="0" /> </File> </CodeBlocks_layout_file> diff --git a/liveengine/src/layers.cpp b/liveengine/src/layers.cpp index ad251ea..e69023b 100755 --- a/liveengine/src/layers.cpp +++ b/liveengine/src/layers.cpp @@ -19,23 +19,23 @@ void svglayer::load(string _f){ } isLoaded= (svg.getNumPath()>0);
}
-void svglayer::getCentre() {
+void svglayer::getCentre(int cx,int cy) {
if (svg.getNumPath()>0) {
- xo=(ofGetWidth()-svg.getWidth())/2;
- yo=(ofGetHeight()-svg.getHeight())/2;
+ xo=(cx-svg.getWidth())/2;
+ yo=(cy-svg.getHeight())/2;
}
}
-void svglayer::draw(float a) {
- getCentre(); +void svglayer::draw(float a,int cx,int cy) {
+ getCentre(cx,cy); for (int i=0;i<svg.getNumPath();i++) { svg.getPathAt(i).setFillColor(fills[i]*a); svg.getPathAt(i).draw(xo,yo); }
} -void svglayer::draw(float a,unsigned char* controllers,bool transparentBlack) {
- getCentre(); +void svglayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack) {
+ getCentre(cx,cy); //draw layers tinted by controllers
for (int i=0;i<svg.getNumPath();i++) { float h=fills[i].getHue(); @@ -77,14 +77,14 @@ WTF is going on with the image drawing */
-void imglayer::draw(float a) { +void imglayer::draw(float a,int cx,int cy) { //if (img.isAllocated()) if (!img.isUsingTexture()) img.setUseTexture(true); //has to be done from the main thread? still doesn't work
img.draw(0,0,ofGetWidth(),ofGetHeight()); printf("drawing %f\n",ofGetElapsedTimef());
} -void imglayer::draw(float a,unsigned char* controllers) { - imglayer::draw(a);
+void imglayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack=false) { + imglayer::draw(a,cx,cy);
} diff --git a/liveengine/src/layers.h b/liveengine/src/layers.h index 6155626..3218264 100755 --- a/liveengine/src/layers.h +++ b/liveengine/src/layers.h @@ -10,12 +10,13 @@ class layer layer(string _f) {load(_f);};
virtual ~layer(){};
virtual void load(string _f){};
- virtual void draw(float a){}; - virtual void draw(float a,unsigned char* controllers,bool transparentBlack=false){ draw(a);}; + virtual void draw(float a,int cx,int cy){}; + virtual void draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack=false){ draw(a,cx,cy);}; bool getLoaded() {return isLoaded;};
protected: - bool isLoaded;
+ bool isLoaded;
private:
+
};
class svglayer: public layer
@@ -25,9 +26,9 @@ class svglayer: public layer svglayer(string _f);
virtual ~svglayer();
void load(string _f);
- void draw(float a); - void draw(float a,unsigned char* controllers,bool transparentBlack=false);
- void getCentre();
+ void draw(float a,int cx,int cy); + void draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack=false);
+ void getCentre(int cx,int cy);
protected:
private:
ofxSVGTiny svg; @@ -43,8 +44,8 @@ class imglayer: public layer imglayer(string _f);
virtual ~imglayer();
void load(string _f);
- void draw(float a); - void draw(float a,unsigned char* controllers);
+ void draw(float a,int cx,int cy); + void draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack);
protected:
private:
ofImage img;
diff --git a/liveengine/src/playlist.cpp b/liveengine/src/playlist.cpp index af44940..af44940 100644..100755 --- a/liveengine/src/playlist.cpp +++ b/liveengine/src/playlist.cpp diff --git a/liveengine/src/testApp.cpp b/liveengine/src/testApp.cpp index fc0adf4..07c34e4 100755 --- a/liveengine/src/testApp.cpp +++ b/liveengine/src/testApp.cpp @@ -7,16 +7,9 @@ void previewWindow::setBuffer(ofFbo *buffer){ rb=buffer; } void previewWindow::draw(){ - float offset=(ofGetWidth()-ofGetHeight())/2; - ofPushMatrix(); - - ofTranslate(ofGetWidth()/2,ofGetHeight()/2); - ofRotate(90); - ofTranslate(-ofGetWidth()/2,-ofGetHeight()/2); + rb->draw(0,0,ofGetWidth(),ofGetHeight()); - rb->draw(offset,-offset,ofGetHeight(),ofGetWidth()); - ofPopMatrix(); } //-------------------------------------------------------------- void testApp::setup(){
@@ -51,12 +44,10 @@ void testApp::setup(){ debug=false; noteRandomiseColours=false; transparentBlack=false; - - //ofGetWidth(), ofGetHeight(),GL_RGB); // - rb1.allocate(1024,768,GL_RGB); - rb2.allocate(1024,768,GL_RGB); - rb3.allocate(1024,768,GL_RGB); - rb4.allocate(1024,768,GL_RGB); + reversemain=false; + + vp1.setup(768,1024,1024,0,-90,-256,-384); + vp2.setup(1024,768,0,0,0,-512,-384); showFPS=false;
ofBackground(0,0,0); @@ -84,17 +75,18 @@ void testApp::setup(){ ofSetFrameRate(60); rotate=-90; scale=1.0f; + fscale=1.0f; //window stuff - ofxFenster* win=ofxFensterManager::get()->createFenster(0, 0, ofGetHeight()/2, ofGetWidth()/2, OF_WINDOW); + ofxFenster* win=ofxFensterManager::get()->createFenster(0, 0, 600, 800, OF_WINDOW); ofAddListener(win->events.mouseDragged, this, &testApp::mousePressedEvent); ofAddListener(win->events.mousePressed, this, &testApp::mousePressedEvent); ofAddListener(win->events.keyPressed, this, &testApp::keyPressedEvent); win->setWindowTitle("preview"); win->addListener(&prevWin); prevWin.setup(); - prevWin.setBuffer(&rb2); + prevWin.setBuffer(&vp1.rb2); fullscreenoutput=false; @@ -112,25 +104,34 @@ void testApp::update(){ //-------------------------------------------------------------- void testApp::draw(){ - float lamda=max(0.0f,1.0f-((ofGetElapsedTimef()-lastnoteTime)/decayTime));
+ float lambda=max(0.0f,1.0f-((ofGetElapsedTimef()-lastnoteTime)/decayTime)); + + ofSetColor(255-fadetime,255-fadetime,255-fadetime); //for feedback
+ vp1.draw(lambda,controllers,xshift,yshift,list,transparentBlack,note,mode,controller_colours,controlColours,scale,fscale); + vp2.draw(lambda,controllers,reversemain?-xshift:xshift,yshift,list,transparentBlack,note,mode,controller_colours,controlColours,reversemain?1.0f/scale:scale,reversemain?1.0f/fscale:fscale); + + ofSetColor(255,255,255); + if (showFPS) ofDrawBitmapString(ofToString(ofGetFrameRate(), 2),20,20); + + /* rb1.begin(); - /* can this work? - grab.setAnchorPoint(xshift,yshift); - grab.setTextureWrap( GL_WRAP_BORDER, GL_WRAP_BORDER); - grab.draw(0,0); // xshift,yshift); - */ + // can this work? + //grab.setAnchorPoint(xshift,yshift); + //grab.setTextureWrap( GL_WRAP_BORDER, GL_WRAP_BORDER); + //grab.draw(0,0); // xshift,yshift); + ofSetColor(255-fadetime,255-fadetime,255-fadetime); - for (int i=(xshift>0?xshift-ofGetWidth():xshift);i<ofGetWidth()*2;i+=ofGetWidth()) { - for (int j=(yshift>0?yshift-ofGetHeight():yshift);j<ofGetHeight()*2;j+=ofGetHeight()) { + for (int i=(xshift>0?xshift-rb1.getWidth():xshift);i<rb1.getWidth()*2;i+=ofGetWidth()) { + for (int j=(yshift>0?yshift-rb1.getHeight():yshift);j<rb1.getHeight()*2;j+=rb1.getHeight()) { rb2.draw(i,j); } } - float notewidth=ofGetWidth()/NUM_NOTES; - float noteheight=ofGetHeight()/NUM_CONTROLLERS; + float notewidth=rb1.getWidth()/NUM_NOTES; + float noteheight=rb1.getHeight()/NUM_CONTROLLERS; @@ -145,13 +146,13 @@ void testApp::draw(){ case LIST: if (list.lock()) { //if playlist is loaded
ofPushMatrix(); - ofTranslate(ofGetWidth()/2,ofGetHeight()/2);
+ ofTranslate(rb1.getWidth()/2,rb1.getHeight()/2); ofScale(scale,scale,scale); ofRotate(rotate); - ofTranslate(-ofGetWidth()/2,-ofGetHeight()/2);
+ ofTranslate(-rb1.getWidth()/2,-rb1.getHeight()/2);
if (list.layers.find(note)!=list.layers.end()) { - if (controlColours) list.layers[note]->draw(lamda,controllers,transparentBlack); - else list.layers[note]->draw(lamda); + if (controlColours) list.layers[note]->draw(lamda,controllers,512,384,transparentBlack); + else list.layers[note]->draw(lamda,512,384); }
ofPopMatrix(); list.unlock(); @@ -176,24 +177,21 @@ void testApp::draw(){ rb3.begin(); //landscape - /* can this work? - grab.setAnchorPoint(xshift,yshift); - grab.setTextureWrap( GL_WRAP_BORDER, GL_WRAP_BORDER); - grab.draw(0,0); // xshift,yshift); - */ + ofSetColor(255-fadetime,255-fadetime,255-fadetime); - for (int i=(yshift>0?yshift-ofGetWidth():yshift);i<ofGetWidth()*2;i+=ofGetWidth()) { - for (int j=(xshift>0?xshift-ofGetHeight():xshift);j<ofGetHeight()*2;j+=ofGetHeight()) { + for (int i=(xshift>0?xshift-rb3.getWidth():xshift);i<rb3.getWidth()*2;i+=ofGetWidth()) { + for (int j=(yshift>0?yshift-rb3.getHeight():yshift);j<rb3.getHeight()*2;j+=rb3.getHeight()) { rb4.draw(i,j); } } - notewidth=ofGetHeight()/NUM_NOTES; - noteheight=ofGetWidth()/NUM_CONTROLLERS; + notewidth=rb3.getHeight()/NUM_NOTES; + noteheight=rb3.getWidth()/NUM_CONTROLLERS; ofPushMatrix(); - ofTranslate(ofGetWidth()/2,ofGetHeight()/2); - ofRotate(-90); + ofTranslate(rb3.getWidth(),rb3.getHeight()/2); + ofRotate(90); + ofTranslate(-rb3.getWidth()/2,-rb3.getHeight()/2); if (note>0) { switch(mode) { @@ -206,13 +204,13 @@ void testApp::draw(){ case LIST: if (list.lock()) { //if playlist is loaded ofPushMatrix(); - ofTranslate(ofGetWidth()/2,ofGetHeight()/2); + ofTranslate(rb3.getWidth()/2,rb3.getHeight()/2); ofScale(scale,scale,scale); ofRotate(rotate); - ofTranslate(-ofGetWidth()/2,-ofGetHeight()/2); + ofTranslate(-rb3.getWidth()/2,-rb3.getHeight()/2); if (list.layers.find(note)!=list.layers.end()) { - if (controlColours) list.layers[note]->draw(lamda,controllers,transparentBlack); - else list.layers[note]->draw(lamda); + if (controlColours) list.layers[note]->draw(lamda,controllers,512,384,transparentBlack); + else list.layers[note]->draw(lamda,512,384); } ofPopMatrix(); list.unlock(); @@ -236,6 +234,8 @@ void testApp::draw(){ rb4.draw(0,0); + */ + /* test screen shape ofSetColor(255,0,0); ofRect(0,0,1024,768); @@ -303,6 +303,9 @@ void testApp::keyPressed(int key){ if(key == 'p'){
list.load("dancing.xml");
} + if(key == 'P'){ + list.load("trainers.xml"); + } if(key == 's'){ XML.saveFile("settings.xml"); printf("settings saved!\n"); @@ -363,6 +366,17 @@ void testApp::keyPressed(int key){ transparentBlack=!transparentBlack; printf("%s transparent black\n",transparentBlack?"use":"don't use"); } + if (key=='j') { + fscale=1.0f; + } + if (key=='h') { + scale=1.0f; + } + if (key=='h') { + reversemain=!reversemain; + printf("%s main screen\n",reversemain?"reversing":"not reversing"); + } + } //-------------------------------------------------------------- @@ -404,12 +418,18 @@ void testApp::dragEvent(ofDragInfo dragInfo){ } void testApp::mousePressedEvent(ofMouseEventArgs &args) { - //printf("mouse: %i,%i %i\n",args.x,args.y,args.button); + //printf("mouse: %i,%i %i of %ix%i\n",args.x,args.y,args.button,ofGetWidth(),ofGetHeight()); //0-2 switch (args.button) { case 0: - yshift=(ofGetWidth()/2)-args.x; - xshift=args.y-(ofGetHeight()/2); + xshift=args.x-(ofGetWidth()/2); + yshift=args.y-(ofGetHeight()/2); + break; + case 1: + scale=pow(pow(args.x-(ofGetWidth()/2),2)+pow(args.y-(ofGetHeight()/2),2),0.5)/(ofGetWidth()*.1); + break; + case 2: + fscale=(pow(pow(args.x-(ofGetWidth()/2),2)+pow(args.y-(ofGetHeight()/2),2),0.5)/(ofGetWidth()))+0.5; break; } } diff --git a/liveengine/src/testApp.h b/liveengine/src/testApp.h index 5e050da..27380af 100755 --- a/liveengine/src/testApp.h +++ b/liveengine/src/testApp.h @@ -69,19 +69,12 @@ option to randomise colours on each note #define OF_ADDON_USING_OFXMIDIIN -#define NUM_NOTES 64 -#define START_NOTE 36 -#define NUM_CONTROLLERS 6 -#define START_CONTROLLER 102 #include "ofxMidi.h" #include "ofxFensterManager.h" -#define NOTHING 0 -#define BLOCKS 1 -#define LIST 2 -#include "playlist.h" +#include "viewport.h" class previewWindow: public ofxFensterListener{ public: @@ -132,6 +125,8 @@ class testApp : public ofxFensterListener, public ofxMidiListener{ bool noteRandomiseColours; bool transparentBlack; + bool reversemain; + bool fullscreenoutput; float lastnoteTime; @@ -139,13 +134,13 @@ class testApp : public ofxFensterListener, public ofxMidiListener{ int fadetime; int rotate; - float scale; + float scale,fscale; int xshift,yshift; ofColor* controller_colours; - ofFbo rb1,rb2,rb3,rb4; //2 buffers * 2 outputs + viewport vp1,vp2; previewWindow prevWin; diff --git a/liveengine/src/viewport.cpp b/liveengine/src/viewport.cpp new file mode 100755 index 0000000..74333b0 --- /dev/null +++ b/liveengine/src/viewport.cpp @@ -0,0 +1,107 @@ +#include "viewport.h"
+
+
+
+viewport::viewport()
+{
+ //ctor
+}
+
+void viewport::setup(int _w,int _h,int _x,int _y,float _r,int _ox,int _oy) {
+ r=_r;
+ w=_w;
+ h=_h;
+ x=_x;
+ y=_y;
+ ox=_ox;
+ oy=_oy;
+ rb1.allocate(w,h,GL_RGB);
+ rb2.allocate(w,h,GL_RGB);
+
+ printf("%ix%i, vp offset: %f,%f\n",w,h,-(sin(ofDegToRad(r))*h/2)-(cos(ofDegToRad(r))*w/2),-(sin(ofDegToRad(r))*w/2)-(cos(ofDegToRad(r))*h/2));
+}
+
+void viewport::draw(float a,unsigned char* controllers,int xshift,int yshift,playlist &list,bool transparentBlack,int note,int mode,ofColor* controller_colours,bool controlColours,float scale,float fscale){
+
+
+
+ // test screen shape
+ /*
+ ofSetColor(255,0,0);
+ ofRect(0,0,w/2,h/2);
+ ofRect(w/2,h/2,w/2,h/2);
+ ofSetColor(0,255,0);
+ ofRect(0,h/2,w/2,h/2);
+ ofRect(w/2,0,w/2,h/2);
+ */
+
+ rb1.begin();
+
+ //can be done with texture offset?
+
+ int startx=((w-(w*fscale))/2)+xshift;
+ while (startx>0) startx-=(w*fscale);
+ int starty=((h-(h*fscale))/2)+yshift;
+ while (starty>0) starty-=(h*fscale);
+
+ for (int i=startx;i<w*2;i+=(w*fscale)) {
+ for (int j=starty;j<h*2;j+=(h*fscale)) {
+ rb2.draw(i,j,w*fscale,h*fscale);
+ }
+ }
+
+ float notewidth=w/NUM_NOTES;
+ float noteheight=h/NUM_CONTROLLERS;
+
+ ofPushStyle();
+
+ if (note>0) {
+ switch(mode) {
+ case BLOCKS:
+ for (int i=0;i<NUM_CONTROLLERS;i++){
+ ofSetColor(ofColor((controller_colours[i].r*controllers[i])>>7,(controller_colours[i].g*controllers[i])>>7,(controller_colours[i].b*controllers[i])>>7));
+ ofRect((note-START_NOTE)*notewidth,i*noteheight,notewidth,noteheight);
+ }
+ break;
+ case LIST:
+ if (list.lock()) { //if playlist is loaded
+ if (list.layers.find(note)!=list.layers.end()) {
+ ofPushMatrix();
+ ofTranslate(w/2,h/2);
+ ofScale(scale,scale,scale);
+ ofTranslate(-w/2,-h/2);
+ if (controlColours) list.layers[note]->draw(a,controllers,w,h,transparentBlack);
+ else list.layers[note]->draw(a,w,h);
+ ofPopMatrix();
+ }
+ list.unlock();
+ }
+ break;
+ }
+ }
+
+ rb1.end();
+
+ rb2.begin();
+ ofSetColor(255,255,255);
+ rb1.draw(0,0);
+ rb2.end();
+
+ ofPushMatrix();
+ ofTranslate(x+(w/2),y+(h/2));
+ ofRotate(r);
+ //ofTranslate(-abs(sin(ofDegToRad(r))*h/2)-abs(cos(ofDegToRad(r))*w/2),-abs(sin(ofDegToRad(r))*w/2)-abs(cos(ofDegToRad(r))*h/2));
+ ofTranslate(ox,oy);
+
+ rb2.draw(0,0);
+
+ ofPopStyle();
+
+ ofPopMatrix();
+
+}
+
+viewport::~viewport()
+{
+ //dtor
+}
diff --git a/liveengine/src/viewport.h b/liveengine/src/viewport.h new file mode 100755 index 0000000..5d990a0 --- /dev/null +++ b/liveengine/src/viewport.h @@ -0,0 +1,33 @@ +#ifndef VIEWPORT_H
+#define VIEWPORT_H
+
+#include "ofMain.h"
+#include "playlist.h"
+
+#define NUM_NOTES 64
+#define START_NOTE 36
+#define NUM_CONTROLLERS 6
+#define START_CONTROLLER 102
+
+#define NOTHING 0
+#define BLOCKS 1
+#define LIST 2
+
+
+
+class viewport
+{
+ public:
+ viewport();
+ void setup(int w,int h,int x, int y,float r,int _ox,int _oy);
+ void draw(float a,unsigned char* controllers,int xshift,int yshift,playlist &list,bool transparentBlack,int note,int mode,ofColor* controller_colours,bool controlColours,float scale,float fscale);
+ virtual ~viewport();
+ ofFbo rb1,rb2;
+ float r;
+ protected:
+ private:
+ int x, y,w,h,ox,oy;
+
+};
+
+#endif // VIEWPORT_H
|
