#pragma once #include "ofMain.h" #include "ofxDmx.h" //#include "ofxArtnet.h" #include "ofxMidi.h" #include "ofxSyphon.h" #include "chainImageSet.h" class USBdmxMap{ //resolution independent DMX colour tracker public: USBdmxMap(){ } USBdmxMap(ofxDmx *_dmx,int chan_base,float _x,float _y){ dmx=_dmx; // R, G, B, white, dimmer, shutter // dimmer, shutter, R, G, B, white chan_intensity=chan_base; chan_shutter=chan_base+1; chan_R=chan_base+2; chan_G=chan_base+3; chan_B=chan_base+4; chan_white=chan_base+5; //dmx->setLevel(chan_shutter,15,0); //dmx->update(); x=_x; y=_y; } void update(int intensity){ unsigned char color[3]; 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,color[0]); //,0); dmx->setLevel(chan_G,color[1]); //,0); dmx->setLevel(chan_B,color[2]); //,0); dmx->setLevel(chan_white,0); //,0); dmx->setLevel(chan_intensity,intensity); //,0); dmx->setLevel(chan_shutter,255); //,0); dmx->update(); //printf("Dmx: %i,%i,%i @ %i \n",color[0],color[1],color[2],intensity); } int chan_R, chan_G, chan_B, chan_intensity, chan_shutter, chan_white; float x,y; ofxDmx *dmx; }; class ArtnetDmxMap{ //resolution independent DMX colour tracker public: ArtnetDmxMap(){ } ArtnetDmxMap(unsigned char *_dmx_data,int chan_base,float _x,float _y){ dmx_data=_dmx_data; chan_shutter=chan_base; chan_intensity=chan_base+1; chan_R=chan_base+2; chan_G=chan_base+3; chan_B=chan_base+4; //dmx->setLevel(chan_shutter,15,0); //dmx->update(); x=_x; y=_y; } void update(int intensity){ unsigned char color[3]; 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_data[chan_shutter]=255; dmx_data[chan_intensity]=intensity; dmx_data[chan_R]=color[0]; dmx_data[chan_G]=color[1]; dmx_data[chan_B]=color[2]; //printf("Dmx: %i,%i,%i @ %i \n",color[0],color[1],color[2],intensity); } int chan_R, chan_G, chan_B, chan_intensity, chan_shutter; float x,y; unsigned char *dmx_data; }; class ofApp : public ofBaseApp, public ofxMidiListener{ public: void setup(); void update(); void draw(); void exit(); void drawGui(ofEventArgs & args); void updateGui(ofEventArgs & args); void guiKeyPressed(ofKeyEventArgs & args); void guiWindowResized(ofResizeEventArgs &resizeargs); void guiDragEvent(ofDragInfo &dragInfo); void keyPressed(ofKeyEventArgs &keyargs); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void mouseEntered(int x, int y); void mouseExited(int x, int y); void windowResized(int w, int h); void gotMessage(ofMessage msg); vector arguments; vector sets; int selected_set; ofxDmx dmx; //ofxArtnet artnet; //unsigned char dmx_data[512]; vector map; void newMidiMessage(ofxMidiMessage& eventArgs); ofxMidiIn midiIn; ofxMidiMessage midiMessage; int dmxIntensity; bool outputFS; float next_update; bool commandPressed; ofxSyphonServer mainOutputSyphonServer; // ofxSyphonServer individualTextureSyphonServer; //ofxSyphonClient mClient; bool bSmooth; };