//-------------------------------------------------------------- void PinballChinoManager::keyReleased(int key){ switch(key) { case 'f': bFullScreen = !bFullScreen; ofSetFullscreen(bFullScreen); break; case 's': savedPose = camera.getGlobalTransformMatrix(); saveCameraPosition(savedPose); // ideal to save on XML cout << "saved camera Pose xml" << endl; break; case 'l': savedPose = loadCameraPosition(); // write over the savedCamPose var camera.setTransformMatrix(savedPose); cout << "load camera Pose xml" << endl; break; case 'n': SoundManager::getInstance()->TogleMute(); break; /* case 'g': myScenario.ScenarioObjects[11]->onCollision(); myScenario.ScenarioObjects[12]->onCollision(); myScenario.ScenarioObjects[13]->onCollision(); break; */ } InputEventManager::keyReleased(key); ScenarioEditor::getInstance()->keyReleased(key); }
bool Map::save() { if (_saveInProgress) return false; // safeguard _saveInProgress = true; // Disable screen updates for the scope of this function ui::ScreenUpdateBlocker blocker(_("Processing..."), _("Saving Map")); // Store the camview position into worldspawn saveCameraPosition(); // Store the map positions into the worldspawn spawnargs GlobalMapPosition().savePositions(); PointFile::Instance().clear(); ScopeTimer timer("map save"); // Save the actual map resource bool success = m_resource->save(); // Remove the saved camera position removeCameraPosition(); // Remove the map positions again after saving GlobalMapPosition().removePositions(); if (success) { // Clear the modified flag setModified(false); } _saveInProgress = false; return success; }
//-------------------------------------------------------------- void myAmeManager::keyPressed(int key ){ switch(key) { case 'h': gui1->toggleVisible(); gui2->toggleVisible(); gui3->toggleVisible(); bStadisticsVisible = !bStadisticsVisible; break; case 's': gui1->saveSettings("GUI/guiSettings1.xml"); gui2->saveSettings("GUI/guiSettings2.xml"); gui3->saveSettings("GUI/guiSettings3.xml"); saveCameraPosition(); printf("camera matrix saved\n"); break; case 'l': loadCameraPosition(); gui1->loadSettings("GUI/guiSettings1.xml"); gui2->loadSettings("GUI/guiSettings2.xml"); gui3->loadSettings("GUI/guiSettings3.xml"); break; case 'f': ofSetWindowPosition(0, 0); ofSetVerticalSync(false); //ofSetFullscreen(false); break; case 'F': ofSetWindowPosition(windowXpos, 0); ofSetVerticalSync(true); ofSetFullscreen(true); break; case OF_KEY_UP: if(bcameraMode)cam.getTarget().boom(-5); else { cam.tilt(1); } break; case OF_KEY_DOWN: if(bcameraMode)cam.getTarget().boom(5); else { cam.tilt(-1); } break; case OF_KEY_LEFT: if(bcameraMode)cam.getTarget().truck(-5); else { cam.pan(1); } break; case OF_KEY_RIGHT: if(bcameraMode)cam.getTarget().truck(5); else { cam.pan(-1); } break; case 'M': bcameraMode = !bcameraMode; break; case OF_KEY_RETURN: //sequence of movements animated with timer animationTimer.reset(); //animationTimer.setup(1000, false); animationTimer.startTimer(); bactionTimer = true; //animationTimer.resumeTimer(); //Save clip position last_clipPlaneDepth = clipPlaneDepth; break; } }
void ofxGameCamera::update(ofEventArgs& args){ rotationChanged = false; positionChanged = false; if(applyTranslation){ int multiplier = invertControls ? -1 : 1; if(ofGetKeyPressed('w') || (useArrowKeys && ofGetKeyPressed(OF_KEY_UP)) ){ if(dampen){ targetNode.dolly(-speed); }else{ dolly(-speed); } positionChanged = true; } if(ofGetKeyPressed('s') || (useArrowKeys && ofGetKeyPressed(OF_KEY_DOWN)) ){ if(dampen){ targetNode.dolly(speed); }else{ dolly(speed); } positionChanged = true; } if(ofGetKeyPressed('a') || (useArrowKeys && ofGetKeyPressed(OF_KEY_LEFT)) ){ if(dampen){ targetNode.truck(-speed); }else{ truck(-speed); } positionChanged = true; } if(ofGetKeyPressed('d') || (useArrowKeys && ofGetKeyPressed(OF_KEY_RIGHT)) ){ if(dampen){ targetNode.truck(speed); } else{ truck(speed); } positionChanged = true; } if(ofGetKeyPressed('c') || (useArrowKeys && ofGetKeyPressed(OF_KEY_PAGE_DOWN)) ){ if(dampen){ targetNode.boom(-speed*multiplier); } else{ boom(-speed*multiplier); } positionChanged = true; } if(ofGetKeyPressed('e') || (useArrowKeys && ofGetKeyPressed(OF_KEY_PAGE_UP)) ){ if(dampen){ targetNode.boom(speed*multiplier); } else{ boom(speed*multiplier); } positionChanged = true; } } if(applyRotation){ if(ofGetKeyPressed('r')){ targetZRot += rollSpeed; rotationChanged = true; } if(ofGetKeyPressed('q')){ targetZRot -= rollSpeed; rotationChanged = true; } } if(dampen){ setPosition(getPosition() + (targetNode.getPosition() - getPosition()) *.2); } ofVec2f mouse( ofGetMouseX(), ofGetMouseY() ); if(usemouse && applyRotation && ofGetMousePressed(0)){ if(!justResetAngles){ float dx = (mouse.x - lastMouse.x) * sensitivityX; float dy = (mouse.y - lastMouse.y) * sensitivityY; // cout << "b4 DX DY! " << dx << " " << dy << " " << targetXRot << " " << targetYRot << endl; targetXRot += dx * (invertControls ? -1 : 1); targetYRot += dy * (invertControls ? -1 : 1); // targetYRot = ClampAngle(targetYRot, minimumY, maximumY); // targetXRot = ClampAngle(targetXRot, minimumX, maximumX); // cout << "after DX DY! " << dx << " " << dy << " " << targetXRot << " " << targetYRot << endl; rotationChanged = true; } justResetAngles = false; } if(rotationChanged){ updateRotation(); } lastMouse = mouse; if(!ofGetMousePressed(0) && autosavePosition && (rotationChanged || positionChanged)){ saveCameraPosition(); } }