/// Handler for keydown void GameEconomicGameClient::HandlerFunctionKeyDown(StringHash eventType, VariantMap& eventData) { /// Get Urho3D Subsystem UI* ui = GetSubsystem<UI>(); /// Get component GameStateHandlerComponent * gamestatehandlercomponent_ = GetSubsystem<GameStateHandlerComponent>(); using namespace KeyDown; int key = eventData[P_KEY].GetInt(); /// parameters for debug related command if(key==KEY_F9) { RenderPath* effectRenderPath = GetSubsystem<Renderer>()->GetViewport(0)->GetRenderPath(); effectRenderPath->ToggleEnabled("Bloom"); } /// parameters for debug related command if(key==KEY_F10) { RenderPath* effectRenderPath = GetSubsystem<Renderer>()->GetViewport(0)->GetRenderPath(); effectRenderPath->ToggleEnabled("FXAA3"); } return; }
void MultipleViewports::MoveCamera(float timeStep) { // Do not move if the UI has a focused element (the console) if (GetSubsystem<UI>()->GetFocusElement()) return; Input* input = GetSubsystem<Input>(); // Movement speed as world units per second const float MOVE_SPEED = 20.0f; // Mouse sensitivity as degrees per pixel const float MOUSE_SENSITIVITY = 0.1f; // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees IntVector2 mouseMove = input->GetMouseMove(); yaw_ += MOUSE_SENSITIVITY * mouseMove.x_; pitch_ += MOUSE_SENSITIVITY * mouseMove.y_; pitch_ = Clamp(pitch_, -90.0f, 90.0f); // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f)); // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed if (input->GetKeyDown('W')) cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep); if (input->GetKeyDown('S')) cameraNode_->Translate(Vector3::BACK * MOVE_SPEED * timeStep); if (input->GetKeyDown('A')) cameraNode_->Translate(Vector3::LEFT * MOVE_SPEED * timeStep); if (input->GetKeyDown('D')) cameraNode_->Translate(Vector3::RIGHT * MOVE_SPEED * timeStep); // Toggle post processing effects on the front viewport. Note that the rear viewport is unaffected RenderPath* effectRenderPath = GetSubsystem<Renderer>()->GetViewport(0)->GetRenderPath(); if (input->GetKeyPress('B')) effectRenderPath->ToggleEnabled("Bloom"); if (input->GetKeyPress('F')) effectRenderPath->ToggleEnabled("FXAA2"); // Toggle debug geometry with space if (input->GetKeyPress(KEY_SPACE)) drawDebug_ = !drawDebug_; }