MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / UpdateScene

Method UpdateScene

deps/LLGL/examples/Cpp/PBR/Example.cpp:385–447  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

383private:
384
385 void UpdateScene()
386 {
387 // Update camera rotation
388 const auto motion = input->GetMouseMotion();
389 const Gs::Vector2f motionVec
390 {
391 static_cast<float>(motion.x),
392 static_cast<float>(motion.y)
393 };
394
395 if (input->KeyPressed(LLGL::Key::LButton))
396 {
397 if (input->KeyPressed(LLGL::Key::Space))
398 {
399 // Rotate mesh
400 auto& m = meshes[currentMesh].transform;
401 Gs::Matrix4f deltaRotation;
402 Gs::RotateFree(deltaRotation, { 1, 0, 0 }, motionVec.y * 0.01f);
403 Gs::RotateFree(deltaRotation, { 0, 1, 0 }, motionVec.x * 0.01f);
404 m = deltaRotation * m;
405 }
406 else
407 {
408 // Rotate camera
409 viewPitch += motionVec.y * 0.25f;
410 viewYaw += motionVec.x * 0.25f;
411 viewPitch = Gs::Clamp(viewPitch, -90.0f, 90.0f);
412 }
413 }
414
415 // Update material and skybox layer switches
416 if (input->KeyDown(LLGL::Key::Tab))
417 {
418 if (input->KeyPressed(LLGL::Key::Shift))
419 {
420 if (numSkyboxes > 0)
421 settings.skyboxLayer = (settings.skyboxLayer + 1) % numSkyboxes;
422 }
423 else if (input->KeyPressed(LLGL::Key::Space))
424 {
425 if (!meshes.empty())
426 currentMesh = (currentMesh + 1) % static_cast<int>(meshes.size());
427 }
428 else
429 {
430 if (numMaterials > 0)
431 settings.materialLayer = (settings.materialLayer + 1) % numMaterials;
432 }
433 }
434
435 // Set projection, view, and world matrix
436 Gs::Matrix4f viewMatrix;
437 Gs::RotateFree(viewMatrix, Gs::Vector3f{ 0, 1, 0 }, Gs::Deg2Rad(viewYaw));
438 Gs::RotateFree(viewMatrix, Gs::Vector3f{ 1, 0, 0 }, Gs::Deg2Rad(viewPitch));
439 Gs::Translate(viewMatrix, Gs::Vector3f{ 0, 0, -4 });
440
441 settings.vpMatrix = projection * viewMatrix.Inverse();
442 settings.wMatrix = meshes[currentMesh].transform;

Callers

nothing calls this directly

Calls 5

ClampFunction · 0.85
KeyPressedMethod · 0.80
KeyDownMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected