void GlobalCameraManager::changeFloorDown(const cmd::ArgumentList& args) { CamWndPtr camWnd = getActiveCamWnd(); if (camWnd == NULL) return; // Pass the call to the currently active CamWnd camWnd->changeFloor(false); }
void GlobalCameraManager::focusCamera(const Vector3& point, const Vector3& angles) { CamWndPtr camWnd = getActiveCamWnd(); if (camWnd == NULL) return; camWnd->setCameraOrigin(point); camWnd->setCameraAngles(angles); }
void GlobalCameraManager::benchmark() { CamWndPtr camWnd = getActiveCamWnd(); if (camWnd != NULL) { camWnd->benchmark(); } }
void GlobalCameraManager::resetCameraAngles(const cmd::ArgumentList& args) { CamWndPtr camWnd = getActiveCamWnd(); if (camWnd != NULL) { Vector3 angles; angles[CAMERA_ROLL] = angles[CAMERA_PITCH] = 0; angles[CAMERA_YAW] = 22.5 * floor((camWnd->getCameraAngles()[CAMERA_YAW]+11)/22.5); camWnd->setCameraAngles(angles); } }
void GlobalCameraManager::onFreelookMoveDownKey(ui::KeyEventType eventType) { CamWndPtr camWnd = getActiveCamWnd(); if (camWnd == NULL) return; if (eventType == ui::KeyPressed) { camWnd->getCamera().setMovementFlags(MOVE_DOWN); } else { camWnd->getCamera().clearMovementFlags(MOVE_DOWN); } }
void GlobalCameraManager::update() { // Issue the update call to all cameras for (CamWndMap::iterator i = _cameras.begin(); i != _cameras.end(); /* in-loop */ ) { CamWndPtr cam = i->second.lock(); if (cam != NULL) { cam->update(); ++i; } else { _cameras.erase(i++); } } }
void MapPosition::store(const cmd::ArgumentList& args) { rMessage() << "Storing map position #" << _index << std::endl; CamWndPtr camwnd = GlobalCamera().getActiveCamWnd(); if (camwnd != NULL) { _position = camwnd->getCameraOrigin(); _angle = camwnd->getCameraAngles(); // Tag the map as modified GlobalMap().setModified(true); } else { rError() << "MapPosition: Warning: Couldn't find Camera." << std::endl; } }
/* greebo: Saves the current camera position/angles to worldspawn */ void Map::saveCameraPosition() { const std::string keyLastCamPos = GlobalRegistry().get(RKEY_LAST_CAM_POSITION); const std::string keyLastCamAngle = GlobalRegistry().get(RKEY_LAST_CAM_ANGLE); if (m_world_node != NULL) { // Retrieve the entity from the worldspawn node Entity* worldspawn = Node_getEntity(m_world_node); assert(worldspawn != NULL); // This must succeed CamWndPtr camWnd = GlobalCamera().getActiveCamWnd(); if (camWnd == NULL) return; worldspawn->setKeyValue(keyLastCamPos, string::to_string(camWnd->getCameraOrigin())); worldspawn->setKeyValue(keyLastCamAngle, string::to_string(camWnd->getCameraAngles())); } }
// Handles the mouseDown event, basically determines which action should be performed (select or manipulate) void RadiantWindowObserver::onMouseDown(const WindowVector& position, GdkEventButton* ev) { // Retrieve the according ObserverEvent for the GdkEventButton ui::ObserverEvent observerEvent = GlobalEventManager().MouseEvents().getObserverEvent(ev); // Check if the user wants to copy/paste a texture if (observerEvent == ui::obsCopyTexture || observerEvent == ui::obsPasteTextureProjected || observerEvent == ui::obsPasteTextureNatural || observerEvent == ui::obsPasteTextureCoordinates || observerEvent == ui::obsPasteTextureToBrush || observerEvent == ui::obsJumpToObject) { // Get the mouse position DeviceVector devicePosition(device_constrained(window_to_normalised_device(position, _width, _height))); // Check the target object render::View scissored(*_selectObserver._view); ConstructSelectionTest(scissored, Rectangle::ConstructFromPoint(devicePosition, _selectObserver._epsilon)); SelectionVolume volume(scissored); // Do we have a camera view (fill() == true)? if (_selectObserver._view->fill()) { if (observerEvent == ui::obsJumpToObject) { CamWndPtr cam = GlobalCamera().getActiveCamWnd(); if (cam != NULL) { cam->jumpToObject(volume); } } // If the apply texture modifier is held else if (observerEvent == ui::obsPasteTextureProjected) { // Paste the shader projected (TRUE), but not to an entire brush (FALSE) selection::algorithm::pasteShader(volume, true, false); } // If the copy texture modifier is held else if (observerEvent == ui::obsCopyTexture) { // Set the source texturable from the given test GlobalShaderClipboard().setSource(volume); } else if (observerEvent == ui::obsPasteTextureNatural) { // Paste the shader naturally (FALSE), but not to an entire brush (FALSE) selection::algorithm::pasteShader(volume, false, false); } else if (observerEvent == ui::obsPasteTextureCoordinates) { // Clone the texture coordinates from the patch in the clipboard selection::algorithm::pasteTextureCoords(volume); } else if (observerEvent == ui::obsPasteTextureToBrush) { // Paste the shader projected (TRUE), and to the entire brush (TRUE) selection::algorithm::pasteShader(volume, true, true); } } } // Have any of the "selection" events occurred? // greebo: This could be an "else if (observerEvent != obsNothing)" as well, // but perhaps there will be more events in the future that aren't selection events. if (observerEvent == ui::obsManipulate || observerEvent == ui::obsSelect || observerEvent == ui::obsToggle || observerEvent == ui::obsToggleFace || observerEvent == ui::obsToggleGroupPart || observerEvent == ui::obsReplace || observerEvent == ui::obsReplaceFace) { _mouseDown = true; // Determine the current mouse position DeviceVector devicePosition(window_to_normalised_device(position, _width, _height)); if (observerEvent == ui::obsManipulate && _manipulateObserver.mouseDown(devicePosition)) { // This is a manipulation operation, register the callbacks // Note: the mouseDown call in the if clause returned already true, // so a manipulator could be successfully selected _mouseMotionCallback = boost::bind(&ManipulateObserver::mouseMoved, &_manipulateObserver, _1); _mouseUpCallback = boost::bind(&ManipulateObserver::mouseUp, &_manipulateObserver, _1); _listenForCancelEvents = true; } else { // Call the mouseDown method of the selector class, this covers all of the other events _selectObserver.mouseDown(devicePosition); _mouseMotionCallback = boost::bind(&SelectObserver::mouseMoved, &_selectObserver, _1); _mouseUpCallback = boost::bind(&SelectObserver::mouseUp, &_selectObserver, _1); // greebo: the according actions (toggle face, replace, etc.) are handled in the mouseUp methods. } } }
void GlobalCameraManager::pitchDownDiscrete(const cmd::ArgumentList& args) { CamWndPtr camWnd = getActiveCamWnd(); if (camWnd == NULL) return; camWnd->getCamera().pitchDownDiscrete(); }
void GlobalCameraManager::cubicScaleOut(const cmd::ArgumentList& args) { CamWndPtr camWnd = getActiveCamWnd(); if (camWnd == NULL) return; camWnd->cubicScaleOut(); }