void FogDemo::Update(const GameTime& gameTime) { UpdateAmbientLight(gameTime); UpdateDirectionalLight(gameTime); UpdateSpecularLight(gameTime); mProxyModel->Update(gameTime); }
void TransparencyMappingDemo::Update(const GameTime& gameTime) { UpdateAmbientLight(gameTime); UpdateDirectionalLight(gameTime); UpdateSpecularLight(gameTime); mProxyModel->Update(gameTime); }
void TransparencyDemo::Update(const GameTime& gameTime) { if (!Camera::CameraControlFlag) { UpdateAmbientLight(gameTime); UpdateDirectionalLight(gameTime); UpdateSpecularLight(gameTime); } mProxyModel->Update(gameTime); }
void SpecularLightingDemo::Update(const GameTime & gameTime) { static float angle = 0.0f; if (mAnimationEnabled) { angle += gameTime.ElapsedGameTimeSeconds().count() * ModelRotationRate; XMStoreFloat4x4(&mWorldMatrix, XMMatrixRotationY(angle)); } if (mKeyboard != nullptr && mKeyboard->WasKeyPressedThisFrame(Keys::Space)) { ToggleAnimation(); } if (mGamePad != nullptr) { auto& gamePadState = mGamePad->CurrentState(); if (gamePadState.IsConnected()) { if (mGamePad->WasButtonPressedThisFrame(GamePadButtons::Start)) { ToggleGamePadControls(); } if (mGamePad->WasButtonPressedThisFrame(GamePadButtons::LeftStick)) { ToggleAnimation(); } UpdateAmbientLight(gameTime); UpdateSpecularLight(gameTime); UpdateDirectionalLight(gameTime, gamePadState); } } mProxyModel->Update(gameTime); }
void BlinnPhongDemo::Update(GameTime gametime) { UpdateAmbientLight(gametime); UpdateDirectionalLight(gametime); UpdateSpecularLight(gametime); }
void MainScreen::onUpdate(float dt) { (void) dt; // Update the core mEngine->Update(dt); auto& scene = mScene; auto& window = mEngine->GetWindow(); auto& renderer = mEngine->GetRenderer(); // Update interpolation variables for (auto& obj : mScene->GetNodes()) { Transform& trans = obj.second->GetTransformation(); trans.Update(); AABB& aabb = obj.second->GetAABB(); aabb.Update(trans.GetPosition(), trans.GetScale(), trans.GetRotation()); } // Update camera euler angles if (window.MouseGrabEnabled()) mCamera.Look(CameraLookOffset()); if (mFollowingCharacter) { // Update character mCharacter.Update(); // Move Camera following character auto trans = mCharacter.GetCharacterNode()->GetTransformation().GetInterpolated(1.0f); mCamera.SetPos(glm::vec3(trans[3].x, trans[3].y + 4, trans[3].z + 4)); } else { // Update camera position mCamera.Move(CameraMoveDirections()); } // Update the camera matrix mCamera.Update(); // Update light position //auto updLight = std::bind(updateLight, renderer, mScene.get(), std::placeholders::_1); auto updLight = [this, &renderer, &scene](const glm::vec3& move) { UpdateLight(renderer, scene.get(), mMovingLightIndex, move); }; float increase = 0.3f; if(window.IsKeyPressed(Key::Kp8)) updLight(glm::vec3(0.0f, increase, 0.0f)); if(window.IsKeyPressed(Key::Kp4)) updLight(glm::vec3(-increase, 0.0f, 0.0f)); if(window.IsKeyPressed(Key::Kp2)) updLight(glm::vec3(0.0f, -increase, 0.0f)); if(window.IsKeyPressed(Key::Kp6)) updLight(glm::vec3(increase, 0.0f, 0.0f)); if(window.IsKeyPressed(Key::Kp5)) updLight(glm::vec3(0.0f, 0.0f, -increase)); if(window.IsKeyPressed(Key::Kp0)) updLight(glm::vec3(0.0f, 0.0f, increase)); // Update cubes' rotations if (mRotationData.rotating) { for(auto& p : scene->GetNodes()) { if (p.first.substr(0, 4) == "cube") scene->Rotate(p.first, RotationAxis::Y, mRotationData.degreesInc); } } // Update dir light increase = 0.3f; if (window.IsKeyPressed(Key::Right)) { if (window.IsKeyPressed(Key::LeftShift)) UpdateDirectionalLight(renderer, glm::vec3(0.0f, 0.0f, increase)); else UpdateDirectionalLight(renderer, glm::vec3(increase, 0.0f, 0.0f)); } if (window.IsKeyPressed(Key::Left)) { if (window.IsKeyPressed(Key::LeftShift)) UpdateDirectionalLight(renderer, glm::vec3(0.0f, 0.0f, -increase)); else UpdateDirectionalLight(renderer, glm::vec3(-increase, 0.0f, 0.0f)); } if (window.IsKeyPressed(Key::Up)) UpdateDirectionalLight(renderer, glm::vec3(0.0f, increase, 0.0f)); if (window.IsKeyPressed(Key::Down)) UpdateDirectionalLight(renderer, glm::vec3(0.0f, -increase, 0.0f)); // Update physics UpdatePhysics(dt); }