rebecca@13
|
1 #include "testApp.h"
|
rebecca@13
|
2
|
rebecca@13
|
3 //--------------------------------------------------------------
|
rebecca@13
|
4 void testApp::setup(){
|
rebecca@13
|
5 drawIt=false;
|
rebecca@13
|
6 // load the default ofxOpenNI config settings
|
rebecca@13
|
7 // see bin/data/openni/config/ofxopenni_config.xml
|
rebecca@13
|
8 context.setupUsingXMLFile();
|
rebecca@13
|
9
|
rebecca@13
|
10 // uncomment this to see what open ni is doing inside
|
rebecca@13
|
11 //context.enableLogging(OF_LOG_VERBOSE);
|
rebecca@13
|
12
|
rebecca@13
|
13 // setup resources
|
rebecca@13
|
14 depth.setup(&context);
|
rebecca@13
|
15 image.setup(&context);
|
rebecca@13
|
16 user.setup(&context, &depth);
|
rebecca@13
|
17 // Davy.loadImage("images/davy.jpg");
|
rebecca@13
|
18 ofEnableSmoothing();
|
rebecca@13
|
19 ofSetBackgroundAuto(false);
|
andrew@49
|
20 ofBackground(255,255,255);
|
andrew@31
|
21 // ofEnableAlphaBlending();
|
rebecca@33
|
22 ofSetLineWidth(12);
|
andrew@17
|
23
|
andrew@38
|
24
|
andrew@44
|
25 for (int y = 0;y < NUMBER_OF_USERS;y++){
|
andrew@44
|
26 typeOfFaceToUse[y] = y%2;
|
andrew@44
|
27 }
|
andrew@31
|
28
|
andrew@47
|
29 anubis.loadImage("images/mask1.png");//anubis-wall-mask.gif
|
andrew@47
|
30 secondUserImage.loadImage("images/mask2.png");//davy2.jpg"
|
andrew@47
|
31 thirdUserImage.loadImage("images/mask3.png");//mubrarksign.jpg
|
andrew@31
|
32
|
andrew@31
|
33 franklinBook.loadFont("frabk.ttf", 32);
|
andrew@31
|
34
|
andrew@47
|
35 // sender.setup( HOST, PORT );
|
andrew@45
|
36 stopSender.setup( STOPHOST, STOPPORT );
|
andrew@45
|
37 heresySender.setup(HERESY_HOST, HERESY_PORT);
|
andrew@49
|
38 mophoSender.setup(STOPHOST, MOPHO_PORT);
|
andrew@45
|
39
|
andrew@17
|
40
|
andrew@38
|
41 maxTorsoValues[0] = 0;
|
andrew@38
|
42 maxTorsoValues[1] = 0;
|
andrew@38
|
43 maxTorsoValues[2] = 0;
|
andrew@38
|
44 double timeNow = ofGetElapsedTimeMillis();
|
andrew@38
|
45 for (int user = 0;user < NUMBER_OF_USERS;user++)
|
andrew@38
|
46 lastRecordedTime[user] = timeNow;
|
andrew@47
|
47
|
andrew@47
|
48 leftMaximum[0] = 700;
|
andrew@47
|
49
|
rebecca@13
|
50 }
|
rebecca@13
|
51
|
rebecca@13
|
52 //--------------------------------------------------------------
|
rebecca@13
|
53 void testApp::update(){
|
rebecca@13
|
54
|
rebecca@13
|
55 // update the open ni context and user tracker
|
rebecca@13
|
56 context.update();
|
rebecca@13
|
57 user.update();
|
andrew@38
|
58
|
andrew@17
|
59
|
andrew@17
|
60 }
|
andrew@17
|
61
|
andrew@17
|
62
|
andrew@31
|
63 void testApp::getCoordinates(int userID){
|
andrew@17
|
64 //tracked = user.getTrackedUser(i);
|
andrew@49
|
65 if (userID < 0 && userID > 7)
|
andrew@49
|
66 cout << "PROBLEM IN NUMBER FOR getCoordinates";
|
andrew@49
|
67
|
andrew@31
|
68 ofxTrackedUser* tracked = user.getTrackedUser(userID);
|
andrew@49
|
69
|
andrew@17
|
70
|
andrew@31
|
71
|
andrew@38
|
72 double timeNow = ofGetElapsedTimeMillis();
|
andrew@38
|
73
|
andrew@38
|
74
|
andrew@38
|
75
|
andrew@38
|
76
|
andrew@38
|
77 if ((fabs(torso[userID][0] - tracked->left_upper_torso.end.x) + fabs(torso[userID][1] - tracked->left_upper_torso.end.y) > 0.1 && tracked->left_upper_torso.end.x > 0 )){
|
andrew@38
|
78 //printf("tracking time %d and last recorded %d\n", timeNow, lastRecordedTime[userID]);
|
andrew@38
|
79 userPresent[userID] = true;
|
andrew@38
|
80 lastRecordedTime[userID] = timeNow ;
|
andrew@45
|
81
|
andrew@31
|
82 torso[userID][0] = tracked->left_upper_torso.end.x;
|
andrew@31
|
83 torso[userID][1] = tracked->left_upper_torso.end.y;
|
andrew@31
|
84 torso[userID][2] = tracked->left_upper_torso.end.z;
|
andrew@45
|
85
|
andrew@45
|
86 leftHandPosition[userID][0] = tracked->left_lower_arm.end.x;
|
andrew@45
|
87 leftHandPosition[userID][1] = tracked->left_lower_arm.end.y;
|
andrew@45
|
88 leftHandPosition[userID][2] = tracked->left_lower_arm.end.z;
|
andrew@45
|
89
|
andrew@45
|
90 rightHandPosition[userID][0] = tracked->right_lower_arm.end.x;
|
andrew@45
|
91 rightHandPosition[userID][1] = tracked->right_lower_arm.end.y;
|
andrew@45
|
92 rightHandPosition[userID][2] = tracked->right_lower_arm.end.z;
|
andrew@45
|
93
|
andrew@38
|
94 checkTorsoMaxima(userID);
|
andrew@38
|
95
|
andrew@38
|
96 //recent track, low distance but do nothing yet
|
andrew@38
|
97 }
|
andrew@38
|
98 else if(userPresent[userID] && (timeNow - lastRecordedTime[userID]) > 500 ){
|
andrew@38
|
99 //not recent track => stopped
|
andrew@31
|
100 userPresent[userID] = false;
|
andrew@38
|
101 printf("user %i has STOPPED!\n", userID);
|
andrew@38
|
102 torso[userID][0] = tracked->left_upper_torso.end.x;
|
andrew@38
|
103 torso[userID][1] = tracked->left_upper_torso.end.y;
|
andrew@38
|
104 torso[userID][2] = tracked->left_upper_torso.end.z;
|
andrew@38
|
105
|
andrew@38
|
106 sendStopMessageForUser(userID);
|
andrew@49
|
107 userInfoString[userID] = "stopped";
|
andrew@49
|
108
|
andrew@49
|
109 //tracked->delete!!
|
andrew@38
|
110
|
andrew@31
|
111 }
|
andrew@17
|
112 ofSetColor(0x00FF00);
|
andrew@17
|
113 outputString = "HeadX : ";
|
andrew@31
|
114 outputString += ofToString(torso[0][0]);
|
andrew@47
|
115 //franklinBook.drawString(outputString, 100,600);
|
andrew@17
|
116
|
andrew@17
|
117 }
|
andrew@17
|
118
|
andrew@38
|
119 void testApp::checkTorsoMaxima(int id){
|
andrew@38
|
120 for (int h = 0; h < 3;h++){
|
andrew@38
|
121 if (torso[id][h] > maxTorsoValues[h])
|
andrew@38
|
122 maxTorsoValues[h] = torso[id][h];
|
andrew@38
|
123 }
|
andrew@47
|
124
|
andrew@47
|
125 for (int h = 0; h < 3;h++){
|
andrew@47
|
126 if (leftHandPosition[id][h] > leftMaximum[h])
|
andrew@47
|
127 leftMaximum[h] = leftHandPosition[id][h];
|
andrew@47
|
128 }
|
andrew@47
|
129
|
andrew@47
|
130 for (int h = 0; h < 3;h++){
|
andrew@47
|
131 if (rightHandPosition[id][h] > rightMaximum[h])
|
andrew@47
|
132 rightMaximum[h] = rightHandPosition[id][h];
|
andrew@47
|
133 }
|
andrew@47
|
134
|
andrew@38
|
135 }
|
andrew@38
|
136
|
andrew@31
|
137 void testApp::sendDataViaOSC(int userID){
|
andrew@47
|
138 /*
|
andrew@31
|
139 ofxOscMessage m;
|
andrew@31
|
140 m.setAddress( "/person" );
|
andrew@31
|
141 m.addIntArg( userID );
|
andrew@38
|
142 m.addFloatArg( torso[userID][0]/maxTorsoValues[0] );
|
andrew@38
|
143 m.addFloatArg( torso[userID][1] /maxTorsoValues[1]);
|
andrew@38
|
144 m.addFloatArg( torso[userID][2] /maxTorsoValues[2]);
|
andrew@31
|
145 sender.sendMessage( m );
|
andrew@47
|
146 */
|
rebecca@13
|
147 }
|
rebecca@13
|
148
|
andrew@38
|
149 void testApp::sendStopMessageForUser(int userID){
|
andrew@38
|
150 ofxOscMessage m;
|
andrew@45
|
151 m.setAddress( "/stopperson" );
|
andrew@38
|
152 m.addIntArg( userID );
|
andrew@38
|
153 m.addFloatArg( torso[userID][0]/maxTorsoValues[0] );
|
andrew@38
|
154 m.addFloatArg( torso[userID][1] /maxTorsoValues[1]);
|
andrew@38
|
155 m.addFloatArg( torso[userID][2] /maxTorsoValues[2]);
|
andrew@38
|
156 stopSender.sendMessage( m );
|
andrew@45
|
157
|
andrew@47
|
158 /*
|
andrew@45
|
159 ofxOscMessage newMess;
|
andrew@45
|
160 newMess.setAddress( "/stopperson" );
|
andrew@45
|
161 newMess.addIntArg( userID );
|
andrew@45
|
162 sender.sendMessage( newMess );
|
andrew@47
|
163 */
|
andrew@38
|
164 }
|
andrew@38
|
165
|
andrew@45
|
166
|
andrew@45
|
167 void testApp::sendInformationToHeresy(int userID){
|
andrew@45
|
168
|
andrew@45
|
169 //map to pitches interpolation
|
andrew@45
|
170 double zVal = torso[userID][2] /maxTorsoValues[2];
|
andrew@45
|
171 int pitch;
|
andrew@45
|
172 if (zVal < 1)
|
andrew@45
|
173 pitch = (int)(16 * zVal);
|
andrew@45
|
174 else
|
andrew@45
|
175 pitch = 15;
|
andrew@45
|
176
|
andrew@45
|
177
|
andrew@45
|
178
|
andrew@49
|
179 if (userID < NUMBER_OF_USERS){
|
andrew@47
|
180 double leftHand, rightHand, leftHandX, rightHandX, leftHandY, rightHandY;
|
andrew@47
|
181 leftHand = leftHandPosition[userID][0]/leftMaximum[0];//i.e x [position
|
andrew@47
|
182 rightHand = rightHandPosition[userID][0]/rightMaximum[0];//same for right
|
andrew@47
|
183
|
andrew@47
|
184
|
andrew@47
|
185 leftHandY = leftHandPosition[userID][1]/leftMaximum[1];//i.e. x position but 0 to 1
|
andrew@47
|
186 rightHandY = rightHandPosition[userID][1]/rightMaximum[1];//same for right
|
andrew@47
|
187
|
andrew@47
|
188 //THIS IS THE ONLY ROUTINE CALLED
|
andrew@45
|
189 //i.e. monophonic
|
andrew@45
|
190
|
andrew@47
|
191 // int controlChangeLeft[3][4];//userId, leftX, leftR, rightX, right Y
|
andrew@47
|
192 //need to send continuous control change not just when note changes
|
andrew@47
|
193 int controlChangeLeft = (int) min((double)127,max((double)0,(leftHand*127)));
|
andrew@47
|
194 int controlChangeRight = (int) min((double)127,max((double)0,(rightHand*127)));
|
andrew@47
|
195
|
andrew@47
|
196 int controlChangeLeftY = (int)((double)127 - min((double)127,max((double)0,(leftHandY*127))));
|
andrew@49
|
197 int controlChangeRightY = (int)((double)127 - min((double)127,max((double)0,(rightHandY*127))));
|
andrew@47
|
198
|
andrew@49
|
199 if (userID > 0){ //hackoo
|
andrew@49
|
200 bool checkNotSame1 = checkSameUserAs(userID, userID + 1 % NUMBER_OF_USERS);
|
andrew@49
|
201 bool checkNotSame2 = checkSameUserAs(userID, userID + 2 % NUMBER_OF_USERS);
|
andrew@49
|
202
|
andrew@49
|
203 checkingSameUser[userID] = checkSameUserAs(userID, userID + 1 % NUMBER_OF_USERS) || checkSameUserAs(userID, userID + 2 % NUMBER_OF_USERS);
|
andrew@49
|
204 }
|
andrew@49
|
205
|
andrew@49
|
206
|
andrew@47
|
207 ControlChangeData[userID][0] = controlChangeLeft ;
|
andrew@47
|
208 ControlChangeData[userID][1] = controlChangeLeftY ;
|
andrew@47
|
209 ControlChangeData[userID][2] = controlChangeRight ;
|
andrew@47
|
210 ControlChangeData[userID][3] = controlChangeRightY ;
|
andrew@47
|
211
|
andrew@47
|
212 userInfoString[userID] = "USER ";
|
andrew@47
|
213 userInfoString[userID] += ofToString(userID+1, 0);
|
andrew@47
|
214 userInfoString[userID] += " Pitch ";
|
andrew@47
|
215 userInfoString[userID] += ofToString(pitch, 0);
|
andrew@47
|
216
|
andrew@47
|
217 userInfoString[userID] += " ccL ";
|
andrew@47
|
218 userInfoString[userID] += ofToString(controlChangeLeft, 0);
|
andrew@47
|
219 userInfoString[userID] += " , ";
|
andrew@47
|
220 userInfoString[userID] += ofToString(controlChangeLeftY, 0);
|
andrew@47
|
221
|
andrew@47
|
222 userInfoString[userID] += " ccR ";
|
andrew@47
|
223 userInfoString[userID] += ofToString(controlChangeRight, 0);
|
andrew@47
|
224 userInfoString[userID] += " , ";
|
andrew@47
|
225 userInfoString[userID] += ofToString(controlChangeRightY, 0);
|
andrew@47
|
226
|
andrew@49
|
227 if (userID == 0){
|
andrew@49
|
228 sendControlChangeDataToAbleton(userID);
|
andrew@49
|
229 }
|
andrew@49
|
230 else{
|
andrew@47
|
231 sendControlChangeDataToMax(userID);
|
andrew@49
|
232 }
|
andrew@47
|
233
|
andrew@45
|
234 if (pitch != pitchPlaying[userID]){
|
andrew@45
|
235 //then we have a change
|
andrew@45
|
236 //send note off
|
andrew@45
|
237 sendNoteMessageToHeresy(pitchPlaying[userID], 0, 0, userID);
|
andrew@47
|
238 printf("note OFF user %i pitch %i \n ", userID+1, pitchPlaying[userID]);
|
andrew@49
|
239
|
andrew@49
|
240 //if (!checkingSameUser[userID]){
|
andrew@49
|
241 sendNoteMessageToHeresy(pitch, 1, 127, userID);// int channel){
|
andrew@49
|
242 pitchPlaying[userID] = pitch;
|
andrew@49
|
243 //}
|
andrew@45
|
244
|
andrew@47
|
245 //now get send control change for the hands XXX TO DO
|
andrew@47
|
246 /*
|
andrew@47
|
247 leftHand *= 127;
|
andrew@47
|
248 rightHand *= 127;
|
andrew@45
|
249
|
andrew@47
|
250 */
|
andrew@47
|
251
|
andrew@47
|
252 // printf("note ON user %i pitch %i \n", userID+1, pitch);
|
andrew@45
|
253 }
|
andrew@45
|
254 }
|
andrew@45
|
255 else{
|
andrew@47
|
256 //NO LONGER CALLED - WE SEND JUST MAIN PITCHES TRIGGERED BY BODY POSITION
|
andrew@47
|
257 //i.e. for was channel for user 2 and 3
|
andrew@47
|
258 /*
|
andrew@45
|
259 double minimum = min(leftHand, rightHand);
|
andrew@45
|
260 double maximum = max(leftHand, rightHand);
|
andrew@45
|
261 int minPitch = (int) (16 * minimum);
|
andrew@45
|
262 int maxPitch = (int) (16 * maximum);
|
andrew@45
|
263 minMaxValues[userID][0] = minPitch;
|
andrew@45
|
264 minMaxValues[userID][1] = maxPitch;
|
andrew@47
|
265
|
andrew@47
|
266 if (maxPitch > 15)
|
andrew@45
|
267 maxPitch = 15;
|
andrew@45
|
268
|
andrew@47
|
269 userInfoString[userID] = "USER ";
|
andrew@47
|
270 userInfoString[userID] += ofToString(userID+1, 0);
|
andrew@47
|
271
|
andrew@47
|
272 printf("user %i min %i max %i\n", userID+1, minPitch, maxPitch);
|
andrew@47
|
273
|
andrew@47
|
274 userInfoString[userID] += "min ";
|
andrew@47
|
275 userInfoString[userID] += ofToString(minPitch, 0);
|
andrew@47
|
276 userInfoString[userID] += "max ";
|
andrew@47
|
277 userInfoString[userID] += ofToString(maxPitch, 0);
|
andrew@47
|
278
|
andrew@45
|
279 for (int p = 0;p < 16;p++){
|
andrew@45
|
280
|
andrew@45
|
281 if (p < minPitch || p > maxPitch){
|
andrew@45
|
282 //sendNoteMessageToHeresy(p, 0, 0, userID);
|
andrew@45
|
283 nowPlaying[userID][p] = false;
|
andrew@45
|
284 }
|
andrew@45
|
285 else{
|
andrew@45
|
286 nowPlaying[userID][p] = true;
|
andrew@45
|
287 }
|
andrew@45
|
288
|
andrew@45
|
289
|
andrew@45
|
290 if (nowPlaying[userID][p] != lastPlaying[userID][p]){
|
andrew@45
|
291 if (nowPlaying[userID][p])
|
andrew@45
|
292 {
|
andrew@47
|
293 //sendNoteMessageToHeresy(p, 1, 127, userID);
|
andrew@45
|
294 lastPlaying[userID][p] = true;
|
andrew@45
|
295 }
|
andrew@45
|
296 else {
|
andrew@47
|
297 //sendNoteMessageToHeresy(p, 0, 0, userID);
|
andrew@45
|
298 lastPlaying[userID][p] = false;
|
andrew@45
|
299 }
|
andrew@45
|
300 }
|
andrew@47
|
301 }//end for p
|
andrew@47
|
302 */
|
andrew@47
|
303 }//end else - not called!
|
andrew@45
|
304
|
andrew@45
|
305
|
andrew@45
|
306
|
andrew@45
|
307
|
andrew@45
|
308
|
andrew@45
|
309 //x and y get sent to max after being mapped 0 to 127
|
andrew@45
|
310 //these are control change messages
|
andrew@45
|
311 //cvan be sent straight to max
|
andrew@45
|
312 int xVal, yVal;
|
andrew@45
|
313 xVal = (int)(127 * torso[userID][0]/maxTorsoValues[0] );
|
andrew@45
|
314 yVal = (int)(127 * torso[userID][1]/maxTorsoValues[1] );
|
andrew@45
|
315
|
andrew@45
|
316
|
andrew@45
|
317
|
andrew@45
|
318 }
|
andrew@45
|
319
|
andrew@47
|
320
|
andrew@49
|
321 bool testApp::checkSameUserAs(int userID, int checkID){
|
andrew@49
|
322 bool check = false;
|
andrew@49
|
323
|
andrew@49
|
324 if (rightHandPosition[userID][0] == rightHandPosition[checkID][0] && leftHandPosition[userID][0] == leftHandPosition[checkID][0])
|
andrew@49
|
325 check = true;
|
andrew@49
|
326
|
andrew@49
|
327 return check;
|
andrew@49
|
328
|
andrew@49
|
329 }
|
andrew@47
|
330
|
andrew@47
|
331
|
andrew@47
|
332
|
andrew@45
|
333 void testApp::sendNoteMessageToHeresy(int noteNumber, int onOrOff, int velocity, int channel){
|
andrew@45
|
334 channel++;
|
andrew@45
|
335
|
andrew@45
|
336 ofxOscMessage m;
|
andrew@45
|
337 m.setAddress( "/test" );
|
andrew@45
|
338 m.addStringArg("note");
|
andrew@45
|
339 m.addIntArg( noteNumber );
|
andrew@45
|
340 m.addIntArg( onOrOff );
|
andrew@45
|
341 m.addIntArg( velocity );
|
andrew@45
|
342 m.addIntArg( channel );
|
andrew@45
|
343 heresySender.sendMessage( m );
|
andrew@45
|
344
|
andrew@45
|
345
|
andrew@45
|
346 }
|
andrew@45
|
347
|
andrew@45
|
348
|
andrew@47
|
349 void testApp::sendControlChangeDataToMax(int userID){
|
andrew@47
|
350 int channel = userID+1;
|
andrew@47
|
351
|
andrew@47
|
352 ofxOscMessage m;
|
andrew@47
|
353 m.setAddress( "/controlChangeData" );
|
andrew@47
|
354 m.addIntArg( channel );
|
andrew@47
|
355 m.addIntArg( ControlChangeData[userID][0] );
|
andrew@47
|
356 m.addIntArg( ControlChangeData[userID][1] );
|
andrew@47
|
357 m.addIntArg( ControlChangeData[userID][2] );
|
andrew@47
|
358 m.addIntArg( ControlChangeData[userID][3] );
|
andrew@47
|
359 stopSender.sendMessage( m );
|
andrew@47
|
360
|
andrew@47
|
361 }
|
andrew@47
|
362
|
andrew@49
|
363 void testApp::sendControlChangeDataToAbleton(int userID){
|
andrew@49
|
364 int channel = userID+1;
|
andrew@49
|
365
|
andrew@49
|
366 ofxOscMessage m;
|
andrew@49
|
367 m.setAddress( "/controlChangeData" );
|
andrew@49
|
368 m.addIntArg( channel );
|
andrew@49
|
369 m.addIntArg( ControlChangeData[userID][0] );
|
andrew@49
|
370 m.addIntArg( ControlChangeData[userID][1] );
|
andrew@49
|
371 m.addIntArg( ControlChangeData[userID][2] );
|
andrew@49
|
372 m.addIntArg( ControlChangeData[userID][3] );
|
andrew@49
|
373 mophoSender.sendMessage( m );
|
andrew@49
|
374
|
andrew@49
|
375 }
|
andrew@49
|
376
|
rebecca@13
|
377 //--------------------------------------------------------------
|
rebecca@13
|
378 void testApp::draw(){
|
andrew@49
|
379 ofBackground(255,255,255);
|
rebecca@13
|
380
|
rebecca@13
|
381 // draw depth and rgb images
|
rebecca@13
|
382 //depth.draw();
|
rebecca@13
|
383 if (drawIt != true) {
|
rebecca@13
|
384 image.draw();
|
rebecca@13
|
385 user.draw();
|
rebecca@13
|
386 }
|
rebecca@13
|
387 // draw all the users automatically?
|
rebecca@13
|
388
|
rebecca@13
|
389
|
rebecca@13
|
390
|
andrew@31
|
391
|
rebecca@13
|
392 stringstream info;
|
rebecca@13
|
393 info << "number of tracked users: " << user.getNumTrackedUsers() << endl;
|
rebecca@13
|
394
|
andrew@49
|
395 //string numString = "num tracked users is ";
|
andrew@49
|
396 //numString += ofToString(user.getNumTrackedUsers());
|
andrew@49
|
397 //franklinBook.drawString(numString, 60, 60);
|
andrew@49
|
398
|
rebecca@13
|
399 // draw the neck positions of each user
|
andrew@49
|
400 for(int i = 0; i < user.getNumTrackedUsers(); ++i) {//
|
andrew@47
|
401
|
rebecca@13
|
402 ofxTrackedUser* tracked = user.getTrackedUser(i);
|
andrew@47
|
403
|
rebecca@13
|
404 if(tracked != NULL) {
|
andrew@38
|
405
|
andrew@17
|
406 //andrews code
|
andrew@17
|
407 int userID = i;
|
andrew@49
|
408 // printf("user %i \n", userID);
|
andrew@49
|
409 int tmpID = userID;
|
andrew@49
|
410 userID = userID % NUMBER_OF_USERS;//hack
|
andrew@49
|
411
|
andrew@49
|
412 if (userID < NUMBER_OF_USERS){// && !checkingSameUser[userID]
|
andrew@17
|
413
|
andrew@31
|
414 getCoordinates(userID);
|
andrew@31
|
415
|
andrew@31
|
416
|
andrew@31
|
417 if (userPresent[userID]){
|
andrew@47
|
418 // sendDataViaOSC(userID);
|
andrew@45
|
419 sendInformationToHeresy(userID);
|
andrew@49
|
420
|
andrew@31
|
421
|
andrew@31
|
422 ofSetColor(0x000000);
|
andrew@31
|
423 outputString = "Us ";
|
andrew@31
|
424 outputString += ofToString(userID);
|
andrew@31
|
425 outputString += " ";
|
andrew@31
|
426 outputString += ofToString(userPresent[userID]);
|
andrew@31
|
427 outputString += "HeadX : ";
|
andrew@31
|
428 outputString += ofToString(torso[userID][0], 2);
|
andrew@17
|
429 outputString += " HeadY : ";
|
andrew@31
|
430 outputString += ofToString(torso[userID][1], 2);
|
andrew@17
|
431 outputString += " HeadZ : ";
|
andrew@31
|
432 outputString += ofToString(torso[userID][2], 2);
|
andrew@47
|
433
|
andrew@47
|
434 franklinBook.drawString(outputString, 100,600+userID*160);
|
andrew@17
|
435
|
andrew@47
|
436
|
andrew@47
|
437 outputString = "LeftX : ";
|
andrew@47
|
438 outputString += ofToString(leftHandPosition[userID][0], 2);
|
andrew@47
|
439 outputString += " LeftY : ";
|
andrew@47
|
440 outputString += ofToString(leftHandPosition[userID][1], 2);
|
andrew@47
|
441 outputString += " LeftZ : ";
|
andrew@47
|
442 outputString += ofToString(leftHandPosition[userID][2], 2);
|
andrew@47
|
443
|
andrew@47
|
444 franklinBook.drawString(outputString, 100,640+userID*160);
|
andrew@47
|
445
|
andrew@47
|
446 outputString = "RightX : ";
|
andrew@47
|
447 outputString += ofToString(rightHandPosition[userID][0], 2);
|
andrew@47
|
448 outputString += " LeftY : ";
|
andrew@47
|
449 outputString += ofToString(rightHandPosition[userID][1], 2);
|
andrew@47
|
450 outputString += " LeftZ : ";
|
andrew@47
|
451 outputString += ofToString(rightHandPosition[userID][2], 2);
|
andrew@47
|
452
|
andrew@47
|
453 franklinBook.drawString(outputString, 100,680+userID*160);
|
andrew@47
|
454
|
andrew@47
|
455 outputString = "MaxX: ";
|
andrew@47
|
456 outputString += ofToString(maxTorsoValues[0], 2);
|
andrew@47
|
457 outputString += " MaxY: ";
|
andrew@47
|
458 outputString += ofToString(maxTorsoValues[1], 2);
|
andrew@47
|
459 outputString += " MaxZ: ";
|
andrew@47
|
460 outputString += ofToString(maxTorsoValues[2], 2);
|
andrew@47
|
461
|
andrew@47
|
462
|
andrew@47
|
463 franklinBook.drawString(outputString, 100,720+userID*160);
|
andrew@17
|
464
|
andrew@47
|
465
|
andrew@49
|
466 // ofSetColor(0,0,255);
|
andrew@49
|
467 // ofCircle(tracked->neck.begin.x, tracked->neck.begin.y , 40);
|
andrew@31
|
468
|
andrew@31
|
469
|
andrew@47
|
470
|
andrew@47
|
471 ofSetColor(255,255,255);
|
andrew@49
|
472 float scalingFactor = 0.75 * 1500 / tracked->neck.begin.z ;
|
andrew@47
|
473 switch (userID){
|
andrew@49
|
474 //x was - anubis.width*scalingFactor /2
|
andrew@49
|
475 //y was - anubis.height*scalingFactor /2
|
andrew@47
|
476 case 0:
|
andrew@49
|
477 anubis.draw(tracked->neck.begin.x - anubis.width*scalingFactor /2,tracked->neck.begin.y - anubis.height*scalingFactor /4, anubis.width*scalingFactor, anubis.height*scalingFactor );
|
andrew@47
|
478 break;
|
andrew@47
|
479 case 1:
|
andrew@49
|
480 secondUserImage.draw(tracked->neck.begin.x- secondUserImage.width*scalingFactor /2,tracked->neck.begin.y - secondUserImage.height*scalingFactor /4, secondUserImage.width*scalingFactor, secondUserImage.height*scalingFactor );
|
andrew@47
|
481 break;
|
andrew@47
|
482 case 2:
|
andrew@49
|
483 thirdUserImage.draw(tracked->neck.begin.x- thirdUserImage.width*scalingFactor /2,tracked->neck.begin.y - thirdUserImage.height*scalingFactor /4, thirdUserImage.width*scalingFactor, thirdUserImage.height*scalingFactor );
|
andrew@49
|
484 break;
|
andrew@49
|
485 default:
|
andrew@49
|
486 drawAcidSmiley(userID);
|
andrew@49
|
487 break;
|
andrew@47
|
488
|
andrew@47
|
489 }//end switch user image
|
andrew@47
|
490
|
andrew@47
|
491 }//end if is present
|
andrew@31
|
492
|
andrew@17
|
493 }
|
andrew@17
|
494
|
andrew@17
|
495 //end andrew
|
andrew@38
|
496
|
rebecca@13
|
497 info << i << " neck pos: "
|
rebecca@13
|
498 << tracked->left_lower_arm.end.x << " "
|
rebecca@13
|
499 << tracked->left_lower_arm.end.y << " "
|
rebecca@13
|
500 << tracked->neck.begin.z << endl;
|
andrew@38
|
501
|
andrew@31
|
502
|
andrew@17
|
503 if (tracked->neck.begin.x != 0)
|
rebecca@13
|
504
|
andrew@38
|
505
|
andrew@17
|
506 ofSetColor(139,0,0,100);
|
rebecca@33
|
507
|
andrew@17
|
508 ofNoFill();
|
andrew@17
|
509 float w = ofGetWidth();
|
andrew@17
|
510 float h = ofGetHeight();
|
andrew@32
|
511
|
andrew@44
|
512 /*
|
andrew@44
|
513 if (typeOfFaceToUse[userID] == 1)
|
andrew@44
|
514 bezierFunctionStuff(userID);
|
andrew@44
|
515 else
|
andrew@44
|
516 drawAcidSmiley(userID);
|
andrew@44
|
517 */
|
andrew@44
|
518 }
|
andrew@47
|
519 ofSetColor(0,0,0);
|
andrew@47
|
520 for (int userNumber = 0;userNumber < 3;userNumber++){
|
andrew@49
|
521 franklinBook.drawString(userInfoString[userNumber], 660, (userNumber*60)+60);
|
andrew@47
|
522 }
|
andrew@47
|
523
|
andrew@44
|
524 }
|
andrew@39
|
525
|
andrew@31
|
526
|
andrew@31
|
527 //faint rectangle?
|
rebecca@13
|
528 ofFill();
|
rebecca@13
|
529 ofSetColor(238,238,224,20);
|
andrew@31
|
530 // ofRect(0,0,ofGetWidth(),ofGetHeight()); blurring
|
rebecca@13
|
531 ofDrawBitmapString(info.str(), 10, 500);
|
andrew@31
|
532
|
rebecca@13
|
533 }
|
rebecca@13
|
534
|
rebecca@13
|
535 //--------------------------------------------------------------
|
rebecca@13
|
536 void testApp::keyPressed(int key){
|
andrew@49
|
537 // if (key=='r')
|
andrew@49
|
538 // ofxUserGenerator::setup(context, depth);
|
andrew@49
|
539 // else {
|
andrew@49
|
540 ofSetColor(238,238,224);
|
andrew@49
|
541 ofRect(0,0,ofGetWidth(),ofGetHeight());
|
andrew@49
|
542 // drawIt =!drawIt;
|
andrew@49
|
543 ofToggleFullscreen();
|
andrew@49
|
544
|
andrew@49
|
545 //sendDataViaOSC(0);
|
andrew@49
|
546 // }
|
rebecca@13
|
547 }
|
rebecca@13
|
548
|
rebecca@13
|
549 //--------------------------------------------------------------
|
rebecca@13
|
550 void testApp::keyReleased(int key){
|
rebecca@13
|
551
|
rebecca@13
|
552 }
|
rebecca@13
|
553
|
rebecca@13
|
554 //--------------------------------------------------------------
|
rebecca@13
|
555 void testApp::mouseMoved(int x, int y ){
|
rebecca@13
|
556
|
rebecca@13
|
557 }
|
rebecca@13
|
558
|
rebecca@13
|
559 //--------------------------------------------------------------
|
rebecca@13
|
560 void testApp::mouseDragged(int x, int y, int button){
|
rebecca@13
|
561
|
rebecca@13
|
562 }
|
rebecca@13
|
563
|
rebecca@13
|
564 //--------------------------------------------------------------
|
rebecca@13
|
565 void testApp::mousePressed(int x, int y, int button){
|
rebecca@13
|
566 ofSetColor(238,238,224);
|
rebecca@13
|
567 ofFill();
|
rebecca@13
|
568 ofRect(0,0,ofGetWidth(),ofGetHeight());
|
andrew@45
|
569
|
andrew@45
|
570 int pitch = (int) ofRandom(0, 15);
|
andrew@47
|
571 //sendNoteMessageToHeresy(pitch, 1, 127, 1);
|
rebecca@13
|
572 }
|
rebecca@13
|
573
|
rebecca@13
|
574 //--------------------------------------------------------------
|
rebecca@13
|
575 void testApp::mouseReleased(int x, int y, int button){
|
rebecca@13
|
576
|
rebecca@13
|
577 }
|
rebecca@13
|
578
|
rebecca@13
|
579 //--------------------------------------------------------------
|
rebecca@13
|
580 void testApp::windowResized(int w, int h){
|
rebecca@13
|
581
|
rebecca@13
|
582 }
|
rebecca@13
|
583
|
andrew@44
|
584
|
andrew@44
|
585 void testApp::bezierFunctionStuff(int i){
|
andrew@44
|
586
|
andrew@44
|
587 ofxTrackedUser* tracked = user.getTrackedUser(i);
|
andrew@44
|
588 float w = ofGetWidth();
|
andrew@44
|
589 float h = ofGetHeight();
|
andrew@44
|
590
|
andrew@44
|
591 ofFill();
|
andrew@44
|
592
|
andrew@44
|
593 ofBezier(tracked->neck.begin.x,
|
andrew@44
|
594 tracked->neck.begin.y,
|
andrew@44
|
595 tracked->neck.end.x,
|
andrew@44
|
596 tracked->neck.end.y,
|
andrew@44
|
597 tracked->left_lower_arm.begin.x,
|
andrew@44
|
598 tracked->left_lower_arm.begin.y,
|
andrew@44
|
599 tracked->left_lower_arm.end.x,
|
andrew@44
|
600 /*tracked->left_lower_arm.end.y*/ w);
|
andrew@44
|
601
|
andrew@44
|
602 ofBezier(tracked->neck.begin.x,
|
andrew@44
|
603 tracked->neck.begin.y,
|
andrew@44
|
604 tracked->neck.end.x,
|
andrew@44
|
605 tracked->neck.end.y,
|
andrew@44
|
606 tracked->right_lower_arm.begin.x,
|
andrew@44
|
607 tracked->right_lower_arm.begin.y,
|
andrew@44
|
608 tracked->right_lower_arm.end.x,
|
andrew@44
|
609 /*tracked->right_lower_arm.end.y*/ w);
|
andrew@44
|
610
|
andrew@44
|
611 ofBezier(tracked->neck.begin.x,
|
andrew@44
|
612 tracked->neck.begin.y,
|
andrew@44
|
613 tracked->neck.end.x,
|
andrew@44
|
614 tracked->neck.end.y,
|
andrew@44
|
615 tracked->left_lower_leg.begin.x,
|
andrew@44
|
616 tracked->left_lower_leg.begin.y,
|
andrew@44
|
617 tracked->left_lower_leg.end.x,
|
andrew@44
|
618 /*tracked->left_lower_leg.end.y*/ h);
|
andrew@44
|
619
|
andrew@44
|
620 ofBezier(tracked->neck.begin.x,
|
andrew@44
|
621 tracked->neck.begin.y,
|
andrew@44
|
622 tracked->neck.end.x,
|
andrew@44
|
623 tracked->neck.end.y,
|
andrew@44
|
624 tracked->right_lower_leg.begin.x,
|
andrew@44
|
625 tracked->right_lower_leg.begin.y,
|
andrew@44
|
626 tracked->right_lower_leg.end.x,
|
andrew@44
|
627 /*tracked->right_lower_leg.end.y*/ h);
|
andrew@44
|
628
|
andrew@44
|
629
|
andrew@44
|
630 ofBezier(tracked->neck.begin.x,tracked->neck.begin.y,tracked->neck.end.x,tracked->neck.end.y,tracked->left_lower_arm.begin.x,tracked->left_lower_arm.begin.y,tracked->left_lower_arm.end.x,/*tracked->left_lower_arm.end.y*/ w);
|
andrew@44
|
631 ofBezier(tracked->neck.begin.x,tracked->neck.begin.y,tracked->neck.end.x,tracked->neck.end.y,tracked->right_lower_arm.begin.x,tracked->right_lower_arm.begin.y,tracked->right_lower_arm.end.x,/*tracked->right_lower_arm.end.y*/ w);
|
andrew@44
|
632 ofBezier(tracked->neck.begin.x,tracked->neck.begin.y,tracked->neck.end.x,tracked->neck.end.y,tracked->left_lower_leg.begin.x,tracked->left_lower_leg.begin.y,tracked->left_lower_leg.end.x,/*tracked->left_lower_leg.end.y*/ h);
|
andrew@44
|
633 ofBezier(tracked->neck.begin.x,tracked->neck.begin.y,tracked->neck.end.x,tracked->neck.end.y,tracked->right_lower_leg.begin.x,tracked->right_lower_leg.begin.y,tracked->right_lower_leg.end.x,/*tracked->right_lower_leg.end.y*/ h);
|
andrew@44
|
634
|
andrew@44
|
635
|
andrew@44
|
636 }
|
andrew@44
|
637
|
andrew@44
|
638 void testApp::drawAcidSmiley(int i){
|
andrew@44
|
639 //acid smiley
|
andrew@44
|
640
|
andrew@44
|
641 ofxTrackedUser* tracked = user.getTrackedUser(i);
|
andrew@44
|
642 float w = ofGetWidth();
|
andrew@44
|
643 float h = ofGetHeight();
|
andrew@44
|
644
|
andrew@44
|
645
|
andrew@44
|
646 ofFill();
|
andrew@44
|
647
|
andrew@44
|
648 ofSetColor(255,255,100);
|
andrew@44
|
649 ofCircle(tracked->neck.begin.x,tracked->neck.begin.y,30);
|
andrew@44
|
650 ofSetColor(0);
|
andrew@44
|
651 ofCircle(tracked->neck.begin.x,tracked->neck.begin.y,35);
|
andrew@44
|
652 ofSetColor(255,255,100);
|
andrew@44
|
653 ofCircle(tracked->neck.begin.x,tracked->neck.begin.y,30);
|
andrew@44
|
654 ofSetColor(0);
|
andrew@44
|
655 ofCircle(tracked->neck.begin.x+10.0f,tracked->neck.begin.y,6);
|
andrew@44
|
656 ofCircle(tracked->neck.begin.x-10.0f,tracked->neck.begin.y,6);
|
andrew@44
|
657
|
andrew@44
|
658
|
andrew@44
|
659
|
andrew@44
|
660 }
|