Skip to content

Commit

Permalink
Add some experimental changes to get camera movement to work
Browse files Browse the repository at this point in the history
  • Loading branch information
kwiesmueller committed Jun 23, 2024
1 parent 4e213f4 commit 9dbe739
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/testapp/scenarios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ static ScenarioMap_t make_scenarios()
shVisual = setup_shader_visualizer (builder, rTopData, windowApp, sceneRenderer, magnum, magnumScene, sc_matVisualizer);
// shFlat = setup_shader_flat (builder, rTopData, windowApp, sceneRenderer, magnum, magnumScene, sc_matFlat);
shPhong = setup_shader_phong (builder, rTopData, windowApp, sceneRenderer, magnum, magnumScene, sc_matPhong);
planetDraw = setup_testplanets_draw (builder, rTopData, windowApp, sceneRenderer, cameraCtrl, commonScene, uniCore, uniScnFrame, uniPlanet, sc_matVisualizer, sc_matFlat);
planetDraw = setup_landerplanet_draw (builder, rTopData, windowApp, sceneRenderer, cameraCtrl, commonScene, uniCore, uniScnFrame, uniPlanet, sc_matVisualizer, sc_matFlat);

prefabDraw = setup_prefab_draw (builder, rTopData, application, windowApp, sceneRenderer, commonScene, prefabs, sc_matPhong);
vehicleDraw = setup_vehicle_spawn_draw (builder, rTopData, sceneRenderer, vehicleSpawn);
Expand Down
12 changes: 8 additions & 4 deletions src/testapp/sessions/universe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ Session setup_landerplanet_draw(
{
if ( ! rCamCtrl.m_target.has_value())
{
OSP_LOG_INFO("Camera Controller target not set");
return;
}
Vector3 &rCamPl = rCamCtrl.m_target.value();
Expand All @@ -467,14 +468,17 @@ Session setup_landerplanet_draw(

if ( ! translate.isZero())
{
rCamCtrl.m_transform.translation() -= translate;
rCamPl -= translate;
// OSP_LOG_INFO("Translate Camera Controller target by {},{},{}", translate.x(), translate.y(), translate.z());
// rCamCtrl.m_transform.translation() -= translate;
// rCamPl -= translate;

// a bit janky to modify universe stuff directly here, but it works lol
Vector3 const rotated = Quaternion(rScnFrame.m_rotation).transformVector(translate);
rScnFrame.m_position += Vector3g(math::mul_2pow<Vector3, int>(rotated, rScnFrame.m_precision));
// Vector3 const rotated = Quaternion(rScnFrame.m_rotation).transformVector(translate);
// OSP_LOG_INFO("Translate SceneFrame by {},{},{}", rotated.x(), rotated.y(), rotated.z());
// rScnFrame.m_position += Vector3g(math::mul_2pow<Vector3, int>(rotated, rScnFrame.m_precision));
}

// OSP_LOG_INFO("SceneFrame position: {},{},{}", rScnFrame.m_position.x(), rScnFrame.m_position.y(), rScnFrame.m_position.z());
rScnFrame.m_scenePosition = Vector3g(math::mul_2pow<Vector3, int>(rCamCtrl.m_target.value(), rScnFrame.m_precision));
});

Expand Down
15 changes: 15 additions & 0 deletions src/testapp/sessions/universe.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@ osp::Session setup_uni_testplanets(
osp::Session const& uniCore,
osp::Session const& uniScnFrame);

/**
* @brief Draw universe, specifically designed for setup_uni_landerplanet
*/
osp::Session setup_landerplanet_draw(
osp::TopTaskBuilder& rBuilder,
osp::ArrayView<entt::any> topData,
osp::Session const& windowApp,
osp::Session const& sceneRenderer,
osp::Session const& cameraCtrl,
osp::Session const& commonScene,
osp::Session const& uniCore,
osp::Session const& uniScnFrame,
osp::Session const& uniTestPlanets,
osp::draw::MaterialId const matPlanets,
osp::draw::MaterialId const matAxis);

/**
* @brief Draw universe, specifically designed for setup_uni_test_planets
Expand Down

0 comments on commit 9dbe739

Please sign in to comment.