From 76ea508dab54d88726cc0602b4ab051f92587fd0 Mon Sep 17 00:00:00 2001 From: Emma Broman Date: Wed, 1 Dec 2021 11:31:53 +0100 Subject: [PATCH 1/2] Tiny navigation code cleanup/fix --- src/navigation/navigationhandler.cpp | 3 +-- src/navigation/navigationstate.cpp | 10 +++++++--- src/navigation/pathnavigator_lua.inl | 8 +++++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/navigation/navigationhandler.cpp b/src/navigation/navigationhandler.cpp index d772b84000..2e8e94d1fc 100644 --- a/src/navigation/navigationhandler.cpp +++ b/src/navigation/navigationhandler.cpp @@ -131,8 +131,7 @@ void NavigationHandler::setCamera(Camera* camera) { _orbitalNavigator.setCamera(camera); } -void NavigationHandler::setNavigationStateNextFrame(NavigationState state) -{ +void NavigationHandler::setNavigationStateNextFrame(NavigationState state) { _pendingNavigationState = std::move(state); } diff --git a/src/navigation/navigationstate.cpp b/src/navigation/navigationstate.cpp index 7d99eb4095..561020402b 100644 --- a/src/navigation/navigationstate.cpp +++ b/src/navigation/navigationstate.cpp @@ -95,16 +95,17 @@ NavigationState::NavigationState(std::string anchor_, std::string aim_, CameraPose NavigationState::cameraPose() const { const SceneGraphNode* referenceFrameNode = sceneGraphNode(referenceFrame); const SceneGraphNode* anchorNode = sceneGraphNode(anchor); + const SceneGraphNode* aimNode = sceneGraphNode(aim); if (!anchorNode) { LERROR(fmt::format( - "Could not find scene graph node '{}' used as anchor.", referenceFrame + "Could not find scene graph node '{}' used as anchor.", anchor )); return CameraPose(); } - if (!aim.empty() && !sceneGraphNode(aim)) { + if (!aim.empty() && !aimNode) { LERROR(fmt::format( - "Could not find scene graph node '{}' used as aim.", referenceFrame + "Could not find scene graph node '{}' used as aim.", aim )); return CameraPose(); } @@ -116,6 +117,9 @@ CameraPose NavigationState::cameraPose() const { return CameraPose(); } + // @TODO (2021-12-01, emmbr) The aim is not used at all below, so this code does + // not work if the navigation state has a defined aim node. This should be fixed + CameraPose resultingPose; const glm::dvec3 anchorWorldPosition = anchorNode->worldPosition(); diff --git a/src/navigation/pathnavigator_lua.inl b/src/navigation/pathnavigator_lua.inl index 2e946a8492..9340d47615 100644 --- a/src/navigation/pathnavigator_lua.inl +++ b/src/navigation/pathnavigator_lua.inl @@ -37,6 +37,8 @@ #include #include +using namespace std::string_literals; + namespace { constexpr const double Epsilon = 1e-5; } // namespace @@ -87,7 +89,7 @@ int goTo(lua_State* L) { } ghoul::Dictionary insDict; - insDict.setValue("TargetType", std::string("Node")); + insDict.setValue("TargetType", "Node"s); insDict.setValue("Target", nodeIdentifier); if (useUpFromTargetOrDuration.has_value()) { if (std::holds_alternative(*useUpFromTargetOrDuration)) { @@ -134,7 +136,7 @@ int goToHeight(lua_State* L) { } ghoul::Dictionary insDict; - insDict.setValue("TargetType", std::string("Node")); + insDict.setValue("TargetType", "Node"s); insDict.setValue("Target", nodeIdentifier); insDict.setValue("Height", height); if (useUpFromTargetOrDuration.has_value()) { @@ -189,7 +191,7 @@ int goToNavigationState(lua_State* L) { } ghoul::Dictionary instruction; - instruction.setValue("TargetType", std::string("NavigationState")); + instruction.setValue("TargetType", "NavigationState"s); instruction.setValue("NavigationState", navigationState); if (duration.has_value()) { From 7191d536ad1f06aa2d57f8dff3d6742264fe27f1 Mon Sep 17 00:00:00 2001 From: Malin E Date: Wed, 1 Dec 2021 14:28:15 +0100 Subject: [PATCH 2/2] Add Mars moon models --- .../solarsystem/planets/default_layers.asset | 2 - .../planets/mars/moons/deimos.asset | 30 +++++++++--- .../planets/mars/moons/deimos_globe.asset | 48 +++++++++++++++++++ .../layers/colorlayers/deimos_viking.asset | 2 +- .../layers/colorlayers/phobos_viking.asset | 2 +- .../planets/mars/moons/phobos.asset | 30 +++++++++--- .../planets/mars/moons/phobos_globe.asset | 48 +++++++++++++++++++ 7 files changed, 146 insertions(+), 16 deletions(-) create mode 100644 data/assets/scene/solarsystem/planets/mars/moons/deimos_globe.asset create mode 100644 data/assets/scene/solarsystem/planets/mars/moons/phobos_globe.asset diff --git a/data/assets/scene/solarsystem/planets/default_layers.asset b/data/assets/scene/solarsystem/planets/default_layers.asset index acfe25579b..fec02595fa 100644 --- a/data/assets/scene/solarsystem/planets/default_layers.asset +++ b/data/assets/scene/solarsystem/planets/default_layers.asset @@ -8,8 +8,6 @@ asset.require('./jupiter/ganymede/default_layers') asset.require('./jupiter/io/default_layers') asset.require('./mars/default_layers') -asset.require('./mars/moons/layers/colorlayers/deimos_viking') -asset.require('./mars/moons/layers/colorlayers/phobos_viking') asset.require('./mercury/default_layers') diff --git a/data/assets/scene/solarsystem/planets/mars/moons/deimos.asset b/data/assets/scene/solarsystem/planets/mars/moons/deimos.asset index a7b3d5e7aa..40c70e00e8 100644 --- a/data/assets/scene/solarsystem/planets/mars/moons/deimos.asset +++ b/data/assets/scene/solarsystem/planets/mars/moons/deimos.asset @@ -1,7 +1,14 @@ -local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') +local transforms = asset.require('../transforms') +local sunTransforms = asset.require('scene/solarsystem/sun/transforms') local kernels = asset.require('../mar097').Kernels +local model = asset.syncedResource({ + Name = "Deimos Model", + Type = "HttpSynchronization", + Identifier = "deimos_model", + Version = 1 +}) local Deimos = { Identifier = "Deimos", @@ -21,10 +28,21 @@ local Deimos = { } }, Renderable = { - Type = "RenderableGlobe", - Radii = { 15000, 12200, 11000 }, - SegmentsPerPatch = 90, - Layers = {} + Type = "RenderableModel", + GeometryFile = model .. "/Deimos_1_1000.glb", + ModelScale = 2000, + AmbientIntensity = 0.02, + SpecularIntensity = 0.0, + LightSources = { + { + Type = "SceneGraphLightSource", + Identifier = "Sun", + Node = sunTransforms.SolarSystemBarycenter.Identifier, + Intensity = 1.0 + } + }, + PerformShading = true, + DisableFaceCulling = true }, Tag = { "moon_solarSystem", "moon_terrestrial", "moon_mars" }, GUI = { @@ -62,7 +80,7 @@ assetHelper.registerSceneGraphNodesAndExport(asset, { Deimos, DeimosTrail }) asset.meta = { Name = "Deimos", Version = "1.0", - Description = [[ RenderableGlobe and Trail for Deimos.]], + Description = [[ RenderableModel and Trail for Deimos.]], Author = "OpenSpace Team", URL = "http://openspaceproject.com", License = "MIT license", diff --git a/data/assets/scene/solarsystem/planets/mars/moons/deimos_globe.asset b/data/assets/scene/solarsystem/planets/mars/moons/deimos_globe.asset new file mode 100644 index 0000000000..afed8e30f5 --- /dev/null +++ b/data/assets/scene/solarsystem/planets/mars/moons/deimos_globe.asset @@ -0,0 +1,48 @@ +local assetHelper = asset.require('util/asset_helper') +local transforms = asset.require('../transforms') +local kernels = asset.require('../mar097').Kernels + + +local DeimosGlobe = { + Identifier = "Deimos_Globe", + Parent = transforms.MarsBarycenter.Identifier, + Transform = { + Rotation = { + Type = "SpiceRotation", + SourceFrame = "IAU_DEIMOS", + DestinationFrame = "GALACTIC", + Kernels = kernels + }, + Translation = { + Type = "SpiceTranslation", + Target = "DEIMOS", + Observer = "MARS BARYCENTER", + Kernels = kernels + } + }, + Renderable = { + Type = "RenderableGlobe", + Radii = { 15000, 12200, 11000 }, + SegmentsPerPatch = 90, + Layers = {} + }, + Tag = { "moon_solarSystem", "moon_terrestrial", "moon_mars" }, + GUI = { + Name = "Deimos_Globe", + Path = "/Solar System/Planets/Mars", + Description = [[One of two moons of Mars.]] + } +} + +assetHelper.registerSceneGraphNodesAndExport(asset, { DeimosGlobe }) + + +asset.meta = { + Name = "Deimos Globe", + Version = "1.0", + Description = [[ RenderableGlobe for Deimos.]], + Author = "OpenSpace Team", + URL = "http://openspaceproject.com", + License = "MIT license", + Identifiers = {"Deimos"} +} diff --git a/data/assets/scene/solarsystem/planets/mars/moons/layers/colorlayers/deimos_viking.asset b/data/assets/scene/solarsystem/planets/mars/moons/layers/colorlayers/deimos_viking.asset index e2d8bcc965..90338f184c 100644 --- a/data/assets/scene/solarsystem/planets/mars/moons/layers/colorlayers/deimos_viking.asset +++ b/data/assets/scene/solarsystem/planets/mars/moons/layers/colorlayers/deimos_viking.asset @@ -1,4 +1,4 @@ -local globeIdentifier = asset.require("./../../deimos").Deimos.Identifier +local globeIdentifier = asset.require("./../../deimos_globe").Deimos_Globe.Identifier local layer = { Identifier = "Deimos_Global_Mosaic_USGS", diff --git a/data/assets/scene/solarsystem/planets/mars/moons/layers/colorlayers/phobos_viking.asset b/data/assets/scene/solarsystem/planets/mars/moons/layers/colorlayers/phobos_viking.asset index a753881a56..99829b7a2a 100644 --- a/data/assets/scene/solarsystem/planets/mars/moons/layers/colorlayers/phobos_viking.asset +++ b/data/assets/scene/solarsystem/planets/mars/moons/layers/colorlayers/phobos_viking.asset @@ -1,4 +1,4 @@ -local globeIdentifier = asset.require("./../../phobos").Phobos.Identifier +local globeIdentifier = asset.require("./../../phobos_globe").Phobos_Globe.Identifier local layer = { Identifier = "Phobos_Global_Shaded_Relief_USGS", diff --git a/data/assets/scene/solarsystem/planets/mars/moons/phobos.asset b/data/assets/scene/solarsystem/planets/mars/moons/phobos.asset index 353c73e320..d3807005e1 100644 --- a/data/assets/scene/solarsystem/planets/mars/moons/phobos.asset +++ b/data/assets/scene/solarsystem/planets/mars/moons/phobos.asset @@ -1,7 +1,14 @@ -local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') +local transforms = asset.require('../transforms') +local sunTransforms = asset.require('scene/solarsystem/sun/transforms') local kernels = asset.require('../mar097').Kernels +local model = asset.syncedResource({ + Name = "Phobos Model", + Type = "HttpSynchronization", + Identifier = "phobos_model", + Version = 1 +}) local Phobos = { Identifier = "Phobos", @@ -21,10 +28,21 @@ local Phobos = { } }, Renderable = { - Type = "RenderableGlobe", - Radii = { 27000, 22000, 18000 }, - SegmentsPerPatch = 90, - Layers = {} + Type = "RenderableModel", + GeometryFile = model .. "/Phobos_1_1000.glb", + ModelScale = 2000, + AmbientIntensity = 0.02, + SpecularIntensity = 0.0, + LightSources = { + { + Type = "SceneGraphLightSource", + Identifier = "Sun", + Node = sunTransforms.SolarSystemBarycenter.Identifier, + Intensity = 1.0 + } + }, + PerformShading = true, + DisableFaceCulling = true }, Tag = { "moon_solarSystem", "moon_terrestrial", "moon_mars" }, GUI = { @@ -62,7 +80,7 @@ assetHelper.registerSceneGraphNodesAndExport(asset, { Phobos, PhobosTrail }) asset.meta = { Name = "Phobos", Version = "1.0", - Description = [[ RenderableGlobe and Trail for Phobos.]], + Description = [[ RenderableModel and Trail for Phobos.]], Author = "OpenSpace Team", URL = "http://openspaceproject.com", License = "MIT license", diff --git a/data/assets/scene/solarsystem/planets/mars/moons/phobos_globe.asset b/data/assets/scene/solarsystem/planets/mars/moons/phobos_globe.asset new file mode 100644 index 0000000000..ef1ae159fb --- /dev/null +++ b/data/assets/scene/solarsystem/planets/mars/moons/phobos_globe.asset @@ -0,0 +1,48 @@ +local assetHelper = asset.require('util/asset_helper') +local transforms = asset.require('../transforms') +local kernels = asset.require('../mar097').Kernels + + +local PhobosGlobe = { + Identifier = "Phobos_Globe", + Parent = transforms.MarsBarycenter.Identifier, + Transform = { + Rotation = { + Type = "SpiceRotation", + SourceFrame = "IAU_PHOBOS", + DestinationFrame = "GALACTIC", + Kernels = kernels + }, + Translation = { + Type = "SpiceTranslation", + Target = "PHOBOS", + Observer = "MARS BARYCENTER", + Kernels = kernels + } + }, + Renderable = { + Type = "RenderableGlobe", + Radii = { 27000, 22000, 18000 }, + SegmentsPerPatch = 90, + Layers = {} + }, + Tag = { "moon_solarSystem", "moon_terrestrial", "moon_mars" }, + GUI = { + Name = "Phobos_Globe", + Path = "/Solar System/Planets/Mars", + Description = [[One of two moons of Mars.]] + } +} + +assetHelper.registerSceneGraphNodesAndExport(asset, { PhobosGlobe }) + + +asset.meta = { + Name = "Phobos Globe", + Version = "1.0", + Description = [[ RenderableGlobe for Phobos.]], + Author = "OpenSpace Team", + URL = "http://openspaceproject.com", + License = "MIT license", + Identifiers = {"Phobos"} +}