//-------------------------------------------------------------- void ofApp::draw(){ if(oculusRift.isSetup()){ if(showOverlay){ oculusRift.beginOverlay(-230, 320,240); ofRectangle overlayRect = oculusRift.getOverlayRectangle(); ofPushStyle(); ofEnableAlphaBlending(); ofFill(); ofSetColor(255, 40, 10, 200); ofRect(overlayRect); ofSetColor(255,255); ofFill(); ofDrawBitmapString("ofxOculusRift by\nAndreas Muller\nJames George\nJason Walters\nElie Zananiri\nFPS:"+ofToString(ofGetFrameRate())+"\nPredictive Tracking " + (oculusRift.getUsePredictiveOrientation() ? "YES" : "NO"), 40, 40); ofSetColor(0, 255, 0); ofNoFill(); ofCircle(overlayRect.getCenter(), 20); ofPopStyle(); oculusRift.endOverlay(); } ofSetColor(255); glEnable(GL_DEPTH_TEST); // oculusRift.beginBackground(); // ofPushMatrix(); // ofTranslate(ofGetMouseX(), ofGetMouseY()); // ofBackgroundGradient(ofColor(30), ofColor(255), OF_GRADIENT_LINEAR); // //ofBackground(200); // ofPopMatrix(); // oculusRift.endBackground(); oculusRift.beginLeftEye(); drawScene(); oculusRift.endLeftEye(); oculusRift.beginRightEye(); drawScene(); oculusRift.endRightEye(); oculusRift.draw(); glDisable(GL_DEPTH_TEST); } else{ cam.begin(); drawHands(); cam.end(); } }
void Loop(){ mat4 ModelMatrix(1.0f); float bgColor[] = { 0.2f, 0.4f, 0.5f }; do{ glClearColor(bgColor[0], bgColor[1], bgColor[2], 1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); g_mutex.lock(); drawHands(); g_mutex.unlock(); g_text.printText2D(info, 30, 30, 15, 0); g_text.printText2D(counter, 370, 500, 100, 0); if (g_leapListener.saved){ int i = next_gesture_id - 1; printf("next = %d\ni = %d\n", next_gesture_id, i); char visible[] = "true"; std::string varname; varname.append(std::to_string(i + 1)); varname.append(" - Name:"); TwSetParam(bar2, varname.c_str(), "visible", TW_PARAM_CSTRING, 1, visible); varname.clear(); varname.append(std::to_string(i + 1)); varname.append(" - ID:"); TwSetParam(bar2, varname.c_str(), "visible", TW_PARAM_CSTRING, 1, visible); varname.clear(); varname.append(std::to_string(i + 1)); varname.append(" - Hands:"); TwSetParam(bar2, varname.c_str(), "visible", TW_PARAM_CSTRING, 1, visible); varname.clear(); varname.append(std::to_string(i + 1)); varname.append(" - Fingers:"); TwSetParam(bar2, varname.c_str(), "visible", TW_PARAM_CSTRING, 1, visible); varname.clear(); varname.append(std::to_string(i + 1)); varname.append(" - sep:"); TwSetParam(bar2, varname.c_str(), "visible", TW_PARAM_CSTRING, 1, visible); g_leapListener.saved = false; } TwDraw(); glfwSwapBuffers(); } while (glfwGetKey(GLFW_KEY_ESC) != GLFW_PRESS && glfwGetWindowParam(GLFW_OPENED)); }
void ofApp::drawScene() { drawHands(); ofPushMatrix(); ofRotate(90, 0, 0, -1); ofDrawGridPlane(5000.0f, 10.0f, false ); ofPopMatrix(); ofPushStyle(); ofNoFill(); for(int i = 0; i < demos.size(); i++){ ofPushMatrix(); // ofRotate(ofGetElapsedTimef()*(50-demos[i].radius), 0, 1, 0); ofTranslate(demos[i].floatPos); // ofRotate(ofGetElapsedTimef()*4*(50-demos[i].radius), 0, 1, 0); if (demos[i].bMouseOver) ofSetColor(ofColor::white.getLerped(ofColor(200, 50, 0), sin(ofGetElapsedTimef()*10.0)*.5+.5)); else if (demos[i].bGazeOver) ofSetColor(ofColor::white.getLerped(ofColor(50, 200, 0), sin(ofGetElapsedTimef()*10.0)*.5+.5)); else ofSetColor(demos[i].color); ofSphere(demos[i].radius); ofPopMatrix(); } //billboard and draw the mouse if(oculusRift.isSetup()){ ofPushMatrix(); oculusRift.multBillboardMatrix(); ofSetColor(255, 0, 0); ofCircle(0,0,.5); ofPopMatrix(); } ofPopStyle(); }