void DebugMenuTouchHandlers::OnTouchUpHandlers(UiObject* uiObject, Touch /* touch */) { GameObject* debugCam = (GameObject*)ENGINE->GetSceneGraph3D()->GetMainCamera()->GetObject(); Transform* trans = debugCam->GetTransform(); if (uiObject->GetName() == "up") { trans->Translate(this->cameraSpeed, trans->GetForward()); ASSERT(uiObject->GetClassType() & CLASS_TYPE_UIELEMENT, "UiObject is a ui element"); ((UiElement*)uiObject)->SetSpriteTextureIndex(TEXTURE_INDEX_BUTTON_UP); } else if (uiObject->GetName() == "down") { trans->Translate(-this->cameraSpeed, trans->GetForward()); ASSERT(uiObject->GetClassType() & CLASS_TYPE_UIELEMENT, "UiObject is a ui element"); ((UiElement*)uiObject)->SetSpriteTextureIndex(TEXTURE_INDEX_BUTTON_UP); } else if (uiObject->GetName() == "left") { trans->Translate(this->cameraSpeed, trans->GetLeft()); ASSERT(uiObject->GetClassType() & CLASS_TYPE_UIELEMENT, "UiObject is a ui element"); ((UiElement*)uiObject)->SetSpriteTextureIndex(TEXTURE_INDEX_BUTTON_UP); } else if (uiObject->GetName() == "right") { trans->Translate(-this->cameraSpeed, trans->GetLeft()); ASSERT(uiObject->GetClassType() & CLASS_TYPE_UIELEMENT, "UiObject is a ui element"); ((UiElement*)uiObject)->SetSpriteTextureIndex(TEXTURE_INDEX_BUTTON_UP); } else if (uiObject->GetName() == "back") { SINGLETONS->GetMenuManager()->LoadGameMenu(); GameObject* debugCam = (GameObject*)ENGINE->GetSceneGraph3D()->GetMainCamera()->GetObject(); ENGINE->GetSceneGraph3D()->SetMainCameraId(this->shadyCamId); delete debugCam; } }
void VUpdate(double milliseconds) override { InitializeCamera(); mPixelSize = { 1.0f / mRenderer->GetWindowWidth(), 1.0f / mRenderer->GetWindowWidth() }; int offset = OFFSET_COUNT / 2; for (int i = 0; i < OFFSET_COUNT; i++) { mBlurH.uvOffsets[i] = { mPixelSize.x * (i - offset) , 0.0f, 0.0f, 0.0f }; mBlurV.uvOffsets[i] = { 0.0f, mPixelSize.y * (i - offset), 0.0f, 0.0f }; } ScreenPoint mousePosition = Input::SharedInstance().mousePosition; if (Input::SharedInstance().GetMouseButton(MOUSEBUTTON_LEFT)) { mCamera.RotatePitch(-(mousePosition.y - mMouseY) * RADIAN * CAMERA_ROTATION_SPEED); mCamera.RotateYaw(-(mousePosition.x - mMouseX) * RADIAN * CAMERA_ROTATION_SPEED); } mMouseX = mousePosition.x; mMouseY = mousePosition.y; vec3f position = mCamera.GetPosition(); if (Input::SharedInstance().GetKey(KEYCODE_W)) { position += mCamera.GetForward() * CAMERA_SPEED; mCamera.SetPosition(position); } if (Input::SharedInstance().GetKey(KEYCODE_A)) { position += mCamera.GetRight() * -CAMERA_SPEED; mCamera.SetPosition(position); } if (Input::SharedInstance().GetKey(KEYCODE_D)) { position += mCamera.GetRight() * CAMERA_SPEED; mCamera.SetPosition(position); } if (Input::SharedInstance().GetKey(KEYCODE_S)) { position += mCamera.GetForward() * -CAMERA_SPEED; mCamera.SetPosition(position); } if (Input::SharedInstance().GetKey(KEYCODE_1)) { mBlurType = BLUR_TYPE_NONE; } if (Input::SharedInstance().GetKey(KEYCODE_2)) { mBlurType = BLUR_TYPE_GAUSSIAN; } if (Input::SharedInstance().GetKey(KEYCODE_3)) { mBlurType = BLUR_TYPE_MOTION; } }
void FlyInput::HandleKeyboard(Transform& transform, GLFWwindow* pWindow, double deltaTime) { glm::vec3 moveDir(0.0f); if (glfwGetKey(pWindow, GLFW_KEY_W) == GLFW_PRESS) { moveDir -= transform.GetForward(); } if (glfwGetKey(pWindow, GLFW_KEY_S) == GLFW_PRESS) { moveDir += transform.GetForward(); } if (glfwGetKey(pWindow, GLFW_KEY_A) == GLFW_PRESS) { moveDir -= transform.GetRight(); } if (glfwGetKey(pWindow, GLFW_KEY_D) == GLFW_PRESS) { moveDir += transform.GetRight(); } if (glfwGetKey(pWindow, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS) { //moveDir += glm::vec3(0.0f, 1.0f, 0.0f); } if (glfwGetKey(pWindow, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS) { //moveDir -= glm::vec3(0.0f, 1.0f, 0.0f); } float fLength = glm::length(moveDir); if (fLength > 0.01f) { moveDir = ((float)deltaTime * m_flySpeed) * glm::normalize(moveDir); transform.Translate(moveDir); } }
void CameraNode::VSetTransform( const Transform& newTransform ) { SceneNode::VSetTransform( newTransform ); m_View = Mat4x4::LookAt( newTransform.GetToWorldPosition(), newTransform.GetToWorldPosition() + newTransform.GetForward(), newTransform.GetUp() ); }