//draw them for debug purposes void ofxTuioServer::drawCursors() { char id[3]; // draw the cursors std::list<TuioCursor*> cursorList = tuioServer->getTuioCursors(); for (std::list<TuioCursor*>::iterator tuioCursor = cursorList.begin(); tuioCursor!=cursorList.end(); tuioCursor++) { TuioCursor * tcur = (*tuioCursor); std::list<TuioPoint> path = tcur->getPath(); if (path.size()>0) { TuioPoint last_point = path.front(); glBegin(GL_LINES); glColor3f(0.0, 0.0, 1.0); for (std::list<TuioPoint>::iterator point = path.begin(); point!=path.end(); point++) { glVertex3f(last_point.getX()*ofGetWidth(), last_point.getY()*ofGetHeight(), 0.0f); glVertex3f(point->getX()*ofGetWidth(), point->getY()*ofGetHeight(), 0.0f); last_point.update(point->getX(),point->getY()); } glEnd(); // draw the finger tip glColor3f(0.0, 0.75, 0.75); //float size = tcur->getWidth() + tcur ofCircle(tcur->getX()*ofGetWidth(), tcur->getY()*ofGetHeight(), 10); } } }
void TuioDemo::drawObjects() { glClear(GL_COLOR_BUFFER_BIT); char id[3]; // draw the cursors std::list<TuioCursor*> cursorList = tuioClient->getTuioCursors(); tuioClient->lockCursorList(); for (std::list<TuioCursor*>::iterator iter = cursorList.begin(); iter!=cursorList.end(); iter++) { TuioCursor *tuioCursor = (*iter); std::list<TuioPoint> path = tuioCursor->getPath(); if (path.size()>0) { TuioPoint last_point = path.front(); glBegin(GL_LINES); glColor3f(0.0, 0.0, 1.0); for (std::list<TuioPoint>::iterator point = path.begin(); point!=path.end(); point++) { glVertex3f(last_point.getScreenX(width), last_point.getScreenY(height), 0.0f); glVertex3f(point->getScreenX(width), point->getScreenY(height), 0.0f); last_point.update(point->getX(),point->getY()); } glEnd(); // draw the finger tip glColor3f(0.75, 0.75, 0.75); glPushMatrix(); glTranslatef(last_point.getScreenX(width), last_point.getScreenY(height), 0.0); glBegin(GL_TRIANGLE_FAN); for(double a = 0.0f; a <= 2*M_PI; a += 0.2f) { glVertex2d(cos(a) * height/100.0f, sin(a) * height/100.0f); } glEnd(); glPopMatrix(); glColor3f(0.0, 0.0, 0.0); glRasterPos2f(tuioCursor->getScreenX(width),tuioCursor->getScreenY(height)); sprintf(id,"%d",tuioCursor->getCursorID()); drawString(id); } } tuioClient->unlockCursorList(); // draw the objects std::list<TuioObject*> objectList = tuioClient->getTuioObjects(); tuioClient->lockObjectList(); for (std::list<TuioObject*>::iterator iter = objectList.begin(); iter!=objectList.end(); iter++) { TuioObject *tuioObject = (*iter); int pos_size = height/25.0f; int neg_size = -1*pos_size; float xpos = tuioObject->getScreenX(width); float ypos = tuioObject->getScreenY(height); float angle = tuioObject->getAngleDegrees(); glColor3f(0.0, 0.0, 0.0); glPushMatrix(); glTranslatef(xpos, ypos, 0.0); glRotatef(angle, 0.0, 0.0, 1.0); glBegin(GL_QUADS); glVertex2f(neg_size, neg_size); glVertex2f(neg_size, pos_size); glVertex2f(pos_size, pos_size); glVertex2f(pos_size, neg_size); glEnd(); glPopMatrix(); glColor3f(1.0, 1.0, 1.0); glRasterPos2f(xpos,ypos+5); sprintf(id,"%d",tuioObject->getSymbolID()); drawString(id); } tuioClient->unlockObjectList(); // draw the blobs std::list<TuioBlob*> blobList = tuioClient->getTuioBlobs(); tuioClient->lockBlobList(); for (std::list<TuioBlob*>::iterator iter = blobList.begin(); iter!=blobList.end(); iter++) { TuioBlob *tuioBlob = (*iter); float blob_width = tuioBlob->getScreenWidth(width)/2; float blob_height = tuioBlob->getScreenHeight(height)/2; float xpos = tuioBlob->getScreenX(width); float ypos = tuioBlob->getScreenY(height); float angle = tuioBlob->getAngleDegrees(); glColor3f(0.25, 0.25, 0.25); glPushMatrix(); glTranslatef(xpos, ypos, 0.0); glRotatef(angle, 0.0, 0.0, 1.0); /*glBegin(GL_QUADS); glVertex2f(blob_width/-2, blob_height/-2); glVertex2f(blob_width/-2, blob_height/2); glVertex2f(blob_width/2, blob_height/2); glVertex2f(blob_width/2, blob_height/-2); glEnd();*/ glBegin(GL_TRIANGLE_FAN); for(double a = 0.0f; a <= 2*M_PI; a += 0.2f) { glVertex2d(cos(a) * blob_width, sin(a) * blob_height); } glEnd(); glPopMatrix(); glColor3f(1.0, 1.0, 1.0); glRasterPos2f(xpos,ypos+5); sprintf(id,"%d",tuioBlob->getBlobID()); drawString(id); } tuioClient->unlockBlobList(); SDL_GL_SwapBuffers(); }
void SimpleSimulator::drawFrame() { if(!running) return; glClear(GL_COLOR_BUFFER_BIT); char id[3]; // draw the cursors std::list<TuioCursor*> cursorList = tuioServer->getTuioCursors(); for (std::list<TuioCursor*>::iterator iter = cursorList.begin(); iter!=cursorList.end(); iter++) { TuioCursor *tcur = (*iter); std::list<TuioPoint> path = tcur->getPath(); if (path.size()>0) { TuioPoint last_point = path.front(); glBegin(GL_LINES); glColor3f(0.0, 0.0, 1.0); for (std::list<TuioPoint>::iterator point = path.begin(); point!=path.end(); point++) { glVertex3f(last_point.getScreenX(width), last_point.getScreenY(height), 0.0f); glVertex3f(point->getScreenX(width), point->getScreenY(height), 0.0f); last_point.update(point->getX(),point->getY()); } glEnd(); // draw the finger tip glColor3f(0.75, 0.75, 0.75); std::list<TuioCursor*>::iterator joint = std::find( jointCursorList.begin(), jointCursorList.end(), tcur ); if( joint != jointCursorList.end() ) { glColor3f(0.5, 0.5, 0.5); } glPushMatrix(); glTranslatef(last_point.getScreenX(width), last_point.getScreenY(height), 0.0f); glBegin(GL_TRIANGLE_FAN); for(double a = 0.0f; a <= 2*M_PI; a += 0.2f) { glVertex2d(cos(a) * height/100.0f, sin(a) * height/100.0f); } glEnd(); glPopMatrix(); glColor3f(0.0, 0.0, 0.0); glRasterPos2f(tcur->getScreenX(width),tcur->getScreenY(height)); sprintf(id,"%d",tcur->getCursorID()); drawString(id); } } if (help) { glColor3f(0.0, 0.0, 1.0); glRasterPos2f(10,20); drawString("h - toggle help display"); glRasterPos2f(10,35); if (verbose) drawString("v - disable verbose mode"); else drawString("v - enable verbose mode"); glRasterPos2f(10,50); drawString("r - reset session"); glRasterPos2f(10,65); if (tuioServer->fullUpdateEnabled()) drawString("f - disable full update"); else drawString("f - enable full update"); glRasterPos2f(10,80); if (tuioServer->periodicMessagesEnabled()) drawString("p - disable periodic messages"); else drawString("p - enable periodic messages"); glRasterPos2f(10,95); drawString("SHIFT click - create persistent cursor"); glRasterPos2f(10,110); drawString("CTRL click - add to cursor group"); glRasterPos2f(10,125); if (fullscreen) drawString("F1 - exit fullscreen mode"); else drawString("F1 - enter fullscreen mode"); glRasterPos2f(10,140); drawString("ESC - Quit"); } SDL_GL_SwapBuffers(); }
//-------------------------------------------------------------- void TuioKinect::draw() { float height = (float)ofGetHeight(); float width = (float)ofGetWidth() ; ofSetColor(0,0,0,200) ; //Additive blend mode glBlendFunc(GL_SRC_COLOR, GL_ONE); ofSetColor(255, 255, 255) ; ofEnableSmoothing(); for(int i=0; i< customParticles.size(); i++) { customParticles[i].draw(0); } box2d.draw(); box2d.drawGround() ; ofSetColor(255, 255, 255); std::list<TuioCursor*> alive_cursor_list = tuioServer->getTuioCursors(); std::list<TuioCursor*>::iterator alive_cursor; for (alive_cursor=alive_cursor_list.begin(); alive_cursor!= alive_cursor_list.end(); alive_cursor++) { TuioCursor *ac = (*alive_cursor); float absXSpeed = ac->getXSpeed() ; float absYSpeed = ac->getYSpeed() ; float xpos = ac->getX() * (float)ofGetWidth() ; float ypos = ac->getY() * (float)ofGetHeight() ; absXSpeed = ( absXSpeed < 0 ) ? absXSpeed * -1 : absXSpeed ; absYSpeed = ( absYSpeed < 0 ) ? absYSpeed * -1 : absYSpeed ; if ( absXSpeed > .30 || absYSpeed > .30 ) { int _size = customParticles.size() ; if ( _size < 20 ) { CustomParticle p; if ( _size % 2 == 0 ) { p.changeIsFire(true); } else { p.changeIsFire(false) ; } float r = ofRandom(.25f, 1.0f); //normalized diff p.setPhysics(4.0 * r, .2 * r, .45 * r ); p.setup(box2d.getWorld(), xpos, ypos, (r*30) ); p.setVelocity( ac->getXSpeed()*10 , ac->getYSpeed()*10 ) ; customParticles.push_back(p); } } //Draw that path! drawTuioPath( ac->getPath() ) ; } //Debug Text ofSetColor(255, 255, 255); char reportStr[1024]; sprintf(reportStr, "set near threshold %i (press: + -)\nset far threshold %i (press: < >)\nnum blobs found %i, fps: %i", nearThreshold, farThreshold, (int)contourFinder.blobs.size(), (int)ofGetFrameRate()); ofDrawBitmapString(reportStr, 20, 650); ofEnableAlphaBlending() ; ofSetColor ( 10 , 10 , 10 ); ofFill() ; ofSetLineWidth( 2 ) ; ofRect(0, 0, 40, 40 ) ; ofSetColor(255, 255, 255 ) ; ofFill() ; grayImage.draw(5, 5, 192, 144 ); contourFinder.draw(5, 5, 192, 144 ); ofFill() ; ofDisableAlphaBlending() ; }