//-------------------------------------------------------------- void gFrameApp::tuioUpdated(ofxTuioCursor &cursor) { if(input_tuio) { GPoint the_point; float x,y; x = cursor.getX(); y = cursor.getY(); the_point.setLocation(ofVec2f(x, y)); the_point.setId(cursor.getFingerId()); the_point.setStrokeId(cursor.getSessionId()); the_point.setColor(localBrushColor); the_point.setType(TUIO); the_point.setStyle(current_style); stroke_list.add(the_point); finger_positions[cursor.getFingerId()] = ofVec2f(x, y); //flowfield simple_flow.inputUpdate(x, y, cursor.getFingerId()); simple_flow_2.inputUpdate(x, y, cursor.getFingerId()); ledFrame.stopPulsing(); ledFrame.updateLastPointsTime(); } }
void testApp::tuioAdded(ofxTuioCursor& tuioCursor) { log = " new cursor: "; log += ofToString(tuioCursor.getFingerId()); log += " X: " + ofToString(tuioCursor.getX()); log += " Y: " + ofToString(tuioCursor.getY()); }
void testApp::tuioUpdated(ofxTuioCursor& tuioCursor) { log = " cursor updated: "; log += ofToString(tuioCursor.getFingerId()); log += " X: " + ofToString(tuioCursor.getX()); log += " Y: " + ofToString(tuioCursor.getY()); }
void ofxMtPhoto::tuioRemoved(ofxTuioCursor &tuioCursor){ ofVec2f loc = ofVec2f(tuioCursor.getX()*ofGetWidth(),tuioCursor.getY()*ofGetHeight()); for (int i = 0; i < cursorsOnBorder.size(); i++ ) if (cursorsOnBorder[i].idN == tuioCursor.getSessionId()) cursorsOnBorder.erase(cursorsOnBorder.begin()+i); }
void testApp::tuioUpdated(ofxTuioCursor &tuioCursor){ ofLog()<< "tuioUpdated" << endl; int mx = W_WIDTH*tuioCursor.getX(); int my = W_HEIGHT*tuioCursor.getY(); ofPoint loc = ofPoint(tuioCursor.getX()*W_WIDTH,tuioCursor.getY()*W_HEIGHT); //cout << "Point n" << tuioCursor.getSessionId() << " updated at " << loc << endl; //o1.slide(loc.x, loc.y,tuioCursor.getSessionId(),tuioCursor.getMotionAccel()); // h1.slide(loc.x, loc.y,tuioCursor.getSessionId(),tuioCursor.getMotionAccel()); touchElements.notifySlide(loc.x, loc.y,tuioCursor.getSessionId(),tuioCursor.getMotionAccel()); puntoX=tuioCursor.getX(); puntoY=tuioCursor.getY(); cout << tuioCursor.getX() << endl; }
void FractalTreeApp::tuioUpdated(ofxTuioCursor &tuioCursor){ ofPoint addedCursor(tuioCursor.getX()*ofGetWidth(), tuioCursor.getY()*ofGetHeight()); addedCursor = toLocalAxisSystem(addedCursor); IC = addedCursor; }
void ofApp::tuioAdded(ofxTuioCursor &tuioCursor) { tuioPoints.push_back(tuioContainer()); tuioPoints.back().sid = tuioCursor.getSessionId(); tuioPoints.back().location.set(tuioCursor.getX(), tuioCursor.getY()); tuioPoints.back().setLastLocation(); }
//-------------------------------------------------------------- void ofApp::tuioUpdated(ofxTuioCursor &cursor){ Finger& f = finger[cursor.getFingerId()]; ofPoint loc = ofPoint(cursor.getX()*ofGetWidth(),cursor.getY()*ofGetHeight()); // save the active value because it will be overwritten after the update bool wasActive = f.isActive(); f.update(loc); // make a new ray if the speed is high enough, the finger was active and if the finger hasn't triggered anything lately if(f.getDirection().length() > triggerSpeed && wasActive && f.getTimeSinceLastTriggered() > triggerTimeout){ f.triggered(); ParticleRay r = ParticleRay(f.getPosition(), f.getDirection().scale(particleSpeed)); // check if we need to create a new ray or if an old one can be reused // this could very well be coded more efficiently... int i = 0; for(i = 0; i< rays.size(); i++){ if(rays[i].isDead()){ break; } } if(i < rays.size()){ rays[i] = r; } else{ rays.push_back(r); } } // ledFrame.stopPulsing(); ledFrame.updateLastPointsTime(); }
ofPoint menu::transf_PosTUIO(ofxTuioCursor & tuioCursor) { int mx = W_WIDTH*tuioCursor.getX() + (ofGetScreenWidth()-W_WIDTH)/2.0; int my = W_HEIGHT*tuioCursor.getY(); // ofPoint loc = ofPoint(mx,my); return ofPoint(mx,my); }
void electromagnetica::tuioUpdated(ofxTuioCursor &tuioCursor){ int mx = W_WIDTH*tuioCursor.getX(); int my = W_HEIGHT*tuioCursor.getY(); hands.notifySlide(mx, my,tuioCursor.getSessionId(),tuioCursor.getMotionAccel()); wavesm.slide(mx, my,tuioCursor.getSessionId(),tuioCursor.getMotionAccel()); // updateMagneticField(100,mx,my); }
void testApp::tuioUpdated(ofxTuioCursor & tuioCursor) { //TODO add linemake function and update object #ifdef DEBUG log="Cursor Updated: "+ofToString(tuioCursor.getFingerId())+ " X: "+ofToString(tuioCursor.getX())+ " Y: "+ofToString(tuioCursor.getY()); ofLog()<<log; #endif }
void FractalTreeApp::tuioAdded(ofxTuioCursor &tuioCursor){ //TODO: Check Menu Items ofPoint addedCursor(tuioCursor.getX()*ofGetWidth(), tuioCursor.getY()*ofGetHeight()); addedCursor = toLocalAxisSystem(addedCursor); }
//call when finger is moved void testApp::tuioAdded(ofxTuioCursor & tuioCursor) { //TODO add function that runs when finger added #ifdef DEBUG log="New Cursor: "+ofToString(tuioCursor.getFingerId())+ " X: "+ofToString(tuioCursor.getX())+ " Y: "+ofToString(tuioCursor.getY()); ofLog()<<log; #endif }
void ofApp::tuioUpdated(ofxTuioCursor &tuioCursor) { // ofPoint loc = ofPoint(tuioCursor.getX()*ofGetWidth(),tuioCursor.getY()*ofGetHeight()); int cursorIndex = getTuioPointIndex(tuioCursor.getSessionId()); if (cursorIndex < 0) { return; } tuioPoints.at(cursorIndex).setLastLocation(); tuioPoints.at(cursorIndex).location.set(tuioCursor.getX(), tuioCursor.getY()); }
void ofxLayout::tuioUpdated(ofxTuioCursor &tuioCursor) { if(tuioCursor.getFingerId() == 0){ if (touchReady){ ofPoint loc = ofPoint(tuioCursor.getX()*ofGetWidth(),tuioCursor.getY()*ofGetHeight()); mouseDraggedPt = ofPoint(loc)*mouseTransformation; ofxLayoutElement* mouseDraggedElement = hittest(mouseDraggedPt); mouseDraggedElement->fingerDragged(loc); string evtStr = "mouseDragged"; ofNotifyEvent(mouseDraggedEvt, evtStr, mouseDraggedElement); ofNotifyEvent(tuioCursorUpdatedEvt, tuioCursor, mouseDraggedElement); } } }
void electromagnetica::tuioRemoved(ofxTuioCursor &tuioCursor){ ofPoint loc = ofPoint(tuioCursor.getX()*W_WIDTH,tuioCursor.getY()*W_HEIGHT); //cout << "Point n" << tuioCursor.getSessionId() << " remove at " << loc << endl; /* if(id_slider1==tuioCursor.getSessionId()) id_slider1=NULL; if(id_jumpingRect==tuioCursor.getSessionId()) id_jumpingRect=NULL; if(id_moverect==tuioCursor.getSessionId()) id_moverect=NULL;*/ hands.removeObjectByTuioID(tuioCursor.getSessionId() ); wavesm.touchUp(tuioCursor.getSessionId()); cheapComm::getInstance()->sendAudio0("/audio/electromagnetism/hand_off_event"); }
//call when finger is removed from Ideatable void testApp::tuioRemoved(ofxTuioCursor & tuioCursor) { //remove line which is related to the finger for(line_itr=lines.begin(); line_itr!=lines.end(); line_itr++) { if((*line_itr).getCursorID()==tuioCursor.getFingerId()) lines.erase(line_itr); } prevStatus.erase(tuioCursor.getFingerId()); #ifdef DEBUG log="Cursor Removed: "+ofToString(tuioCursor.getFingerId())+ " X: "+ofToString(tuioCursor.getX())+ " Y: "+ofToString(tuioCursor.getY()); ofLog()<<log; #endif }
// FINGER ADDED //////////////////////////////////////////////////////// void testApp::cursorAdded(ofxTuioCursor & tuioCursor) { int finger_id = tuioCursor.getFingerId(); pos.x = wQuadro * tuioCursor.getX(); pos.y = hQuadro * tuioCursor.getY(); dito = new Finger(finger_id); dito_list.push_back(dito); dito_list.back()->setup(&pos, blue); dito_list.back()->added(); }
void testApp::tuioAdded(ofxTuioCursor &tuioCursor){ ofLog()<< "tuioAdded" << endl; ofPoint loc = ofPoint(tuioCursor.getX()*W_WIDTH,tuioCursor.getY()*W_HEIGHT); cout << "Point n" << tuioCursor.getSessionId() << " add at " << tuioCursor.getX() << " " << tuioCursor.getY()<< endl; // o1.touch(loc.x, loc.y,tuioCursor.getSessionId()); // h1.touch(loc.x, loc.y,tuioCursor.getSessionId()); handShadow *h1 = new handShadow(); h1->setup(); touchElements.addObject(*h1); touchElements.notifyTouch(loc.x, loc.y,tuioCursor.getSessionId()); }
void testApp::tuioRemoved(ofxTuioCursor &tuioCursor){ ofLog()<< "tuioRemoved" << endl; ofPoint loc = ofPoint(tuioCursor.getX()*W_WIDTH,tuioCursor.getY()*W_HEIGHT); //cout << "Point n" << tuioCursor.getSessionId() << " remove at " << loc << endl; /* if(id_slider1==tuioCursor.getSessionId()) id_slider1=NULL; if(id_jumpingRect==tuioCursor.getSessionId()) id_jumpingRect=NULL; if(id_moverect==tuioCursor.getSessionId()) id_moverect=NULL;*/ touchElements.removeObjectByTuioID(tuioCursor.getSessionId() ); touchElements.notifyTouchUp( tuioCursor.getSessionId() ); }
void ofxLayout::tuioRemoved(ofxTuioCursor &tuioCursor) { if(tuioCursor.getFingerId() == 0) { ofPoint loc = ofPoint(tuioCursor.getX()*ofGetWidth(),tuioCursor.getY()*ofGetHeight()); mouseDraggedPt.set(ofPoint()); mouseReleasedPt = loc*mouseTransformation; ofxLayoutElement* mouseReleasedElement = hittest(mouseReleasedPt); mouseReleasedElement->fingerReleased(loc); string evtStr = "mouseReleased"; ofNotifyEvent(mouseReleasedEvt, evtStr, mouseReleasedElement); ofNotifyEvent(tuioCursorRemovedEvt, tuioCursor, mouseReleasedElement); touchReadyCheck(); } }
// FINGER REMOVED ////////////////////////////////////////////////////// void testApp::cursorRemoved(ofxTuioCursor & tuioCursor) { int finger_id = tuioCursor.getFingerId(); pos.x = wQuadro * tuioCursor.getX(); pos.y = hQuadro * tuioCursor.getY(); list<Finger*>::iterator it; for (it=dito_list.begin(); it !=dito_list.end(); ++it) { if ( (*it)->get_finger_id() == finger_id) { (*it)->removed(); break; } } dito_list.erase(it); }
// FINGER UPDATED ////////////////////////////////////////////////////// void testApp::cursorUpdated(ofxTuioCursor & tuioCursor) { int finger_id = tuioCursor.getFingerId(); pos.x = wFbo * tuioCursor.getX(); pos.y = hFbo * tuioCursor.getY(); int x_speed = tuioCursor.getXSpeed(); int y_speed = tuioCursor.getYSpeed(); int motion_speed = tuioCursor.getMotionSpeed(); int motion_accel = tuioCursor.getMotionAccel(); for (list<Finger*>::iterator it=dito_list.begin(); it !=dito_list.end(); ++it) { if ( (*it)->get_finger_id() == finger_id) { (*it)->update_interrupt(&pos); break; } } }
void electromagnetica::tuioAdded(ofxTuioCursor &tuioCursor){ ofPoint loc = ofPoint(tuioCursor.getX()*W_WIDTH,tuioCursor.getY()*W_HEIGHT); //cout << "Point n" << tuioCursor.getSessionId() << " add at " << loc << endl; // o1.touch(loc.x, loc.y,tuioCursor.getSessionId()); // h1.touch(loc.x, loc.y,tuioCursor.getSessionId()); noiseShadow *h1 = new noiseShadow(); h1->setup(); //h1->setColor(colours[(int)( tuioCursor.getSessionId() % colours.size()-1) ]); // h1->setColor(ofColor::black); hands.addObject(*h1); hands.notifyTouch(loc.x, loc.y,tuioCursor.getSessionId()); //mwave.addPoint(loc.x,loc.y,tuioCursor.getSessionId()); wavesm.touch(loc.x, loc.y,tuioCursor.getSessionId()); // updateMagneticField(100,loc.x,loc.y); cheapComm::getInstance()->sendAudio0("/audio/electromagnetism/hand_on_event"); }
void ofxMtPhoto::tuioAdded(ofxTuioCursor &tuioCursor){ ofVec2f loc = ofVec2f(tuioCursor.getX()*ofGetWidth(),tuioCursor.getY()*ofGetHeight()); if (isOver(loc)){ tCursor c; c.idN = tuioCursor.getSessionId(); c.loc = loc; // PRIMER dedo sobre la imagen if (cursorsOnBorder.size() == 0){ cursorsOnBorder.push_back(c); } // SEGUNDO dedo sobre la imagen else if (cursorsOnBorder.size() == 1){ cursorsOnBorder.push_back(c); oldLoc[0] = cursorsOnBorder[0].loc; oldLoc[1] = cursorsOnBorder[1].loc; } } }
void testApp::tuioUpdated(ofxTuioCursor & tuioCursor){ //カーソル状態更新 log = " cursor updated: " + ofToString(tuioCursor.getFingerId())+ " X: "+ofToString(tuioCursor.getX())+ " Y: "+ofToString(tuioCursor.getY()); }
void testApp::tuioRemoved(ofxTuioCursor & tuioCursor){ //カーソル削除 log = " cursor removed: " + ofToString(tuioCursor.getFingerId())+ " X: "+ofToString(tuioCursor.getX())+ " Y: "+ofToString(tuioCursor.getY()); }
void testApp::tuioAdded(ofxTuioCursor & tuioCursor){ //カーソル追加 log = " new cursor: " + ofToString(tuioCursor.getFingerId())+ " X: "+ofToString(tuioCursor.getX())+ " Y: "+ofToString(tuioCursor.getY()); }
void ofxMtPhoto::tuioUpdated(ofxTuioCursor &tuioCursor){ ofVec2f loc = ofVec2f(tuioCursor.getX()*ofGetWidth(),tuioCursor.getY()*ofGetHeight()); if ( isOver(loc) ){ // ACTUALIZA la LOCacion de los dedos grabados for ( int i = 0; i < cursorsOnBorder.size(); i++) if (cursorsOnBorder[i].idN == tuioCursor.getSessionId()) cursorsOnBorder[i].loc = loc; // Si hay un sólo dedo -> mueve la imagen if (cursorsOnBorder.size() == 1 ) { // ofVec2f newForce = cursorsOnBorder[0].loc - oldLoc[0]; // newForce.normalize(); // Lo normalizo para q la velocidad no se dispare // acc += newForce; // oldLoc[0] = cursorsOnBorder[0].loc; pos = loc; } // Si hay dos Dedos -> gira, escala y mueve else if (cursorsOnBorder.size() == 2) { vel *= 0.5; // Si lo agarra con dos dedos frena la velocidad que tenía de forma dramática int sta = -1; // algo como un NULL parameter int din = -1; // algo como un NULL parameter // encuentra cual es el estático y el dinámico for ( int i = 0; i < cursorsOnBorder.size(); i++) if (cursorsOnBorder[i].loc == oldLoc[i]) sta = i; else din = i; // una vez encontrados, calcula las transformaciones if ((sta != -1) && (din != -1) && (din != sta)){ // Recupera la Direccion, distancia y rotacion VIEJA ofVec2f Di = oldLoc[sta] - oldLoc[din]; float di = Di.length(); float ri = -1*atan2(Di.x,Di.y)+(PI/2); // Obtiene la Direccion, distancia y rotacion NUEVA ofVec2f Dii = oldLoc[sta] - cursorsOnBorder[din].loc; float dii = Dii.length(); float rii = -1*atan2(Dii.x,Dii.y)+(PI/2); // Calcula el porcentaje ( de 0 a 1) de re-escalamiento float scaleF = dii / di; // (<#float value#>, , <#float inputMax#>, <#float outputMin#>, <#float outputMax#>, <#bool clamp#>) ; // Calcula los grados de rotación float rotateF = rii - ri; // Calcula el desplazamiento a partir de coordenadas polares. ofVec2f oldStaCursorToCenter = pos - oldLoc[sta] ; float oldAngleToCenter = -1*atan2(oldStaCursorToCenter.x,oldStaCursorToCenter.y)+(PI/2); float oldRadioToCenter = oldStaCursorToCenter.length(); float newRadioToCenter = oldRadioToCenter * scaleF; float newAngleToCenter = oldAngleToCenter + rotateF; ofVec2f newStaCursorToCenter = ofVec2f(newRadioToCenter*cos(newAngleToCenter),newRadioToCenter*sin(newAngleToCenter)); // Actualiza los valores resize(scaleF); rotate(rotateF); pos = oldLoc[sta] + newStaCursorToCenter; } oldLoc[0] = cursorsOnBorder[0].loc; oldLoc[1] = cursorsOnBorder[1].loc; } } }
void testApp::tuioRemoved(ofxTuioCursor &tuioCursor){ ofPoint loc = ofPoint(tuioCursor.getX()*ofGetWidth(),tuioCursor.getY()*ofGetHeight()); cout << "Point n" << tuioCursor.getSessionId() << " remove at " << loc << endl; }