void Lifeform:: update(){ body.update(); // body.swim(); if(ofGetMousePressed()){ // body.follow_point(ofVec2f(ofGetMouseX(), ofGetMouseY())); body.set_pos(ofVec2f(ofGetMouseX(), ofGetMouseY())); } }
// set any update uniforms in this function void testApp::onParticlesUpdate(ofShader& shader) { ofVec3f mouse(ofGetMouseX() - .5f * ofGetWidth(), .5f * ofGetHeight() - ofGetMouseY() , 0.f); shader.setUniform3fv("mouse", mouse.getPtr()); shader.setUniform1f("elapsed", ofGetLastFrameTime()); shader.setUniform1f("radiusSquared", 1000.f * 1000.f); }
//-------------------------------------------------------------- void testApp::draw(){ // world A boundsA.inside(ofGetMouseX(), ofGetMouseY()) ? ofSetColor(80) : ofSetColor(100); ofFill(); ofRect(boundsA); // world A boundsB.inside(ofGetMouseX(), ofGetMouseY()) ? ofSetColor(180) : ofSetColor(200); ofFill(); ofRect(boundsB); ofFill(); // A World Circles for (int i=0; i<circlesA.size(); i++) { ofSetHexColor(0xBFE364); circlesA[i].draw(); } // B World Circles for (int i=0; i<circlesB.size(); i++) { ofSetHexColor(0xE83AAB); circlesB[i].draw(); } // Shared Rects for (int i=0; i<sharedRects.size(); i++) { ofSetHexColor(0x2F9BA1); ofFill(); sharedRects[i].draw(); } ofSetColor(255); ofDrawBitmapString("World A\nGravity "+ofToString(box2dA.getGravity().x, 1)+","+ofToString(box2dA.getGravity().y, 1), 250, ofGetHeight()/2); ofSetColor(90); ofDrawBitmapString("World B\nGravity "+ofToString(box2dB.getGravity().x, 1)+","+ofToString(box2dB.getGravity().y, 1), 750, ofGetHeight()/2); ofPoint centerA(250, 250); ofPoint centerB(750, 250); ofSetColor(255); drawGravity(centerA, box2dA.getGravity()); drawGravity(centerB, box2dB.getGravity()); }
bool ofx2DFormMapping::mouseScrolled(ofMouseEventArgs &args) { if(!direct_edit && mapping_rect_dst.inside(ofGetMouseX(), ofGetMouseY())) { setZoomFactor(args.y); } return ofxPanel::mouseScrolled(args); }
//-------------------------------------------------------------- /// \brief Callback de gestion du mouvement de la souris /// /// \param x int Coordonnée X du pointeur /// \param y int Coordonnée Y du pointeur /// \return void /// /// void Core::mouseMoved(int x, int y) { m.clear(); m.setAddress("/mallarme3D/florence/position"); m.addIntArg(ofGetMouseX()); m.addIntArg(ofGetMouseY()); oscSend.sendMessage(m); }
void UI::axisGrabbed(int axis, bool shouldDuplicate) { if(shouldDuplicate && selectedObjects.size()==1) { Object *sel = selectedObjects[0]->clone(); setSelectedObject(sel); } grabAxis = axis; prevMouse.set(ofGetMouseX(), ofGetMouseY()); }
void of3dLevelScene::guiEvent(ofxUIEventArgs &e) { if(e.widget == okButton && okButton->isHit(ofGetMouseX(), ofGetMouseY())) { cout << "OK Button clicked" << endl; load(); } }
void Ball::draw(){ if(ofDist(ofGetMouseX(), ofGetMouseY(), x, y) < radius) { isRollOver = true; }else{ isRollOver = false; } ofEllipse(0, 0, radius*2, radius*2); }
void ofxTLPage::selectAll(){ for(int i = 0; i < headers.size(); i++){ //only paste into where we are hovering if(elements[headers[i]->name]->getDrawRect().inside( ofVec2f(ofGetMouseX(), ofGetMouseY()) )){ //TODO: replace with hasFocus() elements[headers[i]->name]->selectAll(); } } }
//-------------------------------------------------------------- void ofApp::mousePressed(int x, int y, int button){ if(button == 2){ locations.push_back(Location()); locations.back().setup(ofGetMouseX(), ofGetMouseY()); }else if(button == 0) { } }
//-------------------------------------------------------------- void testApp::update(){ //------------------------------------- // if we are in addon mode check //------------------------------------- if (mode == MODE_ADDON) addonButton.checkMousePressed(ofPoint(mouseX, mouseY)); //------------------------------------- // layout our normal buttons, check the mouse //------------------------------------- for (int i = 0; i < buttons.size(); i++){ buttons[i].calculateRect(); buttons[i].checkMousePressed(ofPoint(mouseX, mouseY)); } for (int i = 0; i < buttons.size(); i++){ if (i == 0){ buttons[i].topLeftAnchor.set(200,80); } else { if (i != buttons.size()-1) buttons[i].topLeftAnchor.set(buttons[i-1].topLeftAnchor.x, buttons[i-1].topLeftAnchor.y +buttons[i-1].rect.height + 20); } } //------------------------------------- // addons panels can be really long, so use the mouse pos to move them if we need to //------------------------------------- if (panelCoreAddons.getShape().height > ofGetHeight()){ float pct = ofMap(ofGetMouseY(), 0,ofGetHeight(), 0,1,true); float diff = panelCoreAddons.getShape().height - ofGetHeight(); panelCoreAddons.setPosition(300,-diff * pct); } if (panelOtherAddons.getShape().height > ofGetHeight()){ float pct = ofMap(ofGetMouseY(), 0,ofGetHeight(), 0,1,true); float diff = panelOtherAddons.getShape().height - ofGetHeight(); panelOtherAddons.setPosition(750,-diff * pct); } }
//------------------------------------------------------------------ void creature::draw() { ofPushMatrix(); ofTranslate(pos.x, pos.y, 0); ofRotateZ(angle * RAD_TO_DEG); ofBeginShape(); for (int i = 0; i < 100; i++){ ofSetColor(ofRandom(255),ofRandom(255),ofRandom(255)); float add = ofNoise(i/10.0f, ofGetElapsedTimef() * 3 * (float)ofGetMouseX() / (float)ofGetWidth()); ofVertex( (50 + 100 * add) * cos((i / 100.0) * TWO_PI), (50 + 100 * add) * sin((i / 100.0) * TWO_PI)); } ofEndShape(); ofPopMatrix(); ofPushMatrix(); ofTranslate(pos.x + 150, pos.y + 150, 0); ofRotateZ(angle * RAD_TO_DEG); ofBeginShape(); for (int i = 0; i < 100; i++){ ofSetColor(ofRandom(255),ofRandom(255),255); float add = ofNoise(i/15.0f, ofGetElapsedTimef() * 3 * (float)ofGetMouseY()/ (float)ofGetWidth()); ofVertex( (50 * add) * cos((i / 100.0) * TWO_PI), (50 * add) * sin((i / 100.0) * TWO_PI)); } ofEndShape(); ofPopMatrix(); ofPushMatrix(); ofTranslate(pos.x + 150, pos.y + 50, 0); ofRotateZ(angle * RAD_TO_DEG); ofBeginShape(); for (int i = 0; i < 100; i++){ ofSetColor(ofRandom(255),255,ofRandom(255)); float add = ofNoise(i/30.0f, ofGetElapsedTimef() * 3 * (float)ofGetMouseY()/ (float)ofGetWidth()); ofVertex( (20 * add) * cos((i / 100.0) * TWO_PI), (20 * add) * sin((i / 100.0) * TWO_PI)); } ofEndShape(); ofPopMatrix(); }
void Controller::drawDebug(){ state.getTargetPosition().draw(0, 0, 128, 128); state.getTargetVelocity().draw(128, 0, 128, 128); state.getSourcePosition().draw(128*2, 0, 128, 128); state.getSourceVelocity().draw(123*3, 0, 128, 128); ofDrawBitmapString(ofToString(ofGetFrameRate()), 10, ofGetHeight() - 10); if (ofGetMouseX() < 512 && ofGetMouseY() < 128) { ofFbo * fbo; switch (ofGetMouseX() / 128) { case 0: fbo = & state.getSourcePosition(); break; case 1: fbo = & state.getSourceVelocity(); break; case 2: fbo = & state.getTargetPosition(); break; case 3: fbo = & state.getTargetVelocity(); break; default: break; } float mousex = ofGetMouseX() % 128; float mousey = ofGetMouseY(); mousex = mousex / 128.0f * state.getWidth(); mousey = mousey / 128.0f * state.getHeight(); ofFloatPixels pix; fbo->readToPixels(pix); ofVec3f value = *(ofVec3f*)(pix.getPixels() + int(3*(mousex + mousey * state.getWidth()))); ofDrawBitmapString(ofToString(value), ofGetMouseX(), ofGetMouseY()); } if (!this->updating){ ofDrawBitmapString("not updating", 10, ofGetHeight() - 30); } }
void Zones::update() { if (isDragging) { // move the zone as the mouse moves allZones[dragRectIndex].position = dragRectPosition + ofPoint(ofGetMouseX() - mouseStart.x, ofGetMouseY() - mouseStart.y); } else if (isResizing) { allZones[dragRectIndex].width = MAX(minSize, dragRectWidth + ofGetMouseX() - mouseStart.x); allZones[dragRectIndex].height = MAX(minSize, dragRectHeight + ofGetMouseY() - mouseStart.y); } }
//-------------------------------------------------------------- void ofApp::update(){ xenoList[0].update(ofVec2f(ofGetMouseX(), ofGetMouseY())); for (int i = 1; i < xenoList.size(); i++){ xenoList[i].update(xenoList[i-1].pos); } }
//-------------------------------------------------------------- void ofApp::setup(){ ofBackground(0); move.setup(ofGetMouseX(),ofGetMouseY()); grav.set(0,0.5); isthrown = false; }
void MouseTrail::initializePoints(const int &l) { if(l > 0) m_Points.resize(l); else m_Points.resize(1); m_Points[0].x = ofGetMouseX(); m_Points[0].y = ofGetMouseY(); }
//-------------------------------------------------------------- void ofApp::mousePressed(int x, int y, int button){ if (!isthrown) { throwBegin.set(ofGetMouseX(), ofGetMouseY()); isthrown = true; } }
//-------------------------------------------------------------- void ofApp::mouseMoved(int x, int y ){ // debug - adjust the arc res + thickness from mouse x + y bool adjustArcFromMouse = false; if(adjustArcFromMouse) { arcResolution = ofMap(ofGetMouseX(), 0, ofGetWidth(), 1, 1000); // 1000 arcThickness = ofMap(ofGetMouseY(), 0, ofGetHeight(), 1, 3000); // 3000 } }
//-------------------------------------------------------------- void ofApp::update(){ cat1.move(ofGetMouseX(),ofGetMouseY(),0.05); cat1.bounce(); cat2.move(ofGetMouseX(),ofGetMouseY(),0.07); cat2.bounce(); cat3.move(ofGetMouseX(),ofGetMouseY(),0.09); cat3.bounce(); cat4.move(ofGetMouseX(),ofGetMouseY(),0.1); cat4.bounce(); cat5.move(ofGetMouseX(),ofGetMouseY(),0.5); cat5.bounce(); }
bool simpleGui::mouseMoved() { ofMouseEventArgs e; e.x = ofGetMouseX(); e.y = ofGetMouseY(); mouseMoved(e); return true; }
void mainMenu::displayYouWin() { cout<<"MouseX: "<<ofGetMouseX()<<endl<<"MouseY: "<<ofGetMouseY(); ofBackground(30,255,0); ofSetColor(0); ofFill(); ofRect(100,90,400,220); drawEdges(); hoverWin(); }
//-------------------------------------------------------------- void ofApp::update(){ //sequencing time if(!pausa){ if(ofGetElapsedTimeMillis() - elapsedTime > 3000.0) { nextStep = true; elapsedTime = ofGetElapsedTimeMillis(); enviado = false; } } //active step for(int i=0;i < 8; i++){ if(myStep[i]->inside(ofGetMouseX(), ofGetMouseY())){ whichStep = i; } } //activeStep for(int i=0;i <8; i++){ if(myStep[i]->active) activeStep = myStep[i]->id; } // send fx int fxCollection[4]; for(int i=0;i <4; i++){ fxCollection[i] = fxState[(activeStep*4)+i]; } sendFX(fxCollection); //colorize active step if(nextStep == true){ counter +=1; nextStep = false; if(counter > 7){ counter = 0; } } for(int j = 0; j < 32; j++){ pattern[j]->update(); if(pattern[j]->isSelected) movingPattern = pattern[j]->id-1; } for(int i=0;i < 8; i++){ myStep[i]->update(counter); } //chacking buttons state if(myButton[0]->action[0] == true){ reset(); myButton[0]->action[0] = false; } if(myButton[1]->action[1] == true){ random(); myButton[1]->action[1] = false; } if(myButton[2]->action[2] == true){ sendStatus(); myButton[2]->action[2] = false; } }
void CoincidentTool::preSelect() { ofVec2f mouse = ofVec2f(ofGetMouseX(), ofGetMouseY()); if (gApp->mSpace->mBounds.inside(mouse)) { ConstructedObject* underObject = gApp->mSpace->getObjectUnderCursor(); if (underObject != NULL) { gApp->mSpace->mPreSelection.push_back(underObject); } } }
void CompasSelector::mousePressed(int x, int y, int button) { for (int i = 0; i < COMPAS_COUNT; i++) { if (buttons[i].isPointOver(ofPoint(ofGetMouseX(),ofGetMouseY()))){ buttons[i].toggleActive(); } } }
//-------------------------------------------------------------- EVENTS void ofxComposer::_keyPressed(ofKeyEventArgs &e){ if (e.key == OF_KEY_F1 ){ bHelp = !bHelp; } else if (e.key == OF_KEY_F2 ){ bEditMode = !bEditMode; } else if ((e.key == OF_KEY_F3 ) || (e.key == OF_KEY_F4 ) ){ // Special keys reserved for Patch Events // } else if (e.key == OF_KEY_F5 ){ if ( bGLEditorPatch ) addPatchWithOutFile("ofVideoGrabber", ofPoint(ofGetMouseX(),ofGetMouseY())); else bGLEditorPatch = addPatchWithOutFile("ofxGLEditor", ofPoint(ofGetMouseX(),ofGetMouseY())); } else if ( e.key == OF_KEY_F6 ){ addPatchWithOutFile("ofShader", ofPoint(ofGetMouseX(),ofGetMouseY())); } else if (e.key == OF_KEY_F7){ ofToggleFullscreen(); #ifdef USE_OFXGLEDITOR editor.reShape(); editorFbo.allocate(ofGetWindowWidth(),ofGetWindowHeight()); editorFbo.begin(); ofClear(editorBgColor); editorFbo.end(); #endif } else { // If no special key was pressed and the GLEditor is present pass the key // #ifdef USE_OFXGLEDITOR editor.keyPressed(e.key); if (selectedID >= 0){ if (patches[selectedID]->getType() == "ofShader"){ patches[selectedID]->setFrag(editor.getText(1)); patches[selectedID]->saveSettings(); } } #endif } }
//-------------------------------------------------------------- void ofApp::setup() { ofBackground(0); ofSetLogLevel( OF_LOG_VERBOSE ); ofSetVerticalSync( true ); meshFont.loadFont("Fonts/DIN.otf", 10, true, true, true, 0.0, 96 ); //ofToggleFullscreen(); showOverlay = false; predictive = true; oculusRift.baseCamera = &camera; oculusRift.setup(); if( oculusRift.isSetup() ) { ofHideCursor(); } gridSize = 150.0f; // Setup some data for us to see for(int i = 0; i < 500; i++) { DemoSphere d; d.color = ofColor(ofRandom(255), ofRandom(255), ofRandom(255)); d.pos = ofVec3f(ofRandom(-gridSize, gridSize),0,ofRandom(-gridSize,gridSize)); d.myID = i; d.radius = 1.0f; //ofRandom(5.0, 10.0); d.mouseDist = 0.0f; d.isMouseOvered = false; demos.push_back(d); } //enable mouse; camera.begin(); camera.end(); camera.setGlobalPosition( 0, 100, 500 ); // let's start by stepping back a little bit and put ourselves a few units up from the floor lastMouse = ofVec2f( ofGetMouseX(), ofGetMouseY() ); lineConnectionMaxDistanceMin = 20.0f; lineConnectionMaxDistanceMax = 80.0f; lineConnectionMaxDistance = 0.0f; mouseAffectionRadius = 300.0f; initializeSpacePartitioning(); }
//-------------------------------------------------------------- void testApp::update(){ mousePos.x = ofGetMouseX(); mousePos.y = ofGetMouseY(); dimensions.x = ofGetWidth(); dimensions.y = ofGetHeight(); opencl.kernel("updateParticle")->setArg(2, mousePos); opencl.kernel("updateParticle")->setArg(3, dimensions); opencl.kernel("updateParticle")->run1D(NUM_PARTICLES); }
//-------------------------------------------------------------- void testApp::update(){ mousePos.x = ofGetMouseX(); mousePos.y = ofGetMouseY(); dimensions.x = ofGetWidth(); dimensions.y = ofGetHeight(); kernelUpdate->setArg(2, mousePos); kernelUpdate->setArg(3, dimensions); kernelUpdate->run1D(NUM_PARTICLES); }
//-------------------------------------------------------------- void ofApp::draw(){ ofSetColor(255); move.draw(); if (ofGetMousePressed()) { ofLine(throwBegin.x, throwBegin.y, ofGetMouseX(), ofGetMouseY()); } }