void BufferCont::drawSolution(){ float size = m_view[camBot].width<m_view[camBot].height ? m_view[camBot].width : m_view[camBot].height; if (g_showPop) drawPoint(m_view[viewBot], m_cam[camBot], m_solPoint.front()); m_cam[camBot].begin(m_view[viewBot]); ofSetColor(255, 0, 0); ofVec3f start, end; start.x = -size / 2; start.y = -size / 2; start.z = 0; end.x = size / 2; end.y = -size / 2; end.z = 0; ofDrawArrow(start, end, 5.0); m_font.drawString("x1", end.x, end.y); end.x = -size / 2; end.y = size / 2; end.z = 0; ofDrawArrow(start, end, 5.0); m_font.drawString("x2", end.x, end.y); m_cam[camBot].end(); ofPushView(); ofViewport(m_view[viewBot]); ofSetupScreen(); stringstream ss; ss << "evals: " << Global::msp_global->mp_problem->getEvaluations(); ofSetColor(0, 0, 0); m_font.drawString(ss.str(), 5, 25); ofPopView(); }
//-------------------------------------------------------------- void ofApp::draw(){ ofBackgroundGradient(ofColor::lightGrey, ofColor::black, OF_GRADIENT_CIRCULAR); picturePlot.draw( ofGetWidth() / 2 - 200 , 30, 400, 200 ); int xPos = (ofGetWidth() / 2 - 200) + ofMap( timeSlider, 0, weatherTimed.meshVecTemp.size(), 0, 400 ); ofSetLineWidth( 3 ); ofSetColor( ofColor::black ); ofDrawArrow( ofVec3f( xPos, 240, 0), ofVec3f( xPos, 20, 0) ); ofSetLineWidth( 1 ); ofSetColor( ofColor::white ); ofDrawArrow( ofVec3f( xPos, 240, 0), ofVec3f( xPos, 20, 0) ); cam.begin(); ofScale(2, 2, 2); // flip the y axis and zoom in a bit if ( autoRotate ) { rotation = ( (float)ofGetElapsedTimeMillis() / 500 ); } ofRotateZ( rotation ); ofTranslate( -150, -50 ); if (drawGrid) { // ofDrawGrid( 300, 1, true, false, false, true ); ofDrawArrow( ofVec3f( 0, 0, 0 ), ofVec3f( 300, 0, 0 ) ); ofDrawArrow( ofVec3f( 0, 0, 0 ), ofVec3f( 0, 100, 0 ) ); } if (useTemp) { weatherTimed.meshVecTemp[ timeSlider ].draw(); } else { weatherTimed.meshVecWind[ timeSlider ].draw(); } cam.end(); ofFill(); ofSetColor( ofColor::white ); gui.draw(); ofDrawBitmapString( chosenPlot, 40, 180); }
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); ofEnableDepthTest(); cam.begin(); //地面のグリッドを描画 ofPushMatrix(); ofRotate(90, 0, 0, 1); ofSetColor(20); ofDrawGridPlane(800, 20, false); 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); //5本の指をそれぞれ描画 for (int f=0; f<5; f++) { ofPoint mcp = simpleHands[i].fingers[ fingerTypes[f] ].mcp; // 関節1 ofPoint pip = simpleHands[i].fingers[ fingerTypes[f] ].pip; // 関節2 ofPoint dip = simpleHands[i].fingers[ fingerTypes[f] ].dip; // 関節3 ofPoint tip = simpleHands[i].fingers[ fingerTypes[f] ].tip; // 指先 //関節と指先を描画 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); ofDrawLine(mcp.x, mcp.y, mcp.z, pip.x, pip.y, pip.z); ofDrawLine(pip.x, pip.y, pip.z, dip.x, dip.y, dip.z); ofDrawLine(dip.x, dip.y, dip.z, tip.x, tip.y, tip.z); } } cam.end(); ofDisableDepthTest(); }
void khGetInSameCrCircle::draw() { Status* S = getStatusPtr(); Sprite* A = getAPtr(); Sprite* B = getBPtr(); if(!Keyhole::contact(A,B))return; ofPoint PA = A->getPos(); ofPoint PB = B->getPos(); ofVec2f D = PA-PB; D *= 0.618f; ofPushMatrix(); ofPushStyle(); ofSetColor(ofColor::limeGreen); //ofLine(PA,PB); ofSetLineWidth(3.0f); ofDrawArrow(PB+D,PB,5.0f); ofSetLineWidth(1.0f); ofNoFill(); ofCircle(PB,A->getSize()); ofPopStyle(); ofPopMatrix(); }
void Ray::draw() const { if (!this->defined) return; ofPushStyle(); ofEnableSmoothing(); ofSetColor(color); ofPushMatrix(); ofTranslate(s); ofSphere(0.01); ofPopMatrix(); if (infinite) { //'infinite' line //inner line if (width > 2.0f){ ofPushStyle(); ofSetLineWidth(1.0f); ofSetColor(255,255,255); ofLine(s-100*t, s+100*t); ofPopStyle(); } ofSetLineWidth(width==0.0f ? 1.0f : width); ofLine(s-1000*t, s+1000*t); } //arrow ofDrawArrow(s, s+t); ofPopStyle(); }
//-------------------------------------------------------------- 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(){ 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 ofxBone::customDraw(){ ofVec3f p1(0); ofVec3f p2(0); if (tr1::shared_ptr<ofxBone> p = parent.lock()){ p1 = p1 * p->getGlobalTransformMatrix() * ofMatrix4x4::getInverseOf(getGlobalTransformMatrix()); } else { // ofMatrix4x4 m4 = getGlobalTransformMatrix(); // p1 = ofVec3f(0) * m4; p1 = p1 * ofMatrix4x4::getInverseOf(getGlobalTransformMatrix()) ; } ofSetColor(ofColor::white); ofDrawArrow(p1, p2, 4); ofSphere(2); // draw x axis ofSetColor(ofColor::red); ofLine(0, 0, 0, 10, 0, 0); // draw y axis ofSetColor(ofColor::green); ofLine(0, 0, 0, 0, 10, 0); // draw z axis ofSetColor(ofColor::blue); ofLine(0, 0, 0, 0, 0, 10); }
void AbstractPhysicsBehavior::drawForceArrow(ofVec3f position, ofVec3f force) { ofDrawArrow(position, position + force * 20.0f, ofClamp(force.length() * 2.0f, 0, 6.0f)); }
void ofApp::drawLight(){ ofPushMatrix(); ofSetColor(light.getAmbientColor()); ofVec3f p = light.getPosition(); ofTranslate(p); ofDrawArrow(p, p-light.getLookAtDir(), 10); ofPopMatrix(); }
void ofxGLFWJoystick::drawDebug(int x, int y){ ofPushMatrix(); ofPushStyle(); ofTranslate(x, y); int joyRad = 25; int buttonSize = 20; int padding = 10; float yOffset = 0; for(int j = 0; j < numJoysticks; j++){ ofTranslate(0 , yOffset); int xOffset = joyRad * 0.5f; bool joyOK = glfwJoystickPresent(j); if(joyOK){ string msg = "'" + joyData[j].name + "' numAxis: " + ofToString(joyData[j].numAxis) + " numButtons: " + ofToString(joyData[j].numButtons); ofSetColor(255); ofDrawBitmapString(msg, 0, - 22); for(int i = 0; i < joyData[j].numAxis; i+=2){ ofSetColor(255, 128); float xx = xOffset + joyRad * 0.5f; float yy = joyRad * 0.5f; ofCircle(xx, yy, joyRad); float x = joyData[j].axisData[i] * joyRad; float y = 0; if(i + 1 < joyData[j].numAxis ){ y = joyData[j].axisData[i + 1] * joyRad; } ofColor c; c.setHsb((i * 16)%255, 255, 255); ofSetColor(c); ofDrawArrow(ofVec2f(xx, yy), ofVec2f(xx + x, yy + y), 4); xOffset += joyRad * 2 + padding; } ofSetRectMode(OF_RECTMODE_CENTER); for(int i = 0; i < joyData[j].numButtons; i ++ ){ bool pressed = joyData[j].buttonData[i] > 0; //mmm not sure why its a char if its only 0/1 ofSetColor( pressed ? 0:255, pressed ? 255:0, 0 ); ofRect(xOffset, joyRad * 0.5, joyRad * 0.7, joyRad * 0.7); ofSetColor(255); ofDrawBitmapString(ofToString(i), xOffset - 7, joyRad * 0.5 + 22); xOffset += joyRad + padding * 0.5; } ofSetRectMode(OF_RECTMODE_CORNER); yOffset = joyRad * 2 + 4 * padding; } } ofPopStyle(); ofPopMatrix(); }
//-------------------------------------------------------------- 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.setTarget(cam_position.x,cam_position.y,cam_position.z); cam.begin(); cam.setTarget(ofVec3f(cam_position.x,cam_position.y,cam_position.z)); ofPushMatrix(); ofRotate(90, 0, 0, 1); ofSetColor(20); ofDrawGridPlane(800, 20, false); ofPopMatrix(); ofSetColor(255,0,0); // // Threaded Gromacs Calls threadedObject.draw(); // // Leap Motion // 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); } } cam.end(); }
//-------------------------------------------------------------- void ofApp::draw(){ ofNoFill(); ofSetColor(255,255,255,102); ofPushMatrix(); ofTranslate( ofGetWidth() * 0.5, ofGetHeight() * 0.5 ); ofRotateX(count * 0.1 ); ofRotateY(count * 0.1 ); mesh.draw(); ofSetColor(255,0,0,255); ofSpherePrimitive sphere; sphere.set(200,8); sphere.drawWireframe(); ofSetColor(0,255,0,255); ofBoxPrimitive box; box.set( 200, 200, 200, 2, 2, 2 ); box.drawWireframe(); ofSetColor(0,0,255,255); ofCylinderPrimitive cylinder; cylinder.set( 100, 250, 8, 2 ); cylinder.drawWireframe(); ofSetColor(255,0,255,255); ofConePrimitive cone; cone.set( 100,300, 5, 3 ); cone.drawWireframe(); ofSetColor(0,255,255,128); ofIcoSpherePrimitive icoSphere; icoSphere.set( 250, 1 ); icoSphere.drawWireframe(); ofSetColor(255,255,255,128); ofDrawGridPlane(3000); ofSetColor(255,0,0,128); ofDrawAxis(1000); ofDrawArrow(ofVec3f(0,0,0),ofVec3f(1000,0,0)); ofPopMatrix(); ofSetColor( 255 ); ofDrawBitmapString("sketch_20150924", 15, 15); }
// ofxLeapMotionSimpleHand //-------------------------------------------------------------- void ofxLeapMotionSimpleHand::debugDraw(){ ofPushStyle(); ofSetColor(190); ofSetLineWidth(2); ofEnableLighting(); ofPushMatrix(); ofTranslate(handPos); //rotate the hand by the downwards normal ofQuaternion q; q.makeRotate(ofPoint(0, -1, 0), handNormal); ofMatrix4x4 m; q.get(m); glMultMatrixf(m.getPtr()); //scale it to make it not a box ofScale(1, 0.35, 1.0); #if (OF_VERSION_MAJOR == 0) && (OF_VERSION_MINOR < 8) ofBox(0, 0, 0, 60); #else ofDrawBox(0, 0, 0, 60); #endif ofPopMatrix(); // sphere - hand openness debug draw ofSetColor(200, 0, 0, 80); ofDrawSphere(sphereCenter, sphereRadius); for(int i = 0; i < fingers.size(); i++){ //ofDrawArrow(handPos, fingers[i].pos, 10); // fingers base debug draw ofSetColor(190); ofLine(handPos, fingers[i].base); ofDrawBox(fingers[i].base, 20); ofLine(fingers[i].base, fingers[i].pos); ofSetColor(0, 200, 0); ofDrawSphere(fingers[i].pos, 20); } ofSetColor(220, 220, 0); for(int i = 0; i < fingers.size(); i++){ ofDrawArrow(fingers[i].pos + fingers[i].vel/20, fingers[i].pos + fingers[i].vel/10, 10); } ofDisableLighting(); ofPopStyle(); }
void BufferCont::drawObjective(){ float size=m_view[viewTop].width<m_view[viewTop].height?m_view[viewTop].width:m_view[viewTop].height; int objs=Global::msp_global->mp_problem->getNumObj(); ofVec3f start, end; m_cam[camTop].begin(m_view[viewTop]); int offset = 10; if(objs==1){ ofSetColor(255,0,0); start.x = -size / 2; start.y = size / 2; start.z = 0; end.x = size / 2; end.y = size / 2; end.z = 0; ofSetLineWidth(1.0); ofDrawArrow(start, end,5.0); m_font.drawString("f", end.x, end.y); }else if(objs==2){ ofSetColor(255, 0, 0); start.x = -size / 2 - offset; start.y = -size / 2 - offset; start.z = 0; end.x = size / 2 + offset; end.y = -size / 2 - offset; end.z = 0; ofDrawArrow(start, end, 5.0); m_font.drawString("f1", end.x, end.y); end.x = -size / 2 - offset; end.y = size / 2 + offset; end.z = 0; ofDrawArrow(start, end, 5.0); m_font.drawString("f2", end.x, end.y); }else if(objs>=3){ ofSetColor(255, 0, 0); start.x = -size / 2 - offset; start.y = -size / 2 - offset; start.z = -size / 2 - offset; end.x = size / 2 + offset; end.y = -size / 2 - offset; end.z = -size / 2 - offset; ofDrawArrow(start, end, 5.0); ofPushMatrix(); ofTranslate(0, 0, end.z); m_font.drawString("f1", end.x, end.y); ofPopMatrix(); end.x = -size / 2 - offset; end.y = size / 2 + offset; end.z = -size / 2 - offset; ofDrawArrow(start, end, 5.0); ofPushMatrix(); ofTranslate(0, 0, end.z); m_font.drawString("f2", end.x, end.y); ofPopMatrix(); end.x = -size / 2 - offset; end.y = -size / 2 - offset; end.z = size / 2 + offset; ofDrawArrow(start, end, 5.0); ofPushMatrix(); ofTranslate(0, 0, end.z); m_font.drawString("f3", end.x, end.y); ofPopMatrix(); } m_cam[camTop].end(); if (g_showPop) drawPoint(m_view[viewTop], m_cam[camTop], m_objPoint.front()); }
void PlateauScene::drawModel(){ ofSetColor(255,255,0,16); plateau.draw(); ofSetColor(255,255,0,255); ofDrawSphere(plateau.getGlobalPosition(), 5); ofVec3f plateauPivotOriginTranslated = plateauPivotOrigin.get() + plateauPosition.get(); ofSetColor(127,0,127,255); ofDrawSphere(plateauPivotOriginTranslated, 20); ofDrawArrow(plateauPivotOriginTranslated, plateauPivotOriginTranslated+pivotNoise, 5); ofSetColor(255,0,255,255); ofDrawSphere(plateauPivotOriginTranslated+pivotNoise, 20); ofDrawArrow(plateauPivotOriginTranslated+pivotNoise, dp(1), 5); ofPushMatrix(); ofMultMatrix(pivotMatrix); ofDrawAxis(20); ofPopMatrix(); // floor.drawWireframe(); }
void Vehicle::Display() { float theta = velocity.angle(Vector2(0, 1)) + PI / 2; ofSetColor(0, 255, 0); ofPushMatrix(); { ofTranslate(position.x, position.y); ofRotateZ(theta); ofDrawCone(15, 50); } ofPopMatrix(); ofSetColor(255, 0, 0); ofDrawArrow(position, position + (velocity*10),0.1f); }
//------------------------------------------------ void TravelingCam::customDraw() { ofPushStyle(); ofSetColor(ofColor::gray); ofDrawBox(10); ofDrawAxis(20); ofVec3f l = getLookAtDir(); l.normalize(); l*=200; ofSetColor(ofColor::magenta); ofSetLineWidth(3); ofDrawArrow(ofVec3f(0), ofVec3f(0, 0, -200)); ofPopStyle(); }
void AHRS::drawAcc(){ ofPushStyle(); ofSetColor(255, 0, 0); ofLine(ofVec3f::zero(), ofVec3f(1,0,0).scale(acc.x)); ofSetColor(0, 255, 0); ofLine(ofVec3f::zero(), ofVec3f(0,1,0).scale(acc.y)); ofSetColor(0, 0, 255); ofLine(ofVec3f::zero(), ofVec3f(0,0,1).scale(acc.z)); ofSetColor(255,255,255); ofSetColor(255, 255, 0); ofDrawArrow(ofVec3f::zero(), gravity, 5); ofPopStyle(); }
void ofApp::leapMotionHandDraw(){ float _alpha = 80; fingerType fingerTypes[] = {THUMB, INDEX, MIDDLE, RING, PINKY}; ofPushStyle(); 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, _alpha); ofDrawSphere(handPos.x, handPos.y, handPos.z, 10); ofSetColor(255, 255, 0, _alpha); 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, _alpha); ofDrawSphere(mcp.x, mcp.y, mcp.z, 10); ofDrawSphere(pip.x, pip.y, pip.z, 10); ofDrawSphere(dip.x, dip.y, dip.z, 10); ofDrawSphere(tip.x, tip.y, tip.z, 10); ofSetColor(255, 0, 0, _alpha); ofSetLineWidth(5); ofDrawLine(mcp.x, mcp.y, mcp.z, pip.x, pip.y, pip.z); ofDrawLine(pip.x, pip.y, pip.z, dip.x, dip.y, dip.z); ofDrawLine(dip.x, dip.y, dip.z, tip.x, tip.y, tip.z); } } ofPopStyle(); }
//-------------------------------------------------------------- void testApp::draw() { // ofBackground(10); ofSetColor(255, 255, 255, 255); bgImage.draw( 0, 0); glEnable(GL_DEPTH_TEST); ofEnableAlphaBlending(); // store the white highlights created from the lights in the fbo // later it will be blurred and then applied over the render lightFbo.begin(); ofClear(255, 255, 255, 0); // ofClear(0, 0, 0, 0); cam.begin(); ofSetColor(255, 255, 255); ofEnableLighting(); // glDepthMask(false); ofSetLineWidth(4.f); lightShader.begin(); lightShader.setUniform1f( "lightRadius", lightRadius ); lightShader.setUniform1i( "numLights", NUM_LIGHTS ); ofVec3f helixMidPt = h.getMidPoint(); lightShader.setUniform3fv("lightPoss", (float*)lightPoss, NUM_LIGHTS ); lightShader.setUniform1fv("lightRadiuss", (float*)lightRadiuss, NUM_LIGHTS ); glDepthMask(false); // ofEnableBlendMode(OF_BLENDMODE_ADD); ofSetColor(255); h.drawCentered(true, false); h.drawCentered( false, true ); glDepthMask(true); // ofDisableBlendMode(); ofDisableLighting(); lightShader.end(); // glDepthMask(true); // calculate distance and draw a particle image into the glow fbo // glDepthMask(false); ofEnableBlendMode(OF_BLENDMODE_ADD); dust.getTextureReference().bind(); ofSetColor(255, 255, 255, 255); float distance = 0; for(int i = 0; i < h.lines.size(); i++ ) { float closestDistance = 10000.f; float closestDistanceb = 10000.f; ofVec3f pos = h.lines[i].a - helixMidPt; ofVec3f posb = h.lines[i].b - helixMidPt; for(int j = 0; j < NUM_LIGHTS; j++ ) { ofVec3f lightPos = lights[j].getPosition(); distance = (lightPos - pos).length(); if(distance < closestDistance) closestDistance = distance; distance = (lightPos - posb).length(); if(distance < closestDistanceb) closestDistanceb = distance; } if(closestDistance < lightRadius) { float pct = 1.f - (closestDistance / lightRadius); if(pct >= .2f) { pct = ofMap(pct, 0.2f, 1.f, 0.f, 1.f, true); renderGlowParticle( pos, pct ); } } if(closestDistanceb < lightRadius) { float pct = 1.f - (closestDistanceb / lightRadius); if(pct >= .2f) { pct = ofMap(pct, 0.2f, 1.f, 0.f, 1.f, true); renderGlowParticle( posb, pct ); } } } dust.getTextureReference().unbind(); glDepthMask(true); ofDisableBlendMode(); cam.end(); lightFbo.end(); glDisable( GL_DEPTH_TEST ); ofSetColor(255); ofEnableAlphaBlending(); blur.begin(); // ofClear(255, 255, 255, 0); ofClear( 0, 0, 0, 255); lightFbo.draw(0, 0, lightFbo.getWidth(), lightFbo.getHeight() ); lightFbo.draw(0, 0, lightFbo.getWidth(), lightFbo.getHeight() ); blur.end(); ofSetLineWidth(2.f); cam.begin(); bool bDebugLights = ((ofxUIToggle*)gui->getWidget("Debug Lights"))->getValue(); if(bDebugLights) { ofSetColor(255, 255, 255); ofNoFill(); for(int i = 0; i < NUM_LIGHTS; i++ ) { ofPushMatrix(); { ofDrawArrow( ofPoint(0,0,0), ofPoint(1,0,0) ); ofTranslate( lights[i].getPosition() ); ofMatrix4x4 mat; mat.makeRotationMatrix(ofVec3f(0,0,1), cam.getLookAtDir() ); ofPushMatrix(); ofMultMatrix(mat.getPtr()); ofCircle(0, 0, lightRadiuss[i] ); ofPopMatrix(); } ofPopMatrix(); } ofFill(); } // ofSetColor(84,204,254); // h.drawCentered( true, false); // h.drawCentered( false, true ); ofSetColor(84,204,254); h.drawCentered( true, false); h.drawCentered( false, true ); cam.end(); // ofSetColor(255, 255, 255); // glDepthMask(false); // ofEnableBlendMode(OF_BLENDMODE_ADD); ofEnableAlphaBlending(); ofEnableBlendMode( OF_BLENDMODE_ADD ); // glBlendFunc(GL_SRC_COLOR, GL_ONE); ofSetColor(84,204,254); blur.getTextureReference().draw(0,768,1024,-768); ofSetColor(255, 255, 255, 255); blur.getTextureReference().draw(0,768,1024,-768); //// blur.getTextureReference().draw(0,768,1024,-768); ofSetColor(255, 255, 255, 40); // lightFbo.draw(0,768,1024,-768 ); ofDisableBlendMode(); // glDepthMask(true); bool bRenderFbos = ((ofxUIToggle*)gui->getWidget("Render FBOs"))->getValue(); if(bRenderFbos) { ofSetColor(0); ofRect(220, 20, ofGetWidth() * .25f, ofGetHeight() * .25f ); ofSetColor(255,255,255,255); lightFbo.draw(220, 20 + ofGetHeight() * .25, ofGetWidth() * .25, -ofGetHeight() * .25); } }
//-------------------------------------------------------------- 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()); */ }