//-------------------------------------------------------------- void ofxGLWarper::activate(){ ofRegisterMouseEvents(this); active=true; if (bUseKeys) { ofRegisterKeyEvents(this); } }
bool SpaceShip::setup() { // TODO // Initialize spaceships: // - maybe subscribe to keyboard or mouse events ofRegisterKeyEvents(this); ofRegisterMouseEvents(this); // [...] // initial stuff size = 40; thrust = false; speed = 100; rotation = 0; invulnerable = false; // - initial positions // screen is divided horizontally by the number of players and each spaceship is placed in the center of each region rotation = playerNo * PI - PI/2; position.y = ofGetHeight() / 2 - size / 2 * cos( rotation ); position.x = ofGetWidth() / maxPlayerNo * ( playerNo - 0.5 ); // - initial directions //direction = ofPoint( sin( rotation ), -cos( rotation ) ); // ADVISE // Default setup return could be true, you should control that if smth // does not setup properly, then setup could return false and control it return true; }
bool SpaceShip::setup() { // A maximum later size for the SpaceShip size = 30; // Initialize it in the middle of the screen position.x = ofGetWidth()/2 - size / 2; position.y = ofGetHeight()/2 - size / 2; rotation = PI/2; direction.x = cos(rotation); direction.y = sin(rotation); speed = 0; turnLeft = turnRight = thrust = backThrust = isFiring = false; bulletCount = 0; timeIsDestroyed = -1.0; ofRegisterKeyEvents(this); return true; }
void ofxGuiInputField<Type>::registerKeyEvents(){ if(bRegisteredForKeyEvents == true){ return; // already registered. } bRegisteredForKeyEvents = true; ofRegisterKeyEvents(this, OF_EVENT_ORDER_BEFORE_APP); }
//-------------------------------------------------------------- void particleManager::setup(){ //ofSetVerticalSync(true); //TODO Error by Creating this boxes numParticles = 250; //try { // p.assign(num, demoParticle()); // cout << "demoParticle created" << endl; //} //catch(std::bad_alloc&) { // cout << "ERROR Memoria insuficiente" << endl; //} for(int i=0 ; i < numParticles ; i++){ p.push_back(demoParticle()); } currentMode = PARTICLE_MODE_NEAREST_POINTS; //currentModeStr = "1 - PARTICLE_MODE_ATTRACT: attracts to mouse"; ofRegisterMouseEvents(this); ofRegisterKeyEvents(this); //Interaction events // in this case from Gui event //ofAddListener(eventInteraction::onInteraction ,this, &particleManager::listenerMovingGUI); bmouseDisabled = false; resetParticles(); }
//-------------------------------------------------------------- void ofxGLWarper::enableKeys(bool k){ // bUseKeys=k; if (k) { ofRegisterKeyEvents(this); }else{ ofUnregisterKeyEvents(this); } }
//-------------------------------------------------------------- void ofxGLWarper::enableKeys(bool k){ if (bUseKeys != k){ if (k && active) { ofRegisterKeyEvents(this); }else if (active){ ofUnregisterKeyEvents(this); } bUseKeys = k; } }
Interlude1::Interlude1(TextTennis &scene_manager, ofPoint player_position, const std::string &text, const std::string &transition, float delay) : Controller(scene_manager), player_position(player_position), model_(), text(text), transition(transition), delay(delay), done(false) { if (transition == "scene1") { dialogue = new Dialogue(); } else { dialogue = new FontDialogue(); } ofRegisterKeyEvents(static_cast<Controller *>(this)); ofRegisterMouseEvents(static_cast<Controller *>(this)); }
//-------------------------------------------------------------- void ofxGLWarper::activate(bool bActivate){ if (bActivate && !active){ if (bUseMouse){ofRegisterMouseEvents(this);} if (bUseKeys) {ofRegisterKeyEvents(this);} active=true; }else if (!bActivate && active){ if (bUseMouse){ofUnregisterMouseEvents(this);} if (bUseKeys) {ofUnregisterKeyEvents(this);} active=false; } }
ofxFPSCam::ofxFPSCam() : move_speed(10), rotate_speed(1), velocity_side(0), velocity_forward(0), velocity_upward(0), velocity_pan(0), velocity_tilt(0) { ofRegisterKeyEvents(this); setKeyAssignDvorak(); }
Map::Map(): _tileSize(DEFAULT_TILE_SIZE), _maxPending(DEFAULT_MAX_PENDING), _maxImagesToCache(DEFAULT_MAX_IMAGES_TO_CACHE), _gridPadding(DEFAULT_GRID_PADDING), _lastClickTime(0), _numDrawnImages(0) { ofRegisterMouseEvents(this); ofRegisterKeyEvents(this); ofAddListener(ofEvents().update, this, &Map::update); ofRegisterURLNotification(this); }
ofxCamMapper::ofxCamMapper(){ camWin_pos = ofRectangle(640,0,CAM_WIDTH,CAM_HEIGHT); Buffer_src.allocate(BUFFER_WIDTH, BUFFER_HEIGHT); Buffer_out.allocate(BUFFER_WIDTH, BUFFER_HEIGHT); Buffer_invert.allocate(BUFFER_WIDTH, BUFFER_HEIGHT); // camera.initGrabber(CAM_WIDTH, CAM_HEIGHT, true); sampleColor.set(255,0,0); ofRegisterKeyEvents(this); ofRegisterMouseEvents(this); menu.menu_name = "Calib_menu"; menu.RegisterMenu("addPoint"); menu.RegisterMenu("PickColor"); menu.RegisterMenu("GenPoints"); ofAddListener(ofxCDMEvent::MenuPressed, this, &ofxCamMapper::cdmEvent); calib_waitMs = 100; calib_lateMs = 330; Genframe = 0; bGen_Mapping = false; pattern_color.set(255,0,0); src_editor.SetArea(0, 0,BUFFER_WIDTH,BUFFER_HEIGHT); vert_child.SetArea(0, 0, BUFFER_WIDTH, BUFFER_HEIGHT); mask.SetArea(0, 0, BUFFER_WIDTH, BUFFER_HEIGHT); src_editor.setChild(&vert_child); out_pts = &src_editor.pts; camWin_pos.x = 720; camWin_pos.width = 320; camWin_pos.height = 240; float flex_width = MIN(1440-BUFFER_WIDTH,320); float flex_height = flex_width/4.0*3.0; camWin_pos.set (0, 0, CAM_WIDTH,CAM_HEIGHT); vert_child.SetArea (BUFFER_WIDTH,0,flex_width,flex_height); src_editor.SetArea (BUFFER_WIDTH,flex_height,flex_width,flex_height); mask.SetArea(0,900,3,3); mainView = MAINVIEW_CAMERA; inverse_affine = true; main_scroll.set(0, 0); }
void VideoSource::loadVideo(string & filePath) { path = filePath; setNameFromPath(filePath); #ifdef TARGET_RASPBERRY_PI omxPlayer = OMXPlayerCache::instance()->load(filePath); texture = &(omxPlayer->getTextureReference()); #else videoPlayer = new ofVideoPlayer(); videoPlayer->load(filePath); videoPlayer->setLoopState(OF_LOOP_NONE); videoPlayer->play(); videoPlayer->setVolume(VideoSource::enableAudio ? 1.0f : 0.0f); texture = &(videoPlayer->getTexture()); ofAddListener(ofEvents().update, this, &VideoSource::update); #endif ofRegisterKeyEvents(this, OF_EVENT_ORDER_BEFORE_APP); loaded = true; }
bool SpaceShip::setup() { ofRegisterKeyEvents(this); ofRegisterMouseEvents(this); // initial stuff size = 40; thrust = false; speed = 100; rotation = 0; invulnerable = false; // - initial positions // screen is divided horizontally by the number of players and each spaceship is placed in the center of each region rotation = playerNo * PI - PI/2; position.y = ofGetHeight() / 2 - size / 2 * cos( rotation ); position.x = ofGetWidth() / maxPlayerNo * ( playerNo - 0.5 ); return true; }
ofxClickDownMenu::ofxClickDownMenu(){ OnlyRightClick = true; useFont = false; font.loadFont("BEBAS___.TTF", 10); phase = PHASE_WAIT; frame = 0; window_size = ofPoint(0,100); ofRegisterMouseEvents(this); ofRegisterKeyEvents(this); menu_focused = -1; haveChild = false; haveFChild = false; isChild = false; hilight.setHsb(235, 255, 255,180); focus_y = 1; Enable = true; }
void ofx2DPro::play(){ if (!bPlaying){ selfBegin(); #ifdef TARGET_RASPBERRY_PI consoleListener.setup(this); #endif ofRegisterMouseEvents(this); ofRegisterKeyEvents(this); ofAddListener(ofEvents().update,this,&ofx2DPro::update); ofAddListener(ofEvents().draw,this,&ofx2DPro::draw); ofAddListener(ofEvents().exit,this,&ofx2DPro::exit); ofAddListener(ofEvents().windowResized, this, &ofx2DPro::windowResized); guiLoad(); guiHide(); bRenderSystem = true; bUpdateSystem = true; bPlaying = true; } }
void NCKinectControllerofXOpnniMethod::setup() { //niContext.setup(); niContext.setupUsingRecording("oni/crowd_5_p_walking_standing still.oni"); niDepthGenerator.setup( &niContext ); niContext.registerViewport(); niImageGenerator.setup( &niContext ); niUserGenerator.setup( &niContext ); niContext.setMirror(true); niDepthGenerator.setDepthThreshold(500,1500); ofRegisterKeyEvents(this); usermap2d.allocate(640, 480); bDebugDraw = true; bstopGenerating = false; breMap2DToScreen2D = false; remapfactor = 5.0f; ofAddListener(niUserGenerator.newUser ,this,&NCKinectControllerofXOpnniMethod::newUserDetected); ofAddListener(niUserGenerator.lostUser ,this,&NCKinectControllerofXOpnniMethod::lostUserDetected); }
//--------------------------------- void AnimatedMotionPath::setup(ofxBulletWorldRigid &world, ofVec3f position, string url, string pathMotionModel, ofVec3f ModelScale){ // position.z = -0.511; type = ShapeTypeAnimatedMotionPath; collisionTime = -120; ModelPath = url; m_pathMotionModel = pathMotionModel; this->position = position; m_fixedZ = position.z; m_AnimationMeshNo = 1; //rotation = btQuaternion(btVector3(0,1,0), ofDegToRad(-90)); //TODO to try with ofBtGetCylinderCollisionShape, for improve collision detection // create ofxBullet shape body.create(world.world, position, 0); // we set m=0 for kinematic body // load 3D model scale = ModelScale; assimpModel.loadModel(url, true); assimpModel.setScale(scale.x, scale.y, scale.z); assimpModel.setPosition(0, 0, 0); assimpModel.update(); //ofEnableSeparateSpecularLight(); //save init values initScale = scale; // add 3D meshes to ofxBullet shape // for(int i = 0; i < assimpModel.getNumMeshes(); i++) // { body.addMesh(assimpModel.getCurrentAnimatedMesh(0), scale, true); // } bAnimate = true; assimpModel.setLoopStateForAllAnimations(OF_LOOP_NORMAL); assimpModel.playAllAnimations(); body.add(); body.enableKinematic(); //body.setProperties(1., 0.); // .25 (more restituition means more energy) , .95 ( friction ) // to add force to the ball on collision set restitution to > 1 body.setProperties(3, .95); // restitution, friction body.setDamping( .25 ); //Set Rotation Objects setupRot(); body.activate(); setDefaultZ(); assimpPath.loadModel(m_pathMotionModel); assimpPath.setPosition(0, 0, 0); assimpPath.setScale(scale.x, scale.y, scale.z); assimpPath.setLoopStateForAllAnimations(OF_LOOP_NORMAL); assimpPath.playAllAnimations(); m_motionPathCurPos = assimpPath.getAnimation(m_AnimationMeshNo).getPosition(); m_eMotionControl = MOTION_CONTROL_LOOP; ofRegisterKeyEvents(this); }
void ofxCvInputManager::setup(float w, float h){ width = w; height = h; ofRegisterKeyEvents(this); };
Scene5::Scene5(TextTennis &scene_manager) : model(), view(), controller(scene_manager, model) { ofRegisterKeyEvents(static_cast<Controller *>(&controller)); ofRegisterMouseEvents(static_cast<Controller *>(&controller)); }
//-------------------------------------------------------------- void BYBGui::setup( string language){ bAccuracyTestRunning = false; ofXml xml; map<int, string> fingerNames; if (xml.load(ofToDataPath("languages/"+language+".xml"))) { xml.setTo("fingers"); int c = xml.getNumChildren("finger"); xml.setTo("finger[0]"); for (int i = 0; i < c; i++) { fingerNames[xml.getIntValue("ID")] = xml.getValue("name"); xml.setToSibling(); } xml.setToParent(); xml.setToParent(); xml.setTo("buttons"); if (xml.exists("calibrate")) { calibrateButton.name = xml.getValue("calibrate"); } if (xml.exists("accuracy")) { accuracyButton.name = xml.getValue("accuracy"); } if (xml.exists("save")) { saveButton.name = xml.getValue("save"); } if (xml.exists("load")) { loadButton.name = xml.getValue("load"); } if (xml.exists("svm")) { svmButton.name = xml.getValue("svm"); } if (xml.exists("euc")) { eucButton.name = xml.getValue("euc"); } if (xml.exists("arduino")) { arduinoButton.name = xml.getValue("arduino"); } } for (int i = 0; i < NUM_GRAPHS; i++) { graphs[i].setup(ofGetWidth()-5, (string)((fingerNames.count(i)>0)?fingerNames[i]:"")); graphs[i].setFont(fonts); graphs[i].setNormalize(true); } setSizes(); setupParameters(); setupButtons(); logo.load("logo.png"); selectedGraph = selectedFinger= -1; ofRegisterKeyEvents(this); ofRegisterMouseEvents(this); ofAddListener(ofEvents().windowResized, this, &BYBGui::windowResized); calibrationGui.setPtr(this); accuracyGui.setPtr(this); calibrationGui.setButtons(); accuracyGui.setButtons(); accuracyGui.set(MARGIN, MARGIN, ofGetWidth() - (2*MARGIN), guiArea.height); accuracyGui.setup(language); calibrationGui.setLanguage(language); calibrationGui.set(MARGIN, MARGIN, ofGetWidth() - (2*MARGIN), guiArea.height); calibrationGui.update(0, 0, numSamples, false); logoRect.set(guiArea.x + MARGIN,guiArea.y + MARGIN, logo.getWidth(), logo.getHeight()); handImg.setup(); handImg.scaleTo(guiArea , OF_ASPECT_RATIO_KEEP); handImg.x = logoRect.getMaxX() + (calibrateButton.x - logoRect.getMaxX() - handImg.getWidth())/2.0f; svmButton.setSelected(true); bNewPeak = false; }
void ofxRGBDCaptureGui::setup(){ currentTab = TabCalibrate; currentRenderMode = RenderBW; downColor = ofColor(255, 120, 0); idleColor = ofColor(220, 200, 200); hoverColor = ofColor(255*.2, 255*.2, 30*.2); //setup buttons framewidth = 640; frameheight = 480; thirdWidth = framewidth/3; btnheight = 30; btnSetDirectory = new ofxMSAInteractiveObjectWithDelegate(); btnSetDirectory->setPosAndSize(0, 0, framewidth, btnheight); btnSetDirectory->setLabel("Load Directory"); buttonSet.push_back(btnSetDirectory); btnCalibrateTab = new ofxMSAInteractiveObjectWithDelegate(); btnCalibrateTab->setPosAndSize(0, btnheight, thirdWidth, btnheight); btnCalibrateTab->setLabel("Calibrate"); buttonSet.push_back(btnCalibrateTab); currentTabObject = btnCalibrateTab; btnRecordTab = new ofxMSAInteractiveObjectWithDelegate(); btnRecordTab->setPosAndSize(thirdWidth, btnheight, thirdWidth, btnheight); btnRecordTab->setLabel("Record"); buttonSet.push_back(btnRecordTab); btnPlaybackTab = new ofxMSAInteractiveObjectWithDelegate(); btnPlaybackTab->setPosAndSize(thirdWidth*2, btnheight, thirdWidth, btnheight); btnPlaybackTab->setLabel("Playback"); buttonSet.push_back(btnPlaybackTab); btnRenderBW = new ofxMSAInteractiveObjectWithDelegate(); btnRenderBW->setPosAndSize(0, btnheight*2+frameheight, thirdWidth, btnheight); btnRenderBW->setLabel("Blaick&White"); buttonSet.push_back(btnRenderBW); currentRenderModeObject = btnRenderBW; btnRenderRainbow = new ofxMSAInteractiveObjectWithDelegate(); btnRenderRainbow->setPosAndSize(thirdWidth, btnheight*2+frameheight, thirdWidth, btnheight); btnRenderRainbow->setLabel("Rainbow"); buttonSet.push_back(btnRenderRainbow); btnRenderPointCloud = new ofxMSAInteractiveObjectWithDelegate(); btnRenderPointCloud->setPosAndSize(thirdWidth*2, btnheight*2+frameheight, thirdWidth, btnheight); btnRenderPointCloud->setLabel("Pointcloud"); buttonSet.push_back(btnRenderPointCloud); btnRecordBtn = new ofxMSAInteractiveObjectWithDelegate(); btnRecordBtn->setPosAndSize(0, btnheight*3+frameheight, framewidth, btnheight); btnRecordBtn->setLabel("Capture Chessboard"); buttonSet.push_back(btnRecordBtn); for(int i = 0; i < buttonSet.size(); i++){ buttonSet[i]->setIdleColor(idleColor); buttonSet[i]->setDownColor(downColor); buttonSet[i]->setHoverColor(hoverColor); buttonSet[i]->disableKeyEvents(); buttonSet[i]->setDelegate(this); } previewRect = ofRectangle(0, btnheight*2, 640, 480); calibrationPreview.setup(10, 7, 2.5); alignment.setup(10, 7, 2.5); alignment.setupGui(0, btnheight*4+frameheight, ofGetWidth()); timeline.setup(); timeline.getColors().loadColors("defaultColors.xml"); timeline.setOffset(ofVec2f(0,btnRecordBtn->y+btnRecordBtn->height)); timeline.addElement("depth sequence", &depthSequence); timeline.setWidth(ofGetWidth()); timeline.setLoopType(OF_LOOP_NORMAL); depthSequence.setup(); ofxXmlSettings defaults; if(defaults.loadFile("defaults.xml")){ loadDirectory(defaults.getValue("currentDir", "")); } else{ loadDirectory("depthframes"); } updateTakeButtons(); cam.setup(); cam.loadCameraPosition(); cam.speed = 25; cam.setFarClip(50000); ofRegisterMouseEvents(this); ofRegisterKeyEvents(this); ofAddListener(ofEvents().windowResized, this, &ofxRGBDCaptureGui::windowResized); //ofAddListener(ofEvents().exit, this, &ofxRGBDCaptureGui::exit); ofAddListener(ofEvents().exit, this, &ofxRGBDCaptureGui::exit); ofAddListener(ofEvents().update, this, &ofxRGBDCaptureGui::update); ofAddListener(ofEvents().draw, this, &ofxRGBDCaptureGui::draw); createRainbowPallet(); depthImage.allocate(640, 480, OF_IMAGE_COLOR); recorder.setup(); }
ofxWInputManager::ofxWInputManager() { ofRegisterKeyEvents(this); }
Scene2::Scene2(TextTennis &scene_manager, ofPoint player_position) : model(player_position), view(), controller(scene_manager, model) { ofRegisterKeyEvents(static_cast<Controller *>(&controller)); ofRegisterMouseEvents(static_cast<Controller *>(&controller)); }