summaryrefslogtreecommitdiff
path: root/liveengine/src
diff options
context:
space:
mode:
Diffstat (limited to 'liveengine/src')
-rwxr-xr-xliveengine/src/layers.cpp25
-rwxr-xr-xliveengine/src/layers.h12
-rwxr-xr-xliveengine/src/testApp.cpp123
-rwxr-xr-xliveengine/src/testApp.h37
-rwxr-xr-xliveengine/src/viewport.cpp6
-rwxr-xr-xliveengine/src/viewport.h2
6 files changed, 138 insertions, 67 deletions
diff --git a/liveengine/src/layers.cpp b/liveengine/src/layers.cpp
index e69023b..6724255 100755
--- a/liveengine/src/layers.cpp
+++ b/liveengine/src/layers.cpp
@@ -11,11 +11,11 @@ svglayer::svglayer(string _f)
void svglayer::load(string _f){
//check if files exits
svg.load(_f);
- printf("%i paths\n",svg.getNumPath());
+ printf("%s: %i paths\n",_f.c_str(),svg.getNumPath());
for (int i=0;i<svg.getNumPath();i++) {
fills.push_back(svg.getPathAt(i).getFillColor());
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());
+ //printf(" path %i: fill %08x stroke %08x\n",i,svg.getPathAt(i).getFillColor().getHex(),svg.getPathAt(i).getStrokeColor().getHex());
}
isLoaded= (svg.getNumPath()>0);
}
@@ -26,19 +26,24 @@ void svglayer::getCentre(int cx,int cy) {
}
}
-void svglayer::draw(float a,int cx,int cy) {
+void svglayer::draw(float a,int cx,int cy,float colShift) {
getCentre(cx,cy);
- for (int i=0;i<svg.getNumPath();i++) {
- svg.getPathAt(i).setFillColor(fills[i]*a);
+ for (int i=0;i<svg.getNumPath();i++) {
+ ofColor c=fills[i]*a;
+ if (colShift>0.0f) {
+ c.setHue(fmod(c.getHue()+colShift,255.0f));
+ //printf ("shift from %f to %f\n",c.getHue(),c.getHue()+colShift);
+ }
+ svg.getPathAt(i).setFillColor(c);
svg.getPathAt(i).draw(xo,yo);
}
}
-void svglayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack) {
+void svglayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack,float colShift) {
getCentre(cx,cy);
//draw layers tinted by controllers
for (int i=0;i<svg.getNumPath();i++) {
- float h=fills[i].getHue();
+ float h=fmod(fills[i].getHue()+colShift,255.0f);
float ha=h/42.7; //0-5
int h1=(((int)ha)+2)%6;
int h2=h1+1;
@@ -77,14 +82,14 @@ WTF is going on with the image drawing
*/
-void imglayer::draw(float a,int cx,int cy) {
+void imglayer::draw(float a,int cx,int cy,float colShift) {
//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,int cx,int cy,bool transparentBlack=false) {
- imglayer::draw(a,cx,cy);
+void imglayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack=false,float colShift=0.0f) {
+ imglayer::draw(a,cx,cy,colShift);
}
diff --git a/liveengine/src/layers.h b/liveengine/src/layers.h
index 3218264..3a7883e 100755
--- a/liveengine/src/layers.h
+++ b/liveengine/src/layers.h
@@ -10,8 +10,8 @@ class layer
layer(string _f) {load(_f);};
virtual ~layer(){};
virtual void load(string _f){};
- 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);};
+ virtual void draw(float a,int cx,int cy,float colShift){};
+ virtual void draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack=false,float colShift=0.0f){ draw(a,cx,cy,colShift);};
bool getLoaded() {return isLoaded;};
protected:
bool isLoaded;
@@ -26,8 +26,8 @@ class svglayer: public layer
svglayer(string _f);
virtual ~svglayer();
void load(string _f);
- void draw(float a,int cx,int cy);
- void draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack=false);
+ void draw(float a,int cx,int cy,float colShift);
+ void draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack=false,float colShift=0.0f);
void getCentre(int cx,int cy);
protected:
private:
@@ -44,8 +44,8 @@ class imglayer: public layer
imglayer(string _f);
virtual ~imglayer();
void load(string _f);
- void draw(float a,int cx,int cy);
- void draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack);
+ void draw(float a,int cx,int cy,float colShift);
+ void draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack,float colShift);
protected:
private:
ofImage img;
diff --git a/liveengine/src/testApp.cpp b/liveengine/src/testApp.cpp
index 07c34e4..7053421 100755
--- a/liveengine/src/testApp.cpp
+++ b/liveengine/src/testApp.cpp
@@ -12,6 +12,19 @@ void previewWindow::draw(){
}
//--------------------------------------------------------------
+guiWindow::~guiWindow(){
+ cout << "gui window destroyed" << endl;
+}
+void guiWindow::setup(){}
+void guiWindow::setGui(ofxPanel *panel){
+ gui=panel;
+}
+void guiWindow::draw(){
+
+ gui->draw();
+
+}
+//--------------------------------------------------------------
void testApp::setup(){
int midiPort=0;
midiChannel=0;
@@ -39,13 +52,15 @@ void testApp::setup(){
note=0;
makeColours();
+
+ colShift=0;
controlColours=false;
debug=false;
noteRandomiseColours=false;
transparentBlack=false;
reversemain=false;
-
+
vp1.setup(768,1024,1024,0,-90,-256,-384);
vp2.setup(1024,768,0,0,0,-512,-384);
@@ -78,8 +93,8 @@ void testApp::setup(){
fscale=1.0f;
- //window stuff
- ofxFenster* win=ofxFensterManager::get()->createFenster(0, 0, 600, 800, OF_WINDOW);
+ //preview window stuff
+ 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);
@@ -89,12 +104,42 @@ void testApp::setup(){
prevWin.setBuffer(&vp1.rb2);
fullscreenoutput=false;
+
+ gui.setup("","panel.xml",0,0);
+ gui.add(reversemain.setup("reverse main", false));
+ gui.add(controlColours.setup("control colours", false));
+ gui.add(noteRandomiseColours.setup("randomise note colours", false));
+ gui.add(transparentBlack.setup("transparent black", false));
+ gui.add(resetDrawscale.setup("reset draw scale"));
+ gui.add(resetFBscale.setup("reset FB scale"));
+
+ resetDrawscale.addListener(this,&testApp::resetDrawscalePressed);
+ resetFBscale.addListener(this,&testApp::resetFBscalePressed);
+
+ //gui window stuff
+ ofxFenster* win2=ofxFensterManager::get()->createFenster(0, 0, 200, 400, OF_WINDOW);
+ //ofAddListener(win2->events.mouseDragged, this, &testApp::mousePressedEvent);
+ //ofAddListener(win2->events.mousePressed, this, &testApp::mousePressedEvent);
+ //ofAddListener(win2->events.keyPressed, this, &testApp::keyPressedEvent);
+ win2->setWindowTitle("config");
+ win2->addListener(&guiWin);
+ guiWin.setup();
+ guiWin.setGui(&gui);
+
}
+void testApp::resetDrawscalePressed(bool & pressed){
+ scale=1.0f;
+}
+void testApp::resetFBscalePressed(bool & pressed){
+ fscale=1.0f;
+}
+
void testApp::makeColours() {
controller_colours=new ofColor[NUM_CONTROLLERS];
for (int i=0;i<NUM_CONTROLLERS;i++) controller_colours[i]=ofColor::fromHsb(ofRandom(255), 255, 255);
+ colShift=ofRandom(255.0f);
}
//--------------------------------------------------------------
void testApp::update(){
@@ -103,14 +148,14 @@ void testApp::update(){
//--------------------------------------------------------------
void testApp::draw(){
-
+
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);
-
+ vp1.draw(lambda,controllers,xshift,yshift,list,transparentBlack,note,mode,controller_colours,controlColours,scale,fscale,noteRandomiseColours?colShift:0.0f);
+ 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,noteRandomiseColours?colShift:0.0f);
+
ofSetColor(255,255,255);
if (showFPS) ofDrawBitmapString(ofToString(ofGetFrameRate(), 2),20,20);
@@ -133,7 +178,7 @@ void testApp::draw(){
float notewidth=rb1.getWidth()/NUM_NOTES;
float noteheight=rb1.getHeight()/NUM_CONTROLLERS;
-
+
if (note>0) {
switch(mode) {
@@ -173,7 +218,7 @@ void testApp::draw(){
rb2.end();
rb2.draw(1024,0);
-
+
rb3.begin(); //landscape
@@ -187,7 +232,7 @@ void testApp::draw(){
notewidth=rb3.getHeight()/NUM_NOTES;
noteheight=rb3.getWidth()/NUM_CONTROLLERS;
-
+
ofPushMatrix();
ofTranslate(rb3.getWidth(),rb3.getHeight()/2);
ofRotate(90);
@@ -218,7 +263,7 @@ void testApp::draw(){
break;
}
}
-
+
ofPopMatrix();
//for (int i=0;i<numLayers;i++) layers[i]->draw();
@@ -233,9 +278,9 @@ void testApp::draw(){
rb4.end();
rb4.draw(0,0);
-
+
*/
-
+
/* test screen shape
ofSetColor(255,0,0);
ofRect(0,0,1024,768);
@@ -282,6 +327,9 @@ void testApp::keyPressed(int key){
if(key == 't'){
list.load("reptiles.xml");
}
+ if(key == 'T'){
+ list.load("tools.xml");
+ }
if(key == 'y'){
list.load("miltary_ladies.xml");
}
@@ -291,6 +339,9 @@ void testApp::keyPressed(int key){
if(key == 'u'){
list.load("knights.xml");
}
+ if(key == 'U'){
+ list.load("food.xml");
+ }
if(key == 'i'){
list.load("mil_historic.xml");
}
@@ -300,6 +351,9 @@ void testApp::keyPressed(int key){
if(key == 'o'){
list.load("yoga.xml");
}
+ if(key == 'O'){
+ list.load("computers.xml");
+ }
if(key == 'p'){
list.load("dancing.xml");
}
@@ -317,24 +371,20 @@ void testApp::keyPressed(int key){
mode=key-'0';
}
if(key == 267){
- yshift++;
+ xshift--;
}
if(key == 268){
- yshift--;
+ xshift++;
}
if(key == 269){
- xshift--;
+ yshift--;
}
if(key == 270){
- xshift++;
+ yshift++;
}
if(key == '='){
makeColours();
}
- if(key == '-'){
- controlColours=!controlColours;
- printf("%s control colours\n",controlColours?"do":"don't");
- }
if(key == '+'){
fadetime=min(128,fadetime+1);
}
@@ -358,25 +408,14 @@ void testApp::keyPressed(int key){
if(key == 'd'){
debug=!debug;
}
- 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");
- }
+
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");
- }
-
+
}
//--------------------------------------------------------------
@@ -418,18 +457,18 @@ void testApp::dragEvent(ofDragInfo dragInfo){
}
void testApp::mousePressedEvent(ofMouseEventArgs &args) {
- //printf("mouse: %i,%i %i of %ix%i\n",args.x,args.y,args.button,ofGetWidth(),ofGetHeight());
+ //printf("mouse: %i,%i %i of %ix%i\n",args.x,args.y,args.button,win->getWidth(),win->getHeight());
//0-2
switch (args.button) {
case 0:
- xshift=args.x-(ofGetWidth()/2);
- yshift=args.y-(ofGetHeight()/2);
+ xshift=args.x-(win->getWidth()/2);
+ yshift=args.y-(win->getHeight()/2);
break;
case 1:
- scale=pow(pow(args.x-(ofGetWidth()/2),2)+pow(args.y-(ofGetHeight()/2),2),0.5)/(ofGetWidth()*.1);
+ scale=pow(pow(args.x-(win->getWidth()/2),2)+pow(args.y-(win->getHeight()/2),2),0.5)/(win->getWidth()*.1);
break;
case 2:
- fscale=(pow(pow(args.x-(ofGetWidth()/2),2)+pow(args.y-(ofGetHeight()/2),2),0.5)/(ofGetWidth()))+0.5;
+ fscale=(pow(pow(args.x-(win->getWidth()/2),2)+pow(args.y-(win->getHeight()/2),2),0.5)/(win->getWidth()))+0.5;
break;
}
}
@@ -472,7 +511,9 @@ void testApp::newMidiMessage(ofxMidiEventArgs& eventArgs){
if (debug) printf("note: %i %i\n",eventArgs.byteOne,eventArgs.byteTwo);
note=eventArgs.byteOne;
lastnoteTime=ofGetElapsedTimef();
- if (noteRandomiseColours) makeColours();
+ if (noteRandomiseColours) {
+ makeColours(); //
+ }
break;
case 176: //control change channel 0
//for (int i=0;i<numLayers;i++){
diff --git a/liveengine/src/testApp.h b/liveengine/src/testApp.h
index 27380af..0da5eae 100755
--- a/liveengine/src/testApp.h
+++ b/liveengine/src/testApp.h
@@ -73,6 +73,8 @@ option to randomise colours on each note
#include "ofxMidi.h"
#include "ofxFensterManager.h"
+#include "ofxGui.h"
+
#include "viewport.h"
@@ -85,6 +87,16 @@ public:
void draw();
};
+class guiWindow: public ofxFensterListener{
+public:
+ ~guiWindow();
+ ofxPanel *gui;
+ void setup();
+ void setGui(ofxPanel *panel);
+ void draw();
+};
+
+
//#define GRAB_TEXTURE
class testApp : public ofxFensterListener, public ofxMidiListener{
@@ -121,11 +133,7 @@ class testApp : public ofxFensterListener, public ofxMidiListener{
//to be moved into svg object gui
- bool debug, controlColours;
- bool noteRandomiseColours;
- bool transparentBlack;
-
- bool reversemain;
+ bool debug;
bool fullscreenoutput;
@@ -139,11 +147,16 @@ class testApp : public ofxFensterListener, public ofxMidiListener{
int xshift,yshift;
ofColor* controller_colours;
+
+ float colShift;
viewport vp1,vp2;
previewWindow prevWin;
-
+ guiWindow guiWin;
+
+ ofxFenster* win;
+
int midiChannel;
ofxMidiIn midiIn;
@@ -151,6 +164,18 @@ class testApp : public ofxFensterListener, public ofxMidiListener{
void newMidiMessage(ofxMidiEventArgs& eventArgs);
playlist list;
+
+ ofxPanel gui;
+ ofxToggle reversemain;
+ ofxToggle controlColours;
+ ofxToggle noteRandomiseColours;
+ ofxToggle transparentBlack;
+ ofxButton resetDrawscale;
+ ofxButton resetFBscale;
+
+ void resetDrawscalePressed(bool & pressed);
+ void resetFBscalePressed(bool & pressed);
+
};
diff --git a/liveengine/src/viewport.cpp b/liveengine/src/viewport.cpp
index 74333b0..ce67b37 100755
--- a/liveengine/src/viewport.cpp
+++ b/liveengine/src/viewport.cpp
@@ -21,7 +21,7 @@ void viewport::setup(int _w,int _h,int _x,int _y,float _r,int _ox,int _oy) {
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){
+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,float colShift){
@@ -70,8 +70,8 @@ void viewport::draw(float a,unsigned char* controllers,int xshift,int yshift,pla
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);
+ if (controlColours) list.layers[note]->draw(a,controllers,w,h,transparentBlack,colShift);
+ else list.layers[note]->draw(a,w,h,colShift);
ofPopMatrix();
}
list.unlock();
diff --git a/liveengine/src/viewport.h b/liveengine/src/viewport.h
index 5d990a0..4f29a5b 100755
--- a/liveengine/src/viewport.h
+++ b/liveengine/src/viewport.h
@@ -20,7 +20,7 @@ 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);
+ 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,float colShift);
virtual ~viewport();
ofFbo rb1,rb2;
float r;