| 482 | } |
| 483 | |
| 484 | void BakingLab::Update(const Timer& timer) |
| 485 | { |
| 486 | AppSettings::UpdateUI(); |
| 487 | |
| 488 | if(AppSettings::LoadLightSettings) |
| 489 | LoadLightSettings(window.GetHwnd()); |
| 490 | |
| 491 | if(AppSettings::SaveLightSettings) |
| 492 | SaveLightSettings(window.GetHwnd()); |
| 493 | |
| 494 | if(AppSettings::CurrentScene.Changed()) |
| 495 | { |
| 496 | uint64 currSceneIdx = uint64(AppSettings::CurrentScene); |
| 497 | meshRenderer.SetModel(&sceneModels[currSceneIdx]); |
| 498 | camera.SetPosition(SceneCameraPositions[currSceneIdx]); |
| 499 | camera.SetXRotation(SceneCameraRotations[currSceneIdx].x); |
| 500 | camera.SetYRotation(SceneCameraRotations[currSceneIdx].y); |
| 501 | AppSettings::DiffuseAlbedoScale.SetValue(SceneAlbedoScales[currSceneIdx]); |
| 502 | } |
| 503 | |
| 504 | mouseState = MouseState::GetMouseState(window); |
| 505 | KeyboardState kbState = KeyboardState::GetKeyboardState(window); |
| 506 | |
| 507 | if(kbState.IsKeyDown(KeyboardState::Escape)) |
| 508 | window.Destroy(); |
| 509 | |
| 510 | float CamMoveSpeed = 5.0f * timer.DeltaSecondsF(); |
| 511 | const float CamRotSpeed = 0.180f * timer.DeltaSecondsF(); |
| 512 | const float MeshRotSpeed = 0.180f * timer.DeltaSecondsF(); |
| 513 | |
| 514 | // Move the camera with keyboard input |
| 515 | if(kbState.IsKeyDown(KeyboardState::LeftShift)) |
| 516 | CamMoveSpeed *= 0.25f; |
| 517 | |
| 518 | Float3 camPos = camera.Position(); |
| 519 | if(kbState.IsKeyDown(KeyboardState::W)) |
| 520 | camPos += camera.Forward() * CamMoveSpeed; |
| 521 | else if (kbState.IsKeyDown(KeyboardState::S)) |
| 522 | camPos += camera.Back() * CamMoveSpeed; |
| 523 | if(kbState.IsKeyDown(KeyboardState::A)) |
| 524 | camPos += camera.Left() * CamMoveSpeed; |
| 525 | else if (kbState.IsKeyDown(KeyboardState::D)) |
| 526 | camPos += camera.Right() * CamMoveSpeed; |
| 527 | if(kbState.IsKeyDown(KeyboardState::Q)) |
| 528 | camPos += camera.Up() * CamMoveSpeed; |
| 529 | else if (kbState.IsKeyDown(KeyboardState::E)) |
| 530 | camPos += camera.Down() * CamMoveSpeed; |
| 531 | camera.SetPosition(camPos); |
| 532 | |
| 533 | // Rotate the camera with the mouse |
| 534 | if(mouseState.RButton.Pressed && mouseState.IsOverWindow) |
| 535 | { |
| 536 | float xRot = camera.XRotation(); |
| 537 | float yRot = camera.YRotation(); |
| 538 | xRot += mouseState.DY * CamRotSpeed; |
| 539 | yRot += mouseState.DX * CamRotSpeed; |
| 540 | camera.SetXRotation(xRot); |
| 541 | camera.SetYRotation(yRot); |
no test coverage detected