From 4fda3af17e55c0afff35b3f3ebbe5b4fd1ffad7e Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Fri, 14 Sep 2012 19:24:39 +0100 Subject: working nicely multiscreen --- liveengine/bin/data/american_football.xml | 68 +++++++++++++ liveengine/bin/data/birds.xml | 67 +++++++++++++ liveengine/bin/data/crests.xml | 68 +++++++++++++ liveengine/bin/data/cricket.xml | 68 +++++++++++++ liveengine/bin/data/dancing.xml | 118 ++++++++++++---------- liveengine/bin/data/makeplaylist.py | 28 ++++++ liveengine/bin/data/military_ethnic.xml | 68 +++++++++++++ liveengine/bin/data/military_ladies.xml | 51 ---------- liveengine/bin/data/miltary_ladies.xml | 68 +++++++++++++ liveengine/bin/data/organs.xml | 132 +++++++++++++------------ liveengine/bin/data/teamsports.xml | 68 +++++++++++++ liveengine/bin/data/test.svg | 76 --------------- liveengine/liveengine.layout | 8 +- liveengine/src/layers.cpp | 31 +++--- liveengine/src/layers.h | 5 +- liveengine/src/main.cpp | 2 +- liveengine/src/testApp.cpp | 157 +++++++++++++++++++++++++----- liveengine/src/testApp.h | 17 +++- 18 files changed, 813 insertions(+), 287 deletions(-) create mode 100644 liveengine/bin/data/american_football.xml create mode 100644 liveengine/bin/data/birds.xml create mode 100644 liveengine/bin/data/crests.xml create mode 100644 liveengine/bin/data/cricket.xml create mode 100755 liveengine/bin/data/makeplaylist.py create mode 100644 liveengine/bin/data/military_ethnic.xml delete mode 100644 liveengine/bin/data/military_ladies.xml create mode 100644 liveengine/bin/data/miltary_ladies.xml create mode 100644 liveengine/bin/data/teamsports.xml delete mode 100644 liveengine/bin/data/test.svg mode change 100644 => 100755 liveengine/src/layers.cpp mode change 100644 => 100755 liveengine/src/layers.h diff --git a/liveengine/bin/data/american_football.xml b/liveengine/bin/data/american_football.xml new file mode 100644 index 0000000..16b5588 --- /dev/null +++ b/liveengine/bin/data/american_football.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/liveengine/bin/data/birds.xml b/liveengine/bin/data/birds.xml new file mode 100644 index 0000000..9326acf --- /dev/null +++ b/liveengine/bin/data/birds.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/liveengine/bin/data/crests.xml b/liveengine/bin/data/crests.xml new file mode 100644 index 0000000..011936b --- /dev/null +++ b/liveengine/bin/data/crests.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/liveengine/bin/data/cricket.xml b/liveengine/bin/data/cricket.xml new file mode 100644 index 0000000..ff7925a --- /dev/null +++ b/liveengine/bin/data/cricket.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/liveengine/bin/data/dancing.xml b/liveengine/bin/data/dancing.xml index a9e7b7e..0106af8 100644 --- a/liveengine/bin/data/dancing.xml +++ b/liveengine/bin/data/dancing.xml @@ -1,50 +1,68 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/liveengine/bin/data/makeplaylist.py b/liveengine/bin/data/makeplaylist.py new file mode 100755 index 0000000..92ff865 --- /dev/null +++ b/liveengine/bin/data/makeplaylist.py @@ -0,0 +1,28 @@ +#!/usr/bin/python + +from lxml import etree +import sys,os + +if len(sys.argv)<2: + print "usage: makeplaylist source_directory" + sys.exit(0) + +sourcedir=sys.argv[1] + +page = etree.Element('playlist') +doc = etree.ElementTree(page) + +dirList=sorted(os.listdir(sourcedir)) +note = 36 +while note<100: + for fname in dirList: + pageElement = etree.SubElement(page, 'svglayer', + note=str(note), + file=sourcedir+"/"+fname) + note +=1 + if note>100: + break + +file= open(sourcedir+".xml", "w") +doc.write(file, xml_declaration=True, encoding='utf-8',pretty_print=True) +file.close() \ No newline at end of file diff --git a/liveengine/bin/data/military_ethnic.xml b/liveengine/bin/data/military_ethnic.xml new file mode 100644 index 0000000..babad30 --- /dev/null +++ b/liveengine/bin/data/military_ethnic.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/liveengine/bin/data/military_ladies.xml b/liveengine/bin/data/military_ladies.xml deleted file mode 100644 index f61bece..0000000 --- a/liveengine/bin/data/military_ladies.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/liveengine/bin/data/miltary_ladies.xml b/liveengine/bin/data/miltary_ladies.xml new file mode 100644 index 0000000..4cabbd4 --- /dev/null +++ b/liveengine/bin/data/miltary_ladies.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/liveengine/bin/data/organs.xml b/liveengine/bin/data/organs.xml index 59b5d15..dba72d4 100644 --- a/liveengine/bin/data/organs.xml +++ b/liveengine/bin/data/organs.xml @@ -1,64 +1,68 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/liveengine/bin/data/teamsports.xml b/liveengine/bin/data/teamsports.xml new file mode 100644 index 0000000..3c7ff16 --- /dev/null +++ b/liveengine/bin/data/teamsports.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/liveengine/bin/data/test.svg b/liveengine/bin/data/test.svg deleted file mode 100644 index 8869411..0000000 --- a/liveengine/bin/data/test.svg +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - - - diff --git a/liveengine/liveengine.layout b/liveengine/liveengine.layout index 6376d3e..82581a6 100644 --- a/liveengine/liveengine.layout +++ b/liveengine/liveengine.layout @@ -22,13 +22,13 @@ - + - - + + - + diff --git a/liveengine/src/layers.cpp b/liveengine/src/layers.cpp old mode 100644 new mode 100755 index 6ab91ca..ad251ea --- a/liveengine/src/layers.cpp +++ b/liveengine/src/layers.cpp @@ -17,33 +17,42 @@ void svglayer::load(string _f){ strokes.push_back(svg.getPathAt(i).getStrokeColor()); printf(" path %i: fill %08x stroke %08x\n",i,svg.getPathAt(i).getFillColor().getHex(),svg.getPathAt(i).getStrokeColor().getHex()); } - if (svg.getNumPath()>0) { - xo=(ofGetWidth()-svg.getWidth())/2; - yo=(ofGetHeight()-svg.getHeight())/2; - } isLoaded= (svg.getNumPath()>0); } +void svglayer::getCentre() { + if (svg.getNumPath()>0) { + xo=(ofGetWidth()-svg.getWidth())/2; + yo=(ofGetHeight()-svg.getHeight())/2; + } +} void svglayer::draw(float a) { - //svg.draw(); + getCentre(); for (int i=0;i0.1) { + svg.getPathAt(i).draw(xo,yo); + } } -} +} + svglayer::~svglayer() { diff --git a/liveengine/src/layers.h b/liveengine/src/layers.h old mode 100644 new mode 100755 index ae17989..6155626 --- a/liveengine/src/layers.h +++ b/liveengine/src/layers.h @@ -11,7 +11,7 @@ class layer virtual ~layer(){}; virtual void load(string _f){}; virtual void draw(float a){}; - virtual void draw(float a,unsigned char* controllers){ draw(a);}; + virtual void draw(float a,unsigned char* controllers,bool transparentBlack=false){ draw(a);}; bool getLoaded() {return isLoaded;}; protected: bool isLoaded; @@ -26,7 +26,8 @@ class svglayer: public layer virtual ~svglayer(); void load(string _f); void draw(float a); - void draw(float a,unsigned char* controllers); + void draw(float a,unsigned char* controllers,bool transparentBlack=false); + void getCentre(); protected: private: ofxSVGTiny svg; diff --git a/liveengine/src/main.cpp b/liveengine/src/main.cpp index 28ab04b..dadd89f 100755 --- a/liveengine/src/main.cpp +++ b/liveengine/src/main.cpp @@ -7,7 +7,7 @@ int main( ){ ofAppGlutWindow window; - ofSetupOpenGL(ofxFensterManager::get(),1024,768, OF_WINDOW); + ofSetupOpenGL(ofxFensterManager::get(),2048,768, OF_WINDOW); //ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context //ofSetupOpenGL(&window, 1024,768, OF_WINDOW); diff --git a/liveengine/src/testApp.cpp b/liveengine/src/testApp.cpp index 5e5a140..fc0adf4 100755 --- a/liveengine/src/testApp.cpp +++ b/liveengine/src/testApp.cpp @@ -10,11 +10,11 @@ void previewWindow::draw(){ float offset=(ofGetWidth()-ofGetHeight())/2; ofPushMatrix(); - + ofTranslate(ofGetWidth()/2,ofGetHeight()/2); ofRotate(90); ofTranslate(-ofGetWidth()/2,-ofGetHeight()/2); - + rb->draw(offset,-offset,ofGetHeight(),ofGetWidth()); ofPopMatrix(); } @@ -50,10 +50,13 @@ void testApp::setup(){ controlColours=false; 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); showFPS=false; ofBackground(0,0,0); @@ -68,7 +71,7 @@ void testApp::setup(){ mode=BLOCKS; lastnoteTime=ofGetElapsedTimef(); - decayTime=2.0f; + decayTime=1.0f; //ofSetVerticalSync(true); deosn't seem effective //glXSwapIntervalSGI(1); @@ -85,14 +88,16 @@ void testApp::setup(){ //window stuff ofxFenster* win=ofxFensterManager::get()->createFenster(0, 0, ofGetHeight()/2, ofGetWidth()/2, OF_WINDOW); - ofAddListener(win->events.mouseMoved, this, &testApp::mouseMovedEvent); + 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); - + fullscreenoutput=false; + } void testApp::makeColours() { @@ -105,10 +110,12 @@ void testApp::update(){ } //-------------------------------------------------------------- -void testApp::draw(){ +void testApp::draw(){ + + float lamda=max(0.0f,1.0f-((ofGetElapsedTimef()-lastnoteTime)/decayTime)); rb1.begin(); - + /* can this work? grab.setAnchorPoint(xshift,yshift); @@ -121,11 +128,11 @@ void testApp::draw(){ rb2.draw(i,j); } } - + float notewidth=ofGetWidth()/NUM_NOTES; float noteheight=ofGetHeight()/NUM_CONTROLLERS; - float lamda=max(0.0f,1.0f-((ofGetElapsedTimef()-lastnoteTime)/decayTime)); + if (note>0) { switch(mode) { @@ -143,7 +150,7 @@ void testApp::draw(){ ofRotate(rotate); ofTranslate(-ofGetWidth()/2,-ofGetHeight()/2); if (list.layers.find(note)!=list.layers.end()) { - if (controlColours) list.layers[note]->draw(lamda,controllers); + if (controlColours) list.layers[note]->draw(lamda,controllers,transparentBlack); else list.layers[note]->draw(lamda); } ofPopMatrix(); @@ -156,23 +163,94 @@ void testApp::draw(){ //for (int i=0;idraw(); ofSetColor(255,255,255); if (showFPS) ofDrawBitmapString(ofToString(ofGetFrameRate(), 2),20,20); - + rb1.end(); - + rb2.begin(); ofSetColor(255,255,255); rb1.draw(0,0); rb2.end(); + + rb2.draw(1024,0); + + 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);i0?xshift-ofGetHeight():xshift);j0) { + switch(mode) { + case BLOCKS: + for (int i=0;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 + ofPushMatrix(); + ofTranslate(ofGetWidth()/2,ofGetHeight()/2); + ofScale(scale,scale,scale); + ofRotate(rotate); + ofTranslate(-ofGetWidth()/2,-ofGetHeight()/2); + if (list.layers.find(note)!=list.layers.end()) { + if (controlColours) list.layers[note]->draw(lamda,controllers,transparentBlack); + else list.layers[note]->draw(lamda); + } + ofPopMatrix(); + list.unlock(); + } + break; + } + } - rb2.draw(0,0); - + ofPopMatrix(); + + //for (int i=0;idraw(); + ofSetColor(255,255,255); + if (showFPS) ofDrawBitmapString(ofToString(ofGetFrameRate(), 2),20,20); + + rb3.end(); + + rb4.begin(); + ofSetColor(255,255,255); + rb3.draw(0,0); + rb4.end(); + + rb4.draw(0,0); + + /* test screen shape + ofSetColor(255,0,0); + ofRect(0,0,1024,768); + ofSetColor(0,255,0); + ofRect(1024,0,1024,768); + */ } //-------------------------------------------------------------- void testApp::keyPressed(int key, ofxFenster* win){ if(key == ' '){ - win->toggleFullscreen(); + fullscreenoutput=!fullscreenoutput; + win->setFullscreen(fullscreenoutput); + printf("resolution: %ix%i %s\n",win->getWidth(),win->getHeight(),fullscreenoutput?"fullscreen":"windowed"); } else keyPressed(key); } @@ -180,20 +258,35 @@ void testApp::keyPressed(int key){ if(key == 'q'){ list.load("insects.xml"); } - if(key == 'w'){ - list.load("women_ethnic.xml"); + if(key == 'Q'){ + list.load("birds.xml"); + } + if(key == 'w'){ + list.load("teamsports.xml"); + } + if(key == 'W'){ + list.load("american_football.xml"); } if(key == 'e'){ list.load("organs.xml"); } + if(key == 'E'){ + list.load("crests.xml"); + } if(key == 'r'){ list.load("tai_chi.xml"); } + if(key == 'R'){ + list.load("cricket.xml"); + } if(key == 't'){ list.load("reptiles.xml"); } if(key == 'y'){ - list.load("military_ladies.xml"); + list.load("miltary_ladies.xml"); + } + if(key == 'Y'){ + list.load("women_ethnic.xml"); } if(key == 'u'){ list.load("knights.xml"); @@ -201,6 +294,9 @@ void testApp::keyPressed(int key){ if(key == 'i'){ list.load("mil_historic.xml"); } + if(key == 'I'){ + list.load("mil_ethnic.xml"); + } if(key == 'o'){ list.load("yoga.xml"); } @@ -233,7 +329,8 @@ void testApp::keyPressed(int key){ makeColours(); } if(key == '-'){ - controlColours=!controlColours; + controlColours=!controlColours; + printf("%s control colours\n",controlColours?"do":"don't"); } if(key == '+'){ fadetime=min(128,fadetime+1); @@ -253,13 +350,18 @@ void testApp::keyPressed(int key){ if(key == '{'){ rotate-=90; } - - + + if(key == 'd'){ debug=!debug; } - if(key == 'p'){ + if(key == 'l'){ noteRandomiseColours=!noteRandomiseColours; + printf("%s randomise colours\n",noteRandomiseColours?"do":"don't"); + } + if (key=='k') { + transparentBlack=!transparentBlack; + printf("%s transparent black\n",transparentBlack?"use":"don't use"); } } @@ -301,8 +403,15 @@ void testApp::dragEvent(ofDragInfo dragInfo){ } -void testApp::mouseMovedEvent(ofMouseEventArgs &args) { - //cout << "MOUSE WAS MOVED" << endl; +void testApp::mousePressedEvent(ofMouseEventArgs &args) { + //printf("mouse: %i,%i %i\n",args.x,args.y,args.button); + //0-2 + switch (args.button) { + case 0: + yshift=(ofGetWidth()/2)-args.x; + xshift=args.y-(ofGetHeight()/2); + break; + } } void testApp::keyPressedEvent(ofKeyEventArgs &args) { diff --git a/liveengine/src/testApp.h b/liveengine/src/testApp.h index a556038..5e050da 100755 --- a/liveengine/src/testApp.h +++ b/liveengine/src/testApp.h @@ -58,6 +58,10 @@ non random colours option to randomise colours on each note +--make transparent + +--interface for exploring and saving - swapping? + */ @@ -85,7 +89,7 @@ public: ofFbo *rb; void setup(); void setBuffer(ofFbo *buffer); - void draw(); + void draw(); }; //#define GRAB_TEXTURE @@ -109,8 +113,8 @@ class testApp : public ofxFensterListener, public ofxMidiListener{ void dragEvent(ofDragInfo dragInfo); void gotMessage(ofMessage msg); - void mouseMovedEvent(ofMouseEventArgs &args); - void keyPressedEvent(ofKeyEventArgs &args); + void mousePressedEvent(ofMouseEventArgs &args); + void keyPressedEvent(ofKeyEventArgs &args); void makeColours(); @@ -122,8 +126,13 @@ class testApp : public ofxFensterListener, public ofxMidiListener{ unsigned char* controllers; int note, mode; + //to be moved into svg object gui + bool debug, controlColours; bool noteRandomiseColours; + bool transparentBlack; + + bool fullscreenoutput; float lastnoteTime; float decayTime; @@ -136,7 +145,7 @@ class testApp : public ofxFensterListener, public ofxMidiListener{ ofColor* controller_colours; - ofFbo rb1,rb2; + ofFbo rb1,rb2,rb3,rb4; //2 buffers * 2 outputs previewWindow prevWin; -- cgit v1.2.3