rebecca@13: #include "testApp.h" rebecca@13: rebecca@13: //-------------------------------------------------------------- rebecca@13: void testApp::setup(){ rebecca@13: drawIt=false; rebecca@13: // load the default ofxOpenNI config settings rebecca@13: // see bin/data/openni/config/ofxopenni_config.xml rebecca@13: context.setupUsingXMLFile(); rebecca@13: rebecca@13: // uncomment this to see what open ni is doing inside rebecca@13: //context.enableLogging(OF_LOG_VERBOSE); rebecca@13: rebecca@13: // setup resources rebecca@13: depth.setup(&context); rebecca@13: image.setup(&context); rebecca@13: user.setup(&context, &depth); rebecca@13: // Davy.loadImage("images/davy.jpg"); rebecca@13: ofEnableSmoothing(); rebecca@13: ofSetBackgroundAuto(false); andrew@49: ofBackground(255,255,255); andrew@31: // ofEnableAlphaBlending(); rebecca@33: ofSetLineWidth(12); andrew@17: andrew@38: andrew@44: for (int y = 0;y < NUMBER_OF_USERS;y++){ andrew@44: typeOfFaceToUse[y] = y%2; andrew@44: } andrew@31: andrew@47: anubis.loadImage("images/mask1.png");//anubis-wall-mask.gif andrew@47: secondUserImage.loadImage("images/mask2.png");//davy2.jpg" andrew@47: thirdUserImage.loadImage("images/mask3.png");//mubrarksign.jpg andrew@31: andrew@31: franklinBook.loadFont("frabk.ttf", 32); andrew@31: andrew@47: // sender.setup( HOST, PORT ); andrew@45: stopSender.setup( STOPHOST, STOPPORT ); andrew@45: heresySender.setup(HERESY_HOST, HERESY_PORT); andrew@49: mophoSender.setup(STOPHOST, MOPHO_PORT); andrew@45: andrew@17: andrew@38: maxTorsoValues[0] = 0; andrew@38: maxTorsoValues[1] = 0; andrew@38: maxTorsoValues[2] = 0; andrew@38: double timeNow = ofGetElapsedTimeMillis(); andrew@38: for (int user = 0;user < NUMBER_OF_USERS;user++) andrew@38: lastRecordedTime[user] = timeNow; andrew@47: andrew@47: leftMaximum[0] = 700; andrew@47: rebecca@13: } rebecca@13: rebecca@13: //-------------------------------------------------------------- rebecca@13: void testApp::update(){ rebecca@13: rebecca@13: // update the open ni context and user tracker rebecca@13: context.update(); rebecca@13: user.update(); andrew@38: andrew@17: andrew@17: } andrew@17: andrew@17: andrew@31: void testApp::getCoordinates(int userID){ andrew@17: //tracked = user.getTrackedUser(i); andrew@49: if (userID < 0 && userID > 7) andrew@49: cout << "PROBLEM IN NUMBER FOR getCoordinates"; andrew@49: andrew@31: ofxTrackedUser* tracked = user.getTrackedUser(userID); andrew@49: andrew@17: andrew@31: andrew@38: double timeNow = ofGetElapsedTimeMillis(); andrew@38: andrew@38: andrew@38: andrew@38: andrew@38: 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: //printf("tracking time %d and last recorded %d\n", timeNow, lastRecordedTime[userID]); andrew@38: userPresent[userID] = true; andrew@38: lastRecordedTime[userID] = timeNow ; andrew@45: andrew@31: torso[userID][0] = tracked->left_upper_torso.end.x; andrew@31: torso[userID][1] = tracked->left_upper_torso.end.y; andrew@31: torso[userID][2] = tracked->left_upper_torso.end.z; andrew@45: andrew@45: leftHandPosition[userID][0] = tracked->left_lower_arm.end.x; andrew@45: leftHandPosition[userID][1] = tracked->left_lower_arm.end.y; andrew@45: leftHandPosition[userID][2] = tracked->left_lower_arm.end.z; andrew@45: andrew@45: rightHandPosition[userID][0] = tracked->right_lower_arm.end.x; andrew@45: rightHandPosition[userID][1] = tracked->right_lower_arm.end.y; andrew@45: rightHandPosition[userID][2] = tracked->right_lower_arm.end.z; andrew@45: andrew@38: checkTorsoMaxima(userID); andrew@38: andrew@38: //recent track, low distance but do nothing yet andrew@38: } andrew@38: else if(userPresent[userID] && (timeNow - lastRecordedTime[userID]) > 500 ){ andrew@38: //not recent track => stopped andrew@31: userPresent[userID] = false; andrew@38: printf("user %i has STOPPED!\n", userID); andrew@38: torso[userID][0] = tracked->left_upper_torso.end.x; andrew@38: torso[userID][1] = tracked->left_upper_torso.end.y; andrew@38: torso[userID][2] = tracked->left_upper_torso.end.z; andrew@38: andrew@38: sendStopMessageForUser(userID); andrew@49: userInfoString[userID] = "stopped"; andrew@49: andrew@49: //tracked->delete!! andrew@38: andrew@31: } andrew@17: ofSetColor(0x00FF00); andrew@17: outputString = "HeadX : "; andrew@31: outputString += ofToString(torso[0][0]); andrew@47: //franklinBook.drawString(outputString, 100,600); andrew@17: andrew@17: } andrew@17: andrew@38: void testApp::checkTorsoMaxima(int id){ andrew@38: for (int h = 0; h < 3;h++){ andrew@38: if (torso[id][h] > maxTorsoValues[h]) andrew@38: maxTorsoValues[h] = torso[id][h]; andrew@38: } andrew@47: andrew@47: for (int h = 0; h < 3;h++){ andrew@47: if (leftHandPosition[id][h] > leftMaximum[h]) andrew@47: leftMaximum[h] = leftHandPosition[id][h]; andrew@47: } andrew@47: andrew@47: for (int h = 0; h < 3;h++){ andrew@47: if (rightHandPosition[id][h] > rightMaximum[h]) andrew@47: rightMaximum[h] = rightHandPosition[id][h]; andrew@47: } andrew@47: andrew@38: } andrew@38: andrew@31: void testApp::sendDataViaOSC(int userID){ andrew@47: /* andrew@31: ofxOscMessage m; andrew@31: m.setAddress( "/person" ); andrew@31: m.addIntArg( userID ); andrew@38: m.addFloatArg( torso[userID][0]/maxTorsoValues[0] ); andrew@38: m.addFloatArg( torso[userID][1] /maxTorsoValues[1]); andrew@38: m.addFloatArg( torso[userID][2] /maxTorsoValues[2]); andrew@31: sender.sendMessage( m ); andrew@47: */ rebecca@13: } rebecca@13: andrew@38: void testApp::sendStopMessageForUser(int userID){ andrew@38: ofxOscMessage m; andrew@45: m.setAddress( "/stopperson" ); andrew@38: m.addIntArg( userID ); andrew@38: m.addFloatArg( torso[userID][0]/maxTorsoValues[0] ); andrew@38: m.addFloatArg( torso[userID][1] /maxTorsoValues[1]); andrew@38: m.addFloatArg( torso[userID][2] /maxTorsoValues[2]); andrew@38: stopSender.sendMessage( m ); andrew@45: andrew@47: /* andrew@45: ofxOscMessage newMess; andrew@45: newMess.setAddress( "/stopperson" ); andrew@45: newMess.addIntArg( userID ); andrew@45: sender.sendMessage( newMess ); andrew@47: */ andrew@38: } andrew@38: andrew@45: andrew@45: void testApp::sendInformationToHeresy(int userID){ andrew@45: andrew@45: //map to pitches interpolation andrew@45: double zVal = torso[userID][2] /maxTorsoValues[2]; andrew@45: int pitch; andrew@45: if (zVal < 1) andrew@45: pitch = (int)(16 * zVal); andrew@45: else andrew@45: pitch = 15; andrew@45: andrew@45: andrew@45: andrew@49: if (userID < NUMBER_OF_USERS){ andrew@47: double leftHand, rightHand, leftHandX, rightHandX, leftHandY, rightHandY; andrew@47: leftHand = leftHandPosition[userID][0]/leftMaximum[0];//i.e x [position andrew@47: rightHand = rightHandPosition[userID][0]/rightMaximum[0];//same for right andrew@47: andrew@47: andrew@47: leftHandY = leftHandPosition[userID][1]/leftMaximum[1];//i.e. x position but 0 to 1 andrew@47: rightHandY = rightHandPosition[userID][1]/rightMaximum[1];//same for right andrew@47: andrew@47: //THIS IS THE ONLY ROUTINE CALLED andrew@45: //i.e. monophonic andrew@45: andrew@47: // int controlChangeLeft[3][4];//userId, leftX, leftR, rightX, right Y andrew@47: //need to send continuous control change not just when note changes andrew@47: int controlChangeLeft = (int) min((double)127,max((double)0,(leftHand*127))); andrew@47: int controlChangeRight = (int) min((double)127,max((double)0,(rightHand*127))); andrew@47: andrew@47: int controlChangeLeftY = (int)((double)127 - min((double)127,max((double)0,(leftHandY*127)))); andrew@49: int controlChangeRightY = (int)((double)127 - min((double)127,max((double)0,(rightHandY*127)))); andrew@47: andrew@49: if (userID > 0){ //hackoo andrew@49: bool checkNotSame1 = checkSameUserAs(userID, userID + 1 % NUMBER_OF_USERS); andrew@49: bool checkNotSame2 = checkSameUserAs(userID, userID + 2 % NUMBER_OF_USERS); andrew@49: andrew@49: checkingSameUser[userID] = checkSameUserAs(userID, userID + 1 % NUMBER_OF_USERS) || checkSameUserAs(userID, userID + 2 % NUMBER_OF_USERS); andrew@49: } andrew@49: andrew@49: andrew@47: ControlChangeData[userID][0] = controlChangeLeft ; andrew@47: ControlChangeData[userID][1] = controlChangeLeftY ; andrew@47: ControlChangeData[userID][2] = controlChangeRight ; andrew@47: ControlChangeData[userID][3] = controlChangeRightY ; andrew@47: andrew@47: userInfoString[userID] = "USER "; andrew@47: userInfoString[userID] += ofToString(userID+1, 0); andrew@47: userInfoString[userID] += " Pitch "; andrew@47: userInfoString[userID] += ofToString(pitch, 0); andrew@47: andrew@47: userInfoString[userID] += " ccL "; andrew@47: userInfoString[userID] += ofToString(controlChangeLeft, 0); andrew@47: userInfoString[userID] += " , "; andrew@47: userInfoString[userID] += ofToString(controlChangeLeftY, 0); andrew@47: andrew@47: userInfoString[userID] += " ccR "; andrew@47: userInfoString[userID] += ofToString(controlChangeRight, 0); andrew@47: userInfoString[userID] += " , "; andrew@47: userInfoString[userID] += ofToString(controlChangeRightY, 0); andrew@47: andrew@49: if (userID == 0){ andrew@49: sendControlChangeDataToAbleton(userID); andrew@49: } andrew@49: else{ andrew@47: sendControlChangeDataToMax(userID); andrew@49: } andrew@47: andrew@45: if (pitch != pitchPlaying[userID]){ andrew@45: //then we have a change andrew@45: //send note off andrew@45: sendNoteMessageToHeresy(pitchPlaying[userID], 0, 0, userID); andrew@47: printf("note OFF user %i pitch %i \n ", userID+1, pitchPlaying[userID]); andrew@49: andrew@49: //if (!checkingSameUser[userID]){ andrew@49: sendNoteMessageToHeresy(pitch, 1, 127, userID);// int channel){ andrew@49: pitchPlaying[userID] = pitch; andrew@49: //} andrew@45: andrew@47: //now get send control change for the hands XXX TO DO andrew@47: /* andrew@47: leftHand *= 127; andrew@47: rightHand *= 127; andrew@45: andrew@47: */ andrew@47: andrew@47: // printf("note ON user %i pitch %i \n", userID+1, pitch); andrew@45: } andrew@45: } andrew@45: else{ andrew@47: //NO LONGER CALLED - WE SEND JUST MAIN PITCHES TRIGGERED BY BODY POSITION andrew@47: //i.e. for was channel for user 2 and 3 andrew@47: /* andrew@45: double minimum = min(leftHand, rightHand); andrew@45: double maximum = max(leftHand, rightHand); andrew@45: int minPitch = (int) (16 * minimum); andrew@45: int maxPitch = (int) (16 * maximum); andrew@45: minMaxValues[userID][0] = minPitch; andrew@45: minMaxValues[userID][1] = maxPitch; andrew@47: andrew@47: if (maxPitch > 15) andrew@45: maxPitch = 15; andrew@45: andrew@47: userInfoString[userID] = "USER "; andrew@47: userInfoString[userID] += ofToString(userID+1, 0); andrew@47: andrew@47: printf("user %i min %i max %i\n", userID+1, minPitch, maxPitch); andrew@47: andrew@47: userInfoString[userID] += "min "; andrew@47: userInfoString[userID] += ofToString(minPitch, 0); andrew@47: userInfoString[userID] += "max "; andrew@47: userInfoString[userID] += ofToString(maxPitch, 0); andrew@47: andrew@45: for (int p = 0;p < 16;p++){ andrew@45: andrew@45: if (p < minPitch || p > maxPitch){ andrew@45: //sendNoteMessageToHeresy(p, 0, 0, userID); andrew@45: nowPlaying[userID][p] = false; andrew@45: } andrew@45: else{ andrew@45: nowPlaying[userID][p] = true; andrew@45: } andrew@45: andrew@45: andrew@45: if (nowPlaying[userID][p] != lastPlaying[userID][p]){ andrew@45: if (nowPlaying[userID][p]) andrew@45: { andrew@47: //sendNoteMessageToHeresy(p, 1, 127, userID); andrew@45: lastPlaying[userID][p] = true; andrew@45: } andrew@45: else { andrew@47: //sendNoteMessageToHeresy(p, 0, 0, userID); andrew@45: lastPlaying[userID][p] = false; andrew@45: } andrew@45: } andrew@47: }//end for p andrew@47: */ andrew@47: }//end else - not called! andrew@45: andrew@45: andrew@45: andrew@45: andrew@45: andrew@45: //x and y get sent to max after being mapped 0 to 127 andrew@45: //these are control change messages andrew@45: //cvan be sent straight to max andrew@45: int xVal, yVal; andrew@45: xVal = (int)(127 * torso[userID][0]/maxTorsoValues[0] ); andrew@45: yVal = (int)(127 * torso[userID][1]/maxTorsoValues[1] ); andrew@45: andrew@45: andrew@45: andrew@45: } andrew@45: andrew@47: andrew@49: bool testApp::checkSameUserAs(int userID, int checkID){ andrew@49: bool check = false; andrew@49: andrew@49: if (rightHandPosition[userID][0] == rightHandPosition[checkID][0] && leftHandPosition[userID][0] == leftHandPosition[checkID][0]) andrew@49: check = true; andrew@49: andrew@49: return check; andrew@49: andrew@49: } andrew@47: andrew@47: andrew@47: andrew@45: void testApp::sendNoteMessageToHeresy(int noteNumber, int onOrOff, int velocity, int channel){ andrew@45: channel++; andrew@45: andrew@45: ofxOscMessage m; andrew@45: m.setAddress( "/test" ); andrew@45: m.addStringArg("note"); andrew@45: m.addIntArg( noteNumber ); andrew@45: m.addIntArg( onOrOff ); andrew@45: m.addIntArg( velocity ); andrew@45: m.addIntArg( channel ); andrew@45: heresySender.sendMessage( m ); andrew@45: andrew@45: andrew@45: } andrew@45: andrew@45: andrew@47: void testApp::sendControlChangeDataToMax(int userID){ andrew@47: int channel = userID+1; andrew@47: andrew@47: ofxOscMessage m; andrew@47: m.setAddress( "/controlChangeData" ); andrew@47: m.addIntArg( channel ); andrew@47: m.addIntArg( ControlChangeData[userID][0] ); andrew@47: m.addIntArg( ControlChangeData[userID][1] ); andrew@47: m.addIntArg( ControlChangeData[userID][2] ); andrew@47: m.addIntArg( ControlChangeData[userID][3] ); andrew@47: stopSender.sendMessage( m ); andrew@47: andrew@47: } andrew@47: andrew@49: void testApp::sendControlChangeDataToAbleton(int userID){ andrew@49: int channel = userID+1; andrew@49: andrew@49: ofxOscMessage m; andrew@49: m.setAddress( "/controlChangeData" ); andrew@49: m.addIntArg( channel ); andrew@49: m.addIntArg( ControlChangeData[userID][0] ); andrew@49: m.addIntArg( ControlChangeData[userID][1] ); andrew@49: m.addIntArg( ControlChangeData[userID][2] ); andrew@49: m.addIntArg( ControlChangeData[userID][3] ); andrew@49: mophoSender.sendMessage( m ); andrew@49: andrew@49: } andrew@49: rebecca@13: //-------------------------------------------------------------- rebecca@13: void testApp::draw(){ andrew@49: ofBackground(255,255,255); rebecca@13: rebecca@13: // draw depth and rgb images rebecca@13: //depth.draw(); rebecca@13: if (drawIt != true) { rebecca@13: image.draw(); rebecca@13: user.draw(); rebecca@13: } rebecca@13: // draw all the users automatically? rebecca@13: rebecca@13: rebecca@13: andrew@31: rebecca@13: stringstream info; rebecca@13: info << "number of tracked users: " << user.getNumTrackedUsers() << endl; rebecca@13: andrew@49: //string numString = "num tracked users is "; andrew@49: //numString += ofToString(user.getNumTrackedUsers()); andrew@49: //franklinBook.drawString(numString, 60, 60); andrew@49: rebecca@13: // draw the neck positions of each user andrew@49: for(int i = 0; i < user.getNumTrackedUsers(); ++i) {// andrew@47: rebecca@13: ofxTrackedUser* tracked = user.getTrackedUser(i); andrew@47: rebecca@13: if(tracked != NULL) { andrew@38: andrew@17: //andrews code andrew@17: int userID = i; andrew@49: // printf("user %i \n", userID); andrew@49: int tmpID = userID; andrew@49: userID = userID % NUMBER_OF_USERS;//hack andrew@49: andrew@49: if (userID < NUMBER_OF_USERS){// && !checkingSameUser[userID] andrew@17: andrew@31: getCoordinates(userID); andrew@31: andrew@31: andrew@31: if (userPresent[userID]){ andrew@47: // sendDataViaOSC(userID); andrew@45: sendInformationToHeresy(userID); andrew@49: andrew@31: andrew@31: ofSetColor(0x000000); andrew@31: outputString = "Us "; andrew@31: outputString += ofToString(userID); andrew@31: outputString += " "; andrew@31: outputString += ofToString(userPresent[userID]); andrew@31: outputString += "HeadX : "; andrew@31: outputString += ofToString(torso[userID][0], 2); andrew@17: outputString += " HeadY : "; andrew@31: outputString += ofToString(torso[userID][1], 2); andrew@17: outputString += " HeadZ : "; andrew@31: outputString += ofToString(torso[userID][2], 2); andrew@47: andrew@47: franklinBook.drawString(outputString, 100,600+userID*160); andrew@17: andrew@47: andrew@47: outputString = "LeftX : "; andrew@47: outputString += ofToString(leftHandPosition[userID][0], 2); andrew@47: outputString += " LeftY : "; andrew@47: outputString += ofToString(leftHandPosition[userID][1], 2); andrew@47: outputString += " LeftZ : "; andrew@47: outputString += ofToString(leftHandPosition[userID][2], 2); andrew@47: andrew@47: franklinBook.drawString(outputString, 100,640+userID*160); andrew@47: andrew@47: outputString = "RightX : "; andrew@47: outputString += ofToString(rightHandPosition[userID][0], 2); andrew@47: outputString += " LeftY : "; andrew@47: outputString += ofToString(rightHandPosition[userID][1], 2); andrew@47: outputString += " LeftZ : "; andrew@47: outputString += ofToString(rightHandPosition[userID][2], 2); andrew@47: andrew@47: franklinBook.drawString(outputString, 100,680+userID*160); andrew@47: andrew@47: outputString = "MaxX: "; andrew@47: outputString += ofToString(maxTorsoValues[0], 2); andrew@47: outputString += " MaxY: "; andrew@47: outputString += ofToString(maxTorsoValues[1], 2); andrew@47: outputString += " MaxZ: "; andrew@47: outputString += ofToString(maxTorsoValues[2], 2); andrew@47: andrew@47: andrew@47: franklinBook.drawString(outputString, 100,720+userID*160); andrew@17: andrew@47: andrew@49: // ofSetColor(0,0,255); andrew@49: // ofCircle(tracked->neck.begin.x, tracked->neck.begin.y , 40); andrew@31: andrew@31: andrew@47: andrew@47: ofSetColor(255,255,255); andrew@49: float scalingFactor = 0.75 * 1500 / tracked->neck.begin.z ; andrew@47: switch (userID){ andrew@49: //x was - anubis.width*scalingFactor /2 andrew@49: //y was - anubis.height*scalingFactor /2 andrew@47: case 0: andrew@49: 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: break; andrew@47: case 1: andrew@49: 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: break; andrew@47: case 2: andrew@49: 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: break; andrew@49: default: andrew@49: drawAcidSmiley(userID); andrew@49: break; andrew@47: andrew@47: }//end switch user image andrew@47: andrew@47: }//end if is present andrew@31: andrew@17: } andrew@17: andrew@17: //end andrew andrew@38: rebecca@13: info << i << " neck pos: " rebecca@13: << tracked->left_lower_arm.end.x << " " rebecca@13: << tracked->left_lower_arm.end.y << " " rebecca@13: << tracked->neck.begin.z << endl; andrew@38: andrew@31: andrew@17: if (tracked->neck.begin.x != 0) rebecca@13: andrew@38: andrew@17: ofSetColor(139,0,0,100); rebecca@33: andrew@17: ofNoFill(); andrew@17: float w = ofGetWidth(); andrew@17: float h = ofGetHeight(); andrew@32: andrew@44: /* andrew@44: if (typeOfFaceToUse[userID] == 1) andrew@44: bezierFunctionStuff(userID); andrew@44: else andrew@44: drawAcidSmiley(userID); andrew@44: */ andrew@44: } andrew@47: ofSetColor(0,0,0); andrew@47: for (int userNumber = 0;userNumber < 3;userNumber++){ andrew@49: franklinBook.drawString(userInfoString[userNumber], 660, (userNumber*60)+60); andrew@47: } andrew@47: andrew@44: } andrew@39: andrew@31: andrew@31: //faint rectangle? rebecca@13: ofFill(); rebecca@13: ofSetColor(238,238,224,20); andrew@31: // ofRect(0,0,ofGetWidth(),ofGetHeight()); blurring rebecca@13: ofDrawBitmapString(info.str(), 10, 500); andrew@31: rebecca@13: } rebecca@13: rebecca@13: //-------------------------------------------------------------- rebecca@13: void testApp::keyPressed(int key){ andrew@49: // if (key=='r') andrew@49: // ofxUserGenerator::setup(context, depth); andrew@49: // else { andrew@49: ofSetColor(238,238,224); andrew@49: ofRect(0,0,ofGetWidth(),ofGetHeight()); andrew@49: // drawIt =!drawIt; andrew@49: ofToggleFullscreen(); andrew@49: andrew@49: //sendDataViaOSC(0); andrew@49: // } rebecca@13: } rebecca@13: rebecca@13: //-------------------------------------------------------------- rebecca@13: void testApp::keyReleased(int key){ rebecca@13: rebecca@13: } rebecca@13: rebecca@13: //-------------------------------------------------------------- rebecca@13: void testApp::mouseMoved(int x, int y ){ rebecca@13: rebecca@13: } rebecca@13: rebecca@13: //-------------------------------------------------------------- rebecca@13: void testApp::mouseDragged(int x, int y, int button){ rebecca@13: rebecca@13: } rebecca@13: rebecca@13: //-------------------------------------------------------------- rebecca@13: void testApp::mousePressed(int x, int y, int button){ rebecca@13: ofSetColor(238,238,224); rebecca@13: ofFill(); rebecca@13: ofRect(0,0,ofGetWidth(),ofGetHeight()); andrew@45: andrew@45: int pitch = (int) ofRandom(0, 15); andrew@47: //sendNoteMessageToHeresy(pitch, 1, 127, 1); rebecca@13: } rebecca@13: rebecca@13: //-------------------------------------------------------------- rebecca@13: void testApp::mouseReleased(int x, int y, int button){ rebecca@13: rebecca@13: } rebecca@13: rebecca@13: //-------------------------------------------------------------- rebecca@13: void testApp::windowResized(int w, int h){ rebecca@13: rebecca@13: } rebecca@13: andrew@44: andrew@44: void testApp::bezierFunctionStuff(int i){ andrew@44: andrew@44: ofxTrackedUser* tracked = user.getTrackedUser(i); andrew@44: float w = ofGetWidth(); andrew@44: float h = ofGetHeight(); andrew@44: andrew@44: ofFill(); andrew@44: andrew@44: ofBezier(tracked->neck.begin.x, andrew@44: tracked->neck.begin.y, andrew@44: tracked->neck.end.x, andrew@44: tracked->neck.end.y, andrew@44: tracked->left_lower_arm.begin.x, andrew@44: tracked->left_lower_arm.begin.y, andrew@44: tracked->left_lower_arm.end.x, andrew@44: /*tracked->left_lower_arm.end.y*/ w); andrew@44: andrew@44: ofBezier(tracked->neck.begin.x, andrew@44: tracked->neck.begin.y, andrew@44: tracked->neck.end.x, andrew@44: tracked->neck.end.y, andrew@44: tracked->right_lower_arm.begin.x, andrew@44: tracked->right_lower_arm.begin.y, andrew@44: tracked->right_lower_arm.end.x, andrew@44: /*tracked->right_lower_arm.end.y*/ w); andrew@44: andrew@44: ofBezier(tracked->neck.begin.x, andrew@44: tracked->neck.begin.y, andrew@44: tracked->neck.end.x, andrew@44: tracked->neck.end.y, andrew@44: tracked->left_lower_leg.begin.x, andrew@44: tracked->left_lower_leg.begin.y, andrew@44: tracked->left_lower_leg.end.x, andrew@44: /*tracked->left_lower_leg.end.y*/ h); andrew@44: andrew@44: ofBezier(tracked->neck.begin.x, andrew@44: tracked->neck.begin.y, andrew@44: tracked->neck.end.x, andrew@44: tracked->neck.end.y, andrew@44: tracked->right_lower_leg.begin.x, andrew@44: tracked->right_lower_leg.begin.y, andrew@44: tracked->right_lower_leg.end.x, andrew@44: /*tracked->right_lower_leg.end.y*/ h); andrew@44: andrew@44: andrew@44: 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: 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: 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: 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: andrew@44: andrew@44: } andrew@44: andrew@44: void testApp::drawAcidSmiley(int i){ andrew@44: //acid smiley andrew@44: andrew@44: ofxTrackedUser* tracked = user.getTrackedUser(i); andrew@44: float w = ofGetWidth(); andrew@44: float h = ofGetHeight(); andrew@44: andrew@44: andrew@44: ofFill(); andrew@44: andrew@44: ofSetColor(255,255,100); andrew@44: ofCircle(tracked->neck.begin.x,tracked->neck.begin.y,30); andrew@44: ofSetColor(0); andrew@44: ofCircle(tracked->neck.begin.x,tracked->neck.begin.y,35); andrew@44: ofSetColor(255,255,100); andrew@44: ofCircle(tracked->neck.begin.x,tracked->neck.begin.y,30); andrew@44: ofSetColor(0); andrew@44: ofCircle(tracked->neck.begin.x+10.0f,tracked->neck.begin.y,6); andrew@44: ofCircle(tracked->neck.begin.x-10.0f,tracked->neck.begin.y,6); andrew@44: andrew@44: andrew@44: andrew@44: }