summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorTim Redfern <tim@getdrop.com>2017-08-31 23:16:52 +0100
committerTim Redfern <tim@getdrop.com>2017-08-31 23:16:52 +0100
commit14da9cce8d665d2872b76909e8abc001a9921297 (patch)
tree872a61f062f3353e664c080c9f63c7ead3f53899 /gui
parent4637492e2a31c78f9109941638171d05e4007c4c (diff)
additive no good
Diffstat (limited to 'gui')
-rw-r--r--gui/addons.make3
-rw-r--r--gui/src/chainImage.cpp38
-rw-r--r--gui/src/chainImage.h7
-rw-r--r--gui/src/ofApp.cpp101
-rw-r--r--gui/src/ofApp.h31
5 files changed, 159 insertions, 21 deletions
diff --git a/gui/addons.make b/gui/addons.make
index 12b7e26..22f4cad 100644
--- a/gui/addons.make
+++ b/gui/addons.make
@@ -1,2 +1,3 @@
ofxJSON
-ofxDMX \ No newline at end of file
+ofxDMX
+OfxMidi \ No newline at end of file
diff --git a/gui/src/chainImage.cpp b/gui/src/chainImage.cpp
index e2ee598..275b107 100644
--- a/gui/src/chainImage.cpp
+++ b/gui/src/chainImage.cpp
@@ -113,7 +113,7 @@ void chainImage::makeThumbnail(){
thumbnail.setAnchorPoint(thumbnail.getWidth()/2,thumbnail.getHeight()/2);
}
-void chainImage::drawChain(float fadeIn){
+void chainImage::drawChain(float fadeIn,bool additive, float intensity){
//printf("Drawing chain transition: %f\n",transition);
//we are correctly geting to 1
@@ -121,9 +121,20 @@ void chainImage::drawChain(float fadeIn){
glPushMatrix();
- ofDisableAlphaBlending();
+ if (additive){
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ ofSetColor(255,255,255,255*(1.0f-min(1.0,transition/fadeIn))*intensity);
+ }
+ else {
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ ofSetColor(255,255,255,255*intensity);
+ }
- ofSetColor(255,255,255,255);
+ //ofDisableAlphaBlending();
+
+
setAnchorPoint(getWidth()/2,getHeight()/2);
@@ -135,14 +146,18 @@ void chainImage::drawChain(float fadeIn){
glScalef(linkScale,linkScale,linkScale);
- ofEnableAlphaBlending();
+ //ofEnableAlphaBlending();
+ glEnable(GL_BLEND);
- ofSetColor(255,255,255,255*min(1.0,transition/fadeIn));
+ ofSetColor(255,255,255,255*min(1.0,transition/fadeIn)*intensity);
link->setAnchorPoint(link->getWidth()/2,link->getHeight()/2);
link->draw(0,0,link->getWidth(),link->getHeight());
+ glDisable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
glPopMatrix();
}
@@ -173,8 +188,15 @@ void chainImageSet::drawOutput(){
float camera_throw= (float)outputSize.y/(float)outputSize.x; //the ratio of z distance to x width
+ camera_throw*=0.9; //fudge factor to allow tweening
+
if (images.size()){
+/*
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-ofGetWidth()/2, ofGetWidth()/2, ofGetHeight()/2, -ofGetHeight()/2, 0.0f, 5000.0f);
+*/
glMatrixMode ( GL_MODELVIEW );
glLoadIdentity ( );
gluLookAt( currentImage->getTransform().x,
@@ -188,7 +210,7 @@ void chainImageSet::drawOutput(){
0);
- currentImage->drawChain();
+ currentImage->drawChain(DEFAULT_FADEIN,additive,intensity);
}
@@ -391,6 +413,7 @@ void chainImageSet::keyPressed(ofKeyEventArgs &keyargs){
break;
case OF_KEY_BACKSPACE:{
images.clear();
+ filename.clear();
/*
auto previous=selected;
previous--;
@@ -463,6 +486,9 @@ void chainImageSet::mouseDragged(int x, int y, int button){
case OF_MOUSE_BUTTON_3:
//control-click
dragScale=(y-clickPoint.y)/(selected->thumbnail.getHeight());
+ //if (dragScale*selected->linkScale<0.15){
+ // dragScale=0.15/selected->linkScale;
+ //}
break;
}
}
diff --git a/gui/src/chainImage.h b/gui/src/chainImage.h
index a3c9355..891afdd 100644
--- a/gui/src/chainImage.h
+++ b/gui/src/chainImage.h
@@ -39,7 +39,7 @@ class chainImage : public ofImage{
float getScale();
float getRotation();
- void drawChain(float fadeIn=DEFAULT_FADEIN);
+ void drawChain(float fadeIn=DEFAULT_FADEIN,bool additive =false, float intensity=1.0f);
ofImage thumbnail;
void makeThumbnail();
@@ -73,6 +73,8 @@ class chainImageSet{
filename="";
outputSize=ofPoint(1024,576);
decayFactor=.999;
+ additive=false;
+ intensity=1.0f;
}
void drawGui();
void drawOutput();
@@ -102,4 +104,7 @@ class chainImageSet{
chainImage *currentImage;
float decayFactor;
+
+ bool additive;
+ float intensity;
}; \ No newline at end of file
diff --git a/gui/src/ofApp.cpp b/gui/src/ofApp.cpp
index 11ca50d..d99300c 100644
--- a/gui/src/ofApp.cpp
+++ b/gui/src/ofApp.cpp
@@ -4,13 +4,28 @@
//--------------------------------------------------------------
void ofApp::setup(){
- if (dmx.connect("tty.usbserial-EN143965")){
+ if (dmx.connect("tty.usbserial-ENP6ESY9")){
printf("DMX connected!\n");
- map.push_back(dmxMap(&dmx,1,2,3,100,100));
+ //sbx1 - 16chan at 1
+ //sbx2 - 16chan at 16
+ //sbx3 - 16chan at 32
+ //sbx4 - 16chan at 48
+ //par1 - shutter, intensirty, R, G, B, white at 64
+ //par2 - shutter, intensirty, R, G, B, white at 70
+ //par3 - shutter, intensirty, R, G, B, white at 76
+
+ map.push_back(dmxMap(&dmx,66,67,68,65,0.1,0.1));
+ map.push_back(dmxMap(&dmx,72,73,74,71,0.5,0.1));
+ map.push_back(dmxMap(&dmx,78,79,80,77,0.9,0.1));
}
else printf("DMX not connected.\n");
+ midiIn.listPorts();
+ midiIn.openPort(0);
+ midiIn.addListener(this);
+
+ dmxIntensity=0;
}
//--------------------------------------------------------------
@@ -29,7 +44,7 @@ void ofApp::updateOutput(ofEventArgs & args){
if (dmx.isConnected()){
for (auto m=map.begin();m!=map.end();m++){
- m->update();
+ m->update(dmxIntensity);
}
}
@@ -50,6 +65,86 @@ void ofApp::drawOutput(ofEventArgs & args){
}
//--------------------------------------------------------------
+void ofApp::exit() {
+
+ // clean up
+ midiIn.closePort();
+ midiIn.removeListener(this);
+}
+
+//--------------------------------------------------------------
+
+/*
+
+midi - chan 1
+
+bank 1 - program controls
+
+faders: cc 81 - 88
+pots: cc 1 - 8
+
+top buttons: cc 65 - 72 (0/127)
+next buttons: cc 73 - 80 (0/127)
+
+bank 2 - channel controls
+
+fader cc 7 / pot cc 10
+channels 1-8
+
+bank1
+
+fader1 - light intensity
+
+pot 1 - zoom decay
+
+*/
+
+void ofApp::newMidiMessage(ofxMidiMessage& msg) {
+
+ //printf("Midi: %i %i %i\n",msg.channel,msg.control,msg.value);
+
+//column 0 for general controls
+
+ if (msg.channel==1&&msg.control==1){
+ //pot 0
+ //from .9 to 1.1 but reaching numbers very near 1
+
+ images.decayFactor=1.0 - (pow(2.0f,((float)msg.value-64)/8)/pow(2,8));
+
+ //printf("Val %i, decay: %f \n",msg.value,sf);
+
+ }
+ if (msg.channel==1&&msg.control==65){
+ //top button 0
+ }
+ if (msg.channel==1&&msg.control==73){
+ //bottom button 0
+ }
+ if (msg.channel==1&&msg.control==81){
+ //fader 0
+ dmxIntensity=msg.value*2;
+ }
+
+//column 1 for image set 0
+
+ if (msg.channel==1&&msg.control==2){
+ //pot 1
+ }
+ if (msg.channel==1&&msg.control==66){
+ //top button 1
+ images.additive=(msg.value==127);
+ }
+ if (msg.channel==1&&msg.control==74){
+ //bottom button 1
+ }
+ if (msg.channel==1&&msg.control==82){
+ //fader 1
+ images.intensity=((float)msg.value)/127.0f;
+ }
+
+}
+
+//--------------------------------------------------------------
void ofApp::keyPressed(ofKeyEventArgs &keyargs){
images.keyPressed(keyargs);
}
diff --git a/gui/src/ofApp.h b/gui/src/ofApp.h
index 6bb0c15..20116a1 100644
--- a/gui/src/ofApp.h
+++ b/gui/src/ofApp.h
@@ -2,37 +2,41 @@
#include "ofMain.h"
#include "ofxDmx.h"
+#include "ofxMidi.h"
#include "chainImage.h"
class dmxMap{
+ //resolution independent DMX colour tracker
public:
dmxMap(){
}
- dmxMap(ofxDmx *_dmx,int _chan_R,int _chan_G,int _chan_B,int _x,int _y){
+ dmxMap(ofxDmx *_dmx,int _chan_R,int _chan_G,int _chan_B,int _chan_intensity,float _x,float _y){
dmx=_dmx;
chan_R=_chan_R;
chan_G=_chan_G;
chan_B=_chan_B;
+ chan_intensity=_chan_intensity;
x=_x;
y=_y;
}
- void update(){
+ void update(int intensity){
unsigned char color[3];
- glReadPixels(x , ofGetHeight() - y , 1 , 1 , GL_RGB , GL_UNSIGNED_BYTE , color);
+ glReadPixels(x*ofGetWidth() , ofGetHeight() - (y*ofGetHeight()) , 1 , 1 , GL_RGB , GL_UNSIGNED_BYTE , color);
//printf("dmxMap %i,%i: colour %i %i %i\n",x,y,color[0],color[1],color[2]);
- //dmx->setLevel(chan_R, R);
- //dmx->setLevel(chan_G, G);
- //dmx->setLevel(chan_B, B);
- //dmx->update();
+ dmx->setLevel(chan_R, color[0]);
+ dmx->setLevel(chan_G, color[1]);
+ dmx->setLevel(chan_B, color[2]);
+ dmx->setLevel(chan_intensity, intensity);
+ dmx->update();
}
- int chan_R, chan_G, chan_B;
- int x,y;
+ int chan_R, chan_G, chan_B, chan_intensity;
+ float x,y;
ofxDmx *dmx;
};
-class ofApp : public ofBaseApp{
+class ofApp : public ofBaseApp, public ofxMidiListener{
public:
void setup();
@@ -40,6 +44,7 @@ class ofApp : public ofBaseApp{
void updateOutput(ofEventArgs & args);
void draw();
void drawOutput(ofEventArgs & args);
+ void exit();
void keyPressed(ofKeyEventArgs &keyargs);
void keyReleased(int key);
@@ -61,4 +66,10 @@ class ofApp : public ofBaseApp{
ofxDmx dmx;
vector<dmxMap> map;
+ void newMidiMessage(ofxMidiMessage& eventArgs);
+ ofxMidiIn midiIn;
+ ofxMidiMessage midiMessage;
+
+ int dmxIntensity;
+
};