diff --git a/data/assets/examples/globerotation.asset b/data/assets/examples/globerotation.asset deleted file mode 100644 index 58f7ab0dfc..0000000000 --- a/data/assets/examples/globerotation.asset +++ /dev/null @@ -1,71 +0,0 @@ -local sun = asset.require("scene/solarsystem/sun/transforms") -local earth = asset.require("scene/solarsystem/planets/earth/earth") - - - -local models = asset.resource({ - Name = "New Horizons Model", - Type = "HttpSynchronization", - Identifier = "newhorizons_model", - Version = 2 -}) - - -local ExampleGlobeRotation = { - Identifier = "ExampleGlobeRotation", - Parent = earth.Earth.Identifier, - Transform = { - Translation = { - Type = "GlobeTranslation", - Globe = earth.Earth.Identifier, - Latitude = 40.7306, - Longitude = -73.9352, - Altitude = 6, - UseHeightmap = true - }, - Rotation = { - Type = "GlobeRotation", - Globe = earth.Earth.Identifier, - Latitude = 40.7306, - Longitude = -73.9352 - -- Can be used to to put flat on leaning surfaces, but also leads to updating - -- the rotation every frame - --UseHeightmap = true - } - }, - Renderable = { - Type = "RenderableModel", - GeometryFile = models .. "NewHorizonsCleanModel.obj", - LightSources = { - sun.LightSource - } - }, - GUI = { - Name = "GlobeRotation", - Path = "/Examples" - } -} - - -asset.onInitialize(function() - openspace.addSceneGraphNode(ExampleGlobeRotation) -end) - -asset.onDeinitialize(function() - openspace.removeSceneGraphNode(ExampleGlobeRotation) -end) - -asset.export(ExampleGlobeRotation) - - - -asset.meta = { - Name = "GlobeRotation Example", - Description = [[An example that demonstrates how to load a 3D model from a geometry - file, placing it on a planetary surface and rotate it to align with the surface - normal using a "GlobeRotation" transform. Note that "GlobeTranslation" is needed to - put the model in the correct location.]], - Author = "OpenSpace Team", - URL = "http://openspaceproject.com", - License = "MIT license" -} diff --git a/data/assets/examples/rotation/globerotation/angle.asset b/data/assets/examples/rotation/globerotation/angle.asset new file mode 100644 index 0000000000..03aa39e050 --- /dev/null +++ b/data/assets/examples/rotation/globerotation/angle.asset @@ -0,0 +1,57 @@ +-- Angle +-- This asset creates a rotation that places a coordinate axes on the surface of a +-- planetary body. The rotation causes the coordinate axes to remain fixed to the surface +-- of the globe. Additionally, the coordinate axes are rotated around the up-axis by a +-- fixed amount. +-- +-- In order for this feature to work properly, the coordinate axes need to be located at +-- the same place as well, so this example also needs a `GlobeTranslation` applied. + +-- The example needs a `RenderableGlobe` as a parent to function +local Globe = { + Identifier = "GlobeRotation_Example_Angle_Globe", + Renderable = { + Type = "RenderableGlobe" + }, + GUI = { + Name = "GlobeRotation - Angle (Globe)", + Path = "/Examples" + } +} + +local Node = { + Identifier = "GlobeRotation_Example_Angle", + Parent = "GlobeRotation_Example_Angle_Globe", + Transform = { + Translation = { + Type = "GlobeTranslation", + Globe = "GlobeRotation_Example_Angle_Globe", + Latitude = 20.0, + Longitude = -45.0 + }, + Rotation = { + Type = "GlobeRotation", + Globe = "GlobeRotation_Example_Angle_Globe", + Latitude = 20.0, + Longitude = -45.0, + Angle = 45.0 + } + }, + Renderable = { + Type = "RenderableCartesianAxes" + }, + GUI = { + Name = "GlobeRotation - Angle", + Path = "/Examples" + } +} + +asset.onInitialize(function() + openspace.addSceneGraphNode(Globe) + openspace.addSceneGraphNode(Node) +end) + +asset.onDeinitialize(function() + openspace.removeSceneGraphNode(Node) + openspace.removeSceneGraphNode(Globe) +end) diff --git a/data/assets/examples/rotation/globerotation/globe.asset b/data/assets/examples/rotation/globerotation/globe.asset new file mode 100644 index 0000000000..b85209bfcb --- /dev/null +++ b/data/assets/examples/rotation/globerotation/globe.asset @@ -0,0 +1,55 @@ +-- Basic +-- This asset creates a rotation that places a coordinate axes on the surface of a +-- planetary body. The rotation causes the coordinate axes to remain fixed to the surface +-- of the globe. +-- +-- In order for this feature to work properly, the coordinate axes need to be located at +-- the same place as well, so this example also needs a `GlobeTranslation` applied. + +-- The example needs a `RenderableGlobe` as a parent to function +local Globe = { + Identifier = "GlobeRotation_Example_Globe", + Renderable = { + Type = "RenderableGlobe" + }, + GUI = { + Name = "GlobeRotation - Basic (Globe)", + Path = "/Examples" + } +} + +local Node = { + Identifier = "GlobeRotation_Example", + Parent = "GlobeRotation_Example_Globe", + Transform = { + Translation = { + Type = "GlobeTranslation", + Globe = "GlobeRotation_Example_Globe", + Latitude = 20.0, + Longitude = -45.0 + }, + Rotation = { + Type = "GlobeRotation", + Globe = "GlobeRotation_Example_Globe", + Latitude = 20.0, + Longitude = -45.0 + } + }, + Renderable = { + Type = "RenderableCartesianAxes" + }, + GUI = { + Name = "GlobeRotation - Basic", + Path = "/Examples" + } +} + +asset.onInitialize(function() + openspace.addSceneGraphNode(Globe) + openspace.addSceneGraphNode(Node) +end) + +asset.onDeinitialize(function() + openspace.removeSceneGraphNode(Node) + openspace.removeSceneGraphNode(Globe) +end) diff --git a/data/assets/examples/rotation/globerotation/usecamera.asset b/data/assets/examples/rotation/globerotation/usecamera.asset new file mode 100644 index 0000000000..ceb2b3e156 --- /dev/null +++ b/data/assets/examples/rotation/globerotation/usecamera.asset @@ -0,0 +1,61 @@ +-- UseCamera +-- This asset creates a rotation that places a coordinate axes on the surface of a +-- planetary body. The rotation causes the coordinate axes to remain fixed to the surface +-- of the globe. In this example, the rotation of the object will be updated based on the +-- location of the camera. When loading this example, make sure to focus the camera on +-- the Globe object for the follow-function to work. +-- +-- In order for this feature to work properly, the coordinate axes need to be located at +-- the same place as well, so this example also needs a `GlobeTranslation` applied, which +-- in this case also updated based on the camera location. + +-- The example needs a `RenderableGlobe` as a parent to function +local Globe = { + Identifier = "GlobeRotation_Example_UseCamera_Globe", + Renderable = { + Type = "RenderableGlobe" + }, + GUI = { + Name = "GlobeRotation - UseCamera (Globe)", + Path = "/Examples" + } +} + +local Node = { + Identifier = "GlobeRotation_Example_UseCamera", + Parent = "GlobeRotation_Example_UseCamera_Globe", + Transform = { + Translation = { + Type = "GlobeTranslation", + Globe = "GlobeRotation_Example_UseCamera_Globe", + Latitude = 20.0, + Longitude = -45.0, + UseCamera = true + }, + Rotation = { + Type = "GlobeRotation", + Globe = "GlobeRotation_Example_UseCamera_Globe", + Latitude = 20.0, + Longitude = -45.0, + Angle = 45.0, + UseCamera = true + } + }, + Renderable = { + Type = "RenderableCartesianAxes" + }, + GUI = { + Name = "GlobeRotation - UseCamera", + Path = "/Examples" + } +} + +asset.onInitialize(function() + openspace.addSceneGraphNode(Globe) + openspace.addSceneGraphNode(Node) +end) + +asset.onDeinitialize(function() + openspace.removeSceneGraphNode(Node) + openspace.removeSceneGraphNode(Globe) +end) diff --git a/modules/globebrowsing/src/globerotation.cpp b/modules/globebrowsing/src/globerotation.cpp index 0dbe8ae0d4..bc2ea848bf 100644 --- a/modules/globebrowsing/src/globerotation.cpp +++ b/modules/globebrowsing/src/globerotation.cpp @@ -49,7 +49,7 @@ namespace { "Latitude", "The latitude of the location on the globe's surface. The value can range from " "-90 to 90, with negative values representing the southern hemisphere of the " - "globe. The default value is 0.0.", + "globe.", openspace::properties::Property::Visibility::User }; @@ -58,15 +58,15 @@ namespace { "Longitude", "The longitude of the location on the globe's surface. The value can range from " "-180 to 180, with negative values representing the western hemisphere of the " - "globe. The default value is 0.0.", + "globe.", openspace::properties::Property::Visibility::User }; constexpr openspace::properties::Property::PropertyInfo AngleInfo = { "Angle", "Angle", - "A rotation angle that can be used to rotate the object around its own y-axis, " - "which will be pointing out of the globe's surface.", + "A rotation angle (in degrees) that can be used to rotate the object around its " + "own y-axis, which will be pointing out of the globe's surface.", openspace::properties::Property::Visibility::AdvancedUser }; @@ -82,7 +82,8 @@ namespace { constexpr openspace::properties::Property::PropertyInfo UseCameraInfo = { "UseCamera", "Use Camera", - "If this value is 'true', the lat and lon are updated to match the camera.", + "If this value is 'true', the latitute and longitude are updated each frame " + "to match the location of the camera.", openspace::properties::Property::Visibility::AdvancedUser }; @@ -92,10 +93,10 @@ namespace { [[codegen::annotation("A valid scene graph node with a RenderableGlobe")]]; // [[codegen::verbatim(LatitudeInfo.description)]] - std::optional latitude; + double latitude [[codegen::inrange(-90.0, 90.0)]]; // [[codegen::verbatim(LongitudeInfo.description)]] - std::optional longitude; + double longitude [[codegen::inrange(-180.0, 180.0)]]; // [[codegen::verbatim(AngleInfo.description)]] std::optional angle; @@ -132,11 +133,11 @@ GlobeRotation::GlobeRotation(const ghoul::Dictionary& dictionary) }); addProperty(_globe); - _latitude = p.latitude.value_or(_latitude); + _latitude = p.latitude; _latitude.onChange([this]() { setUpdateVariables(); }); addProperty(_latitude); - _longitude = p.longitude.value_or(_longitude); + _longitude = p.longitude; _longitude.onChange([this]() { setUpdateVariables(); }); addProperty(_longitude); @@ -151,7 +152,6 @@ GlobeRotation::GlobeRotation(const ghoul::Dictionary& dictionary) _useCamera = p.useCamera.value_or(_useCamera); _useCamera.onChange([this]() { setUpdateVariables(); }); addProperty(_useCamera); - } void GlobeRotation::findGlobe() {