diff options
| -rw-r--r-- | gui/addons.make | 1 | ||||
| -rw-r--r-- | gui/src/chainImage.cpp | 19 | ||||
| -rw-r--r-- | gui/src/chainImage.h | 1 | ||||
| -rw-r--r-- | gui/src/ofApp.cpp | 13 | ||||
| -rw-r--r-- | gui/src/ofApp.h | 30 |
5 files changed, 62 insertions, 2 deletions
diff --git a/gui/addons.make b/gui/addons.make index ab5217b..12b7e26 100644 --- a/gui/addons.make +++ b/gui/addons.make @@ -1 +1,2 @@ ofxJSON +ofxDMX
\ No newline at end of file diff --git a/gui/src/chainImage.cpp b/gui/src/chainImage.cpp index 032b54c..83363db 100644 --- a/gui/src/chainImage.cpp +++ b/gui/src/chainImage.cpp @@ -77,6 +77,16 @@ float chainImage::getScale(){ return scale; } +float chainImage::getRotation(){ + //this is the camera rotation + //at the beginning of the transition + //this should rotate to match linkRot + //at the end, it should match link->linkRot + //when we switch image, link->linkRot becomes linkRot + //linkRot is no longer seen + + return linkRot+(transition*link->linkRot); +}; void chainImage::makeThumbnail(){ thumbnail=(const ofImage)*this; //copy the ofImage itself @@ -110,6 +120,8 @@ void chainImage::drawChain(float fadeIn){ glTranslatef(linkPos.x,linkPos.y,0); + glRotatef(linkRot,0,0,1); + glScalef(linkScale,linkScale,linkScale); ofEnableAlphaBlending(); @@ -146,6 +158,8 @@ bool chainImage::fromJson(Json::Value json){ void chainImageSet::drawOutput(){ + //movment and rotation are working on their own but not together. + float camera_throw= (float)outputSize.y/(float)outputSize.x; //the ratio of z distance to x width if (images.size()){ @@ -158,7 +172,10 @@ void chainImageSet::drawOutput(){ currentImage->getTransform().x, currentImage->getTransform().y, // i1.linkPos.y+(xform.y*intervalpoint), 0, - 0,1,0); + sin(-currentImage->getRotation()*(PI/180)), + cos(-currentImage->getRotation()*(PI/180)), + 0); + currentImage->drawChain(); diff --git a/gui/src/chainImage.h b/gui/src/chainImage.h index 8eec4bf..a3c9355 100644 --- a/gui/src/chainImage.h +++ b/gui/src/chainImage.h @@ -37,6 +37,7 @@ class chainImage : public ofImage{ bool update(float decayRatio); ofVec3f getTransform(); float getScale(); + float getRotation(); void drawChain(float fadeIn=DEFAULT_FADEIN); diff --git a/gui/src/ofApp.cpp b/gui/src/ofApp.cpp index b026984..11ca50d 100644 --- a/gui/src/ofApp.cpp +++ b/gui/src/ofApp.cpp @@ -1,10 +1,15 @@ #include "ofApp.h" #include "glew.h" + //-------------------------------------------------------------- void ofApp::setup(){ + if (dmx.connect("tty.usbserial-EN143965")){ + printf("DMX connected!\n"); - + map.push_back(dmxMap(&dmx,1,2,3,100,100)); + } + else printf("DMX not connected.\n"); } @@ -22,6 +27,12 @@ void ofApp::updateOutput(ofEventArgs & args){ images.update(); + if (dmx.isConnected()){ + for (auto m=map.begin();m!=map.end();m++){ + m->update(); + } + } + } diff --git a/gui/src/ofApp.h b/gui/src/ofApp.h index ac6d850..6bb0c15 100644 --- a/gui/src/ofApp.h +++ b/gui/src/ofApp.h @@ -1,10 +1,37 @@ #pragma once #include "ofMain.h" +#include "ofxDmx.h" #include "chainImage.h" +class dmxMap{ + public: + dmxMap(){ + } + dmxMap(ofxDmx *_dmx,int _chan_R,int _chan_G,int _chan_B,int _x,int _y){ + dmx=_dmx; + chan_R=_chan_R; + chan_G=_chan_G; + chan_B=_chan_B; + x=_x; + y=_y; + } + void update(){ + unsigned char color[3]; + glReadPixels(x , ofGetHeight() - y , 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(); + } + int chan_R, chan_G, chan_B; + int x,y; + ofxDmx *dmx; +}; + class ofApp : public ofBaseApp{ public: @@ -31,4 +58,7 @@ class ofApp : public ofBaseApp{ chainImageSet images; + ofxDmx dmx; + vector<dmxMap> map; + }; |
