//-------------------------------------------------------------- void testApp::draw(){ ofBackground(background); float windowWidth = ofGetWidth(); float windowHeight = ofGetHeight(); //draw the playback over the top for debugging for now ofSetColor(ofColor::white); ofPushMatrix(); //openNIPlayer.drawDebug(0, 0); if(drawVideo){ openNIPlayer.drawImage(0, 0, windowWidth, windowHeight); } if(drawDepth){ openNIPlayer.drawDepth(0, 0, windowWidth, windowHeight); } ofPopMatrix(); ofEnableBlendMode(OF_BLENDMODE_ALPHA); ofSetColor(foreground); ofColor theColourToUse = foreground; ofFill(); if(allPointsTracking){ for(int i=0; i< (int) bodyCharts.size(); i++){ bodyCharts[i].draw(0,0,windowWidth,windowHeight, lineScale, lineAlpha, lineWidth, fadeHistory, theColourToUse); } } if(allPointsVerticalLines){ for(int i=0; i< (int) bodyCharts.size(); i++){ bodyCharts[i].drawVerticalLines(0,0,windowWidth,windowHeight, lineScale, lineAlpha, lineWidth, fadeHistory, theColourToUse); } } if(allPointsHorizontalLines){ for(int i=0; i< (int) bodyCharts.size(); i++){ bodyCharts[i].drawHorizontalLines(0, 0, windowWidth, windowHeight, lineScale, lineAlpha, lineWidth, fadeHistory, theColourToUse); } } if(allPointsCircles){ for(int i=0; i< (int) bodyCharts.size(); i++){ bodyCharts[i].drawCircles(0, 0, windowWidth, windowHeight, lineScale, lineAlpha, lineWidth,fadeHistory, theColourToUse); } } if(allPointsRibbon){ for(int i=0; i< (int) bodyCharts.size(); i++){ bodyCharts[i].drawRibbon(0, 0, windowWidth, windowHeight, lineAlpha, fadeHistory, theColourToUse); } } if(hipLine){ hipChart.draw(0, 0, windowWidth, windowHeight, lineAlpha, lineWidth, fadeHistory, theColourToUse); } if(shoulderLine){ shoulderChart.draw(0, 0, windowWidth, windowHeight, lineAlpha, lineWidth, fadeHistory, theColourToUse); } if(handsLine){ handsChart.draw(0, 0, windowWidth, windowHeight, lineAlpha, lineWidth, fadeHistory, theColourToUse); } if(hipLineToEdge){ hipChart.drawToEdgeOfScreen(0, 0, windowWidth, windowHeight, lineAlpha, lineWidth, theColourToUse); } if(shoulderLineToEdge){ shoulderChart.drawToEdgeOfScreen(0, 0, windowWidth, windowHeight, lineAlpha, lineWidth, theColourToUse); } if(handsLineToEdge){ handsChart.drawToEdgeOfScreen(0, 0, windowWidth, windowHeight, lineAlpha, lineWidth, theColourToUse); } // auto draw? // should the gui control hiding? if( !bHide){ gui.draw(); } }
//-------------------------------------------------------------- void ofApp::draw() { image.draw(0, 0); //vidGrabber.draw(20, 20); ofNoFill(); for (int i = 0; i < haarFinderLinks.blobs.size(); i++) { ofRectangle blobBoundingRect = haarFinderLinks.blobs[i].boundingRect; if(blobBoundingRect.width < 150 && blobBoundingRect.width > 100){ ofImage oog = beeld; oog.crop(blobBoundingRect.x, blobBoundingRect.y, blobBoundingRect.width, blobBoundingRect.height); for (int i = 0; i < 40; i++) { switch (i) { case 0: ofEnableAlphaBlending(); ofPushMatrix(); ofTranslate(250, 500, 0); ofRotate(80); ofSetColor(255, 255, 255, transperantie); oog.draw(0, 0); ofPopMatrix(); ofDisableAlphaBlending(); break; case 1: //oog.draw(100, 100); break; case 2: ofEnableAlphaBlending(); ofPushMatrix(); ofTranslate(260, 600, 0); ofRotate(50); ofSetColor(255, 255, 255, transperantie); oog.draw(0, 0); ofPopMatrix(); ofDisableAlphaBlending(); break; case 3: ofEnableAlphaBlending(); ofPushMatrix(); ofTranslate(320, 690, 0); ofRotate(25); ofSetColor(255, 255, 255, transperantie); oog.draw(0, 0); ofPopMatrix(); ofDisableAlphaBlending(); break; case 4: ofEnableAlphaBlending(); ofPushMatrix(); ofTranslate(400, 740, 0); ofRotate(5); ofSetColor(255, 255, 255, transperantie); oog.draw(0, 0); ofPopMatrix(); ofDisableAlphaBlending(); break; case 5: ofEnableAlphaBlending(); ofPushMatrix(); ofTranslate(510, 750, 0); ofRotate(-5); ofSetColor(255, 255, 255, transperantie); oog.draw(0, 0); ofPopMatrix(); ofDisableAlphaBlending(); break; case 6: ofEnableAlphaBlending(); ofPushMatrix(); ofTranslate(600, 750, 0); ofRotate(-35); ofSetColor(255, 255, 255, transperantie); oog.draw(0, 0); ofPopMatrix(); ofDisableAlphaBlending(); break; case 7: ofEnableAlphaBlending(); ofPushMatrix(); ofTranslate(700, 700, 0); ofRotate(-65); ofSetColor(255, 255, 255, transperantie); oog.draw(0, 0); ofPopMatrix(); ofDisableAlphaBlending(); break; case 8: ofEnableAlphaBlending(); ofPushMatrix(); ofTranslate(760, 620, 0); ofRotate(-90); ofSetColor(255, 255, 255, transperantie); oog.draw(0, 0); ofPopMatrix(); ofDisableAlphaBlending(); break; case 9: ofEnableAlphaBlending(); ofPushMatrix(); ofTranslate(770, 510, 0); ofRotate(-100); ofSetColor(255, 255, 255, transperantie); oog.draw(0, 0); ofPopMatrix(); ofDisableAlphaBlending(); break; case 10: ofEnableAlphaBlending(); ofPushMatrix(); ofTranslate(750, 400, 0); ofRotate(-125); ofSetColor(255, 255, 255, transperantie); oog.draw(0, 0); ofPopMatrix(); ofDisableAlphaBlending(); break; case 11: ofEnableAlphaBlending(); ofPushMatrix(); ofTranslate(700, 320, 0); ofRotate(-145); ofSetColor(255, 255, 255, transperantie); oog.draw(0, 0); ofPopMatrix(); ofDisableAlphaBlending(); break; case 12: ofEnableAlphaBlending(); ofPushMatrix(); ofTranslate(620, 260, 0); ofRotate(-170); ofSetColor(255, 255, 255, transperantie); oog.draw(0, 0); ofPopMatrix(); ofDisableAlphaBlending(); break; case 13: ofEnableAlphaBlending(); ofPushMatrix(); ofTranslate(510, 240, 0); ofRotate(-190); ofSetColor(255, 255, 255, transperantie); oog.draw(0, 0); ofPopMatrix(); ofDisableAlphaBlending(); break; case 14: ofEnableAlphaBlending(); ofPushMatrix(); ofTranslate(410, 255, 0); ofRotate(-210); ofSetColor(255, 255, 255, transperantie); oog.draw(0, 0); ofPopMatrix(); ofDisableAlphaBlending(); break; case 15: ofEnableAlphaBlending(); ofPushMatrix(); ofTranslate(320, 310, 0); ofRotate(-230); ofSetColor(255, 255, 255, transperantie); oog.draw(0, 0); ofPopMatrix(); ofDisableAlphaBlending(); break; case 16: ofEnableAlphaBlending(); ofPushMatrix(); ofTranslate(260, 390, 0); ofRotate(-265); ofSetColor(255, 255, 255, transperantie); oog.draw(0, 0); ofPopMatrix(); ofDisableAlphaBlending(); break; break; } } } } }
//-------------------------------------------------------------- void testApp::drawGeometry(){ float pointAlpha = timeline.getValue("Point Alpha"); float pointSize = timeline.getValue("Point Size"); float wireAlpha = timeline.getValue("Wireframe Alpha"); float thickness = timeline.getValue("Wireframe Thickness"); float particleAlpha = timeline.getValue("particle fade"); // float particleSize = timeline.getValue("particle size"); glEnable(GL_LINE_SMOOTH); glEnable(GL_POINT_SMOOTH); player.getVideoPlayer()->getTextureReference().bind(); ofPushMatrix(); ofPushStyle(); ofScale(1,-1,1); ofPushMatrix(); ofTranslate(timeline.getValue("x offset"), 0, timeline.getValue("z offset")); ofEnableBlendMode(OF_BLENDMODE_SCREEN); if(drawWireframe && wireAlpha > 0){ glPushAttrib(GL_ALL_ATTRIB_BITS); glEnable(GL_CULL_FACE); glCullFace(GL_FRONT); ofTranslate(0,0,-.5); ofSetColor(255*wireAlpha); thickness *= thickness; ofSetLineWidth(thickness); meshBuilder.getMesh().drawWireframe(); glPopAttrib(); } if(drawPointcloud && pointAlpha > 0){ ofTranslate(0,0,-.5); ofSetColor(255*pointAlpha); meshBuilder.getMesh().disableColors(); meshBuilder.getMesh().setMode(OF_PRIMITIVE_POINTS); glPointSize(pointSize*pointSize); meshBuilder.getMesh().draw(); meshBuilder.getMesh().setMode(OF_PRIMITIVE_TRIANGLES); meshBuilder.getMesh().enableColors(); } ofPopMatrix(); if(drawParticles){ cloudShader.begin(); particleRenderer.mesh.drawVertices(); cloudShader.end(); } player.getVideoPlayer()->getTextureReference().unbind(); if(justLoadedNewScene){ cout << "RENDERED FIRST FRAME OF " << player.getVideoPlayer()->getCurrentFrame() << endl; justLoadedNewScene = false; } ofPopStyle(); ofPopMatrix(); }
//-------------------------------------------------------------- void testApp::draw() { ofBackground(255, 255, 255); back.draw(0,0,ofGetWidth(),ofGetHeight()); //cbot01.draw(0, 0); if (b02==true) { back002.draw(0,0, ofGetWidth(),ofGetHeight()); svg02.load("bot04.svg"); ofPath path02; path02 = svg02.getPathAt(0); ofPolyline line02 = path02.getOutline()[0]; polyLine.clear(); cout << line02.getVertices().size() << endl; for (int i = 0; i < line02.getVertices().size(); i++){ polyLine.addVertex(line02.getVertices()[i]); } polyLine.setPhysics(0.0, 0.5, 0.5); polyLine.create(box2d.getWorld()); } if (b03==true) { back003.draw(0,0, ofGetWidth(),ofGetHeight()); svg03.load("bot02.svg"); ofPath path03; path03 = svg03.getPathAt(0); ofPolyline line03 = path03.getOutline()[0]; polyLine.clear(); cout << line03.getVertices().size() << endl; for (int i = 0; i < line03.getVertices().size(); i++){ polyLine.addVertex(line03.getVertices()[i]); } polyLine.setPhysics(0.0, 0.5, 0.5); polyLine.create(box2d.getWorld()); } if (b04==true) { back004.draw(0,0, ofGetWidth(),ofGetHeight()); svg04.load("bot03.svg"); ofPath path04; path04 = svg04.getPathAt(0); ofPolyline line04 = path04.getOutline()[0]; polyLine.clear(); cout << line04.getVertices().size() << endl; for (int i = 0; i < line04.getVertices().size(); i++){ polyLine.addVertex(line04.getVertices()[i]); } polyLine.setPhysics(0.0, 0.5, 0.5); polyLine.create(box2d.getWorld()); } if (b05==true) { ofSetColor(255); back.draw(0,0, ofGetWidth(),ofGetHeight()); svg.load("bot01.svg"); ofPath path; path = svg.getPathAt(0); ofPolyline line = path.getOutline()[0]; polyLine.clear(); cout << line.getVertices().size() << endl; for (int i = 0; i < line.getVertices().size(); i++){ polyLine.addVertex(line.getVertices()[i]); } polyLine.setPhysics(0.0, 0.5, 0.5); polyLine.create(box2d.getWorld()); } // circle with animals for(int i=0; i<circles.size(); i++) { ofNoFill(); circles[i].draw(); } // testing boxes /*for(int i=0; i<boxes.size(); i++) { ofFill(); SoundData * data = (SoundData*)boxes[i].getData(); if(data && data->bHit) ofSetHexColor(0xff0000); else ofSetHexColor(0x4ccae9); //ofEnableAlphaBlending(); //ofSetColor(255,0,0,0); //ofSetHexColor(0xe63b8b); // boxes[i].draw(); }*/ // animal boxes /*for(int i=0; i<boxes.size(); i++) { //ofFill(); SoundData * data = (SoundData*)boxes[i].getData(); //ofEnableAlphaBlending(); //ofSetColor(R,G,B); //ofSetHexColor(0xe63b8b); // boxes[i].draw(); }*/ for(int i=0; i<images.size(); i++) { ofSetColor(circles[i].color.r, circles[i].color.g, circles[i].color.b); ofSetRectMode(OF_RECTMODE_CENTER); ofPushMatrix(); ofTranslate(circles[i].getPosition().x, circles[i].getPosition().y); ofRotateZ(circles[i].getRotation()); images[i].draw(0,0); ofSetRectMode(OF_RECTMODE_CORNER); ofPopMatrix(); } /*for(int i=0; i<circles.size(); i++) { ofFill(); SoundData * data = (SoundData*)circles[i].getData(); if(data && data->bHit) ofSetHexColor(0xff0000); else ofSetHexColor(0x4ccae9); circles[i].draw(); }*/ //ofSetColor(255,255,130); // // ofDrawBitmapString("drawing mode: inward", 50, 90); // // ofDrawBitmapString("drawing mode: outward", 50, 120); // // ofDrawBitmapString("drawing mode: clockwise", 50, 150); // // ofDrawBitmapString("drawing mode: counter-clockwise", 50, 170); // // // // // // string info = ""; // info += "FPS: "+ofToString(ofGetFrameRate(), 1)+"\n"; // info += "FPS: "+ofToString(R, 1)+"\n"; // info += "FPS: "+ofToString(G, 1)+"\n"; // info += "FPS: "+ofToString(B, 1)+"\n"; // ofSetHexColor(0x444342); // ofDrawBitmapString(info, 30, 30); // /*for(int i=0; i<customParticles.size(); i++) { customParticles[i].draw(); }*/ ofNoFill(); //ofSetHexColor(0x444342); ofEnableAlphaBlending(); ofSetColor(255, 0, 255,0); ofEnableAlphaBlending(); //if(drawing.size()==0) polyLine.draw(); //else drawing.draw(); //text //ofSetColor(80); //ofRect(20,20, 300, 800); ofSetColor(0, 0, 0); ofPushMatrix(); ofTranslate(1005,550); ofRotateZ(-12); //font.drawString(typeStr, 0,0); ofDrawBitmapString(typeStr, 0,0); ofPopMatrix(); ofSetColor(255, 255, 255);//****important if (startscreen) { frontPage.draw(0, 0, ofGetWidth(),ofGetHeight()); } }
//------------------------------- void ofxControlPanel::draw(){ if( hidden ) return; ofPushStyle(); ofEnableAlphaBlending(); float panelH = boundingBox.height; if( minimize ){ panelH = topBar.height; } glPushMatrix(); glTranslatef(boundingBox.x, boundingBox.y, 0); //draw the background ofFill(); glColor4fv(bgColor.getColorF()); ofRect(0, 0, boundingBox.width, panelH); //draw the outline ofNoFill(); glColor4fv(outlineColor.getColorF()); ofRect(0, 0, boundingBox.width, panelH); ofLine(0, topBar.height, boundingBox.width, topBar.height); glPopMatrix(); ofRect(minimizeButton.x, minimizeButton.y, minimizeButton.width, minimizeButton.height); ofPushStyle(); ofFill(); if( saveDown )glColor4fv(fgColor.getSelectedColorF()); else glColor4fv(fgColor.getColorF()); ofRect(saveButton.x, saveButton.y, saveButton.width,saveButton.height); ofSetColor(255, 255, 255); if(bUseTTFFont) { guiTTFFont.drawString("save", saveButton.x + 3, saveButton.y + saveButton.height -4); } else { ofDrawBitmapString("save", saveButton.x + 3, saveButton.y + saveButton.height -3); } ofPopStyle(); ofPushStyle(); ofFill(); if( restoreDown )glColor4fv(fgColor.getSelectedColorF()); else glColor4fv(fgColor.getColorF()); ofRect(restoreButton.x, restoreButton.y, restoreButton.width,restoreButton.height); ofSetColor(255, 255, 255); if(bUseTTFFont) { guiTTFFont.drawString("restore", restoreButton.x + 3, restoreButton.y + restoreButton.height -4); } else { ofDrawBitmapString("restore", restoreButton.x + 3, restoreButton.y + restoreButton.height -3); } ofPopStyle(); ofPushMatrix(); ofTranslate(2,0,0); glColor4fv(textColor.getColorF()); guiBaseObject::renderText(); ofPopMatrix(); if( !minimize ){ //don't let gui elements go out of their panels glEnable(GL_SCISSOR_TEST); glScissor(boundingBox.x, ofGetHeight() - ( boundingBox.y + boundingBox.height - (-2 + topSpacing) ), boundingBox.width - borderWidth , boundingBox.height); for(int i = 0; i < (int) panelTabs.size(); i++){ if( i == selectedPanel){ ofPushStyle(); ofFill(); glColor4fv(fgColor.getSelectedColorF()); ofRect(panelTabs[i].x, panelTabs[i].y, panelTabs[i].width, panelTabs[i].height); glColor4fv(outlineColor.getColorF()); ofPopStyle(); } glColor4fv(outlineColor.getColorF()); ofNoFill(); ofRect(panelTabs[i].x, panelTabs[i].y, panelTabs[i].width, panelTabs[i].height); } glPushMatrix(); glTranslatef(hitArea.x, hitArea.y, 0); for(int i = 0; i < (int) panels.size(); i++){ if( i == selectedPanel )panels[i]->render(); } glPopMatrix(); glDisable(GL_SCISSOR_TEST); } ofPopStyle(); }
//-------------------------------------------------------------- void testApp::draw(){ if (myPortalCam.needsCalib()) { /* * So this camera needs to be calibrated only once every time * either the kinect or screen is physically moved. Once * calibrated "needsCalib()" will return as false. This is * true for this session, as well as any future sessions (a * config for the calibration is saved and reloaded whenever * the app runs). * * If, for whatever reason, you'd like to manually reset the * calibration, call the "resetCalib()" function (press the * "r" key as is defined in the key bindings below). */ myPortalCam.drawCalib(); /* * "drawCalib()" draws your calibration. When initialized it will * show a view from your Kinect's camera. * * To register your skeleton, do the cactus pose: * http://bit.ly/cactus_pose * * Sometimes skeleton registration takes a while... You'll know * when it happens when a red drawing of your skeleton appears * superimposed on top of your body. Once your body registers, * you're ready to start calibration. * * Notice that there's a red dot in the top left corner of the * screen. Grab your computer mouse and, standing at a distance, * extend your right arm forward so that your right hand obscures * your vision of the dot. When you're there, click the mouse * button to set that calibration point. * * A new dot will appear on the right side of the screen. Do * the same thing for this dot. Lastly, it will appear in the * bottom left corner of the screen. Do that once again. * * Great! You've just calibrated one set of points. Now we need * to calibrate 3 other sets of points (4 sets in total). Stand * somewhere else in the room and repeat that action for those * three dots. The further you can move your head around (while * keeping your whole head completely the in the Kinect's camera), * the stronger your calibration will tend to be. * * When all 12 points (4 sets of 3) are calibrated, you're almost * done! * * To finalize the calibration, you will need to "tweak" the * orientation. Put your head in line with the center of the * screen. It doesn't matter how far away you are from the screen * as long as your head is in line with the center. Once there, * call the "tweakOrientation()" function by pressing "t". * * Great, you're all calibrated! * */ } else { myPortalCam.begin(); ofSetColor(255, 255, 255); ofBackground(0, 0, 0, 1); // Draw the wall grids int portalDepth = -1000; ofNoFill(); for (int i= 0; i >= portalDepth; i = i - 100) { ofPushMatrix(); ofTranslate(0, 0, i); ofRect(-ofGetWindowWidth()/2, -ofGetWindowHeight()/2, ofGetWindowWidth(), ofGetWindowHeight()); ofPopMatrix(); } for (int i = 0; i < 18; i++) { float f = -ofGetWindowWidth()/2 + float(i) * (ofGetWindowWidth() / 18); ofPolyline line; line.addVertex(f, ofGetWindowHeight()/2, 0); line.addVertex(f, ofGetWindowHeight()/2, portalDepth); line.addVertex(f, -ofGetWindowHeight()/2, portalDepth); line.addVertex(f, -ofGetWindowHeight()/2, 0); line.draw(); } for (int i = 0; i < 12; i++) { float f = -ofGetWindowHeight()/2 + float(i) * (ofGetWindowHeight() / 12); ofPolyline line; line.addVertex( ofGetWindowWidth()/2, f, 0); line.addVertex( ofGetWindowWidth()/2, f, portalDepth); line.addVertex(-ofGetWindowWidth()/2, f, portalDepth); line.addVertex(-ofGetWindowWidth()/2, f, 0); line.draw(); } // Draw a sphere ofSetColor(0, 255, 0); ofSphere(0, 0, portalDepth/2, ofGetWindowHeight() / 4); myPortalCam.end(); } }
//----------- void ModuleImageAnalyzer::draw() { //ofTranslate(320, 240); //ofSetHexColor(0xffffff); // colorImg = img; // colorImg.draw(20,20); /* int scale = 10; hist_img = outHistImg.getCvImage(); cvZero ( hist_img ); float max_value = 0; cvGetMinMaxHistValue( hist, 0, &max_value, 0, 0 ); for( int h = 0; h < h_bins; h++ ){ for( int s = 0; s < s_bins; s++ ){ float bin_val = cvQueryHistValue_2D( hist, h, s ); int intensity = cvRound( bin_val * 255 / max_value ); cout << "intensity " << h << " " << s << " " << intensity << " " << bin_val << endl; cvRectangle( hist_img, cvPoint( h*scale, s*scale ), cvPoint( (h+1)*scale - 1, (s+1)*scale - 1 ), CV_RGB( intensity, intensity, intensity ), CV_FILLED ); } } outImg = hist_img; outImg.draw(20, 20); */ if (visible) { Learn::draw(); ofPushMatrix(); ofTranslate(x, y); //ofScale(0.5, 0.5); /* cam.getTextureReference().bind(); mesh.draw(); cam.getTextureReference().unbind(); if(ofGetMousePressed()) { mesh.drawWireframe(); } */ player.getTextureReference().bind(); mesh.draw(); player.getTextureReference().unbind(); if(ofGetMousePressed()) { mesh.drawWireframe(); } diff.draw(640, 0); /* ofTranslate(0, 400); ofSetColor(255, 0, 0); flow.setWindowSize(8); flow.calcOpticalFlow(cam); int i = 0; float distortionStrength = 4; for(int y = 1; y + 1 < ySteps; y++) { for(int x = 1; x + 1 < xSteps; x++) { int i = y * xSteps + x; ofVec2f position(x * stepSize, y * stepSize); ofRectangle area(position - ofVec2f(stepSize, stepSize) / 2, stepSize, stepSize); ofVec2f offset = flow.getAverageFlowInRegion(area); //mesh.setVertex(i, position + distortionStrength * offset); ofPushMatrix(); ofTranslate(x*20, y*20); ofLine(0, 0, distortionStrength*offset.x, distortionStrength*offset.y); ofPopMatrix(); i++; } } */ ofTranslate(0, 400); drawHistograms(); ofPopMatrix(); } }
//------------------------------- void ofxLabGui::draw(){ if( hidden ) return; ofPushStyle(); ofEnableAlphaBlending(); float panelH = boundingBox.height; if( minimize ){ panelH = 20; } if (bDrawBarOnTop || panels.size() == 0){ glPushMatrix(); glTranslatef(boundingBox.x, boundingBox.y, 0); //draw the background ofFill(); glColor4fv(bgColor.getColorF()); ofRect(0, 0, boundingBox.width, panelH); //draw the outline ofNoFill(); glColor4fv(outlineColor.getColorF()); ofRect(0, 0, boundingBox.width, panelH); ofLine(0, 20, boundingBox.width, 20); glPopMatrix(); } else { glPushMatrix(); glTranslatef(boundingBox.x, (int) boundingBox.y + panels[0]->getPosY(), 0); //draw the background ofFill(); glColor4fv(bgColor.getColorF()); ofRect(0, 0, boundingBox.width, (int) panelH - panels[0]->getPosY()); //draw the outline ofNoFill(); glColor4fv(outlineColor.getColorF()); ofRect(0, 0, boundingBox.width, (int) panelH - panels[0]->getPosY()); ofLine(0, 20, boundingBox.width, 20); glPopMatrix(); } if (bCollapsible) ofRect(minimizeButton.x, minimizeButton.y, minimizeButton.width, minimizeButton.height); saveButton->render(); restoreButton->render(); loadButton->render(); saveAsButton->render(); ofPushMatrix(); ofTranslate(2,0,0); glColor4fv(textColor.getColorF()); guiBaseObject::renderText(); ofPopMatrix(); if( !minimize ){ //don't let gui elements go out of their panels //glEnable(GL_SCISSOR_TEST); //glScissor(boundingBox.x, ofGetHeight() - ( boundingBox.y + boundingBox.height - (-2 + topSpacing) ), boundingBox.width - borderWidth , boundingBox.height); //glScissor(boundingBox.x-1, ofGetHeight() - ( boundingBox.y + boundingBox.height+1 ), boundingBox.width+2, boundingBox.height+2); /*for(int i = 0; i < panelTabs.size(); i++){ if( i == selectedPanel){ ofPushStyle(); ofFill(); glColor4fv(fgColor.getSelectedColorF()); ofBeginShape(); ofVertex(panelTabs[i].x, panelTabs[i].y+panelTabs[i].height); ofVertex(panelTabs[i].x, panelTabs[i].y); ofVertex(panelTabs[i].x+panelTabs[i].width, panelTabs[i].y); ofVertex(panelTabs[i].x+panelTabs[i].width, panelTabs[i].y + panelTabs[i].height); ofEndShape(false); //ofRect(panelTabs[i].x, panelTabs[i].y, panelTabs[i].width, panelTabs[i].height); glColor4fv(outlineColor.getColorF()); ofPopStyle(); } glColor4fv(outlineColor.getColorF()); ofNoFill(); ofBeginShape(); ofVertex(panelTabs[i].x, panelTabs[i].y+panelTabs[i].height); ofVertex(panelTabs[i].x, panelTabs[i].y); ofVertex(panelTabs[i].x+panelTabs[i].width, panelTabs[i].y); ofVertex(panelTabs[i].x+panelTabs[i].width, panelTabs[i].y + panelTabs[i].height); ofEndShape(false); //ofRect(panelTabs[i].x, panelTabs[i].y, panelTabs[i].width, panelTabs[i].height); }*/ glPushMatrix(); glTranslatef(hitArea.x, hitArea.y, 0); for(int i = 0; i < panels.size(); i++){ if( i == selectedPanel )panels[i]->render(); else panels[i]->renderTab(); } glPopMatrix(); //glDisable(GL_SCISSOR_TEST); } ofPopStyle(); }
//-------------------------------------------------------------- void ofApp::draw() { //現在のモードに応じて、表示する映像を切り替え switch (videoMode) { case 1: //グレースケール映像 grayImage.draw(0, 0, ofGetWidth(), ofGetHeight()); break; case 2: //背景画像 grayBg.draw(0, 0, ofGetWidth(), ofGetHeight()); break; case 3: //2値化された差分映像 grayDiff.draw(0, 0, ofGetWidth(), ofGetHeight()); break; default: //カラー映像 colorImg.draw(0, 0, ofGetWidth(), ofGetHeight()); break; } //画面に対する映像の比率を計算 float ratioX = ofGetWidth()/320; float ratioY = ofGetHeight()/240; //解析結果を表示する場合 if (showCvAnalysis) { //検出した解析結果を表示 for (int i = 0; i < contourFinder.nBlobs; i++) { ofPushMatrix(); //画面サイズいっぱいに表示されるようリスケール glScalef((float)ofGetWidth() / (float)grayDiff.width, (float)ofGetHeight() / (float)grayDiff.height, 1.0f); contourFinder.blobs[i].draw(0,0); ofFill(); ofSetColor(255, 0, 0); ofEllipse(contourFinder.blobs[i].centroid.x, contourFinder.blobs[i].centroid.y, 4, 4); ofPopMatrix(); } } //ログと操作説明を表示 ofSetColor(255, 255, 255); ofDrawBitmapString("FPS: "+ofToString(ofGetFrameRate()), 20, 20); ofDrawBitmapString("Threshold: "+ofToString(threshold), 20, 35); ofDrawBitmapString("Number of Blobs: "+ofToString(contourFinder.nBlobs), 20, 50); ofDrawBitmapString("[0] Show original video", 20, 65); ofDrawBitmapString("[1] Show grayscale video", 20, 80); ofDrawBitmapString("[2] Show captured background", 20, 95); ofDrawBitmapString("[3] Show difference from background", 20, 110); ofDrawBitmapString("[space] Captuer background", 20, 125); ofDrawBitmapString("[a] Analysis on / off", 20, 140); ofDrawBitmapString("device0: " + vids[0].deviceName + " " + ofToString(vids[0].id, 2), windowS.x - 320, 65); ofDrawBitmapString("device1: " + vids[1].deviceName + " " + ofToString(vids[1].id, 2), windowS.x - 320, 80); // ofDrawBitmapString("device2: " + vids[2].deviceName + ofToString(vids[2].id, 1), windowS.x - 20, 95); // ofDrawBitmapString("device3: " + vids[3].deviceName + ofToString(vids[3].id, 1), windowS.x - 20, 110); // ofDrawBitmapString("device4: " + vids[4].deviceName + ofToString(vids[4].id, 1), windowS.x - 20, 125); ofDrawBitmapString("cam: " + ofToString(vids[devID].deviceName,1), windowS.x - 320, 140); }
//-------------------------------------------------------------- void ofApp::draw() { float spinX = sin(ofGetElapsedTimef()*.35f); float spinY = cos(ofGetElapsedTimef()*.075f); if(bMousePressed) { spinX = spinY = 0.0f; } ofEnableDepthTest(); ofEnableLighting(); pointLight.enable(); pointLight2.enable(); pointLight3.enable(); material.begin(); ofSetColor(180); ofNoFill(); ofDrawSphere(ofGetWidth()/2, ofGetHeight()/2, ofGetWidth()); if(mode == 1 || mode == 3) texture.getTexture().bind(); if(mode == 2) vidGrabber.getTexture().bind(); // Plane // plane.setPosition(ofGetWidth()*.2, ofGetHeight()*.25, 0); plane.rotate(spinX, 1.0, 0.0, 0.0); plane.rotate(spinY, 0, 1.0, 0.0); if(mode == 3) { deformPlane = plane.getMesh(); // x = columns, y = rows // ofVec3f planeDims = plane.getResolution(); float planeAngleX = ofGetElapsedTimef()*3.6; float planeAngleInc = 3.f/(float)planeDims.x; ofVec3f vert; for(size_t i = 0; i < deformPlane.getNumIndices(); i++ ) { planeAngleX += planeAngleInc; int ii = deformPlane.getIndex( i ); vert = deformPlane.getVertex( ii ); vert.z += cos(planeAngleX) * 50; deformPlane.setVertex( ii, vert ); } } if(bFill) { ofFill(); ofSetColor(255); if(mode == 3) { plane.transformGL(); deformPlane.draw(); plane.restoreTransformGL(); } else { plane.draw(); } } if(bWireframe) { ofNoFill(); ofSetColor(0, 0, 0); if(!bFill) ofSetColor(255); plane.setPosition(plane.getPosition().x, plane.getPosition().y, plane.getPosition().z+1); //if(bFill) { if( mode == 3 ) { ofSetColor(255); } plane.drawWireframe(); //} plane.setPosition(plane.getPosition().x, plane.getPosition().y, plane.getPosition().z-2); } // Box // box.setPosition(ofGetWidth()*.5, ofGetHeight()*.25, 0); box.rotate(spinX, 1.0, 0.0, 0.0); box.rotate(spinY, 0, 1.0, 0.0); if(bFill) { ofFill(); ofSetColor(255); if(mode == 3) { box.transformGL(); for(int i = 0; i < ofBoxPrimitive::SIDES_TOTAL; i++ ) { ofPushMatrix(); ofTranslate( boxSides[i].getNormal(0) * sin(ofGetElapsedTimef()) * 50 ); boxSides[i].draw(); ofPopMatrix(); } box.restoreTransformGL(); } else { box.draw(); } } if(bWireframe) { ofNoFill(); ofSetColor(0, 0, 0); if(!bFill) ofSetColor(255); box.setScale(1.01f); if(mode == 3) { ofSetColor(255); } box.drawWireframe(); box.setScale(1.f); } // Sphere // sphere.setPosition(ofGetWidth()*.8f, ofGetHeight()*.25, 0); sphere.rotate(spinX, 1.0, 0.0, 0.0); sphere.rotate(spinY, 0, 1.0, 0.0); if(mode == 3) { sphere.setMode( OF_PRIMITIVE_TRIANGLES ); triangles = sphere.getMesh().getUniqueFaces(); } if(bFill) { ofFill(); ofSetColor(255); if(mode == 3) { float angle = ofGetElapsedTimef()*3.2; float strength = (sin( angle+.25 )) * .5f * 5.f; ofVec3f faceNormal; for(size_t i = 0; i < triangles.size(); i++ ) { // store the face normal here. // we change the vertices, which makes the face normal change // every time that we call getFaceNormal // faceNormal = triangles[i].getFaceNormal(); for(int j = 0; j < 3; j++ ) { triangles[i].setVertex( j, triangles[i].getVertex(j) + faceNormal * strength); } } sphere.getMesh().setFromTriangles( triangles ); } sphere.draw(); } if(bWireframe) { ofNoFill(); ofSetColor(0, 0, 0); if(!bFill) ofSetColor(255); sphere.setScale(1.01f); sphere.drawWireframe(); sphere.setScale(1.f); } // ICO Sphere // icoSphere.setPosition(ofGetWidth()*.2, ofGetHeight()*.75, 0); icoSphere.rotate(spinX, 1.0, 0.0, 0.0); icoSphere.rotate(spinY, 0, 1.0, 0.0); if(mode == 3) { triangles = icoSphere.getMesh().getUniqueFaces(); } if(bFill) { ofFill(); ofSetColor(255); if(mode == 3) { float angle = (ofGetElapsedTimef() * 1.4); ofVec3f faceNormal; for(size_t i = 0; i < triangles.size(); i++ ) { float frc = ofSignedNoise(angle* (float)i * .1, angle*.05) * 4; faceNormal = triangles[i].getFaceNormal(); for(int j = 0; j < 3; j++ ) { triangles[i].setVertex(j, triangles[i].getVertex(j) + faceNormal * frc ); } } icoSphere.getMesh().setFromTriangles( triangles ); } icoSphere.draw(); } if(bWireframe) { ofNoFill(); ofSetColor(0, 0, 0); if(!bFill) ofSetColor(255); icoSphere.setScale(1.01f); icoSphere.drawWireframe(); icoSphere.setScale(1.f); } // Cylinder // if(mode == 3) { topCap = cylinder.getTopCapMesh(); bottomCap = cylinder.getBottomCapMesh(); body = cylinder.getCylinderMesh(); } cylinder.setPosition(ofGetWidth()*.5, ofGetHeight()*.75, 0); cylinder.rotate(spinX, 1.0, 0.0, 0.0); cylinder.rotate(spinY, 0, 1.0, 0.0); if(bFill) { ofFill(); ofSetColor(255); if(mode == 3) { cylinder.transformGL(); ofPushMatrix(); { if(topCap.getNumNormals() > 0) { ofTranslate( topCap.getNormal(0) * (cos(ofGetElapsedTimef()*5)+1)*.5f * 100 ); topCap.draw(); } } ofPopMatrix(); ofPushMatrix(); { if(bottomCap.getNumNormals() > 0) { ofTranslate( bottomCap.getNormal(0) * (cos(ofGetElapsedTimef()*4)+1)*.5f * 100 ); bottomCap.draw(); } } ofPopMatrix(); ofPushMatrix(); { float scale = (cos(ofGetElapsedTimef()*3)+1)*.5f + .2; ofScale( scale, scale, scale ); body.draw(); } ofPopMatrix(); cylinder.restoreTransformGL(); } else { cylinder.draw(); } } if(bWireframe) { ofNoFill(); ofSetColor(0, 0, 0); if(!bFill || mode == 3) ofSetColor(255); cylinder.setScale(1.01f); cylinder.drawWireframe(); cylinder.setScale(1.0f); } // Cone // cone.setPosition(ofGetWidth()*.8, ofGetHeight()*.75, 0); cone.rotate(spinX, 1.0, 0.0, 0.0); cone.rotate(spinY, 0, 1.0, 0.0); if(mode == 3) { bottomCap = cone.getCapMesh(); body = cone.getConeMesh(); } if(bFill) { ofFill(); ofSetColor(255); if(mode == 3) { cone.transformGL(); ofPushMatrix(); if(bottomCap.getNumNormals() > 0 ) { ofTranslate( bottomCap.getNormal(0) * cone.getHeight()*.5 ); ofRotate( sin(ofGetElapsedTimef()*5) * RAD_TO_DEG, 1, 0, 0); bottomCap.draw(); } ofPopMatrix(); ofPushMatrix(); ofRotate(90, 1, 0, 0); ofRotate( (cos(ofGetElapsedTimef()*6) +1)*.5 * 360 , 1, 0, 0 ); body.draw(); ofPopMatrix(); cone.restoreTransformGL(); } else { cone.draw(); } } if(bWireframe) { ofNoFill(); ofSetColor(0, 0, 0); if(!bFill || mode == 3) ofSetColor(255); cone.setScale(1.01f); cone.drawWireframe(); cone.setScale(1.0f); } if(mode == 1 || mode == 3) texture.getTexture().unbind(); if(mode == 2) vidGrabber.getTexture().unbind(); material.end(); ofDisableLighting(); if(bDrawLights) { ofFill(); ofSetColor(pointLight.getDiffuseColor()); pointLight.draw(); ofSetColor(pointLight2.getDiffuseColor()); pointLight2.draw(); ofSetColor(pointLight3.getDiffuseColor()); pointLight3.draw(); } if(bDrawNormals) { ofSetColor(225, 0, 255); plane.drawNormals(20, bSplitFaces); box.drawNormals(20, bSplitFaces); sphere.drawNormals(20, bSplitFaces); icoSphere.drawNormals(20, bSplitFaces); cylinder.drawNormals(20, bSplitFaces); cone.drawNormals(20, bSplitFaces); } if(bDrawAxes) { plane.drawAxes(plane.getWidth()*.5+30); box.drawAxes(box.getWidth()+30); sphere.drawAxes(sphere.getRadius()+30); icoSphere.drawAxes(icoSphere.getRadius()+30); cylinder.drawAxes(cylinder.getHeight()+30); cone.drawAxes(cone.getHeight()+30); } ofDisableDepthTest(); ofFill(); ofSetColor(0); ofDrawRectangle(plane.getPosition().x-154, plane.getPosition().y + 120, 140, 24); ofSetColor(255); ofDrawBitmapString("ofPlanePrimitive", plane.getPosition().x-150, plane.getPosition().y+136 ); ofSetColor(0); ofDrawRectangle(box.getPosition().x-154, box.getPosition().y + 120, 126, 24); ofSetColor(255); ofDrawBitmapString("ofBoxPrimitive", box.getPosition().x-150, box.getPosition().y+136 ); ofSetColor(0); ofDrawRectangle(sphere.getPosition().x-154, sphere.getPosition().y + 120, 148, 24); ofSetColor(255); ofDrawBitmapString("ofSpherePrimitive", sphere.getPosition().x-150, sphere.getPosition().y+136 ); ofSetColor(0); ofDrawRectangle(icoSphere.getPosition().x-154, icoSphere.getPosition().y + 120, 168, 24); ofSetColor(255); ofDrawBitmapString("ofIcoSpherePrimitive", icoSphere.getPosition().x-150, icoSphere.getPosition().y+136 ); ofSetColor(0); ofDrawRectangle(cylinder.getPosition().x-154, cylinder.getPosition().y + 120, 160, 24); ofSetColor(255); ofDrawBitmapString("ofCylinderPrimitive", cylinder.getPosition().x-150, cylinder.getPosition().y+136 ); ofSetColor(0); ofDrawRectangle(cone.getPosition().x-154, cone.getPosition().y + 120, 136, 24); ofSetColor(255); ofDrawBitmapString("ofConePrimitive", cone.getPosition().x-150, cone.getPosition().y+136 ); if(bInfoText) { stringstream ss; ss << "Framerate: " << ofToString(ofGetFrameRate(),0) << "\n"; ss << "(f): Toggle Fullscreen"<<endl<<"(s): Draw Solid Shapes"<<endl<<"(w): Draw Wireframes"<<endl; ss <<"(1/2/3/4): Set Resolutions" <<endl<<"(n): Draw Normals"<<"\n(LEFT/RIGHT): Set Mode "<<ofToString(mode,0)<<endl; ss <<"(z): Split Faces " <<bSplitFaces<<endl; ss <<"(a): Draw Axes"<<endl<<"(l): Render lights"<<endl<<"(t): Info Text"<<endl; ofDrawBitmapString(ss.str().c_str(), 20, 20); } }
//-------------------------------------------------------------- void testApp::draw(){ if(!setupFailed){ //debug view ofPushStyle(); ofPushMatrix(); ofTranslate(0, ofGetWindowHeight()-130); //----- channel 01 ----- ofPushMatrix(); ofTranslate(100, 0); ofFill(); ofDrawBitmapString("Channel01", -90,0); ofSetColor(255,40); ofDrawBitmapString("FFT: "+ ofToString(Channel01_FFT_size) + " freq", 0,15); ofDrawBitmapString("Frequency: " + ofToString(Channel01_Pitch,0), 0,30); ofDrawBitmapString("Linear Pitch: " + ofToString(Channel01_LinearPitch,0), 0,45); ofDrawBitmapString("Amplitude: " + ofToString(Channel01_Amplitude,4), 0,60); ofDrawBitmapString("Attack: " + ofToString(Channel01_Attack,4), 0,75); for (int i = 0; i < Channel01_FFT_size; i++){ ofSetColor(255,20); ofRect((i*6),0,5,-Channel01_Analyzer.averages[i] * 3); ofSetColor(255); ofLine((i*6), -Channel01_Analyzer.averages[i] * 3, ((i+1)*6), -Channel01_Analyzer.averages[i+1] * 3); } ofSetColor(255, 255*Channel01_Amplitude); ofCircle(-50,50, Channel01_Attack*3); ofSetColor(255); ofNoFill(); ofCircle(-50, 50, Channel01_Attack*3); ofPopMatrix(); //----- channel 02 ----- ofPushMatrix(); ofTranslate(350, 0); ofFill(); ofDrawBitmapString("Channel02", -90,0); ofSetColor(255,40); ofDrawBitmapString("FFT: "+ ofToString(Channel02_FFT_size) + " freq", 0,15); ofDrawBitmapString("Frequency: " + ofToString(Channel02_Pitch,0), 0,30); ofDrawBitmapString("Linear Pitch: " + ofToString(Channel02_LinearPitch,0), 0,45); ofDrawBitmapString("Amplitude: " + ofToString(Channel02_Amplitude,4), 0,60); ofDrawBitmapString("Attack: " + ofToString(Channel02_Attack,4), 0,75); for (int i = 0; i < Channel02_FFT_size; i++){ ofSetColor(255,20); ofRect((i*6),0,5,-Channel02_Analyzer.averages[i] * 3); ofSetColor(255); ofLine((i*6), -Channel02_Analyzer.averages[i] * 3, ((i+1)*6), -Channel02_Analyzer.averages[i+1] * 3); } ofSetColor(255, 255*Channel02_Amplitude); ofCircle(-50,50, Channel02_Attack*3); ofSetColor(255); ofNoFill(); ofCircle(-50, 50, Channel02_Attack*3); ofPopMatrix(); //----- channel 03 ----- ofPushMatrix(); ofTranslate(600, 0); ofFill(); ofDrawBitmapString("Channel03", -90,0); ofSetColor(255,40); ofDrawBitmapString("FFT: "+ ofToString(Channel03_FFT_size) + " freq", 0,15); ofDrawBitmapString("Frequency: " + ofToString(Channel03_Pitch,0), 0,30); ofDrawBitmapString("Linear Pitch: " + ofToString(Channel03_LinearPitch,0), 0,45); ofDrawBitmapString("Amplitude: " + ofToString(Channel03_Amplitude,4), 0,60); ofDrawBitmapString("Attack: " + ofToString(Channel03_Attack,4), 0,75); for (int i = 0; i < Channel03_FFT_size; i++){ ofSetColor(255,20); ofRect((i*6),0,5,-Channel03_Analyzer.averages[i] * 3); ofSetColor(255); ofLine((i*6), -Channel03_Analyzer.averages[i] * 3, ((i+1)*6), -Channel03_Analyzer.averages[i+1] * 3); } ofSetColor(255, 255*Channel03_Amplitude); ofCircle(-50,50, Channel03_Attack*3); ofSetColor(255); ofNoFill(); ofCircle(-50, 50, Channel03_Attack*3); ofPopMatrix(); //----- channel 04 ----- ofPushMatrix(); ofTranslate(850, 0); ofFill(); ofDrawBitmapString("Channel04", -90,0); ofSetColor(255,40); ofDrawBitmapString("FFT: "+ ofToString(Channel04_FFT_size) + " freq", 0,15); ofDrawBitmapString("Frequency: " + ofToString(Channel04_Pitch,0), 0,30); ofDrawBitmapString("Linear Pitch: " + ofToString(Channel04_LinearPitch,0), 0,45); ofDrawBitmapString("Amplitude: " + ofToString(Channel04_Amplitude,4), 0,60); ofDrawBitmapString("Attack: " + ofToString(Channel04_Attack,4), 0,75); for (int i = 0; i < Channel04_FFT_size; i++){ ofSetColor(255,20); ofRect((i*6),0,5,-Channel04_Analyzer.averages[i] * 3); ofSetColor(255); ofLine((i*6), -Channel04_Analyzer.averages[i] * 3, ((i+1)*6), -Channel04_Analyzer.averages[i+1] * 3); } ofSetColor(255, 255*Channel04_Amplitude); ofCircle(-50,50, Channel04_Attack*3); ofSetColor(255); ofNoFill(); ofCircle(-50, 50, Channel04_Attack*3); ofPopMatrix(); ofPopMatrix(); ofPopStyle(); } else { //setup failed! ofBackground(255, 20, 0); ofSetColor(255); ofDrawBitmapString(" WRONG DEVICE SELECTED ", ofGetWidth()/2-90, ofGetHeight()/2 - 50); ofDrawBitmapString(" CHANGE SYSTEM SETTINGS ", ofGetWidth()/2-90, ofGetHeight()/2); ofDrawBitmapString(" TO 4-CHANNEL INTERFACE ", ofGetWidth()/2-90, ofGetHeight()/2+50); } }
//-------------------------------------------------------------- void ofApp::draw(){ ofBackgroundGradient(ofColor(90, 90, 90), ofColor(30, 30, 30), OF_GRADIENT_BAR); ofSetColor(200); ofDrawBitmapString("ofxLeapMotion - Example App\nLeap Connected? " + ofToString(leap.isConnected()), 20, 20); cam.begin(); ofPushMatrix(); ofRotate(90, 0, 0, 1); ofSetColor(20); ofDrawGridPlane(1000, 50, false); //creates the grid (columns , rows) ofPopMatrix(); fingerType fingerTypes[] = {THUMB, INDEX, MIDDLE, RING, PINKY}; for(int i = 0; i < simpleHands.size(); i++){ bool isLeft = simpleHands[i].isLeft; ofPoint handPos = simpleHands[i].handPos; ofPoint handNormal = simpleHands[i].handNormal; ofSetColor(0, 0, 255); ofDrawSphere(handPos.x, handPos.y, handPos.z, 20); ofSetColor(255, 255, 0); ofDrawArrow(handPos, handPos + 100*handNormal); for (int f=0; f<5; f++) { ofPoint mcp = simpleHands[i].fingers[ fingerTypes[f] ].mcp; // metacarpal ofPoint pip = simpleHands[i].fingers[ fingerTypes[f] ].pip; // proximal ofPoint dip = simpleHands[i].fingers[ fingerTypes[f] ].dip; // distal ofPoint tip = simpleHands[i].fingers[ fingerTypes[f] ].tip; // fingertip ofSetColor(0, 255, 0); ofDrawSphere(mcp.x, mcp.y, mcp.z, 12); ofDrawSphere(pip.x, pip.y, pip.z, 12); ofDrawSphere(dip.x, dip.y, dip.z, 12); ofDrawSphere(tip.x, tip.y, tip.z, 12); ofSetColor(255, 0, 0); ofSetLineWidth(20); ofLine(mcp.x, mcp.y, mcp.z, pip.x, pip.y, pip.z); ofLine(pip.x, pip.y, pip.z, dip.x, dip.y, dip.z); ofLine(dip.x, dip.y, dip.z, tip.x, tip.y, tip.z); } if ((handPos.x > -100) && (handPos.x < 100)) { synth.play(); } if ((handPos.x > 50) && (handPos.x < 250)) { beats.play(); } /*if (handPos.y > 100) { synth.play(); }*/ /*if (handPos.z > 100) { synth.play(); }*/ } cam.end(); //sound player /* //---------------------------------- synth: if (synth.getIsPlaying()) ofSetHexColor(0xFF0000); else ofSetHexColor(0x000000); font.drawString("synth !!", 50,50); ofSetHexColor(0x000000); string tempStr = "click to play\npct done: "+ofToString(synth.getPosition())+"\nspeed: " + ofToString(synth.getSpeed()) + "\npan: " + ofToString(synth.getPan()) ; ofDrawBitmapString(tempStr, 50,ofGetHeight()-50); //---------------------------------- beats: if (beats.getIsPlaying()) ofSetHexColor(0xFF0000); ofSetHexColor(0x000000); tempStr = "click and drag\npct done: "+ofToString(beats.getPosition())+"\nspeed: " +ofToString(beats.getSpeed()); //---------------------------------- vocals: if (vocals.getIsPlaying()) ofSetHexColor(0xFF0000); else ofSetHexColor(0x000000); ofSetHexColor(0x000000); tempStr = "click to play (multiplay)\npct done: "+ofToString(vocals.getPosition())+"\nspeed: " + ofToString(vocals.getSpeed()); */ }
//-------------------------------------------------------------- void testApp::draw(){ char reportStr[1024]; ofPushMatrix(); ofTranslate(20, 20, 1); ofSetLineWidth(1); ofSetHexColor(0xffffff); colorImg.draw(0, 0); colorPin.draw(360, 0); grayPin.draw(360, 120); grayDiff.draw(0, 280); ofNoFill(); ofSetColor(0, 0, 255, 255); ofRect(cntPts.x, cntPts.y + 280, cntPts.width, cntPts.height); // Region Numeros ofBeginShape(); for (int i = 0; i < 4; i++) ofVertex(roiPts[i]); ofSetColor(moviendo > -1 && moviendo < 4 ? 255 : 0, 255, 0, 255); ofEndShape(true); ofBeginShape(); for (int i = 0; i < 4; i++) { ofSetColor(i == moviendo ? 255 : 0, 255, 0, 255); sprintf(reportStr, "%d", i + 1); ofDrawBitmapString(reportStr, roiPts[i].x, roiPts[i].y - 10); ofCircle(roiPts[i].x, roiPts[i].y, 5); ofVertex(roiPts[i]); } ofFill(); ofSetColor(0, 255, 0, 32); ofEndShape(); // Region barritas contador ofNoFill(); ofSetColor(255, moviendo > -1 ? 255 : 0, 0, 255); ofRect(cntPts); ofDrawBitmapString("x, y", cntPts.x, cntPts.y - 10); ofDrawBitmapString("w, h", cntPts.x + cntPts.width, cntPts.y + cntPts.height + 10); ofCircle(cntPts.x, cntPts.y, 5); ofCircle(cntPts.x + cntPts.width, cntPts.y + cntPts.height, 5); ofSetHexColor(0x333333); ofRect(360,540,320,240); ofFill(); ofSetColor(0, 0, 0, 196); ofRect(0, 180, 320, 50); ofSetHexColor(0xffffff); sprintf(reportStr, "[+/-] - Cambiar threshold: %i\n[ G ] - Guardar configuracion\nUltima barra presente: %s\nToken detectado: %s", threshold, ultimaBarra ? "SI" : "NO", token); ofDrawBitmapString(reportStr, 5, 195); // detecta los numeros de 7 segmentos ofNoFill(); ofSetColor(0, 0, 255, 255); ofSetLineWidth(2); for (int x = 0; x < 45 * 6; x += 50) { ofRect(360 + (x > 110 ? x + 25 : x), 120, 45, 120); } bool segmento[6], cambio = false; int lpixel = 0, pixel = 255, cambios = 0; for (int y = 30; y < 61; y += 60) for (int x = 0; x < 45; x++) { int i = x+ (y * 320); lpixel = pixel; pixel = grayPin.getPixels()[i]; cambio = (lpixel != pixel);// && lpixel; if (cambio) cambios++; } printf ("cambios: %d\n", cambios); ofPopMatrix(); }
//-------------------------------------------------------------- void testApp::draw(){ bool bAnySelected = false; ofPoint selectionPoint; for (int i=0; i<frames.size();i++){ if (frames[i].isMousepressed()) { bAnySelected = true; selectionPoint =frames[i].getPos(); } } if (bAnySelected){ ofBackground(100); targetPos = 0.98 * targetPos + 0.02 *selectionPoint; } else { ofBackground(150); targetPos = 0.98 * targetPos + 0.02 *centerPos; } ofPushMatrix(); ofTranslate(-targetPos.x,-targetPos.y); ofTranslate(centerPos.x,centerPos.y); for (int i=0; i<frames.size();i++){ if (!frames[i].isSelected()) { frames[i].draw(); } } for (int i=0; i<frames.size();i++){ if (frames[i].isSelected()) { frames[i].draw(); } } ofPopMatrix(); if (enable_Debug_Mode) { string info = "INFO : \n"; info += "space: add new frame\n"; info += "key = 'w': width + \n"; info += "key = 's': width - \n"; info += "key = 'a': rotate left \n"; info += "key = 'd': rotate right \n"; info += "key = 'z': delete last frame \n"; info += "number key = 1, 2, 3, 4 : level 1 - 4 \n"; info += "key = 'e' : frame style 1 - 4 \n"; info += "key = 'q' : shadow style 1 - 4 \n"; info += "Level = "+ ofToString(frames.back().getLevel())+"\n"; ofSetColor(255); ofDrawBitmapStringHighlight(info, 20,20); }else{ ofSetColor(255); banner.draw(0, 0, banner.width/2,banner.height/2); } }
//---------- void Device::drawWorld() { auto colorSource = this->getColorSource(); auto depthSource = this->getDepthSource(); auto bodySource = this->getBodySource(); if (!depthSource) { ofLogError("ofxKinectForWindows2::Device::drawPrettyMesh") << "No depth source initialised"; return; } //point cloud { //setup some point cloud properties for kicks bool usePointSize = true; #if OF_VERSION_MAJOR > 0 || OF_VERSION_MINOR >= 10 auto mainWindow = std::static_pointer_cast<ofAppGLFWWindow>(ofGetCurrentWindow()); usePointSize = mainWindow ? mainWindow->getSettings().glVersionMajor <= 2 : false; #endif usePointSize = false; if (usePointSize) { glPushAttrib(GL_POINT_BIT); glPointSize(5.0f); glEnable(GL_POINT_SMOOTH); } ofPushStyle(); bool useColor = colorSource.get(); if (useColor) { useColor &= colorSource->getTexture().isAllocated(); } if (useColor) { //bind kinect color camera texture and draw mesh from depth (which has texture coordinates) colorSource->getTexture().bind(); } auto opts = Source::Depth::PointCloudOptions(true, Source::Depth::PointCloudOptions::TextureCoordinates::ColorCamera); auto mesh = depthSource->getMesh(opts); //draw point cloud mesh.drawVertices(); //draw triangles ofSetColor(255, 150); mesh.drawWireframe(); //draw fills faded ofSetColor(255, 50); mesh.drawFaces(); if (useColor) { //unbind colour camera colorSource->getTexture().unbind(); } ofPopStyle(); //clear the point cloud drawing attributes if (usePointSize) { glPopAttrib(); } } //bodies and floor if (bodySource) { bodySource->drawWorld(); ofPushMatrix(); ofRotateDeg(90, 0, 0, 1); ofMultMatrix(bodySource->getFloorTransform()); ofDrawGridPlane(5.0f); ofPopMatrix(); } //draw the view cones of depth and colour cameras ofPushStyle(); ofNoFill(); ofSetLineWidth(2.0f); ofSetColor(100, 200, 100); depthSource->drawFrustum(); if (colorSource) { ofSetColor(200, 100, 100); colorSource->drawFrustum(); } ofPopStyle(); }
//-------------------------------------------------------------- void testApp::draw(){ ofBackgroundGradient(ofColor(40,40,40), ofColor(20,20,20), OF_GRADIENT_CIRCULAR); if(stage != 1){ gui->toggleVisible(); gui2->toggleVisible(); } if (stage == 0) { ofSetColor(255); helveticafont30.drawString("DO YOU HAVE SOMETHING TO HIDE?", ofGetWindowWidth()/2-340 , ofGetWindowHeight()/2); helveticafont30.drawString("LET THE NSA KNOW WHERE YOU ARE!", ofGetWindowWidth()/2-345 , ofGetWindowHeight()/2 + 45); } else if (stage == 1) { ofSetColor(255); helveticafont30.drawString("IS IN NEW YORK", ofGetWindowWidth()/2 - 142 , ofGetWindowHeight()/2); helfont15.drawString("Latitude: 40.704196 | Longitude: -74.042358", ofGetWindowWidth()/2 - 132, ofGetWindowHeight()/2 + 25); } else if (stage == 2) { helveticafont30.drawString("THANK YOU FOR YOUR COOPERATION.", ofGetWindowWidth()/2 - 310 , ofGetWindowHeight()/2); if(counter >= 140) stage = 0; } if(tracker.getFound()) { bFirst = false; if(counter >= 100 && stage == 0) { stage = 1; } if (bSnapshot == true){ unsigned char *camPixels = cam.getPixels(); img.setFromPixels(camPixels, cam.width, cam.height, OF_IMAGE_COLOR); img.crop(tracker.getPosition().x-150, tracker.getPosition().y-150, 300,300); string fileName; // string dir = "/Users/gusfaria11/Documents/openframeworks_v0.8.0/apps/thesis/PhotoFace/bin/data/img/"; // string dir = "/Users/gusfaria11/Documents/openframeworks_v0.8.0/apps/thesis/RT_FaceDetect/bin/data/faces/"; string dir = "/Users/gusfaria11/Documents/ofx_v0.8.0/apps/thesis/RT_FaceDetect/bin/data/faces/"; // if(typeStr == ""){ // fileName = "snapshot_"+ofToString(10000+snapCounter)+".png"; // } else { fileName = typeStr+".png"; // } img.saveImage(dir+fileName); sprintf(snapString, "saved %s", fileName.c_str()); //send text to another file. // string mydir = "/Users/gusfaria11/Documents/openframeworks_v0.8.0/apps/thesis/RT_FaceDetect/bin/data/train2.txt"; string mydir = "/Users/gusfaria11/Documents/ofx_v0.8.0/apps/thesis/RT_FaceDetect/bin/data/train2.txt"; // myfile.open(mydir); // string str = "HELLO its me again!\n"; // cout << str.length() << endl; // buffer.allocate(fileName.length()); // buffer.append(fileName+"\n"); // myfile.writeFromBuffer(buffer); // bool fileWritten = ofBufferToFile(mydir, buffer); // buffer.append(fileName+"\n"); // myfile.close(); snapCounter++; bSnapshot = false; bClick = false; bFirst = true; cam.draw(ofGetWindowWidth(),0); buffer = ofBufferFromFile(mydir); buffer.append(fileName+"\n"); ofBufferToFile(mydir, buffer); typeStr.clear(); stage = 2; } } if(bDebug){ //DEBUGGING ofDrawBitmapStringHighlight("stage: " + ofToString(stage), ofPoint(10,40)); ofDrawBitmapString(ofToString(counter), ofPoint(10,ofGetWindowHeight()-70)); ofDrawBitmapString(typeStr, ofPoint(10,ofGetWindowHeight()-50)); ofPushMatrix(); ofScale(0.25, 0.25); cam.draw(0,0); tracker.draw(); ofPopMatrix(); } }
void TextBlock::draw(){ float yAlig = y; if (vAlignment == OF_TEXT_ALIGN_BOTTOM){ yAlig = y + height - getTextHeight(); } else if (vAlignment == OF_TEXT_ALIGN_MIDDLE){ yAlig = getCenter().y - getTextHeight()*0.5; } if (hAlignment == OF_TEXT_ALIGN_LEFT){ string strToDraw; int currentWordID; float drawX; float drawY; float currX = 0; if (words.size() > 0){ for(int l=0;l < lines.size(); l++){ for(int w=0;w < lines[l].wordsID.size(); w++){ currentWordID = lines[l].wordsID[w]; drawX = x + currX; drawY = yAlig + (font->getLineHeight() * (l + 1)); ofPushMatrix(); font->drawString(words[currentWordID].rawWord.c_str(), drawX, drawY); currX += words[currentWordID].width; ofPopMatrix(); } currX = 0; } } } else if (hAlignment == OF_TEXT_ALIGN_RIGHT){ string strToDraw; int currentWordID; float drawX; float drawY; float currX = 0; if (words.size() > 0) { for(int l=0;l < lines.size(); l++){ for(int w=lines[l].wordsID.size() - 1; w >= 0; w--){ currentWordID = lines[l].wordsID[w]; drawX = -currX - words[currentWordID].width; drawY = font->getLineHeight() * (l + 1); ofPushMatrix(); //Move to top left point using pre-scaled co-ordinates ofTranslate(x + width, yAlig, 0.0f); font->drawString(words[currentWordID].rawWord.c_str(), drawX, drawY); currX += words[currentWordID].width; ofPopMatrix(); } currX = 0; } } } else if (hAlignment == OF_TEXT_ALIGN_JUSTIFIED){ string strToDraw; int currentWordID; float drawX; float drawY; int spacesN; float nonSpaceWordWidth; float pixelsPerSpace; float currX = 0; if (words.size() > 0) { for(int l=0;l < lines.size(); l++){ //Find number of spaces and width of other words; spacesN = 0; nonSpaceWordWidth = 0; for(int w = 0; w < lines[l].wordsID.size(); w++){ currentWordID = lines[l].wordsID[w]; if (words[currentWordID].rawWord == " ") spacesN++; else nonSpaceWordWidth += words[currentWordID].width; } pixelsPerSpace = (width - x - nonSpaceWordWidth) / spacesN; for(int w=0;w < lines[l].wordsID.size(); w++){ currentWordID = lines[l].wordsID[w]; drawX = currX; drawY = font->getLineHeight() * (l + 1); ofPushMatrix(); //Move to top left point using pre-scaled co-ordinates ofTranslate(x, yAlig, 0.0f); if (words[currentWordID].rawWord != " ") { font->drawString(words[currentWordID].rawWord.c_str(), drawX, drawY); currX += words[currentWordID].width; } else { currX += pixelsPerSpace; } ofPopMatrix(); } currX = 0; } } } else if (hAlignment == OF_TEXT_ALIGN_CENTER ){ string strToDraw; int currentWordID; float drawX; float drawY; float lineWidth; float currX = 0; if (words.size() > 0) { for(int l=0;l < lines.size(); l++){ //Get the length of the line. lineWidth = 0; for(int w=0;w < lines[l].wordsID.size(); w++){ currentWordID = lines[l].wordsID[w]; lineWidth += words[currentWordID].width; } for(int w=0;w < lines[l].wordsID.size(); w++){ currentWordID = lines[l].wordsID[w]; drawX = -(lineWidth / 2) + currX; drawY = font->getLineHeight() * (l + 1); ofPushMatrix(); //Move to central point using pre-scaled co-ordinates ofTranslate(getCenter().x, yAlig, 0.0f); font->drawString(words[currentWordID].rawWord.c_str(), drawX, drawY); currX += words[currentWordID].width; ofPopMatrix(); } currX = 0; } } } }
//-------------------------------------------------------------- void ofApp::draw(){ // DISPLAY STATUS ofDrawBitmapString("Recording Status: " + status, 0, 20); ofDrawBitmapString("Recognition Status: " + statusWord, 0, 40); // AUDIO INPUT ofNoFill(); // draw the average volume: ofPushStyle(); ofPushMatrix(); ofTranslate(300, 150, 0); ofSetColor(225); ofDrawBitmapString("Scaled average vol: " + ofToString(scaledVol * 100.0, 0), 4, 18); ofRect(0, 0, 400, 400); ofSetColor(245, 58, 135); ofFill(); //ofCircle(200, 200, scaledVol * 180.0f); //lets draw the volume history as a graph if (isRecording) { ofBeginShape(); for (unsigned int i = 0; i < volHistory.size(); i++){ if( i == 0 ) ofVertex(i, 400); ofVertex(i, 400 - volHistory[i] * 70); if( i == volHistory.size() -1 ) ofVertex(i, 400); } ofEndShape(false); } ofPopMatrix(); ofPopStyle(); // DRAW FONT if (!isRecording && volHistory.size() != 0 && hasRecognized) { //cout << "Mesh Size: " << meshesFront.size() << endl; // WAVE if(ofGetElapsedTimef() > addCountAt){ tempHistory = (tempHistory + 1)%volHistory.size(); addCountAt = ofGetElapsedTimef() + volHistory.size() * 0.001; } for (unsigned int i = 0; i < meshesFront.size(); i++) { float scale = meshesFront.size()/400.0; // DRAW MESH ofPushStyle(); ofPushMatrix(); ofTranslate(300, 350, 0); ofScale(1, volHistory[countHistory] * 2.0); meshesFront[i].draw(); ofPopMatrix(); ofPopStyle(); countHistory = (countHistory + 1)%volHistory.size(); } countHistory = tempHistory; } }
/** * Function: draw * -------------- * Use the waveform and FFT buffers * to render a tunnel-like thing. */ void ofApp::draw() { // TBD: figure out good title ofSetWindowTitle(country.name); float time = ofGetElapsedTimef(); // get time in seconds float angle = time * rotMultiplier; // rotation angle [and speed] /* float widthAngle = angle / 180 * PI; float heightAngle = (angle - 90) / 180 / PI; float scaledWidth, scaledHeight; float absCosWidthAngle = fabs(cos(widthAngle)); float absSinWidthAngle = fabs(sin(widthAngle)); float absCosHeightAngle = fabs(cos(heightAngle)); float absSinHeightAngle = fabs(sin(heightAngle)); if (ofGetWidth() / 2 * absSinWidthAngle <= ofGetHeight() / 2 * absCosWidthAngle) scaledWidth = ofGetWidth() / 2 / absCosWidthAngle; else scaledWidth = ofGetHeight() / 2 / absSinWidthAngle; if (ofGetWidth() / 2 * absSinHeightAngle <= ofGetHeight() / 2 * absCosHeightAngle) scaledHeight = ofGetWidth() / 2 / absCosHeightAngle; else scaledHeight = ofGetHeight() / 2 / absSinHeightAngle; */ // just some experimentation for a seamless tunnel float scaledHeight = max(ofGetHeight(), ofGetWidth()); float scaledWidth = max(ofGetHeight(), ofGetWidth()); // just for correctness bufferLock.lock(); // calculate the waveform drawing for (int i = 0; i < bufferSize; i += 2) { float offset = (scaledWidth / 2) / (bufferSize / 2) * bufferSize / 12; float x = (scaledWidth / 2) / (bufferSize / 2) * i; // fit hallway float y = inBuffer[i] * (scaledHeight / 2) / (bufferSize / 2) * i; wave.addVertex(ofPoint(x + offset, y, 0)); float alpha = ((float) 255 / (float) bufferSize) * 2 * i; ofColor waveColor = country.colorOne; waveColor.a = (int) alpha; wave.addColor(waveColor); } // so threadsafe bufferLock.unlock(); float ellipseWidth = ofGetWidth() / 2 * sqrt(2); float ellipseHeight = ofGetHeight() / 2 * sqrt(2); if (fftBuffers.size() <= 10) return; // get some data first if (beat.isHat() || beat.isSnare()) beatCount += 1; // for cycling if (beatCount % 64 == 0 && cyclingMode) // cycle flag country = flags[(++flagIndex) % flagCount]; // calculate the FFT spectrum drawing for (int i = 0; i < fftBuffers.size() - 10; i += 1) { vector<float> fftBuffer = fftBuffers[i]; int rev = fftBuffers.size() - 1 - i; // see above // so that we avoid overlap on the innermost rings int step = (rev > 10) ? 2 : ((rev > 5) ? 4 : 8); // for each FFT frequency in the buffer [by step] for (int j = 0; j < bufferSize; j += step) { float magnitude = sqrt(pow(fftBuffer[j], 2) + pow(fftBuffer[j + 1], 2)); // complex norm float theta = 2 * PI / (bufferSize / step) * j / step; // parametrize frequency by angle // used for ellipse parametrization in ellipse mode float maxRadius = sqrt(pow(ellipseWidth * cos(theta), 2) + pow(ellipseHeight * sin(theta), 2)); float bufferRadius = maxRadius / fftBuffers.size() * rev; // get radius by buffer num and angle float maxWidth = scaledWidth / 2; float maxHeight = scaledHeight / 2; float bufferWidth = maxWidth / (fftBuffers.size() - 15) * rev; float bufferHeight = maxHeight / (fftBuffers.size() - 15) * rev; // two ways float x, y; if (ellipseMode) x = (1 + magnitude) * bufferRadius * cos(theta); // for rectangles we use Lame curves else x = (1 + magnitude) * bufferWidth * (abs(cos(theta)) * cos(theta) + abs(sin(theta)) * sin(theta)); if (ellipseMode) y = (1 + magnitude) * bufferRadius * sin(theta); // for rectangles we use Lame curves else y = (1 + magnitude) * bufferHeight * (abs(cos(theta)) * cos(theta) - abs(sin(theta)) * sin(theta)); spectrum.addVertex(ofPoint(x, y, 0)); // TBD: depth? float alpha = ((float) 20 / (float) fftBuffers.size()) * rev + 235; scaledVol = ofMap(smoothedVol, 0.0, 0.17, 0.0, 1.0, true); // if (beat.isKick()) spectrum.addColor(country.colorOne); if (beat.isHat()) spectrum.addColor(ofColor(country.colorTwo)); if (beat.isSnare()) spectrum.addColor(ofColor(country.colorThree)); spectrum.addColor(country.gradientFn(i, fftBuffers.size(), alpha)); } } ofEnableDepthTest(); // enable z-buffering ofBackgroundGradient(ofColor(0, 0, 0), ofColor(0, 0, 0)); ofPushMatrix(); // draw the spectrum first ofEnableAlphaBlending(); // for transparency ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2, 0); ofRotate(angle); // see controls if (drawingType == 1) { spectrum.setMode(OF_PRIMITIVE_LINE_STRIP); ofSetLineWidth(2); } else if (drawingType == 2) { spectrum.setMode(OF_PRIMITIVE_POINTS); glPointSize(3); glEnable( GL_POINT_SMOOTH ); } // drawingType == 3 corresponds to triangles else spectrum.setMode(OF_PRIMITIVE_TRIANGLES); spectrum.draw(); // draw the spectrum mesh ofDisableAlphaBlending(); // turn off transparency spectrum.clear(); // clear the mesh for next time ofPopMatrix(); // restore the coordinate system ofPushMatrix(); // then draw the waveform ofEnableAlphaBlending(); // for transparency // ofSetColor(ofColor(255, 255, 255)); wave.setMode(OF_PRIMITIVE_LINE_STRIP); ofSetLineWidth(5); ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2, 0); ofRotate(angle); // sync with spectrum rotation wave.draw(); // draw the mesh ofRotate(180); // reflect mesh wave.draw(); // draw mesh again ofDisableAlphaBlending(); wave.clear(); // clear the mesh for next time ofPopMatrix(); // restore the coordinate system }
void scene01::draw(){ bool bAnySelected = false; ofPoint selectionPoint; for (int i=0; i<photos.size();i++){ if (photos[i].condition == photo::seleced) { bAnySelected = true; selectionPoint =photos[i].pos; dragPoint = photos[i].pos; } } if (bAnySelected){ targetPos = 0.92 * targetPos + 0.08 *selectionPoint; }else{ targetPos = 0.70 * targetPos + 0.30 *dragPoint; } //------------------------------------------------darg ofPushMatrix(); ofTranslate(-targetPos.x,-targetPos.y,screenZ); ofTranslate(centerPos.x,centerPos.y, 0); for (int i=0; i<photos.size(); i++) { if (photos[i].condition == photo::display) { photos[i].draw(); } } for (int i=0; i<photos.size(); i++) { if (photos[i].condition == photo::seleced) { photos[i].draw(); } } ofPopMatrix(); //------------------------------------------------buttons for (int i=0; i<photos.size(); i++) { if (photos[i].animation == photo::stop) { ofSetColor(255); createOwn.draw(createOwnRect); moreMoto.draw(moreMotoRect); closeIcon.draw(closeIconRect); break; } } if (bNarrow) { ofSetColor(255); ofPushMatrix(); ofTranslate(ofGetWidth()/2, ofGetHeight()/2); int w = narrow.getWidth()/6; int h = narrow.getHeight()/6; narrow.draw(-w/2,-h/2, w,h); ofPopMatrix(); } }
//-------------------------------------------------------------- void testApp::draw() { ofEnableAlphaBlending(); ofSetHexColor(0xffffff); // we read the values in the depth buffer and test against them. // We are also *writing* to the depth buffer when we draw glEnable(GL_DEPTH_TEST); ofPushMatrix(); ofTranslate(ofGetWidth()/2, ofGetHeight()/2, zoom); ofRotate(cameraRotation.x, 1, 0, 0); ofRotate(cameraRotation.y, 0, 1, 0); ofRotate(cameraRotation.y, 0, 0, 1); // Now we *Still test against depth*, // but we *no longer write* to the depth buffer glDepthMask(GL_FALSE); // bind the shader so that wee can change the // size of the points via the vert shader billboardShader.begin(); billboardShader.setUniform1fv("pointSize", billboardSize, NUM_BILLBOARDS); ofEnableAlphaBlending(); ofEnablePointSprites(); texture.getTextureReference().bind(); billboardVbo.bind(); billboardVbo.setVertexData(billboardVerts, NUM_BILLBOARDS, GL_DYNAMIC_DRAW); billboardVbo.setColorData(billboardColor, NUM_BILLBOARDS, GL_DYNAMIC_DRAW); billboardVbo.draw(GL_POINTS, 0, NUM_BILLBOARDS); billboardVbo.unbind(); texture.getTextureReference().unbind(); ofDisablePointSprites(); billboardShader.end(); ofPopMatrix(); // re0enable writing to the depth buffer, so the next drame is ok. // We need to do this because GL is a state machine, and its a dumb mother f****r. glDepthMask(GL_TRUE); ofPushStyle(); ofEnableAlphaBlending(); ofSetHexColor(0xffffff); texture.draw(30, 80); //ofSetHexColor(0xff0000); //ofNoFill(); //ofRect(20, 100, texture.getWidth(), texture.getHeight()); ofSetHexColor(0xffffff); ofDrawBitmapString("<-- This is your billboard texture\n the texture needs to a power of\n 2 for proper rendering.", 95, 32+texture.getHeight()); // ------------------------- // debug info ofSetColor(255, 255, 255); string info = ofToString(ofGetFrameRate(), 2)+"\n"; info += "Particle Count: "+ofToString(NUM_BILLBOARDS)+"\n"; ofDrawBitmapString(info, 30, 30); ofPopStyle(); }
void slitScanApp::draw(){ if(!useLiveVideo){ //weird video player bug... may not need this any more vidPlayer.play(); } ofPushStyle();{ ofSetHexColor(COLOR_GREEN_DARK); ofRect(0, 0, ofGetWidth(), ofGetHeight()); }ofPopStyle(); if(isFullScreen){ warp.getOutputImage().draw(0, 0, ofGetWidth(), ofGetHeight()); return; } //Draw top selector ofPushStyle(); ofPushMatrix(); { ofFill(); ofSetHexColor(COLOR_GREEN_DARK); ofRect(0, 0, DRAW_WIDTH, SELECTOR_HEIGHT); ofSetHexColor(0xffffff); for(int i = 0; i <= sampleMaps.size(); i++){ //if it's selected, draw a selection highlight if(i == currentSampleMapIndex){ ofPushStyle();{ ofSetHexColor(COLOR_GREEN_LIGHT); ofRect(FRAME_PADDING/2 + i*(MAP_THUMB_WIDTH+FRAME_PADDING), FRAME_PADDING/2, MAP_THUMB_WIDTH+FRAME_PADDING, MAP_THUMB_HEIGHT+FRAME_PADDING); ofNoFill(); ofSetHexColor(COLOR_YELLOW_HIGHLIGHT); ofRect(FRAME_PADDING/2 + i*(MAP_THUMB_WIDTH+FRAME_PADDING), FRAME_PADDING/2, MAP_THUMB_WIDTH+FRAME_PADDING, MAP_THUMB_HEIGHT+FRAME_PADDING); } ofPopStyle(); } if(i < sampleMaps.size()){ //draw the map sampleMaps[i]->draw(FRAME_PADDING + i*(MAP_THUMB_WIDTH+FRAME_PADDING), FRAME_PADDING, MAP_THUMB_WIDTH, MAP_THUMB_HEIGHT ); } else{ if(currentSampleMapIndex == i){ customMap.draw(FRAME_PADDING + i*(MAP_THUMB_WIDTH+FRAME_PADDING), FRAME_PADDING, MAP_THUMB_WIDTH, MAP_THUMB_HEIGHT); } else{ ofSetHexColor(0xFFFFFF); loadYourOwn.draw(FRAME_PADDING + i*(MAP_THUMB_WIDTH+FRAME_PADDING), FRAME_PADDING); } } } } ofPopMatrix(); ofPopStyle(); ofTranslate(0, SELECTOR_HEIGHT); //Draw view ports ofPushStyle(); ofPushMatrix(); { ofFill(); ofSetHexColor(COLOR_YELLOW); ofRect(0, 0, WIDTH+(FRAME_PADDING*2), HEIGHT+(FRAME_PADDING*2)); ofSetHexColor(0xffffff); warp.getOutputImage().draw(FRAME_PADDING, FRAME_PADDING); //if we are hovering, draw the overlay //normalize coordinates for (0,0) at top of the overlay int viewMouseX = mouseX - FRAME_PADDING*2; int viewMouseY = mouseY - (FRAME_PADDING*2 + SELECTOR_HEIGHT); if(viewMouseX > 0 && viewMouseX < WIDTH && viewMouseY > 0 && viewMouseY < HEIGHT){ ofEnableAlphaBlending(); //movie / live video selector ofPushMatrix(); ofPushStyle();{ ofTranslate(FRAME_PADDING*2, FRAME_PADDING*2); if(useLiveVideo){ buttonLiveOn.draw(0,0); } else { buttonMovieOn.draw(0, 0); } } ofPopMatrix(); ofPopStyle(); //frame blender ofPushMatrix(); ofPushStyle(); { ofTranslate(WIDTH - HUD_BUTTON_WIDTH, FRAME_PADDING*2); if(warp.isBlending()){ buttonBlendingOn.draw(0,0); } else{ buttonBlendingOff.draw(0, 0); } } ofPopMatrix(); ofPopStyle(); //pause button ofPushMatrix(); ofPushStyle();{ ofTranslate(FRAME_PADDING*2, HEIGHT - ( FRAME_PADDING+HUD_BUTTON_HEIGHT)); if(isPaused){ buttonPauseOn.draw(0, 0); } else{ buttonPauseOff.draw(0, 0); } } ofPopMatrix(); ofPopStyle(); //full screen button ofPushMatrix(); ofPushStyle();{ ofTranslate(WIDTH - HUD_BUTTON_WIDTH, HEIGHT - ( FRAME_PADDING+HUD_BUTTON_HEIGHT)); buttonFullscreenOff.draw(0,0); } ofPopMatrix(); ofPopStyle(); } ofTranslate(WIDTH+(FRAME_PADDING*2), 0); ofSetHexColor(COLOR_GREEN_DARK); ofRect(0, 0, WIDTH+(FRAME_PADDING*2), HEIGHT+(FRAME_PADDING*2)); ofSetHexColor(0xffffff); warp.getDelayMap().draw(FRAME_PADDING, FRAME_PADDING, WIDTH, HEIGHT); } ofPopMatrix(); ofPopStyle(); ofTranslate(0, HEIGHT+FRAME_PADDING*2); //draw filmstrip ofPushStyle(); ofPushMatrix(); { ofFill(); ofSetHexColor(COLOR_YELLOW); ofRect(0, 0, DRAW_WIDTH, heightPerFrame+FRAME_PADDING*4); ofTranslate(FRAME_PADDING+CLAMP_HANDLE_WIDTH, FRAME_PADDING); ofSetHexColor(0xffffff); int frameStep = warp.getCapacity() / framesToShow; int fameIndex = 0; unsigned char* pixels = previewImage.getPixels(); for(int i = 0; i < framesToShow; i ++){ warp.pixelsForFrame(warp.getCapacity() - (frameStep*i) - 1, pixels); previewImage.setFromPixels(pixels, WIDTH, HEIGHT, OF_IMAGE_COLOR); previewImage.draw(widthPerFrame*i, FRAME_PADDING, widthPerFrame, heightPerFrame); } float leftClampX = leftClamp * filmStripWidth; float rightClampX = rightClamp * filmStripWidth; ofEnableAlphaBlending(); ofSetColor(0xac, 0x99, 0x66, 200); ofFill(); //block out left side ofRect(0, 0, leftClampX, FRAME_PADDING+heightPerFrame); //block out right side ofRect(rightClampX, 0, filmStripWidth - rightClampX, heightPerFrame+FRAME_PADDING); //handles ofSetHexColor(0xFFFFFF); leftHandle.draw(leftClampX - 1, 0); rightHandle.draw(rightClampX - CLAMP_HANDLE_WIDTH, FRAME_PADDING); ofDisableAlphaBlending(); } ofPopMatrix(); ofPopStyle(); //draw capacity slider ofTranslate(0, heightPerFrame + FRAME_PADDING*3); ofPushStyle(); ofPushMatrix(); { ofFill(); ofSetHexColor(COLOR_YELLOW); ofRect(0, 0, DRAW_WIDTH, CAPACITY_SLIDER_HEIGHT + FRAME_PADDING*2); ofTranslate(FRAME_PADDING, FRAME_PADDING); float capacitySliderWidth = DRAW_WIDTH - FRAME_PADDING*2; ofSetHexColor(0xFFFFFF); frameCapacityBar.draw(0,0); ofFill(); ofSetHexColor(COLOR_YELLOW); ofRect(capacitySliderWidth * (1.0 * capacity / MAX_CAPACITY), 1, capacitySliderWidth * (1.0 - 1.0 * capacity / MAX_CAPACITY)-1 , CAPACITY_SLIDER_HEIGHT-2); ofSetHexColor(0xFFFFFF); ofEnableAlphaBlending(); frameCapacityText.draw(capacitySliderWidth/2 - frameCapacityText.width/2, CAPACITY_SLIDER_HEIGHT/2.0 - frameCapacityText.height/2); ofDisableAlphaBlending(); } ofPopMatrix(); ofPopStyle(); //draw bottom label ofTranslate(0, CAPACITY_SLIDER_HEIGHT + 22); bottomImage.draw(0,0); }
//-------------------------------------------------------------- void ofApp::draw() { ofBackground(30); float w = _shapeSize; float s = 40.0f; float x = s; float y = s; ofSetColor(ofColor::fromHex(0xFF7B87)); ofRect(x, y, 0, w, w); x += w + s; ofSetColor(ofColor::fromHex(0x475887)); ofCircle(x + w/2, y + w/2, w/2); x += w + s; ofSetColor(220, 222, 121); ofSetLineWidth(30.0f); ofLine(x + s, y + s, x + w - s, y + w - s); x += w + s; ofSetColor(255, 232, 183); ofEllipse(x + w, y + w/2, w*2, w); x = s; y = s + w + s; ofSetLineWidth(20.0f); ofSetColor(100, 255, 255); ofPushMatrix(); ofTranslate(x + (w/2), y + (w/2)); _polygon.draw(); ofPopMatrix(); x += w + s; ofPushMatrix(); ofTranslate(x + (w/2), y + (w/2)); _star.draw(); ofPopMatrix(); x += w + w + s; y += w; ofPushMatrix(); ofTranslate(x + (w/2), y + (w/2)); _curvedPath.draw(); ofPopMatrix(); ofSetColor(255, 255, 255); stringstream m; m << "FPS: " << (int)ofGetFrameRate(); m << " | current renderer: "; m << (ofGetCurrentRenderer() == _defaultRenderer ? "DEFAULT" : "OFX_SHIVA_VG"); m << " | click to toogle renderer"; m << " | hit 'c' to toggle line-cap style"; ofDrawBitmapString(m.str(), s, ofGetHeight() - s); }
//-------------------------------------------------------------- void cyrilApp::draw(){ if (fxOn) { _state.post.begin(); } ofEnableDepthTest(); if (lightsOn) { _state.light->enable(); // The default position of the light (apply z-scale) _state.light->setPosition(0,0,1000); } else { ofDisableLighting(); } //ofEnableAlphaBlending(); _state.ms->clearStacks(); float X_MAX = (*_state.sym)[REG_X_MAX]; float Y_MAX = (*_state.sym)[REG_Y_MAX]; float X_MID = (*_state.sym)[REG_X_MID]; float Y_MID = (*_state.sym)[REG_Y_MID]; float X_SCALE = (*_state.sym)[REG_X_SCALE]; float Y_SCALE = (*_state.sym)[REG_Y_SCALE]; float Z_SCALE = (*_state.sym)[REG_Z_SCALE]; for (int i = 0; i < 10; ++i) { if (running[i]) { if (prog[i]->valid) { ofPushMatrix(); ofTranslate(X_MID, Y_MID); _state.ms->pushMatrix(); _state.ms->translate(X_MID, Y_MID); ofScale(X_SCALE, Y_SCALE, Z_SCALE); _state.ms->scale(X_SCALE, Y_SCALE, Z_SCALE); prog[i]->eval(_state); _state.ms->popMatrix(); ofPopMatrix(); } } } for(vector<Particle*>::iterator it = _state.ps->begin(); it != _state.ps->end(); ++it){ (*it)->draw(&_state); } if (lightsOn) { _state.light->disable(); } if (fxOn) { _state.post.end(); } //mainOutputSyphonServer.publishScreen(); // Draw the editor if enabled if (editorVisible) { ofDisableDepthTest(); ofPushMatrix(); ofPushStyle(); ofSetColor(255); ofFill(); editor.draw(); ofTranslate(X_MID - 50, 10); for (int i = 0; i < 10; ++i) { if (error[i]) { ofSetColor(255,0,0); } else if (running[i]) { ofSetColor(255); } else { ofSetColor(150); } ofRect(i * 10, 0, 8, 8); if (editor.currentBuffer == i) { ofSetColor(255); ofRect(i * 10, 10, 8, 5); } } ofPopStyle(); ofPopMatrix(); } }
//-------------------------------------------------------------- void testApp::draw(){ jonnysMovies.draw(0, 0, ofGetWidth(), ofGetHeight()); if (oneOn == true) { ofSetColor(255, 255, 255); string user = "******" + twitter[1]["user"]["screen_name"].asString() + ":"; font.drawString(user, 10, ofGetHeight()/5 - 50); ofSetColor(0,255,255); string message = twitter[1]["text"].asString(); float messageWidth = font.stringWidth(message); if (messageWidth > ofGetWidth()-10) { string line1 = message.substr(0, 70); string line2 = message.substr(71, 70); font.drawString(line1, 10, ofGetHeight()/5); font.drawString(line2, 10, ofGetHeight()/5+50); }else { font.drawString(message, 10, ofGetHeight()/5); } ofSetColor(255, 255, 255); }else if (twoOn == true) { ofSetColor(255, 255, 255); string user = "******" + twitter[2]["user"]["screen_name"].asString() + ":"; font.drawString(user, 10, 2*ofGetHeight()/5 - 50); ofSetColor(255,0,255); string message = twitter[2]["text"].asString(); float messageWidth = font.stringWidth(message); if (messageWidth > ofGetWidth()-10) { string line1 = message.substr(0, 70); string line2 = message.substr(71, 70); font.drawString(line1, 10, 2*ofGetHeight()/5); font.drawString(line2, 10, 2*ofGetHeight()/5+50); }else { font.drawString(message, 10, 2*ofGetHeight()/5); } ofSetColor(255, 255, 255); }else if (threeOn == true) { ofSetColor(255, 255, 255); string user = "******" + twitter[3]["user"]["screen_name"].asString() + ":"; font.drawString(user, 10, 3*ofGetHeight()/5 - 50); ofSetColor(255,255,0); string message = twitter[3]["text"].asString(); float messageWidth = font.stringWidth(message); if (messageWidth > ofGetWidth()-10) { string line1 = message.substr(0, 70); string line2 = message.substr(71, 70); font.drawString(line1, 10, 3*ofGetHeight()/5); font.drawString(line2, 10, 3*ofGetHeight()/5+50); }else { font.drawString(message, 10, 3*ofGetHeight()/5); } ofSetColor(255, 255, 255); }else if (fourOn == true) { ofSetColor(255, 255, 255); string user = "******" + twitter[4]["user"]["screen_name"].asString() + ":"; font.drawString(user, 10, 4*ofGetHeight()/5 - 50); ofSetColor(200,200,200); string message = twitter[4]["text"].asString(); float messageWidth = font.stringWidth(message); if (messageWidth > ofGetWidth()-10) { string line1 = message.substr(0, 70); string line2 = message.substr(71, 70); font.drawString(line1, 10, 4*ofGetHeight()/5); font.drawString(line2, 10, 4*ofGetHeight()/5+50); }else { font.drawString(message, 10, 4*ofGetHeight()/5); } ofSetColor(255, 255, 255); }else if (sliderOn == true){ ofSetColor(0, 0, 0); string feed = "#FEEDmixer"; float mappedSize = ofMap(stringSize, 0, 127, 1, 5); float feedWidth = font.stringWidth(feed)/2; float feedHeight = font.stringHeight(feed)/2; float screenWidth = ofGetWidth()/2; float screenHeight = ofGetHeight()/2; float x = screenWidth-feedWidth; float y = screenHeight-feedHeight; ofSetRectMode(OF_RECTMODE_CENTER); ofPushMatrix(); ofTranslate(screenWidth,screenHeight); ofScale(mappedSize, mappedSize); font.drawString(feed, 0-feedWidth, 0); ofPopMatrix(); ofSetRectMode(OF_RECTMODE_CORNER); ofSetColor(255, 255, 255); } }
void ofxTLAudioTrack::draw(){ if(!soundLoaded || player.getBuffer().size() == 0){ ofPushStyle(); ofSetColor(timeline->getColors().disabledColor); ofRectangle(bounds); ofPopStyle(); return; } if(shouldRecomputePreview || viewIsDirty){ recomputePreview(); } //cout << "ofxTLAudioTrack::draw" << endl; ofSetColor(255, 255, 255, 205); ofFill(); ofRect(bounds); ofPushStyle(); //ofSetColor(timeline->getColors().keyColor); ofSetColor(0, 0 , 0, 255); ofNoFill(); for(int i = 0; i < previews.size(); i++){ ofPushMatrix(); ofTranslate( normalizedXtoScreenX(computedZoomBounds.min, zoomBounds) - normalizedXtoScreenX(zoomBounds.min, zoomBounds), 0, 0); ofScale(computedZoomBounds.span()/zoomBounds.span(), 1, 1); previews[i].draw(); ofPopMatrix(); } ofPopStyle(); if(getIsPlaying() || timeline->getIsPlaying()){ ofPushStyle(); //will refresh fft bins for other calls too vector<float>& bins = getFFTSpectrum(defaultFFTBins); float binWidth = bounds.width / bins.size(); //find max float averagebin = 0 ; for(int i = 0; i < bins.size(); i++){ maxBinReceived = MAX(maxBinReceived, bins[i]); averagebin += bins[i]; } averagebin /= bins.size(); ofFill(); ofSetColor(timeline->getColors().disabledColor, 120); for(int i = 0; i < bins.size(); i++){ float height = bounds.height * bins[i]/maxBinReceived; float y = bounds.y + bounds.height - height; ofRect(bounds.x + i*binWidth, y, binWidth, height); } ofPopStyle(); } // playhead ofPushStyle(); ofSetColor(0, 0, 0, 255); float x = normalizedXtoScreenX( oldpos, zoomBounds); ofLine(x, bounds.y, x, bounds.y + bounds.height); ofSetLineWidth(3); ofPopStyle(); /* float pos = player.getPosition(); if (pos) { ofxTLZoomer2D *zoom = (ofxTLZoomer2D*)timeline->getZoomer(); ofRange z = zoom->getViewRange(); ofRange oldz = z; float c = z.center(); float d = pos - c; z.min = ofClamp(z.min + d, 0, 1); z.max = ofClamp(z.max + d, 0, 1); if (z.min == .0 && z.span() < oldz.span()) z.max = oldz.max - oldz.min; if (z.max == 1. && z.span() < oldz.span()) z.min = z.max - oldz.max + oldz.min; }*/ // draw markers: for (vector<AlignMarker>::iterator m = markers.begin(); m != markers.end(); m++) { float xn = screenXtoNormalizedX(millisToScreenX(m->ms)); if (zoomBounds.contains(xn)) { float x = timeline->normalizedXtoScreenX(xn, zoomBounds); if (m->selected) ofSetColor(255, 0, 0, 255); else ofSetColor(0, 0, 0, 255); ofLine(x, bounds.y, x, bounds.y+bounds.height); m->rect = ofRectangle(x - 5, bounds.y + bounds.height - 12, 10, 10); ofSetColor(10, 0, 200, 100); ofFill(); ofRect(m->rect); //cout << "m:" << m->ms << endl; ofSetColor(0, 0, 0, 255); timeline->getFont().drawString(ofToString(m->ms), x+1, bounds.y + 30); } } }
//-------------------------------------------------------------- void testApp::draw(){ updateParticleSystem(); updatePerlinLuminosity(); renderTarget.begin(); ofClear(0,0,0,255); cam.begin(ofRectangle(0,0,renderTarget.getWidth(), renderTarget.getHeight())); if(player.isLoaded()){ drawGeometry(); } ofPushMatrix(); // ofScale(1,-1,1); ofTranslate(timeline.getValue("x offset"), 0, timeline.getValue("z offset")); glEnable(GL_DEPTH_TEST); ofEnableBlendMode(OF_BLENDMODE_SCREEN); ofSetColor(0); ofPushMatrix(); ofScale(1, -1, 1); meshBuilder.getMesh().disableColors(); meshBuilder.getMesh().draw(); meshBuilder.getMesh().enableColors(); ofPopMatrix(); ofSetColor(255); ambientShader.begin(); ofEnablePointSprites(); ofDisableArbTex(); crossSprite.getTextureReference().bind(); ambientShader.setUniform1f("maxDisance", particleMaxDistance) ; ambientShader.setUniform1f("maxSize", particeMaxSize) ; ofEnableBlendMode(OF_BLENDMODE_SCREEN); ofPushStyle(); glPointSize(3.0); ofSetColor(particleFade*255); ambientParticles.drawVertices(); ofPopStyle(); ambientShader.end(); crossSprite.getTextureReference().unbind(); glDisable(GL_DEPTH_TEST); ofDisablePointSprites(); ofEnableArbTex(); ofPopMatrix(); // randomUnits.drawVertices(); // clusters.drawVertices(); cam.end(); renderTarget.end(); ofEnableAlphaBlending(); ofPushStyle(); ofSetColor(0); ofRect(fboRect); ofPopStyle(); renderTarget.getTextureReference().draw(fboRect.x,fboRect.getBottom(),fboRect.width,-fboRect.height); if(rendering){ saveImage.setUseTexture(false); renderTarget.readToPixels(saveImage.getPixelsRef()); saveImage.mirror(true, false); char filename[1024]; sprintf(filename, "%sframe_%05d.png",renderFolder.c_str(), currentFrameNumber); saveImage.saveImage(filename); currentFrameNumber++; } timeline.draw(); gui.draw(); }
//-------------------------------------------------------------- void testApp::draw(){ if (calibrateOn) drawGrid(); if (calibrateOn) calibrate(); drawText(); //draw the cities------------------------------------------// ofPushMatrix(); ofTranslate(gridX,gridY); ofScale(gridScaleX + scaleFactor, gridScaleY + scaleFactor); ofRotateZ(degreesFactor); ofEnableSmoothing(); ofFill(); for (int i = 0; i < 129; i++) { if (cities[i].isNear) { ofSetHexColor(0xe0be21); } else { ofSetColor(0); } cities[i].display(); } ofFill(); ofPopMatrix(); //check distance------------------------------------------// for (int i = 0; i < 129; i++) { //we set the new coordinates of the cities to compare with mousePosition float loc_x_temp = cities[i].loc.x*(scaleFactor)+gridX; float loc_y_temp = cities[i].loc.y*(scaleFactor)+gridY; float d = ofDist(loc_x_temp, loc_y_temp,knob.x, knob.y); //magnitude if (rotation){ ofVec2f locV(loc_x_temp,loc_y_temp); locV.rotate(degreesFactor); d= ofDist(locV.x, locV.y,knob.x, knob.y); } d = ofClamp(d, 0, 15); //add the station to the playlist. change later to "play"---------// if (d < 15) { int vol = ofMap(d, 0, 15, 100, 0); cities[i].volume = vol; string setVol = "volume " + cities[i].volume; //for soundflower? cities[i].isNear = true; if (!cities[i].isPlaying) { string command = "add " + cities[i].station; vlc.run(command); nowPlaying = cities[i].name; cities[i].isPlaying = true; } } else { cities[i].isNear = false; cities[i].isPlaying = false; } } //tuio---------------------------// //render TUIO Cursors and Objects myTuio.drawCursors(); myTuio.drawObjects(); knob = myTuio.returnCursor(); ofSetColor(100, 250, 100); ofCircle (knob.x, knob.y, 60); }
void testApp::drawScene() { light.enable(); ofPushMatrix(); ofScale(whole_scene_scale,whole_scene_scale,whole_scene_scale); ofRotateX(scene_rx); ofRotateY(scene_ry); ofRotateZ(scene_rz); ofTranslate(whole_scene_x, whole_scene_y, whole_scene_z); ofPushMatrix(); ofVboMesh theCloud; theCloud.setUsage(GL_DYNAMIC_DRAW); theCloud.setMode(OF_PRIMITIVE_POINTS); theCloud.getNormals().resize(cloudField,ofVec3f(0)); for (int i=0; i<cloud.size();i++) { theCloud.addVertex(cloud[i].location); theCloud.setNormal(i,ofVec3f( ofMap(meditationLevel, 0, 100, 5, 0) +ofNoise(ofGetElapsedTimef()+i),0,0)); } billboardShader.begin(); glDisable(GL_DEPTH_TEST); ofEnablePointSprites(); texture.getTextureReference().bind(); theCloud.draw(); texture.getTextureReference().unbind(); ofDisablePointSprites(); billboardShader.end(); glEnable(GL_DEPTH_TEST); ofPopMatrix(); // ---- room ---- if(showRoom){ ofPushMatrix(); ofEnableDepthTest(); ofSetColor(255); ofRotateX(270); ofRotateY(roomRotateY); ofTranslate(roomModelPos); roomModel.draw(); ofPopMatrix(); } // ---- end room ---- ofPushMatrix(); drawPointCloud(); ofPopMatrix(); #ifdef USE_TWO_KINECTS ofPushMatrix(); drawAnotherPointCloud(); ofPopMatrix(); #endif ofPopMatrix(); }
//-------------------------------------------------------------- void Leaf::draw(){ //DRAW STUFF // ofRect(xPos, yPos, 20, 40); //Draw leave //draw leaf left ofPushMatrix(); ofTranslate(xPos, yPos); ofRotateZ(rotation); ofScale(scaleFactor, scaleFactor); ofSetColor(leafColor); ofBeginShape(); float x0 = 0; float x1 = x0 - leafWidth/2; float x2 = x0 - leafWidth/4; float x3 = 0; float y0 = 0 + stemLength; float y1 = y0 + leafLength/3; float y2 = y1 + leafLength/3; float y3 = y0 + leafLength; ofVertex(x0,y0); ofBezierVertex(x1,y1,x2,y2,x3,y3); ofEndShape(); //draw leaf right ofBeginShape(); x0 = 0; x1 = x0 + leafWidth/2; x2 = x0 + leafWidth/4; x3 = 0; y0 = 0 + stemLength; y1 = y0 + leafLength/3; y2 = y1 + leafLength/3; y3 = y0 + leafLength; ofVertex(x0,y0); ofBezierVertex(x1,y1,x2,y2,x3,y3); ofEndShape(); //draw stem ofSetColor(stemColor); ofRect(0, 0 + stemLength/2, stemWidth, stemLength); //triangular stem through leaf ofTriangle(0 - stemWidth/2, 0 + stemLength, 0 + stemWidth/2, 0 + stemLength, 0, 0 + stemLength + 2*(leafLength/3)); ofPopMatrix(); }