void ofxTLDepthImageSequence::threadedFunction(){ while(isThreadRunning()){ backLock.lock(); ofImage thumbImage; if(!ofGetMousePressed() && isLoaded() && !currentlyZooming && thumbsEnabled){ for(int i = 0; i < backThumbs.size(); i++){ if(!backThumbs[i].loaded){ if(currentlyZooming || ofGetMousePressed()){ break; } if(currentlyZooming || ofGetMousePressed()){ break; } backThumbs[i].useTexture = false; depthImageSequence->getPixelsAtTime(ofClamp(videoThumbs[i].timestamp+timeOffsetInMillis, 0, depthImageSequence->getDurationInMillis()), thumbnailDepthRaw); thumbImage = depthImageSequence->getCompressor().convertTo8BitImage(thumbnailDepthRaw, false); backThumbs[i].create(thumbImage.getPixelsRef()); lock(); videoThumbs[i] = backThumbs[i]; unlock(); } } } backLock.unlock(); ofSleepMillis(10); } }
void ofxTLVideoTrack::threadedFunction(){ while(isThreadRunning()){ backLock.lock(); if(!ofGetMousePressed() && !currentlyZooming && thumbsEnabled && backthreadedPlayer != NULL && backthreadedPlayer->isLoaded()){ for(int i = 0; i < backThumbs.size(); i++){ if(!backThumbs[i].loaded){ if(currentlyZooming || ofGetMousePressed()){ break; } if(backThumbs[i].framenum < backthreadedPlayer->getTotalNumFrames()){ backthreadedPlayer->setFrame(backThumbs[i].framenum); if(currentlyZooming || ofGetMousePressed()){ break; } backThumbs[i].useTexture = false; backThumbs[i].create(backthreadedPlayer->getPixelsRef()); } lock(); videoThumbs[i] = backThumbs[i]; unlock(); } } } backLock.unlock(); ofSleepMillis(100); } }
//-------------------------------------------------------------- void testApp::mouseMoved(int x, int y ){ rg.handleMouse( ofPoint(mouseX, mouseY), ofGetMousePressed()); settings.handleMouse( ofPoint(mouseX, mouseY), ofGetMousePressed()); addons.handleMouse( ofPoint(mouseX, mouseY), ofGetMousePressed()); }
//-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button){ if (rg.bVisible) rg.handleMouse( ofPoint(mouseX, mouseY), ofGetMousePressed()); else if (settings.bVisible) settings.handleMouse( ofPoint(mouseX, mouseY), ofGetMousePressed()); else if (addons.bVisible) addons.handleMouse( ofPoint(mouseX, mouseY), ofGetMousePressed()); }
//-------------------------------------------------------------- void testApp::draw(){ ofBackground(255); if (ofGetMousePressed(0)) { for (int i=0;i<100;i++) { la[i].dna.mutate( ofMap(mouseX, 0, ofGetWidth(), 0, 0.1) ); } } if (ofGetMousePressed(2)) { for (int i=0;i<99;i++) { la[i].dna.mate( la[i+1].dna, ofMap(mouseX, 0, ofGetWidth(), 0, 0.1) ); } } for (int i=0;i<100;i++) { la[i].display(); } string txt = "notmutating"; if (ofGetMousePressed(0)) txt = "mutating"; if (ofGetMousePressed(2)) txt = "mating"; txt += "\nmutationindex: "+ofToString(ofMap(mouseX, 0, ofGetWidth(), 0, 0.1)); ofSetColor(0); ofDrawBitmapString(txt, 5, 20); }
//-------------------------------------------------------------- void ofApp::draw(){ // If the left mouse button is pressed... if (ofGetMousePressed(OF_MOUSE_BUTTON_LEFT)) { int maxRadius = 100; // Increase for a wider brush int radiusStepSize = 5; // Decrease for more circles (i.e. a more opaque brush) int alpha = 3; // Increase for a more opaque brush int maxOffsetDistance = 100; // Increase for a larger spread of circles for (int radius=maxRadius; radius>0; radius-=radiusStepSize) { // Formula for converting from polar to Cartesian coordinates: // x = cos(polar angle) * (polar distance) // y = sin(polar angle) * (polar distance) // We need our angle to be in radians if we want to use sin() or cos() // so we can make use of an openFrameworks function to convert from degrees // to radians float angle = ofRandom(ofDegToRad(360.0)); float distance = ofRandom(maxOffsetDistance); float xOffset = cos(angle) * distance; float yOffset = sin(angle) * distance; // Using the ofColor class, we will randomly select a color between orange and red ofColor myOrange(255, 132, 0, alpha); ofColor myRed(255, 6, 0, alpha); ofColor inBetween = myOrange.getLerped(myRed, ofRandom(1.0)); ofSetColor(inBetween); ofCircle(ofGetMouseX()+xOffset, ofGetMouseY()+yOffset, radius); } } // If the right mouse button is pressed... if (ofGetMousePressed(OF_MOUSE_BUTTON_RIGHT)) { ofBackground(0); // Erase the screen with a black background } }
void ofxNUIWidgetNode::widgetEventListener(ofxUIEventArgs &e) { for (int i=0; i < getCanvas()->getWidgets().size(); i++) { ofxUIWidget *widget = getCanvas()->getWidgets().at(i); if(e.widget->getName() == widget->getName()){ /* Slider */ if (widget->getKind() == OFX_UI_WIDGET_SLIDER_H || widget->getKind() == OFX_UI_WIDGET_SLIDER_V) { ofxUISlider *slider = dynamic_cast<ofxUISlider*>(widget); widgetFunctions(slider->getName()); } /* Int Slider */ else if (widget->getKind() == OFX_UI_WIDGET_INTSLIDER_H || widget->getKind() == OFX_UI_WIDGET_INTSLIDER_V) { ofxUIIntSlider *intSlider = dynamic_cast<ofxUIIntSlider*>(widget); widgetFunctions(intSlider->getName()); } /* Number Dialer */ else if (widget->getKind() == OFX_UI_WIDGET_NUMBERDIALER) { ofxUINumberDialer *numberDialer = dynamic_cast<ofxUINumberDialer*>(widget); widgetFunctions(numberDialer->getName()); } /* Drop Down List */ else if (widget->getKind() == OFX_UI_WIDGET_DROPDOWNLIST) { ofxUIDropDownList *dropDownList = dynamic_cast<ofxUIDropDownList*>(widget); if (ofGetMousePressed() == false && dropDownList->getSelected().size()) { ofxUIWidget *selected = dropDownList->getSelected().front(); widgetFunctions(selected->getName()); } } /* Label Button */ else if (widget->getKind() == OFX_UI_WIDGET_LABELBUTTON) { ofxUILabelButton *labelButton = dynamic_cast<ofxUILabelButton*>(widget); if(ofGetMousePressed() == false){ widgetFunctions(labelButton->getName()); labelButton->setValue(false); } } /* Text Input */ else if (widget->getKind() == OFX_UI_WIDGET_TEXTINPUT) { ofxUITextInput *textInput = dynamic_cast<ofxUITextInput*>(widget); widgetFunctions(textInput->getName()); } break; } } }
void resetDrawSettings() { m_inSetup = false; fill(m_defaultFillColor.getHex()); stroke(m_defaultStrokeColor.getHex()); strokeWeight(m_defaultStrokeWeight); m_hasFill = m_defaultHasFill; m_hasStroke = m_defaultHasStroke; ofEnableBlendMode(OF_BLENDMODE_ALPHA); smooth(2); width = ofGetWidth(); height = ofGetHeight(); pmouseX = ofGetPreviousMouseX(); pmouseY = ofGetPreviousMouseY(); keyPressed = ofGetKeyPressed(); mousePressed = ofGetMousePressed(); mouseButton = NONE; if( ofGetMousePressed(0) ) mouseButton = LEFT; else if(ofGetMousePressed(1)) mouseButton = RIGHT; ofSetCircleResolution(100); ofSetCurveResolution(100); }
//-------------------------------------------------------------- void testApp::mouseDragged(int x, int y, int button){ rg.handleScroll( ofPoint(mouseX, mouseY), ofGetMousePressed()); addons.handleScroll( ofPoint(mouseX, mouseY), ofGetMousePressed()); }
//-------------------------------------------------------------- void ofApp::draw() { ofDrawBitmapString(ofToString(ofGetFrameRate()),20,20); ofPushMatrix(); ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2); ofRotate(mouseX); float scale = ofMap(mouseY, 0, ofGetHeight(), .5, 10); ofScale(scale, scale, scale); ofTranslate(-250, -250); if(ofGetMousePressed()) { ofNoFill(); for (int i = 0; i < (int)outlines.size(); i++) { ofPolyline & line = outlines[i]; int num = step * line.size(); ofBeginShape(); for (int j = 0; j < num; j++) { ofVertex(line[j]); } ofEndShape(); } } else { svg.draw(); } ofPopMatrix(); }
void ofApp::draw() { ofBackground(0); ofPushMatrix(); ofScale(.5, .5); src.draw(0, 0); dst.draw(640, 0); if(!ofGetMousePressed()) { maskedBlur(src, mask, srcBlur); } maskedBlur(dst, mask, dstBlur); srcBlur.draw(0, 480); dstBlur.draw(640, 480); ofPopMatrix(); ofEnableAlphaBlending(); dst.draw(640, 0); cloneShader.begin(); cloneShader.setUniformTexture("src", src, 1); cloneShader.setUniformTexture("srcBlur", srcBlur, 2); cloneShader.setUniformTexture("dstBlur", dstBlur, 3); dst.draw(640, 0); cloneShader.end(); ofDisableAlphaBlending(); ofDrawBitmapString(ofToString((int) ofGetFrameRate()), 10, 20); }
void testApp::drawScreen() { if (!screens.empty()) { screen s = screens[currentScreen]; ofSetColor(0, 0, 255,100); ofBeginShape(); for (vector<int>::iterator viter=s.indices.begin(); viter!=s.indices.end(); viter++) { ofVec3f vec = tentMesh.getVerticesPointer()[*viter]-s.origin; ofVec3f pos; pos.z = 0; pos.x = s.xVec.dot(vec)*scale; pos.y = s.yVec.dot(vec)*scale; ofVertex(pos); } ofEndShape(true); } ofSetColor(0, 255, 0,100); ofFill; for (vector<ofRectangle>::iterator iter = rects.begin(); iter!=rects.end(); iter++) { ofRect(*iter); } if (ofGetMousePressed()) { ofRect(downPos, ofGetMouseX()-downPos.x, ofGetMouseY()-downPos.y); } }
//-------------------------------------------------------------- void testApp::draw(){ // cam.begin(); ofBackground(0); ofSetColor(255); mc.draw(); float zpos = fmodf( ofGetFrameNum()*-zspeed, mc.worlddim.z ); ofPoint mp( ofGetMouseX(), ofGetMouseY(), zpos); if(ofGetMousePressed()) ofSetColor(255,0,0); ofBox(mp.x, mp.y, mp.z, 20); ofSetColor(255,0,0); mc.drawnormals(0.021); // cam.end(); ofSetColor(255); ofDrawBitmapString("fps: "+ofToString(ofGetFrameRate()) + "\n"+mc.getinfo() +"\npos: "+ofToString(mp) +"\n(c) clear" +"\n(f) fade data" +"\n(s) save stl", 10, 20); }
//-------------------------------------------------------------- void ofApp::draw(){ // If the left mouse button is pressed... if (ofGetMousePressed(OF_MOUSE_BUTTON_LEFT)) { // Randomness! float randomColor = ofRandom(50, 255); ofSetColor(randomColor); // Exclude dark grayscale values (0 - 50) that won't show on black background ofSetRectMode(OF_RECTMODE_CENTER); // Draw rect by specifying the center ofDrawRectangle(ofGetMouseX(), ofGetMouseY(), 50, 50); // Draw a 50 x 50 rect centered over the mouse } // If the right mouse button is pressed... if (ofGetMousePressed(OF_MOUSE_BUTTON_RIGHT)) { ofBackground(0); // Erase the screen with a black background } }
//-------------------------------------------------------------- void testApp::draw(){ float angle; if (ofGetMousePressed()){ angle = mouseX; } else { angle = step; } ofDrawBitmapString(ofToString(ofGetFrameRate()),20,20); ofPushMatrix(); ofTranslate(ofGetWidth() / 4, ofGetHeight() / 2); ofRotate(angle); float scale = ofMap(mouseY, 0, ofGetHeight(), 1, 20); ofScale(scale, scale, scale); svg.draw(); ofPopMatrix(); ofPushMatrix(); ofTranslate(ofGetWidth() * 3 / 4., ofGetHeight() / 2.); ofRotate(angle); ofScale(scale, scale, scale); image.setAnchorPercent(0.5,0.5); image.draw(0,0, image.getWidth()/42, image.getHeight()/42); ofPopMatrix(); }
//-------------------------------------------------------------- void testApp::update(){ if(!ofGetMousePressed(0)){ timeline.setOffset(ofVec2f(0,ofGetHeight()-timeline.getHeight())); } ofRectangle fboContainer = ofRectangle(0,0,ofGetWidth()-250,timeline.getTopLeft().y); fboRect = ofRectangle(0,0,16,9); fboRect.scaleTo(fboContainer); fboRect.x = 200; cam.applyRotation = cam.applyTranslation = fboRect.inside(mouseX, mouseY) && !camTrack.lockCameraToTrack; // gui.add(lineStartTime.setup("line start", ofxParameter<float>(), 0, 1.0)); // gui.add(lineEndTime.setup("line end", ofxParameter<float>(), 0, 1.0)); // gui.add(lineFadeVerts.setup("line fade verts", ofxParameter<int>(), 1, 10)); int vertEndIndex = ofMap(timeline.getPercentComplete(), lineStartTime, lineEndTime, 0, traversal.getVertices().size()); int vertsToHighlight = ofClamp(vertEndIndex,0,traversal.getVertices().size()-1); int lineDissolveVerts = vertEndIndex*timeline.getValue("line dissolve"); float nodeSize = powf(timeline.getValue("traversed node size"), 2); for(int i = 0; i < vertsToHighlight; i++){; // float fade = ofMap(i, vertsToHighlight*.9, vertsToHighlight, 1.0, 0, true); float alpha = ofMap(i, vertEndIndex, vertEndIndex-nodePopLength, 0.0, 1.0, true); float dissolveAlpha = 1.0; if(lineDissolveVerts > 0){ dissolveAlpha = ofMap(i, lineDissolveVerts, lineDissolveVerts+20, 0.0, 1.0, true); } ofFloatColor currentColor = lineColor->getColorAtPosition(alpha); traversal.setColor(i, currentColor * dissolveAlpha); if(traversalIndexToNodeIndex.find(i) != traversalIndexToNodeIndex.end()){ //traversedNodePoints.getNormals()[ traversalIndexToNodeIndex[i ] ].x = 1.0; // cout << "setting color of line point " << i << " to node index " << endl; traversedNodePoints.getNormals()[ traversalIndexToNodeIndex[i ] ].x = nodeSize*timeline.getValueAtPercent("node bounce", alpha); traversedNodePoints.getColors()[ traversalIndexToNodeIndex[i ] ] = currentColor; } } for(int i = vertsToHighlight; i < traversal.getVertices().size(); i++){ traversal.setColor(i, ofFloatColor(0)); if(traversalIndexToNodeIndex.find(i) != traversalIndexToNodeIndex.end()){ traversedNodePoints.getNormals()[ traversalIndexToNodeIndex[i ] ].x = 0.0; } } if(traversal.getVertices().size() > 0){ trailHead = traversal.getVertices()[vertsToHighlight]; } float clusterNodeBaseSize = timeline.getValue("cluster node size"); vector<ofVec3f>& normals = nodeCloudPoints.getNormals(); for(int i = 0; i < nodes.size(); i++){ if(nodes[i]->nodePointIndex != -1){ normals[ nodes[i]->nodePointIndex ].x = (normals[ nodes[i]->nodePointIndex ].y - normals[ nodes[i]->nodePointIndex ].z)* clusterNodeBaseSize; } } }
//-------------------------------------------------------------- void ofApp::update() { // unsigned char * pixels = myImage.getPixels().getData(); // // for (int i = 0; i < 500*500; i++){ // pixels[i] = ofRandom(0,255); // } unsigned char * pixels = myImage.getPixels().getData(); // for (int i = 0; i < 500; i++){ // for (int j = 0; j < 500; j++){ // pixels[j*500 + i] = (i % (j+1)) ; // } // } for (int i = 0; i < 500; i++) { for (int j = 0; j < 500; j++) { float distance = ofDist(i,j, mouseX, mouseY); if (ofGetMousePressed() && distance < 100) { pixels[j*500 + i] = 255; } //pixels[j*500 + i] -=1; } } myImage.update(); }
void Lifeform:: update(){ body.update(); // body.swim(); if(ofGetMousePressed()){ // body.follow_point(ofVec2f(ofGetMouseX(), ofGetMouseY())); body.set_pos(ofVec2f(ofGetMouseX(), ofGetMouseY())); } }
void ramControlPanel::update(ofEventArgs &e) { if(!ofGetMousePressed()) { bool hover = mSceneTabs.isHit(ofGetMouseX(), ofGetMouseY()); ramCameraManager::instance().setEnableInteractiveCamera(!hover); } }
int ofxAppEmscriptenWindow::mousemoved_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData){ if(ofGetMousePressed()){ instance->events().notifyMouseDragged(mouseEvent->canvasX,mouseEvent->canvasY,0); }else{ instance->events().notifyMouseMoved(mouseEvent->canvasX,mouseEvent->canvasY); } return 0; }
//-------------------------------------------------------------- void RuleThree::update(){ if (ofGetMousePressed()){ for(int i=0; i<NSTUDENTS; i++){ myStudents[i].moveTowards(645, 366); //center point of artowkr } } }
//-------------------------------------------------------------- void ofApp::draw(){ ofSetColor(255); move.draw(); if (ofGetMousePressed()) { ofLine(throwBegin.x, throwBegin.y, ofGetMouseX(), ofGetMouseY()); } }
//---------------------------------------- void ofEasyCam::begin(ofRectangle rect) { if (lastMouseActionFrame != ofGetFrameNum()) { lastMouseActionFrame = ofGetFrameNum(); if(ofGetMousePressed(0)) { ofVec3f targetPos = target.getGlobalPosition(); ofVec3f mousePos(ofGetMouseX() - rect.width/2, rect.height/2 - ofGetMouseY(), targetPos.z); ofVec3f mousePosView; float sphereRadius = min(rect.width, rect.height)/2; float diffSquared = sphereRadius * sphereRadius - (targetPos - mousePos).lengthSquared(); if(diffSquared <= 0) { mousePos.z = 0; } else { mousePos.z = sqrtf(diffSquared); } mousePos.z += targetPos.z; mousePosView = ofMatrix4x4::getInverseOf(target.getGlobalTransformMatrix()) * mousePos; if(oldMousePress) { ofQuaternion rotAmount; rotAmount.makeRotate(mousePosViewPrev, mousePosView); target.rotate(rotAmount.conj()); //target.rotate(rotAmount); } printf("mousePos: %f %f %f\n", mousePos.x, mousePos.y, mousePos.z); if(oldMousePress) { // vel -= (mousePos - mousePrev) * speed; } mousePosViewPrev = ofMatrix4x4::getInverseOf(target.getGlobalTransformMatrix()) * mousePos; } oldMousePress = ofGetMousePressed(0); } ofCamera::begin(rect); }
void ofApp::draw(){ ofSetColor(255); if(ofGetMousePressed()) { camera.draw(0, 0); } else { lut.getTexture().draw(0, 0); } ofSetColor(0); ofDrawBitmapString(ofToString((int) ofGetFrameRate()), 10, 20); }
//---------------------------------------- void ofxViewportCam::begin(ofRectangle viewport) { ofPushStyle(); if(drawWireFrame) { ofNoFill(); } else { ofFill(); } ofVec3f pos = getPosition(); ofVec2f mousePosScreen = ofVec3f(ofGetMouseX() - viewport.width / 2 - viewport.x, viewport.height / 2 - (ofGetMouseY() - viewport.y), 0); #ifdef TARGET_LINUX if(ofGetKeyPressed(OF_KEY_SHIFT)) #else if(ofGetKeyPressed(OF_KEY_ALT)) #endif { ofVec2f trans(mousePosScreenPrev - mousePosScreen); if(ofGetMousePressed(0)) { tumble(trans.x, -trans.y); } else if(ofGetMousePressed(1)) { track(trans.x, trans.y); } else if(ofGetMousePressed(2)) { float zoomAmount = trans.y; zoom(zoomAmount); } } mousePosScreenPrev = mousePosScreen; ofCamera::begin(viewport); ofPopStyle(); }
void CloudsHUDScroller::update(){ if(bIsScrollDownPressed || bIsScrollUpPressed){ float timeSincePress = ofGetElapsedTimef() - scrollPressedTime; bool scrolled = ofGetMousePressed() && ( ( bIsHoldScrolling && timeSincePress > .5) || (!bIsHoldScrolling && timeSincePress > .75) ); if(scrolled){ float newScrollPosition = scrollPosition + scrollIncrement * (bIsScrollUpPressed ? -1 : 1); scrollPosition = ofClamp(newScrollPosition, 0, totalScrollHeight - scrollBounds.height); bIsHoldScrolling = true; } } }
void TextBox::draw() { ofPushStyle(); ofNoFill(); ofSetColor(255,100); // ofRectRounded(*this, 3); ofRect(*this); ofFill(); ofSetColor(100,100); // ofRectRounded(*this, 3); ofRect(*this); ofPopStyle(); ofPushMatrix(); ofTranslate(x, y); int margin = 10; string sType = ""; if (type == UNIFORM_SAMPLE2DRECT) { sType = "sample2DRect"; } else if (type == UNIFORM_VEC2) { sType = "vec2"; } else if (type == UNIFORM_FLOAT) { sType = "float"; } ofDrawBitmapString(sType+" "+name+": ", margin,12); int nameHeight = (sType.size()+1)*8+margin+(name.size()+2)*8; ofDrawBitmapString(text, nameHeight,12); width = nameHeight+(text.size()+2)*8; int cursorPos; // draw cursor line // if(drawCursor) { ofPushStyle(); float timeFrac = 0.5 * sin(3.0f * ofGetElapsedTimef()) + 0.5; ofColor col = ofGetStyle().color; cursorPos = nameHeight + 8*cursorx ; ofSetColor(col.r * timeFrac, col.g * timeFrac, col.b * timeFrac); ofSetLineWidth(3.0f); //TODO: multiline with fontRef ofLine(cursorPos, 13.7*cursory+2,cursorPos, 13.7*cursory+12); ofPopStyle(); } ofPopMatrix(); if (type == UNIFORM_FLOAT && mouseDownInRect && ofGetMousePressed()) { ofLine(x+nameHeight+16,y+height*0.5,lastMousePos.x,lastMousePos.y); } }
//-------------------------------------------------------------- void ofApp::draw(){ ofEnableLighting(); ofBackgroundGradient(ofColor(65,62,50),ofColor(25,22,10) ); // disable normals if a key is pressed if(ofGetKeyPressed() || ofGetMousePressed()){ mesh.disableNormals(); }else{ mesh.enableNormals(); } cam.begin(); mesh.enableColors(); mesh.drawWireframe(); mesh.disableColors(); ofSetColor(137,137,140); ofFill(); #ifndef TARGET_OPENGLES glEnable(GL_POLYGON_OFFSET_LINE); glPolygonOffset(-1,-1); #endif mesh.drawFaces(); ofSetColor(255,255,255); light.draw(); // draw our normals, and show that they are perpendicular to the vector from the center to the vertex vector<ofVec3f> n = mesh.getNormals(); vector<ofVec3f> v = mesh.getVertices(); float normalLength = 50.; if(!ofGetKeyPressed()){ ofDisableLighting(); ofSetColor(255,255,255,70); for(unsigned int i=0; i < n.size() ;i++){ ofDrawLine(v[i].x,v[i].y,v[i].z, v[i].x+n[i].x*normalLength,v[i].y+n[i].y*normalLength,v[i].z+n[i].z*normalLength); ofDrawLine(.98*v[i].x,.98*v[i].y,.98*v[i].z, .98*v[i].x+n[i].x*normalLength*.2,.98*v[i].y+n[i].y*normalLength*.2,.98*v[i].z+n[i].z*normalLength*.2); ofDrawLine(.98*v[i].x+n[i].x*normalLength*.2,.98*v[i].y+n[i].y*normalLength*.2,.98*v[i].z+n[i].z*normalLength*.2, v[i].x+n[i].x*normalLength*.2,v[i].y+n[i].y*normalLength*.2,v[i].z+n[i].z*normalLength*.2); } } cam.end(); ofSetColor(255,255,255); ofDrawBitmapString("press any key or mouse button to disable mesh normals", 20,20); ofDrawBitmapString("light", cam.worldToScreen(light.getGlobalPosition()) + ofPoint(10,0)); }
//---------------------------------------- void ofEasyCam::begin(ofRectangle rect) { // orbit(ofMap(ofGetMouseX(), 0, ofGetWidth(), 180, -180), ofMap(ofGetMouseY(), 0, ofGetHeight(), 90, -90), orbitRadius, testNodes[targetIndex[1]]); if(ofGetMousePressed(0)) { ofVec2f mousePos(ofGetMouseX(), ofGetMouseY()); if(oldMousePress) { vel -= (mousePos - pmouse) * speed; } pmouse = mousePos; } pos += vel; vel *= (1-drag); orbit(pos.x, pos.y, distance, (targetNode ? targetNode->getGlobalPosition() : targetPoint)); oldMousePress = ofGetMousePressed(0); ofCamera::begin(rect); }
void testApp::draw() { ofPushMatrix(); //ofPushStyle(); scenes[curScene]->draw(); //ofPopStyle(); ofPopMatrix(); if(ofGetMousePressed()) { int frameLength = 1000 * ofGetLastFrameTime(); ofSetColor(frameLength > 10 ? ofColor::red : ofColor::green); ofDrawBitmapString(ofToString(frameLength) + " ms", 10, 20); } }