1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
#pragma once
#include "ofMain.h"
#include "ofxDmx.h"
//#include "ofxArtnet.h"
#include "ofxMidi.h"
#include "ofxSyphon.h"
#include "chainImageSet.h"
#include "ofxGpuLut.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 guiMouseDragged(ofMouseEventArgs &args);
void guiMousePressed(ofMouseEventArgs &args);
void guiMouseReleased(ofMouseEventArgs &args);
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<string> arguments;
vector<chainImageSet> sets;
int selected_set;
ofxDmx dmx;
//ofxArtnet artnet;
//unsigned char dmx_data[512];
vector<USBdmxMap> 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;
};
|