//-------------------------------------------------------------- void ofApp::draw(){ float y = 1; float angle; ofVec3f axis; ofDrawBitmapStringHighlight("Connected bands: " + ofToString(myo.numConnectedArmbands()), 20, 20 * y); for (int i = 0; i < myo.numConnectedArmbands(); i++) { ofxMyoWebSockets::Armband* armband = myo.armbands[i]; cam.begin(); ofDrawGrid(250, 5); ofVec3f pos = armband->quat * ofVec3f(300, 0, 0); ofSetColor( ofColor::fromHsb((float)i/myo.numConnectedArmbands()*255, 225, 225) ); ofDrawArrow( ofVec3f(0, 0, 0), pos, 8 ); cam.end(); y++; ofDrawBitmapStringHighlight("Armband " + ofToString(i), 20, 20 * ++y); ofDrawBitmapStringHighlight("Myo ID: " + ofToString(armband->id), 20, 20 * ++y); ofDrawBitmapStringHighlight("Arm: " + armband->arm, 20, 20 * ++y); ofDrawBitmapStringHighlight("X Direction: " + armband->direction, 20, 20 * ++y); ofDrawBitmapStringHighlight("Pose: " + armband->pose, 20, 20 * ++y); ofDrawBitmapStringHighlight("Pose Confirmed: " + ofToString(armband->poseConfirmed), 20, 20 * ++y); ofDrawBitmapStringHighlight("Unlocked: " + ofToString(armband->unlocked), 20, 20 * ++y); } }
void ofApp::draw() { gui.draw(); // verplaats het 0-punt naar 't midden van 't scherm ofTranslate(ofGetWidth()/2, ofGetHeight()/2); // draai het grid om de x-as ofRotateX(rotationX); ofSetColor(255,0,0); ofCircle(-300,0,130); // draai het grid om de y-as ofRotateY(rotationY); ofSetColor(0,255,0); ofCircle(0,0,130); // draai het grid om de z-as ofRotateZ(rotationZ); ofSetColor(0,0,255); ofCircle(300,0,130); // als het 'drawGrid' vlaggetje op 'true' staat, teken dan 't grid if (drawGrid) ofDrawGrid(200); }
//-------------------------------------------------------------- void ofApp::draw(){ ofColor cyan = ofColor::fromHex(0x00abec); ofColor magenta = ofColor::fromHex(0xec008c); ofColor yellow = ofColor::fromHex(0xffee00); ofBackgroundGradient(magenta * .6, magenta * .4); ofNoFill(); easyCam.begin(); ofRotateXDeg(15); ofSetColor(0); ofDrawGrid(500, 10, false, false, true, false); // draw the path of the box ofSetLineWidth(2); ofSetColor(cyan); pathLines.draw(); // draw a line connecting the box to the grid ofSetColor(yellow); ofDrawLine(current.x, current.y, current.z, current.x, 0, current.z); ofTranslate(current.x, current.y, current.z); if( (current - previous ).length() > 0.0 ){ // translate and rotate every 3D object after this line to the current position and orientation of our line, but only if the line is longer than 0 or has a length rotateToNormal(current - previous); } ofSetColor(255); ofDrawBox(32); ofDrawAxis(32); easyCam.end(); }
//-------------------------------------------------------------- void testApp::draw(){ ofColor cyan = ofColor::fromHex(0x00abec); ofColor magenta = ofColor::fromHex(0xec008c); ofColor yellow = ofColor::fromHex(0xffee00); ofBackgroundGradient(magenta * .6, magenta * .4); ofNoFill(); easyCam.begin(); ofRotateX(15); ofSetColor(0); ofDrawGrid(500, 10, false, false, true, false); // draw the path of the box ofSetLineWidth(2); ofSetColor(cyan); pathLines.draw(); // draw a line connecting the box to the grid ofSetColor(yellow); ofLine(current.x, current.y, current.z, current.x, 0, current.z); // translate and rotate to the current position and orientation ofTranslate(current.x, current.y, current.z); rotateToNormal(current - previous); ofSetColor(255); ofDrawBox(32); ofDrawAxis(32); easyCam.end(); }
//-------------------------------------------------------------- void ofApp::draw(){ float gridsize = 500; cam.begin(); ofDrawGrid(gridsize/2.0, 8.0f, false, false, false, true); ofPushMatrix(); ofMultMatrix(tabmtx); ofDrawAxis(30); ofEnableLighting(); light.enable(); ofPushMatrix(); ofRotateX(90); ofDrawCylinder(0,52,0,3,100); ofPopMatrix(); // you can also get global tablet data at any time TabletData& data = ofxTablet::tabletData; float p= data.pressure*25; if (p<10) p = 10; ofDrawArrow(ofVec3f(0,0,100), ofVec3f(0,0,0), p); ofDisableLighting(); ofPopMatrix(); cam.end(); }
//-------------------------------------------------------------- void ofApp::draw() { ofEnableDepthTest(); cam.begin(); light.enable(); if (drawGrid) ofDrawGrid(200); if (drawBox) { ofNoFill(); ofSetColor(ofColor::white); ofDrawBox( BoxSize_X , BoxSize_Y , BoxSize_Z ); } ball_1.draw(); ball_2.draw(); ball_3.draw(); ball_4.draw(); ball_5.draw(); ball_6.draw(); ball_7.draw(); ball_8.draw(); ball_9.draw(); ball_10.draw(); light.disable(); cam.end(); ofDisableDepthTest(); }
//--------- void appWrapper::symbolSet() { ofSetFrameRate(0); cout << ofGetFrameRate(); cout << ofGetFrameNum(); ofSetVerticalSync(false); ofLine(0, 0, 0, 0); ofRect(0, 0, 0, 0); ofBackground(0); ofToggleFullscreen(); ofEnableSmoothing(); ofVec3f position; ofEasyCam camera; camera.draw(); camera.begin(); camera.end(); ofDrawGrid(100); ofBox(0); ofTranslate(position); ofDrawBitmapString("", 0, 0); ofDrawBitmapString(ofToString(ofGetFrameRate()), 10, 10); ofToString(float()); ofToString(int()); ofPushMatrix(); ofPopMatrix(); ofRandom(0, 100); glEnable(GL_DEPTH_FUNC); glDisable(GL_DEPTH_FUNC); }
void ofApp::draw() { ofEnableDepthTest(); ofEnableAlphaBlending(); cam.begin(); light.enable(); if (drawGrid) ofDrawGrid(200); if (drawLight) light.draw(); if (drawBox) { // ofNoFill(); // ofSetColor(ofColor::white); ofSetColor(255, 255, 255, 20); ofDrawBox(BOX_MAX * 2, BOX_MAX * 2, BOX_MAX * 2); // ofFill(); } ball.draw(); ball2.draw(); light.disable(); cam.end(); ofDisableAlphaBlending(); ofDisableDepthTest(); }
//-------------------------------------------------------------- void ofApp::draw() { ofEnableDepthTest(); cam.begin(); light.enable(); if (drawGrid) { ofDrawGrid(200); } if (drawBox) { //ofNoFill(); ofSetColor(255,255,255,100); ofDrawBox(800, 800, 800); ofFill(); } ball.draw(); ball2.draw(); light.disable(); cam.end(); ofDisableDepthTest(); }
void grid::customDraw(){ ofPushStyle(); //give a saturation and lightness ofSetColor(255, 100, 100); ofDrawGrid(100.0f); ofPopStyle(); }
//-------------------------------------------------------------- void ofApp::draw(){ NCKinectControllerofXOpnniMethod::getInstance()->draw(); cam.begin(); silhouettes.draw(); ofDrawGrid(); cam.end(); }
//-------------------------------------------------------------- void ofApp::draw(){ string touchStatus; stringstream info; cam.begin(); ofDrawGrid(500, 5, true); light1.enable(); light2.enable(); ofSetColor(255, 215, 0); Frame frame = controller.frame(); for (int i=0; i < frame.hands().count(); i++) { Hand hand = frame.hands()[i]; for (int j = 0; j < hand.fingers().count(); j ++) { if (j == 0) { Finger finger = frame.fingers()[j]; ofSpherePrimitive sphere; sphere.setPosition(finger.tipPosition().x, finger.tipPosition().y, finger.tipPosition().z); sphere.draw(); info << "Finger position x : " << finger.tipPosition().x << " y : " << finger.tipPosition().y << " z : " << finger.tipPosition().z << endl; } } } cam.end(); PointableList pointables = controller.frame().pointables(); InteractionBox iBox = controller.frame().interactionBox(); for (int p = 0; p < pointables.count(); p++) { Pointable pointable = pointables[p]; Vector normalizedPosition = iBox.normalizePoint(pointable.stabilizedTipPosition()); float x = normalizedPosition.x * ofGetWidth(); float y = ofGetHeight() - normalizedPosition.y * ofGetHeight(); if (pointable.touchDistance() > 0 && pointable.touchZone() != Leap::Pointable::ZONE_NONE) { ofSetColor(0, 255, 0); touchStatus = "Hover"; } else if (pointable.touchDistance() <= 0) { ofSetColor(255, 0, 0); touchStatus = "Touch"; } else { ofSetColor(0, 0, 255); touchStatus = "None"; } ofCircle(x, y, 30); info << "Point Number : " << p << endl; info << "Touch distance : " << ofToString(pointable.touchDistance()) << endl; info << "Circle x : " << x << " y : " << y << endl; } ofDrawBitmapString("Touch Status : " + touchStatus, 20, 20); ofDrawBitmapString(info.str(), 20, 40); }
//-------------------------------------------------------------- void testApp::draw() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); GLfloat color[] = { backdrop_r , backdrop_g, backdrop_b, backdrop_a}; // GLfloat color[] = { 1, 0.1, 0.1, 0.2}; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color); backdrop.draw(0,0, ofGetWidth(), ofGetHeight()); cam.begin(); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_ALWAYS); for (int i = 0; i < boidNum; i++) { glPushMatrix(); glTranslatef(boids[i].position.x, boids[i].position.y, boids[i].position.z); GLfloat color[] = { 1, 1, 1, 1.0 }; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color); glCallList(1); glPopMatrix(); } //Draw tuio touch points if(bOverlayTargets && bHasTuioTarget){ for(int i=0; i<tuioTargets.size(); i++){ glPushMatrix(); glTranslatef(tuioTargets[i][0], tuioTargets[i][1], tuioTargets[i][2]); GLfloat color[]={0.1, 0.2, 0.6}; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color); glCallList(2); glPopMatrix(); } } //Draw mouse touch points if(bOverlayTargets && bHasMouseTarget){ glPushMatrix(); glTranslatef(target[0], target[1], target[2]); GLfloat color[]={0.1, 0.2, 0.6}; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color); glCallList(2); glPopMatrix(); } glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color); if(bDrawFlyBox) { ofDrawGrid(); drawFlyBox(); } cam.end(); }
//-------------------------------------------------------------- void ofApp::draw(){ camera.begin(); ofPushStyle(); ofSetColor(200, 100, 100); ofDrawGrid(10,5,true); ofPopStyle(); plane.draw(); camera.end(); drawSelection(); }
//-------------------------------------------------------------- void testApp::draw(){ ofBackgroundGradient(ofColor(64), ofColor(0)); ofSetColor(255); ofDrawBitmapString("rotate: " + ofToString(rotationPosition), 10, 20); ofDrawBitmapString("swipe: " + ofToString(swipePosition), 10, 40); ofDrawBitmapString("magnify: " + ofToString(magnifyPosition), 10, 60); ofDrawBitmapString("scroll: " + ofToString(scrollPosition), 10, 80); ofDrawBitmapString("position: " + ofToString(mousePosition), 10, 100); cam.begin(); ofPushMatrix(); ofTranslate(0, -180, 0); ofDrawGrid(1000, 40, false, false, true, false); ofPopMatrix(); ofSetColor(ofColor::gray); mesh.drawWireframe(); glPointSize(2); ofSetColor(ofColor::white); mesh.drawVertices(); cam.end(); int n = mesh.getNumVertices(); float nearestDistance = 0; ofVec2f nearestVertex; int nearestIndex; ofVec2f mouse(mouseX, mouseY); for(int i = 0; i < n; i++) { ofVec3f cur = cam.worldToScreen(mesh.getVertex(i)); float distance = cur.distance(mouse); if(i == 0 || distance < nearestDistance) { nearestDistance = distance; nearestVertex = cur; nearestIndex = i; } } ofSetColor(ofColor::gray); ofLine(nearestVertex, mouse); ofNoFill(); ofSetColor(ofColor::yellow); ofSetLineWidth(2); ofCircle(nearestVertex, 4); ofSetLineWidth(1); ofVec2f offset(10, -10); ofDrawBitmapStringHighlight(ofToString(nearestIndex), mouse + offset); }
//-------------------------------------------------------------- void testApp::draw(){ cam.begin(); //TODO draw with render settings renderer.drawWireFrame(); ofDrawGrid(100.0f, 5.0f, true); for(int i = 0; i < debugNodes.size(); i++){ debugNodes[i].draw(); } cam.end(); ofDrawBitmapString("of framerate " + ofToString(ofGetFrameRate()), 30, 30 ); //allPortraits[currentPortrait].videoPlayer.draw(0,0, 640,360); }
//-------------------------------------------------------------- void ofApp::draw() { //-- // 2d view drawViewportOutline(viewport2D); // keep a copy of your viewport and transform matrices for later ofPushView(); // tell OpenGL to change your viewport. note that your transform matrices will now need setting up ofViewport(viewport2D); // setup transform matrices for normal oF-style usage, i.e. // 0,0=left,top // ofGetViewportWidth(),ofGetViewportHeight()=right,bottom ofSetupScreen(); ofFill(); ofSetColor(220); for(int x = 0; x < 1000; x += 20) { for(int y = 0; y < 1000; y += 20) { ofCircle(x, y, sin((x + y) / 100.0f + ofGetElapsedTimef()) * 5.0f); } } // restore the old viewport (now full view and oF coords) ofPopView(); //-- //-- // 3d view drawViewportOutline(viewport3D); // note the camera accepts the viewport as an argument // this is so that the camera can be aware of which viewport // it is acting on // // ofPushView() / ofPopView() are automatic camera.begin(viewport3D); ofDrawGrid(100); camera.end(); //-- ofDrawBitmapString("Press [space] to randomize viewports", 20, 20); }
//-------------------------------------------------------------- void testApp::draw(){ camera.begin(); if (drawEnabled["ofGrid"]) { ofPushStyle(); ofSetColor(155,100,100); ofDrawGrid(1.0f, 5.0f, true); ofPopStyle(); } if (drawEnabled["ofRay"]) ray.draw(); if (drawEnabled["ofPlane"]) { plane.draw(); for (int i=0; i<4; i++) corners[i].draw(); } if (drawEnabled["ofProjector"]) { projector.draw(); pRay.draw(); } if (drawEnabled["ofRay"] && drawEnabled["ofRay"]) { bool intersects; ofVec3f intersect; intersects = plane.intersect(ray, intersect); ofPushMatrix(); ofPushStyle(); ofTranslate(intersect); if (intersects) ofFill(); else ofNoFill(); ofCircle(0, 0, 0.1f); ofPopStyle(); ofPopMatrix(); } camera.end(); drawSelection(); }
void ofApp::draw() { ofBackground(0); ofSetColor(255); if(showKinect) { kinect.draw(0, 0); kinect.drawDepth(640, 0); } cam.begin(); ofScale(globalScale, globalScale, globalScale); ofDrawGrid(2000, 20, false, false, true, false); ofTranslate(0, 0, (nearRange + farRange) / 2); ofPushMatrix(); ofTranslate(0, -floorOffset, 0); mesh.draw(); ofPopMatrix(); // draw all planes cam.end(); }
//-------------------------------------------------------------- void ofApp::draw() { ofBackground(ofColor(0)); shader.begin(); camera.begin(); //グリッドの猫写 ofDrawGrid(); ofSetColor(ofColor::white); branch.drawWireframe(); camera.end(); shader.end(); }
void ofApp::draw(){ light.enable(); gui.draw(); //light.disable(); // zorg ervoor dat OF rekening houdt met de 'diepte' (z-coord) van alle objecten ofEnableDepthTest(); // start de camera cam.begin(); // als je een camera gebruikt, hoef je geen translate te doen // om het 0-punt naar het midden van 't scherm te verplaatsen if (drawGrid) ofDrawGrid(200); if (drawLight) light.draw(); //light.enable(); // teken eerste planeet planet01.draw(); // verplaats het 0-punt naar de positie van de 1e planeet... ofTranslate(planet01.distance,100); // ... en teken de tweede planeet planet02.draw(); ofTranslate(planet01.distance, 130); planet03.draw(); ofTranslate(planet01.distance, 150); planet04.draw(); light.disable(); // eindig het camera blok cam.end(); // schakel de diepte-test weer uit ofDisableDepthTest(); }
//-------------------------------------------------------------- void ofApp::draw(){ gui.draw(); ofTranslate(ofGetWidth()/2, ofGetHeight()/2); ofRotateX(rotationX); ofRotateY(rotationY); ofRotateZ(rotationZ); ofSetColor(255,0,0); ofCircle(-300,0,130); ofSetColor(0,255,0); ofCircle(0,0,130); ofSetColor(0,0,255); ofCircle(300,0,130); if (drawGrid) ofDrawGrid(200); }
void testApp::draw3DCam(ofNode& n) { if (NUM_CAMERAS != 2) return; int i; if (&n == (ofNode*)&camera[0].calib) i = 0; else i = 1; ofDrawAxis(10); ofPushMatrix(); ofRotate(90,1,0,0); ofDrawGrid(100); ofPopMatrix(); ofPushMatrix(); glMultMatrixf(matPosRotFromXtoOther[i].getPtr()); ofDrawAxis(10); ofPopMatrix(); }
//-------------------------------------------------------------- void ofApp::draw(){ ofColor cyan = ofColor::fromHex(0x00abec); ofColor magenta = ofColor::fromHex(0xec008c); ofColor yellow = ofColor::fromHex(0xffee00); ofColor bgColor = ofColor::fromHex(0x333333); ofBackgroundGradient(bgColor * 0.6, bgColor * 0.4); ofNoFill(); ofEnableDepthTest(); ofEnableLighting(); overheadLight.enable(); underLight.enable(); angleLight.enable(); easyCam.begin(); ofRotateX(15); ofSetColor(0); ofDrawGrid(500, 10, false, false, true, false); ofPushMatrix(); ofTranslate(-latticeWidth/2, 0, -latticeDepth/2); lattice.draw(); ofPopMatrix(); drawStrands(); easyCam.end(); ofDisableDepthTest(); ofDisableLighting(); drawIndexInput(10, 10); drawNeighborReadout(10, ofGetHeight() - 385); }
void testApp::renderTransito() { transito.update(); fboUno.begin(); ofClear(0,0,0,0); //ofPushMatrix(); ofSetColor(255,255,255); if (verFija) { cam.begin(); ofDrawGrid(); }else { camFija.begin(); } ofEnableLighting(); luzPuntual.enable(); luzDos.enable(); transito.draw(); luzDos.disable(); luzPuntual.disable(); ofDisableLighting(); if (verFija) { cam.end(); }else { camFija.end(); } //ofPopMatrix(); fboUno.end(); }
//-------------------------------------------------------------- void testApp::draw(){ camera.begin(); ofPushStyle(); ofDrawGrid(1000); ofPopStyle(); ofPushStyle(); ofPushMatrix(); ofScale(-1, -1, -1); ofRotate(angle, vec.x, vec.y, vec.z); // ofNoFill(); // ofSetLineWidth(5); ofSetColor(255, 0, 255); ofRect(-kWidth/2, -kHeight/2, kWidth, kHeight); ofEllipse(0, kHeight/2+kButtonMargin, kButtonWidth, kButtonHeight); ofPopMatrix(); ofPopStyle(); camera.end(); // string message= ""; // message+= "z : "+ofToString(camera.z)+"\n"; // ofSetColor(255, 255, 255); // ofDrawBitmapString(message, 0, 100); }
//-------------------------------------------------------------- void testApp::drawScene(bool isPreview){ glEnable(GL_DEPTH_TEST); if (isPreview) { ofPushStyle(); ofSetColor(150, 100, 100); ofDrawGrid(1.0f, 5.0f, true); ofSetColor(255); //-- //draw camera preview // headTrackedCamera.transformGL(); ofPushMatrix(); ofScale(0.002f, 0.002f, 0.002f); ofNode().draw(); ofPopMatrix(); ofMultMatrix(headTrackedCamera.getProjectionMatrix().getInverse()); ofPushStyle(); ofNoFill(); ofBox(2.0f); ofPopStyle(); headTrackedCamera.restoreTransformGL(); // //-- //-- //draw window preview // ofMesh window; window.addVertex(windowTopLeft); window.addVertex(windowBottomLeft); window.addVertex(windowBottomRight); window.setMode(OF_PRIMITIVE_LINE_STRIP); window.draw(); glPointSize(3.0f); window.drawVertices(); // //-- } ofPushStyle(); ofNoFill(); ofColor col(200,100,100); for (float z = 0.0f; z > -40.0f; z-= 0.1f){ col.setHue(int(-z * 100.0f + ofGetElapsedTimef() * 10.0f) % 360); ofSetColor(col); ofRect(-windowWidth / 2.0f, -windowHeight / 2.0f, z, windowWidth, windowHeight); } ofPopStyle(); ofPushStyle(); ofEnableSmoothing(); ofSetColor(255); ofSetLineWidth(5.0f); ofBeginShape(); for (int i=0; i<headPositionHistory.size(); i++) { ofPoint vertex(headPositionHistory[i].x, headPositionHistory[i].y, -float( headPositionHistory.size() - i ) * 0.05f); ofCurveVertex(vertex); } ofEndShape(false); ofPopStyle(); glDisable(GL_DEPTH_TEST); }
//-------------------------------------------------------------- void testApp::draw(){ camera.begin(); ofDrawGrid(2.0f, 5.0f, true); testScan.draw(); camera.end(); }
void ofApp::draw(){ // dit zorgt er voor dat de texture passend gescaled wordt glMatrixMode(GL_TEXTURE); glPushMatrix(); ofScale(image1.getWidth(),image1.getHeight()); ofScale(image2.getWidth(),image2.getHeight()); ofScale(image3.getWidth(),image3.getHeight()); ofScale(image4.getWidth(),image4.getHeight()); glMatrixMode(GL_MODELVIEW); light.enable(); gui.draw(); light.disable(); // zorg ervoor dat OF rekening houdt met de 'diepte' (z-coord) van alle objecten // start de camera cam.begin(); ofEnableDepthTest(); // als je een camera gebruikt, hoef je geen translate te doen // om het 0-punt naar het midden van 't scherm te verplaatsen if (drawGrid) ofDrawGrid(200); if (drawLight) light.draw(); light.enable(); //light.enable(); // teken eerste planeet image4.bind(); planet01.draw(); image4.unbind(); // verplaats het 0-punt naar de positie van de 1e planeet... ofTranslate(planet01.distance,100); image1.bind(); planet02.draw(); image1.unbind(); ofTranslate(planet01.distance, 130); image3.bind(); planet03.draw(); image3.unbind(); ofTranslate(planet01.distance, 150); image2.bind(); planet04.draw(); image2.unbind(); light.disable(); ofDisableDepthTest(); // eindig het camera blok cam.end(); // schakel de diepte-test weer uit // dit maakt de texture-schaal-instellingen van boven weer ongedaan glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL_MODELVIEW); }
void grid::customDraw(float labels, float x, float y, float z) { ofPushStyle(); ofDrawGrid(1000.0f,20,labels,x,y,z); ofPopStyle(); }