diff --git a/CMakeLists.txt b/CMakeLists.txt index eabc169d1f..1694b170b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,6 @@ set(OPENSPACE_CMAKE_EXT_DIR "${OPENSPACE_BASE_DIR}/support/cmake") set(GHOUL_BASE_DIR "${OPENSPACE_BASE_DIR}/ext/ghoul") include(${OPENSPACE_CMAKE_EXT_DIR}/module_common.cmake) -include(${OPENSPACE_CMAKE_EXT_DIR}/global_variables.cmake) include(${GHOUL_BASE_DIR}/support/cmake/copy_shared_libraries.cmake) include(${GHOUL_BASE_DIR}/support/cmake/handle_external_library.cmake) include(${GHOUL_BASE_DIR}/support/cmake/message_macros.cmake) @@ -164,7 +163,6 @@ if (UNIX) endif () add_subdirectory(ext) - add_subdirectory(src) add_subdirectory(support/coding/codegen) diff --git a/apps/OpenSpace-MinVR/CMakeLists.txt b/apps/OpenSpace-MinVR/CMakeLists.txt index 8f799b8b37..ae592d8d42 100644 --- a/apps/OpenSpace-MinVR/CMakeLists.txt +++ b/apps/OpenSpace-MinVR/CMakeLists.txt @@ -50,7 +50,7 @@ target_include_directories(OpenSpace-MinVR PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/ex target_include_directories(OpenSpace-MinVR PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/ext/minvr/external/GLFW/src/include) -target_link_libraries(OpenSpace-MinVR openspace-core MinVR) +target_link_libraries(OpenSpace-MinVR PUBLIC openspace-core MinVR) # Web Browser and Web gui # Why not put these in the module's path? Because they do not have access to the @@ -71,16 +71,7 @@ elseif (OPENSPACE_MODULE_WEBBROWSER) message(WARNING "Web configured to be included, but no CEF_ROOT was found, please try configuring CMake again.") endif () -if (OPENSPACE_MODULE_WEBGUI AND WEBGUI_MODULE_PATH) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${WEBGUI_MODULE_PATH}/cmake") - include(webgui_helpers) - build_webgui_source(OpenSpace-MinVR) -elseif (OPENSPACE_MODULE_WEBGUI) - message(WARNING "WebGui is configured to be included, but the web source could not be found. Try configuring CMake again.") -endif () -# End Web Browser and Web gui - if (MSVC) # This library is used for being able to output the callstack if an exception escapes - target_link_libraries(OpenSpace-MinVR Dbghelp.lib) + target_link_libraries(OpenSpace-MinVR PUBLIC Dbghelp.lib) endif () diff --git a/apps/OpenSpace/CMakeLists.txt b/apps/OpenSpace/CMakeLists.txt index ba01953e86..b8677938df 100644 --- a/apps/OpenSpace/CMakeLists.txt +++ b/apps/OpenSpace/CMakeLists.txt @@ -25,7 +25,6 @@ include(${GHOUL_BASE_DIR}/support/cmake/copy_shared_libraries.cmake) include(${GHOUL_BASE_DIR}/support/cmake/message_macros.cmake) include(${OPENSPACE_CMAKE_EXT_DIR}/application_definition.cmake) -include(${OPENSPACE_CMAKE_EXT_DIR}/global_variables.cmake) # We are getting all_enabled_modules from the handle_applications.cmake file which gets # it from the main CMakeLists file @@ -141,6 +140,18 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ext/launcher) target_link_libraries(OpenSpace PRIVATE openspace-ui-launcher) end_header("Dependency: Profile Editor") +if (WIN32) + # Find the windeployqt application + get_target_property(_qmake_executable Qt6::qmake IMPORTED_LOCATION) + get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY) + find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}") + add_custom_command( + TARGET OpenSpace POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E env PATH="${_qt_bin_dir}" "${WINDEPLOYQT_EXECUTABLE}" --verbose 0 --no-compiler-runtime \"$\" + COMMENT "Deploying Qt libraries" + ) +endif () + # Web Browser and Web gui # Why not put these in the module's path? Because they do not have access to the @@ -161,7 +172,7 @@ if (OPENSPACE_MODULE_WEBBROWSER AND CEF_ROOT) set_cef_targets("${CEF_ROOT}" OpenSpace) run_cef_platform_config("${CEF_ROOT}" "${CEF_TARGET}" "${WEBBROWSER_MODULE_PATH}") elseif () - message(WARNING "Web configured to be included, but no CEF_ROOT was found, please try configuring CMake again.") + message(WARNING "Web configured to be included, but no CEF_ROOT was found, please try configuring CMake again") endif () if (MSVC) @@ -174,3 +185,10 @@ endif () if (OPENSPACE_NVTOOLS_ENABLED) target_link_libraries(OpenSpace PRIVATE "${OPENSPACE_NVTOOLS_PATH}/lib/x64/nvToolsExt64_1.lib") endif () + +if (WIN32) + add_custom_command(TARGET OpenSpace POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ + COMMAND_EXPAND_LISTS + ) +endif () diff --git a/apps/TaskRunner/main.cpp b/apps/TaskRunner/main.cpp index 194b52e4de..663e27140d 100644 --- a/apps/TaskRunner/main.cpp +++ b/apps/TaskRunner/main.cpp @@ -113,7 +113,7 @@ int main(int argc, char** argv) { // Register the base path as the directory where the configuration file lives std::filesystem::path base = configFile.parent_path(); constexpr std::string_view BasePathToken = "${BASE}"; - FileSys.registerPathToken(BasePathToken, base); + FileSys.registerPathToken(BasePathToken.data(), base); // Using same configuration for size as in apps/OpenSpace/main.cpp glm::ivec2 size = glm::ivec2(1920, 1080); diff --git a/data/assets/educational/scale/eiffeltower.asset b/data/assets/educational/scale/eiffeltower.asset index dc91b4ed1d..226a41b6d5 100644 --- a/data/assets/educational/scale/eiffeltower.asset +++ b/data/assets/educational/scale/eiffeltower.asset @@ -2,76 +2,77 @@ local earthAsset = asset.require('scene/solarsystem/planets/earth/earth') local sunAsset = asset.require('scene/solarsystem/sun/sun') local modelFolder = asset.syncedResource({ - Name = "Eiffel Tower Model", - Type = "HttpSynchronization", - Identifier = "eiffel_tower_model", - Version = 1 + Name = "Eiffel Tower Model", + Type = "HttpSynchronization", + Identifier = "eiffel_tower_model", + Version = 1 }) - + local eiffelTower = { - Identifier = "eiffelTower", - Parent = earthAsset.Earth.Identifier, - --Note: Lat/Lon/Scale values comes from alignment with Esri World Imagery 2D layer - Transform = { - Translation = { - Type = "GlobeTranslation", - Globe = earthAsset.Earth.Identifier, - Longitude = 2.29448, - Latitude = 48.85824, - Altitude = 0.0, - UseHeightmap = true - }, - Rotation = { - Type = "GlobeRotation", - Globe = earthAsset.Earth.Identifier, - Longitude = 2.29448, - Latitude = 48.85824, - UseHeightmap = false - }, - Scale = { - Type = "StaticScale", - Scale = 4.38 - } - }, - Renderable = { - Type = "RenderableModel", - GeometryFile = modelFolder .. "eiffeltower.osmodel", - ModelScale = "Centimeter", - RotationVector = { 0.0, 45.0, 0.0 }, - LightSources = { sunAsset.LightSource } - }, - GUI = { - Name = "Eiffel Tower", - Path = "/Scale Objects" - } + Identifier = "eiffelTower", + Parent = earthAsset.Earth.Identifier, + --Note: Lat/Lon/Scale values comes from alignment with Esri World Imagery 2D layer + Transform = { + Translation = { + Type = "GlobeTranslation", + Globe = earthAsset.Earth.Identifier, + Longitude = 2.29448, + Latitude = 48.85824, + Altitude = 0.0, + UseHeightmap = true + }, + Rotation = { + Type = "GlobeRotation", + Globe = earthAsset.Earth.Identifier, + Longitude = 2.29448, + Latitude = 48.85824, + UseHeightmap = false + }, + Scale = { + Type = "StaticScale", + Scale = 4.38 + } + }, + Renderable = { + Type = "RenderableModel", + GeometryFile = modelFolder .. "eiffeltower.osmodel", + ModelScale = "Centimeter", + RotationVector = { 0.0, 45.0, 0.0 }, + LightSources = { sunAsset.LightSource } + }, + GUI = { + Name = "Eiffel Tower", + Path = "/Scale Objects" + } } local updatePositionAction = { - Identifier = "os.drop_eiffel_tower", - Name = "Drop Eiffel Tower under camera", - Command = [[local lat, lon, alt = openspace.globebrowsing.getGeoPositionForCamera(); - local camera = openspace.navigation.getNavigationState(); - openspace.setParent('eiffelTower', camera.Anchor) - openspace.setPropertyValueSingle('Scene.eiffelTower.Translation.Globe', camera.Anchor); - openspace.setPropertyValueSingle('Scene.eiffelTower.Translation.Latitude', lat); - openspace.setPropertyValueSingle('Scene.eiffelTower.Translation.Longitude', lon); - openspace.setPropertyValueSingle('Scene.eiffelTower.Rotation.Globe', camera.Anchor); - openspace.setPropertyValueSingle('Scene.eiffelTower.Rotation.Latitude', lat); - openspace.setPropertyValueSingle('Scene.eiffelTower.Rotation.Longitude', lon); - ]], - Documentation = "Updates the Eiffel Tower position based on the globe location of the camera", - GuiPath = "/Scale Objects", - IsLocal = false + Identifier = "os.drop_eiffel_tower", + Name = "Drop Eiffel Tower under camera", + Command = [[ + local lat, lon, alt = openspace.globebrowsing.getGeoPositionForCamera(); + local camera = openspace.navigation.getNavigationState(); + openspace.setParent('eiffelTower', camera.Anchor) + openspace.setPropertyValueSingle('Scene.eiffelTower.Translation.Globe', camera.Anchor); + openspace.setPropertyValueSingle('Scene.eiffelTower.Translation.Latitude', lat); + openspace.setPropertyValueSingle('Scene.eiffelTower.Translation.Longitude', lon); + openspace.setPropertyValueSingle('Scene.eiffelTower.Rotation.Globe', camera.Anchor); + openspace.setPropertyValueSingle('Scene.eiffelTower.Rotation.Latitude', lat); + openspace.setPropertyValueSingle('Scene.eiffelTower.Rotation.Longitude', lon); + ]], + Documentation = "Updates the Eiffel Tower position based on the globe location of the camera", + GuiPath = "/Scale Objects", + IsLocal = false } asset.onInitialize(function() - openspace.addSceneGraphNode(eiffelTower) - openspace.action.registerAction(updatePositionAction) + openspace.addSceneGraphNode(eiffelTower) + openspace.action.registerAction(updatePositionAction) end) - + asset.onDeinitialize(function() - openspace.action.removeAction(updatePositionAction) - openspace.removeSceneGraphNode(eiffelTower) + openspace.action.removeAction(updatePositionAction) + openspace.removeSceneGraphNode(eiffelTower) end) - + asset.export(eiffelTower) diff --git a/data/assets/examples/grids.asset b/data/assets/examples/grids.asset index 2fe816e3fb..6c32a1be5a 100644 --- a/data/assets/examples/grids.asset +++ b/data/assets/examples/grids.asset @@ -36,9 +36,12 @@ local planarGrid = { Type = "RenderableGrid", Color = { 0.0, 1.0, 0.8 }, LineWidth = 2.0, - Segments = { 5, 10 }, + Segments = { 6, 10 }, Size = { 1, 2 }, - Enabled = false + Enabled = false, + HighlightColor = {1.0, 0.8, 0.0 }, + HighlightLineWidth = 3.2, + HighlightRate = { 3, 3 } }, GUI = { Name = "Example Grid", diff --git a/data/assets/scene/digitaluniverse/abell.asset b/data/assets/scene/digitaluniverse/abell.asset index d9339aa103..649fbf182a 100644 --- a/data/assets/scene/digitaluniverse/abell.asset +++ b/data/assets/scene/digitaluniverse/abell.asset @@ -17,16 +17,20 @@ local object = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = speck .. "abell.label", + Opacity = 1.0, + Color = { 0.0, 0.8, 0.0 }, + Size = 22, + MinMaxSize = { 10, 12 }, + Unit = "Mpc" + }, Color = { 1.0, 0.4, 0.2 }, Opacity = 1.0, --ColorMap = speck .. "abell.cmap", File = speck .. "abell.speck", Texture = textures .. "point3A.png", - LabelFile = speck .. "abell.label", Unit = "Mpc", - TextColor = { 0.0, 0.8, 0.0 }, - TextSize = 22, - TextMinMaxSize = { 10, 12 }, TransformationMatrix = { -0.7357425748, 0.67726129641, 0.0, 0.0, -0.074553778365, -0.080991471307, 0.9939225904, 0.0, diff --git a/data/assets/scene/digitaluniverse/alternatestarlabels.asset b/data/assets/scene/digitaluniverse/alternatestarlabels.asset index a97cd3cbee..42776124b9 100644 --- a/data/assets/scene/digitaluniverse/alternatestarlabels.asset +++ b/data/assets/scene/digitaluniverse/alternatestarlabels.asset @@ -10,14 +10,17 @@ local object = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = speck .. "stars-altlbl.label", + Color = { 0.4, 0.4, 0.4 }, + Size = 14.7, + MinMaxSize = { 6, 20 }, + Unit = "pc" + }, Color = { 1.0, 1.0, 1.0 }, Opacity = 0.65, - LabelFile = speck .. "stars-altlbl.label", Unit = "pc", - TextColor = { 0.4, 0.4, 0.4 }, - DrawLabels = true, - TextSize = 14.7, - TextMinMaxSize = { 6, 20 } + DrawLabels = true }, GUI = { Name = "Stars Labels - Alternate", @@ -28,7 +31,7 @@ local object = { attempts over thousands of years to name all the visible stars have led to two main catalogs: Johann Bayer's Catalog from 1603 and John Flamsteed's Catalog published in 1725. (Description from URL)

Data Reference: Various - sources]], + sources]] } } @@ -36,11 +39,11 @@ local object = { asset.onInitialize(function() openspace.addSceneGraphNode(object) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(object) end) - + asset.export(object) diff --git a/data/assets/scene/digitaluniverse/clusters.asset b/data/assets/scene/digitaluniverse/clusters.asset index 1d97d63e72..57aa7a429c 100644 --- a/data/assets/scene/digitaluniverse/clusters.asset +++ b/data/assets/scene/digitaluniverse/clusters.asset @@ -10,14 +10,17 @@ local object = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = speck .. "galclust.label", + Color = { 1.0, 0.44, 0.0 }, + Size = 22, + MinMaxSize = { 8, 20 }, + Unit = "Mpc" + }, Color = { 1.0, 1.0, 1.0 }, Opacity = 0.65, - LabelFile = speck .. "galclust.label", Unit = "Mpc", - TextColor = { 1.0, 0.44, 0.0 }, DrawLabels = true, - TextSize = 22, - TextMinMaxSize = { 8, 20 }, TransformationMatrix = { -0.7357425748, 0.67726129641, 0.0, 0.0, -0.074553778365, -0.080991471307, 0.9939225904, 0.0, @@ -39,11 +42,11 @@ local object = { asset.onInitialize(function() openspace.addSceneGraphNode(object) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(object) end) - + asset.export(object) diff --git a/data/assets/scene/digitaluniverse/constellations.asset b/data/assets/scene/digitaluniverse/constellations.asset index a5530f6eb1..8707c05e4a 100644 --- a/data/assets/scene/digitaluniverse/constellations.asset +++ b/data/assets/scene/digitaluniverse/constellations.asset @@ -15,17 +15,19 @@ local constellationsExtragalactic = { Renderable = { Type = "RenderableConstellationLines", Enabled = false, + Labels = { + File = speck .. "constellationsEXGAL.label", + Opacity = 0.4, + Color = { 0.8, 0.8, 0.8 }, + Size = 20.0, + MinMaxSize = { 20, 30 }, + Unit = "Mpc", + }, Opacity = 0.4, File = speck .. "constellationsEXGAL.speck", - LabelFile = speck .. "constellationsEXGAL.label", NamesFile = speck .. "constellations.dat", - TextColor = { 0.8, 0.8, 0.8 }, - TextOpacity = 0.4, - TextSize = 20.0, - TextMinMaxSize = { 20, 30 }, Colors = { { 0.6, 0.4, 0.4 }, { 0.8, 0.0, 0.0 }, { 0.0, 0.3, 0.8 } }, - LabelUnit = "Mpc", - LineUnit = "Mpc", + Unit = "Mpc", -- Selection = zodiacs }, GUI = { @@ -39,17 +41,19 @@ local constellations = { Renderable = { Type = "RenderableConstellationLines", Enabled = false, + Labels = { + File = speck .. "constellations.label", + Opacity = 0.3, + Color = { 0.8, 0.8, 0.8 }, + Size = 14.5, + MinMaxSize = { 8, 170 }, + Unit = "pc", + }, Opacity = 0.3, File = speck .. "constellations.speck", - LabelFile = speck .. "constellations.label", NamesFile = speck .. "constellations.dat", - TextColor = { 0.8, 0.8, 0.8 }, - TextOpacity = 0.3, - TextSize = 14.5, - TextMinMaxSize = { 8, 170 }, Colors = { { 0.6, 0.4, 0.4 }, { 0.8, 0.0, 0.0 }, { 0.0, 0.3, 0.8 } }, - LabelUnit = "pc", - LineUnit = "pc", + Unit = "pc", -- Selection = zodiacs }, GUI = { diff --git a/data/assets/scene/digitaluniverse/deepsky.asset b/data/assets/scene/digitaluniverse/deepsky.asset index eee9f485f8..d9fd9cad1b 100644 --- a/data/assets/scene/digitaluniverse/deepsky.asset +++ b/data/assets/scene/digitaluniverse/deepsky.asset @@ -17,6 +17,13 @@ local deepSkyPoints = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = speck .. "dso.label", + Color = { 0.1, 0.4, 0.6 }, + Size = 20.50, + MinMaxSize = { 16, 20 }, + Unit = "pc" + }, Color = { 1.0, 1.0, 0.0 }, Opacity = 0.99, ScaleFactor = 500.0, @@ -27,11 +34,7 @@ local deepSkyPoints = { --ColorOption = { "proximity" }, --ColorOption = { "prox5Mpc" }, --ColorRange = { { 1.0, 30.0 } }, - LabelFile = speck .. "dso.label", Unit = "pc", - TextColor = { 0.1, 0.4, 0.6 }, - TextSize = 20.50, - TextMinMaxSize = { 16, 20 }, --FadeInDistances = { 0.05, 1.0 }, -- Fade in value in the same unit as "Unit" BillboardMinMaxSize = { 0.0, 8.22 }, -- in pixels --CorrectionSizeEndDistance = 22.0, @@ -94,12 +97,12 @@ asset.onInitialize(function() openspace.addSceneGraphNode(deepSkyPoints) openspace.addSceneGraphNode(deepSkyImages) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(deepSkyImages) openspace.removeSceneGraphNode(deepSkyPoints) end) - + asset.export(deepSkyPoints) asset.export(deepSkyImages) diff --git a/data/assets/scene/digitaluniverse/dwarfs.asset b/data/assets/scene/digitaluniverse/dwarfs.asset index 64aa5d74bf..70db45410c 100644 --- a/data/assets/scene/digitaluniverse/dwarfs.asset +++ b/data/assets/scene/digitaluniverse/dwarfs.asset @@ -17,18 +17,21 @@ local object = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = speck .. "dwarfs.label", + Color = { 0.5, 0.1, 0.2 }, + Size = 14.6, + MinMaxSize = { 10, 20 }, + Unit = "pc" + }, Color = { 0.4, 0.0, 0.1 }, Opacity = 1.0, File = speck .. "dwarfs.speck", Texture = textures .. "point3.png", - LabelFile = speck .. "dwarfs.label", Unit = "pc", ColorMap = speck .. "dwarfs.cmap", ColorOption = { "typeindex" }, --ColorRange = { { 1.0, 4.0} }, - TextColor = { 0.5, 0.1, 0.2 }, - TextSize = 14.6, - TextMinMaxSize = { 10, 20 }, ScaleFactor = 372.1, --CorrectionSizeEndDistance = 16.1, --CorrectionSizeFactor = 7.75, @@ -61,11 +64,11 @@ local object = { asset.onInitialize(function() openspace.addSceneGraphNode(object) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(object) end) - + asset.export(object) diff --git a/data/assets/scene/digitaluniverse/exoplanets.asset b/data/assets/scene/digitaluniverse/exoplanets.asset index 60539b3fac..a863a257ee 100644 --- a/data/assets/scene/digitaluniverse/exoplanets.asset +++ b/data/assets/scene/digitaluniverse/exoplanets.asset @@ -17,17 +17,20 @@ local object = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = speck .. "expl.label", + Color = { 0.3, 0.3, 0.8 }, + Size = 14.8, + MinMaxSize = { 10, 100 }, + Unit = "pc" + }, Color = { 1.0, 1.0, 1.0 }, Opacity = 1.0, ScaleFactor = 10.0, Texture = textures .. "target-blue.png", File = speck .. "expl.speck", - LabelFile = speck .. "expl.label", Unit = "pc", ScaleFactor = 388.67923, - TextColor = { 0.3, 0.3, 0.8 }, - TextSize = 14.8, - TextMinMaxSize = { 10, 100 }, CorrectionSizeEndDistance = 15.23, CorrectionSizeFactor = 13.3, BillboardMinMaxSize = { 0.0, 75.0 }, @@ -49,11 +52,11 @@ local object = { asset.onInitialize(function() openspace.addSceneGraphNode(object) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(object) end) - + asset.export(object) diff --git a/data/assets/scene/digitaluniverse/globularclusters.asset b/data/assets/scene/digitaluniverse/globularclusters.asset index 30f0bb75b4..a4476dc6da 100644 --- a/data/assets/scene/digitaluniverse/globularclusters.asset +++ b/data/assets/scene/digitaluniverse/globularclusters.asset @@ -17,19 +17,22 @@ local object = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = speck .. "gc.label", + Color = { 0.5, 0.5, 0.0 }, + Size = 16.7, + MinMaxSize = { 4, 20 }, + Unit = "pc" + }, Color = { 0.8, 0.8, 0.0 }, Opacity = 0.4, File = speck .. "gc.speck", Texture = textures .. "point4.png", PolygonSides = 5, - LabelFile = speck .. "gc.label", Unit = "pc", - TextColor = { 0.5, 0.5, 0.0 }, ScaleFactor = 431.0, - TextSize = 16.7, - TextMinMaxSize = { 4, 20 }, BillboardMinMaxSize = { 0.0, 500.0 }, - EnablePixelSizeControl = true, + EnablePixelSizeControl = true }, GUI = { Name = "Globular Clusters", @@ -53,11 +56,11 @@ local object = { asset.onInitialize(function() openspace.addSceneGraphNode(object) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(object) end) - + asset.export(object) diff --git a/data/assets/scene/digitaluniverse/grids.asset b/data/assets/scene/digitaluniverse/grids.asset index 91a8619ba7..dccad41868 100644 --- a/data/assets/scene/digitaluniverse/grids.asset +++ b/data/assets/scene/digitaluniverse/grids.asset @@ -20,6 +20,10 @@ local speck = asset.syncedResource({ Version = 2 }) +local lightDay = 2.59020684E13 +local lightMonth = 7.771E14 +local lightYear = 9.4605284E15 + local radio = { Identifier = "RadioSphere", Parent = earth_transforms.EarthBarycenter.Identifier, @@ -106,14 +110,17 @@ local eclipticLabels = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = speck .. "eclip.label", + Color = { 0.5, 0.5, 0.5 }, + Size = 14.75, + MinMaxSize = { 1, 50 }, + Unit = "pc" + }, Color = { 1.0, 1.0, 1.0 }, Opacity = 0.65, - LabelFile = speck .. "eclip.label", Unit = "pc", DrawLabels = true, - TextColor = { 0.5, 0.5, 0.5 }, - TextSize = 14.75, - TextMinMaxSize = { 1, 50 }, TransformationMatrix = { -0.05487554, 0.4941095, -0.8676661, 0.0, -0.9938214 , -0.1109906, -0.0003515167, 0.0, @@ -159,14 +166,17 @@ local equatorialLabels = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = speck .. "radec.label", + Color = { 0.5, 0.5, 0.5 }, + Size = 14.5, + MinMaxSize = { 2, 70 }, + Unit = "pc" + }, Color = { 1.0, 1.0, 1.0 }, Opacity = 0.65, - LabelFile = speck .. "radec.label", Unit = "pc", DrawLabels = true, - TextColor = { 0.5, 0.5, 0.5 }, - TextSize = 14.5, - TextMinMaxSize = { 2, 70 }, TransformationMatrix = { -0.05487554, 0.4941095, -0.8676661, 0.0, -0.8734371 , -0.4448296, -0.1980764, 0.0, @@ -208,14 +218,17 @@ local galacticLabels = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = speck .. "galac.label", + Color = { 0.5, 0.5, 0.5 }, + Size = 15.8, + MinMaxSize = { 1, 100 }, + Unit = "pc" + }, Color = { 1.0, 1.0, 1.0 }, Opacity = 0.65, - LabelFile = speck .. "galac.label", Unit = "pc", - DrawLabels = true, - TextColor = { 0.5, 0.5, 0.5 }, - TextSize = 15.8, - TextMinMaxSize = { 1, 100 } + DrawLabels = true }, GUI = { Name = "Galactic Sphere Labels", @@ -233,16 +246,20 @@ local plane1ld = { } }, Renderable = { - Type = "RenderableDUMeshes", + Type = "RenderableGrid", Enabled = false, + Labels = { + File = speck .. "1ld.label", + Color = { 0.0, 0.2, 0.5 }, + Size = 10.3, + MinMaxSize = { 0, 30 }, + Unit = "Km" + }, Opacity = 0.4, - File = speck .. "1ld.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "1ld.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 10.3, - TextMinMaxSize = { 0, 30 }, - Unit = "Km" + Color = { 0.1, 0.5, 0.6 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + Size = { 2*lightDay, 2*lightDay } }, GUI = { Name = "1ld Grid", @@ -260,16 +277,20 @@ local plane1lm = { } }, Renderable = { - Type = "RenderableDUMeshes", + Type = "RenderableGrid", Enabled = false, + Labels = { + File = speck .. "1lm.label", + Color = { 0.0, 0.2, 0.5 }, + Size = 11.8, + MinMaxSize = { 0, 30 }, + Unit = "pc" + }, Opacity = 0.4, - File = speck .. "1lm.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "1lm.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 11.8, - TextMinMaxSize = { 0, 30 }, - Unit = "pc" + Color = { 0.1, 0.5, 0.6 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + Size = { 2*lightMonth, 2*lightMonth } }, GUI = { Name = "1lm Grid", @@ -287,16 +308,20 @@ local plane1ly = { } }, Renderable = { - Type = "RenderableDUMeshes", + Type = "RenderableGrid", Enabled = false, + Labels = { + File = speck .. "1ly.label", + Color = { 0.0, 0.2, 0.5 }, + Size = 13.0, + MinMaxSize = { 0, 30 }, + Unit = "pc" + }, Opacity = 0.4, - File = speck .. "1ly.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "1ly.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 13.0, - TextMinMaxSize = { 0, 30 }, - Unit = "pc" + Color = { 0.1, 0.5, 0.6 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + Size = { 2*lightYear, 2*lightYear } }, GUI = { Name = "1ly Grid", @@ -314,16 +339,20 @@ local plane10ly = { } }, Renderable = { - Type = "RenderableDUMeshes", + Type = "RenderableGrid", Enabled = false, + Labels = { + File = speck .. "10ly.label", + Color = { 0.0, 0.2, 0.5 }, + Size = 14.17, + MinMaxSize = { 0, 30 }, + Unit = "pc" + }, Opacity = 0.4, - File = speck .. "10ly.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "10ly.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 14.17, - TextMinMaxSize = { 0, 30 }, - Unit = "pc" + Color = { 0.1, 0.5, 0.6 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + Size = { 10*2*lightYear, 10*2*lightYear } }, GUI = { Name = "10ly Grid", @@ -341,16 +370,20 @@ local plane100ly = { } }, Renderable = { - Type = "RenderableDUMeshes", + Type = "RenderableGrid", Enabled = false, + Labels = { + File = speck .. "100ly.label", + Color = { 0.0, 0.2, 0.5 }, + Size = 15.0, + MinMaxSize = { 0, 30 }, + Unit = "pc" + }, Opacity = 0.4, - File = speck .. "100ly.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "100ly.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 15.0, - TextMinMaxSize = { 0, 30 }, - Unit = "pc" + Color = { 0.1, 0.5, 0.6 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + Size = { 100*2*lightYear, 100*2*lightYear } }, GUI = { Name = "100ly Grid", @@ -368,16 +401,20 @@ local plane1kly = { } }, Renderable = { - Type = "RenderableDUMeshes", + Type = "RenderableGrid", Enabled = false, + Labels = { + File = speck .. "1kly.label", + Color = { 0.0, 0.2, 0.5 }, + Size = 16.0, + MinMaxSize = { 0, 30 }, + Unit = "pc" + }, Opacity = 0.4, - File = speck .. "1kly.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "1kly.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 16.0, - TextMinMaxSize = { 0, 30 }, - Unit = "pc" + Color = { 0.1, 0.5, 0.6 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + Size = { 1E3*2*lightYear, 1E3*2*lightYear } }, GUI = { Name = "1kly Grid", @@ -395,16 +432,20 @@ local plane10kly = { } }, Renderable = { - Type = "RenderableDUMeshes", + Type = "RenderableGrid", Enabled = false, + Labels = { + File = speck .. "10kly.label", + Color = { 0.0, 0.2, 0.5 }, + Size = 17.25, + MinMaxSize = { 0, 30 }, + Unit = "pc" + }, Opacity = 0.4, - File = speck .. "10kly.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "10kly.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 17.25, - TextMinMaxSize = { 0, 30 }, - Unit = "pc" + Color = { 0.1, 0.5, 0.6 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + Size = { 10E3*2*lightYear, 10E3*2*lightYear } }, GUI = { Name = "10kly Grid", @@ -415,16 +456,22 @@ local plane10kly = { local plane100kly = { Identifier = "100klyGrid", Renderable = { - Type = "RenderableDUMeshes", + Type = "RenderableGrid", Enabled = false, + Labels = { + File = speck .. "100kly.label", + Color = { 0.0, 0.2, 0.5 }, + Size = 18.6, + MinMaxSize = { 0, 30 }, + Unit = "Mpc" + }, Opacity = 0.4, - File = speck .. "100kly.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "100kly.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 18.6, - TextMinMaxSize = { 0, 30 }, - Unit = "Mpc" + Color = { 0.1, 0.5, 0.6 }, + HighlightColor = { 0.3, 0.7, 0.8 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + HighlightRate = { 5, 5 }, + Size = { 100E3*2*lightYear, 100E3*2*lightYear } }, GUI = { Name = "100kly Grid", @@ -435,16 +482,22 @@ local plane100kly = { local plane1Mly = { Identifier = "1MlyGrid", Renderable = { - Type = "RenderableDUMeshes", + Type = "RenderableGrid", Enabled = false, + Labels = { + File = speck .. "1Mly.label", + Color = { 0.0, 0.2, 0.5 }, + Size = 19.6, + MinMaxSize = { 0, 30 }, + Unit = "Mpc" + }, Opacity = 0.4, - File = speck .. "1Mly.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "1Mly.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 19.6, - TextMinMaxSize = { 0, 30 }, - Unit = "Mpc" + Color = { 0.1, 0.5, 0.6 }, + HighlightColor = { 0.3, 0.7, 0.8 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + HighlightRate = { 5, 5 }, + Size = { 1E6*2*lightYear, 1E6*2*lightYear } }, GUI = { Name = "1Mly Grid", @@ -455,16 +508,22 @@ local plane1Mly = { local plane10Mly = { Identifier = "10MlyGrid", Renderable = { - Type = "RenderableDUMeshes", + Type = "RenderableGrid", Enabled = false, + Labels = { + File = speck .. "10Mly.label", + Color = { 0.0, 0.2, 0.5 }, + Size = 20.6, + MinMaxSize = { 0, 30 }, + Unit = "Mpc" + }, Opacity = 0.4, - File = speck .. "10Mly.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "10Mly.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 20.6, - TextMinMaxSize = { 0, 30 }, - Unit = "Mpc" + Color = { 0.1, 0.5, 0.6 }, + HighlightColor = { 0.3, 0.7, 0.8 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + HighlightRate = { 5, 5 }, + Size = { 10E6*2*lightYear, 10E6*2*lightYear } }, GUI = { Name = "10Mly Grid", @@ -475,16 +534,22 @@ local plane10Mly = { local plane100Mly = { Identifier = "100MlyGrid", Renderable = { - Type = "RenderableDUMeshes", + Type = "RenderableGrid", Enabled = false, + Labels = { + File = speck .. "100Mly.label", + Color = { 0.0, 0.2, 0.5 }, + Size = 21.6, + MinMaxSize = { 0, 30 }, + Unit = "Mpc" + }, Opacity = 0.4, - File = speck .. "100Mly.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "100Mly.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 21.6, - TextMinMaxSize = { 0, 30 }, - Unit = "Mpc" + Color = { 0.1, 0.5, 0.6 }, + HighlightColor = { 0.3, 0.7, 0.8 }, + LineWidth = 2.0, + Segments = { 20, 20 }, + HighlightRate = { 5, 5 }, + Size = { 100E6*2*lightYear, 100E6*2*lightYear } }, GUI = { Name = "100Mly Grid", @@ -495,16 +560,22 @@ local plane100Mly = { local plane20Gly = { Identifier = "20GlyGrid", Renderable = { - Type = "RenderableDUMeshes", + Type = "RenderableGrid", Enabled = false, + Labels = { + File = speck .. "20Gly.label", + Color = { 0.0, 0.2, 0.5 }, + Size = 23.6, + MinMaxSize = { 0, 30 }, + Unit = "Mpc" + }, Opacity = 0.4, - File = speck .. "20Gly.speck", - MeshColor = {{ 0.1, 0.5, 0.6 }}, - LabelFile = speck .. "20Gly.label", - TextColor = { 0.0, 0.2, 0.5 }, - TextSize = 23.6, - TextMinMaxSize = { 0, 30 }, - Unit = "Mpc" + Color = { 0.1, 0.5, 0.6 }, + HighlightColor = { 0.3, 0.7, 0.8 }, + LineWidth = 2.0, + Segments = { 40, 40 }, + HighlightRate = { 5, 5 }, + Size = { 20E9*2*lightYear, 20E9*2*lightYear } }, GUI = { Name = "20Gly Grid", @@ -524,7 +595,7 @@ asset.onInitialize(function() openspace.addSceneGraphNode(node) end end) - + asset.onDeinitialize(function() for i = #nodes, 1, -1 do local node = nodes[i] diff --git a/data/assets/scene/digitaluniverse/groups.asset b/data/assets/scene/digitaluniverse/groups.asset index e3a8904197..1cd3e928f8 100644 --- a/data/assets/scene/digitaluniverse/groups.asset +++ b/data/assets/scene/digitaluniverse/groups.asset @@ -10,14 +10,17 @@ local object = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = speck .. "groups.label", + Color = { 0.1, 0.6, 0.2 }, + Size = 21.5, + MinMaxSize = { 8, 20 }, + Unit = "Mpc" + }, Color = { 1.0, 1.0, 1.0 }, Opacity = 0.65, --ScaleFactor = 10.0, - LabelFile = speck .. "groups.label", Unit = "Mpc", - TextColor = { 0.1, 0.6, 0.2 }, - TextSize = 21.5, - TextMinMaxSize = { 8, 20 }, DrawLabels = true, TransformationMatrix = { -0.7357425748, 0.67726129641, 0.0, 0.0, @@ -39,11 +42,11 @@ local object = { asset.onInitialize(function() openspace.addSceneGraphNode(object) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(object) end) - + asset.export(object) diff --git a/data/assets/scene/digitaluniverse/h2regions.asset b/data/assets/scene/digitaluniverse/h2regions.asset index 480d0aaa3b..db4b036bca 100644 --- a/data/assets/scene/digitaluniverse/h2regions.asset +++ b/data/assets/scene/digitaluniverse/h2regions.asset @@ -17,17 +17,20 @@ local object = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = speck .. "h2.label", + Color = { 0.5, 0.5, 0.5 }, + Size = 16.24, + MinMaxSize = { 4, 20 }, + Unit = "pc" + }, Color = { 0.0, 0.5, 1.0 }, Opacity = 0.70, File = speck .. "h2.speck", Texture = textures .. "point4.png", PolygonSides = 6, - LabelFile = speck .. "h2.label", Unit = "pc", - TextColor = { 0.5, 0.5, 0.5 }, ScaleFactor = 420, - TextSize = 16.24, - TextMinMaxSize = { 4, 20 }, BillboardMinMaxSize = { 0.0, 300.0 }, EnablePixelSizeControl = false }, @@ -44,18 +47,18 @@ local object = { Because of this, they are great tracers of the spiral arms of the Galaxy, and were instrumental in our understanding of the Galaxy's overall structure (Description from URL)

Data Reference: The WISE catalog of Galactic - HII Regions (Anderson+, 2014)]], + HII Regions (Anderson+, 2014)]] } } asset.onInitialize(function() openspace.addSceneGraphNode(object) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(object) end) - + asset.export(object) diff --git a/data/assets/scene/digitaluniverse/localdwarfs.asset b/data/assets/scene/digitaluniverse/localdwarfs.asset index 9322874697..7d59c8275a 100644 --- a/data/assets/scene/digitaluniverse/localdwarfs.asset +++ b/data/assets/scene/digitaluniverse/localdwarfs.asset @@ -17,6 +17,13 @@ local object = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = speck .. "localgroup.label", + Color = { 0.3, 0.3, 1.0 }, + Size = 18.3, + MinMaxSize = { 7, 20 }, + Unit = "Mpc" + }, Color = { 0.5, 1.0, 0.2 }, ColorMap = speck .. "localgroup.cmap", ColorOption = { "association" }, @@ -24,12 +31,8 @@ local object = { File = speck .. "localgroup.speck", Texture = textures .. "point4.png", PolygonSides = 12, - LabelFile = speck .. "localgroup.label", Unit = "Mpc", - TextColor = { 0.3, 0.3, 1.0 }, ScaleFactor = 465, - TextSize = 18.3, - TextMinMaxSize = { 7, 20 }, BillboardMinMaxSize = { 0.0, 20.0 }, EnablePixelSizeControl = true }, @@ -46,18 +49,18 @@ local object = { bevy of dwarf galaxies-smaller, often irregular galaxies, that contain hundreds of millions to a few billion stars. (Description from URL)

Data Reference: Properties of dwarf galaxies in the Local Group - (McConnachie+, 2012)]], + (McConnachie+, 2012)]] } } asset.onInitialize(function() openspace.addSceneGraphNode(object) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(object) end) - + asset.export(object) diff --git a/data/assets/scene/digitaluniverse/milkyway_label.asset b/data/assets/scene/digitaluniverse/milkyway_label.asset index ae32435c2b..f6501a647f 100644 --- a/data/assets/scene/digitaluniverse/milkyway_label.asset +++ b/data/assets/scene/digitaluniverse/milkyway_label.asset @@ -10,15 +10,18 @@ local homeLabel = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = homespeck .. "home.label", + Color = { 0.8, 0.8, 0.8 }, + Size = 20.50, + MinMaxSize = { 16, 20 }, + Unit = "Mpc" + }, Color = { 1.0, 0.4, 0.2 }, Opacity = 0.99, ScaleFactor = 500.0, DrawLabels = true, - LabelFile = homespeck .. "home.label", Unit = "Mpc", - TextColor = { 0.8, 0.8, 0.8 }, - TextSize = 20.50, - TextMinMaxSize = { 16, 20 }, TransformationMatrix = { -0.7357425748, 0.67726129641, 0.0, 0.0, -0.074553778365, -0.080991471307, 0.9939225904, 0.0, @@ -32,18 +35,18 @@ local homeLabel = { GUI = { Name = "Home Label", Path = "/Universe/Galaxies", - Description = "Label for the Milky Way titled 'Home', sided for the galactic level", + Description = "Label for the Milky Way titled 'Home', sided for the galactic level" } } asset.onInitialize(function() openspace.addSceneGraphNode(homeLabel) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(homeLabel) end) - + asset.export(homeLabel) diff --git a/data/assets/scene/digitaluniverse/obassociations.asset b/data/assets/scene/digitaluniverse/obassociations.asset index 74e439360d..5d5afefd2a 100644 --- a/data/assets/scene/digitaluniverse/obassociations.asset +++ b/data/assets/scene/digitaluniverse/obassociations.asset @@ -17,6 +17,13 @@ local object = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = speck .. "ob.label", + Color = { 0.4, 0.5, 1.0 }, + Size = 16.24, + MinMaxSize = { 4, 25 }, + Unit = "pc" + }, Color = { 1.0, 1.0, 1.0 }, ColorMap = speck .. "ob.cmap", ColorOption = { "arm" }, @@ -27,11 +34,7 @@ local object = { Unit = "pc", Texture = textures .. "point4.png", PolygonSides = 7, - LabelFile = speck .. "ob.label", - TextColor = { 0.4, 0.5, 1.0 }, ScaleFactor = 390.0, - TextSize = 16.24, - TextMinMaxSize = { 4, 25 }, BillboardMinMaxSize = { 0.0, 450.0 }, EnablePixelSizeControl = true }, @@ -48,18 +51,18 @@ local object = { coded by their spiral arm membership. Blue associations trace the Sagittarius Arm. Purple associations are in the local Orion Spur. Orange associations are in the Perseus Arm (Description from URL)

Data Reference: New List of - OB Associations (Melnik+)]], + OB Associations (Melnik+)]] } } asset.onInitialize(function() openspace.addSceneGraphNode(object) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(object) end) - + asset.export(object) diff --git a/data/assets/scene/digitaluniverse/openclusters.asset b/data/assets/scene/digitaluniverse/openclusters.asset index bd025ed7a5..06dfbf3219 100644 --- a/data/assets/scene/digitaluniverse/openclusters.asset +++ b/data/assets/scene/digitaluniverse/openclusters.asset @@ -17,17 +17,20 @@ local object = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = speck .. "oc.label", + Color = { 0.05, 0.4, 0.2 }, + Size = 15.5, + MinMaxSize = { 4, 30 }, + Unit = "pc" + }, Color = { 0.1, 0.8, 0.4 }, Opacity = 0.5, File = speck .. "oc.speck", Unit = "pc", Texture = textures .. "point4.png", PolygonSides = 12, - TextColor = { 0.05, 0.4, 0.2 }, - LabelFile = speck .. "oc.label", ScaleFactor = 405.75, - TextSize = 15.5, - TextMinMaxSize = { 4, 30 }, BillboardMinMaxSize = { 0.0, 604.0 }, EnablePixelSizeControl = true }, @@ -48,18 +51,18 @@ local object = { as Galactic clusters, but this term fell out of favor once astronomers began to understand that the Galaxy includes objects beyond the Milky Way's disk.

Data Reference: Optically - visible open clusters and Candidates (Dias+ 2002-2015)]], + visible open clusters and Candidates (Dias+ 2002-2015)]] } } asset.onInitialize(function() openspace.addSceneGraphNode(object) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(object) end) - + asset.export(object) diff --git a/data/assets/scene/digitaluniverse/planetarynebulae.asset b/data/assets/scene/digitaluniverse/planetarynebulae.asset index 937a33043f..4670c4a6b1 100644 --- a/data/assets/scene/digitaluniverse/planetarynebulae.asset +++ b/data/assets/scene/digitaluniverse/planetarynebulae.asset @@ -17,17 +17,20 @@ local object = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = speck .. "pn.label", + Color = { 0.25, 0.25, 0.65 }, + Size = 16.24, + MinMaxSize = { 4, 25 }, + Unit = "pc" + }, Color = { 0.4, 0.4, 0.9 }, Opacity = 0.65, File = speck .. "pn.speck", Texture = textures .. "point4.png", PolygonSides = 3, - LabelFile = speck .. "pn.label", Unit = "pc", - TextColor = { 0.25, 0.25, 0.65 }, ScaleFactor = 425.0, - TextSize = 16.24, - TextMinMaxSize = { 4, 25 }, BillboardMinMaxSize = { 0.0, 500.0 }, EnablePixelSizeControl = true }, @@ -41,18 +44,18 @@ local object = { way are they related to planets, rather, they are products of dying stars. (Description from URL)

Data Reference: Planetary Nebulae distances in Gaia DR2 (Kimeswenger+, 2018), Strasbourg-ESO Catalog of Planetary Nebulae - (Acker+ 1992)]], + (Acker+ 1992)]] } } asset.onInitialize(function() openspace.addSceneGraphNode(object) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(object) end) - + asset.export(object) diff --git a/data/assets/scene/digitaluniverse/pulsars.asset b/data/assets/scene/digitaluniverse/pulsars.asset index 91f08b8a74..1bc18492ef 100644 --- a/data/assets/scene/digitaluniverse/pulsars.asset +++ b/data/assets/scene/digitaluniverse/pulsars.asset @@ -17,17 +17,20 @@ local object = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = speck .. "pulsar.label", + Color = { 0.7, 0.2, 0.2 }, + Size = 15.77, + MinMaxSize = { 4, 20 }, + Unit = "pc" + }, Color = { 0.7, 0.0, 0.0 }, Opacity = 1.0, File = speck .. "pulsar.speck", Texture = textures .. "point4.png", PolygonSides = 4, - LabelFile = speck .. "pulsar.label", Unit = "pc", - TextColor = { 0.7, 0.2, 0.2 }, ScaleFactor = 424, - TextSize = 15.77, - TextMinMaxSize = { 4, 20 }, BillboardMinMaxSize = { 0.0, 500.0 }, EnablePixelSizeControl = false }, @@ -45,18 +48,18 @@ local object = { cannot be packed any tighter. At this point, the star has a radius of about 10-15 kilometers. The density of this material is so high that a teaspoonful would weigh about 100 million tons on Earth. (Description from URL)

- Data Reference: ATNF Pulsar Catalogue, (Manchester+, 2005)]], + Data Reference: ATNF Pulsar Catalogue, (Manchester+, 2005)]] } } asset.onInitialize(function() openspace.addSceneGraphNode(object) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(object) end) - + asset.export(object) diff --git a/data/assets/scene/digitaluniverse/starlabels.asset b/data/assets/scene/digitaluniverse/starlabels.asset index b4efcfe6ea..8543b5a6d6 100644 --- a/data/assets/scene/digitaluniverse/starlabels.asset +++ b/data/assets/scene/digitaluniverse/starlabels.asset @@ -10,30 +10,33 @@ local object = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = speck .. "stars.label", + Color = { 0.4, 0.4, 0.4 }, + Size = 14.7, + MinMaxSize = { 6, 50 }, + Unit = "pc" + }, Color = { 1.0, 1.0, 1.0 }, Opacity = 0.65, - LabelFile = speck .. "stars.label", Unit = "pc", - TextColor = { 0.4, 0.4, 0.4 }, - DrawLabels = true, - TextSize = 14.7, - TextMinMaxSize = { 6, 50 } + DrawLabels = true }, GUI = { Name = "Stars Labels", Path = "/Milky Way/Stars", - Description = "Labels for stars in the Milky Way. See 'Stars' for more info", + Description = "Labels for stars in the Milky Way. See 'Stars' for more info" } } asset.onInitialize(function() openspace.addSceneGraphNode(object) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(object) end) - + asset.export(object) diff --git a/data/assets/scene/digitaluniverse/superclusters.asset b/data/assets/scene/digitaluniverse/superclusters.asset index cd7a4a649e..375128e9d1 100644 --- a/data/assets/scene/digitaluniverse/superclusters.asset +++ b/data/assets/scene/digitaluniverse/superclusters.asset @@ -17,19 +17,22 @@ local object = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = speck .. "superclust.label", + Color = { 0.9, 0.9, 0.9 }, + Size = 22.44, + MinMaxSize = { 8, 20 }, + Unit = "Mpc" + }, DrawElements = false, Color = { 1.0, 1.0, 1.0 }, Opacity = 0.65, File = speck .. "superclust.speck", Texture = textures .. "point3A.png", - LabelFile = speck .. "superclust.label", Unit = "Mpc", - TextColor = { 0.9, 0.9, 0.9 }, ScaleFactor = 531.0, - TextSize = 22.44, - TextMinMaxSize = { 8, 20 }, DrawLabels = true, - --BillboardMinMaxSize = { 0.0, 7.2 }, + -- BillboardMinMaxSize = { 0.0, 7.2 }, EnablePixelSizeControl = true }, GUI = { @@ -47,11 +50,11 @@ local object = { asset.onInitialize(function() openspace.addSceneGraphNode(object) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(object) end) - + asset.export(object) diff --git a/data/assets/scene/digitaluniverse/supernovaremnants.asset b/data/assets/scene/digitaluniverse/supernovaremnants.asset index 0f3fefa885..6d331cccb5 100644 --- a/data/assets/scene/digitaluniverse/supernovaremnants.asset +++ b/data/assets/scene/digitaluniverse/supernovaremnants.asset @@ -17,17 +17,20 @@ local object = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = speck .. "snr.label", + Color = { 0.6, 0.46, 0.0 }, + Size = 16.44, + MinMaxSize = { 4, 100 }, + Unit = "pc" + }, Color = { 1.0, 0.5, 0.0 }, Opacity = 0.32, File = speck .. "snr.speck", Texture = textures .. "point4.png", PolygonSides = 7, - LabelFile = speck .. "snr.label", Unit = "pc", - TextColor = { 0.6, 0.46, 0.0 }, ScaleFactor = 424, - TextSize = 16.44, - TextMinMaxSize = { 4, 100 }, --CorrectionSizeEndDistance = 17.5, --CorrectionSizeFactor = 13.96, BillboardMinMaxSize = { 0.0, 500.0 }, @@ -40,18 +43,18 @@ local object = { remnant is the ejected gas that results from a supernova. It glows for a cosmically short period of time before mixing with the interstellar medium. (Description from URL)

Data Reference: The First Fermi LAT SNR - Catalog (Acero+, 2016)]], + Catalog (Acero+, 2016)]] } } asset.onInitialize(function() openspace.addSceneGraphNode(object) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(object) end) - + asset.export(object) diff --git a/data/assets/scene/digitaluniverse/tully.asset b/data/assets/scene/digitaluniverse/tully.asset index cb488b17ff..96521ba5f2 100644 --- a/data/assets/scene/digitaluniverse/tully.asset +++ b/data/assets/scene/digitaluniverse/tully.asset @@ -17,6 +17,13 @@ local tullyPoints = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = true, + Labels = { + File = speck .. "tully.label", + Color = { 0.7, 0.7, 0.7 }, + Size = 19.36, + MinMaxSize = { 8, 20 }, + Unit = "Mpc" + }, Color = { 1.0, 0.4, 0.2 }, Opacity = 0.99, ScaleFactor = 504.0, @@ -27,12 +34,8 @@ local tullyPoints = { --ColorOption = { "proximity" }, ColorOption = { "prox5Mpc" }, ColorRange = { { 1.0, 30.0 } }, - LabelFile = speck .. "tully.label", DrawLabels = false, Unit = "Mpc", - TextColor = { 0.7, 0.7, 0.7 }, - TextSize = 19.36, - TextMinMaxSize = { 8, 20 }, TransformationMatrix = { -0.7357425748, 0.67726129641, 0.0, 0.0, -0.074553778365, -0.080991471307, 0.9939225904, 0.0, @@ -110,12 +113,12 @@ asset.onInitialize(function() openspace.addSceneGraphNode(tullyPoints) openspace.addSceneGraphNode(tullyImages) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(tullyImages) openspace.removeSceneGraphNode(tullyPoints) end) - + asset.export(tullyPoints) asset.export(tullyImages) diff --git a/data/assets/scene/digitaluniverse/voids.asset b/data/assets/scene/digitaluniverse/voids.asset index 02c0b964c9..f380b05e32 100644 --- a/data/assets/scene/digitaluniverse/voids.asset +++ b/data/assets/scene/digitaluniverse/voids.asset @@ -10,15 +10,18 @@ local object = { Renderable = { Type = "RenderableBillboardsCloud", Enabled = false, + Labels = { + File = speck .. "voids.label", + Color = { 0.296, 0.629, 1.0 }, + Size = 20.9, + MinMaxSize = { 8, 20 }, + Unit = "Mpc" + }, DrawElements = false, DrawLabels = true, Color = { 1.0, 1.0, 1.0 }, Opacity = 0.65, - LabelFile = speck .. "voids.label", - Unit = "Mpc", - TextColor = { 0.296, 0.629, 1.0 }, - TextSize = 20.9, - TextMinMaxSize = { 8, 20 } + Unit = "Mpc" }, GUI = { Name = "Voids", @@ -39,11 +42,11 @@ local object = { asset.onInitialize(function() openspace.addSceneGraphNode(object) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(object) end) - + asset.export(object) diff --git a/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto.asset b/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto.asset index a40164704d..da1200f3bf 100644 --- a/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto.asset +++ b/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto.asset @@ -54,7 +54,7 @@ local PlutoLabel = { Parent = Pluto.Identifier, Renderable = { Enabled = false, - Type = "RenderableLabels", + Type = "RenderableLabel", Text = "Pluto", FontSize = 70.0, Size = 9.05, diff --git a/data/assets/scene/solarsystem/missions/jwst/jwst.asset b/data/assets/scene/solarsystem/missions/jwst/jwst.asset index 7e15b87ad1..cefeb1e481 100644 --- a/data/assets/scene/solarsystem/missions/jwst/jwst.asset +++ b/data/assets/scene/solarsystem/missions/jwst/jwst.asset @@ -131,7 +131,7 @@ local JWSTLabel = { End = endTime }, Renderable = { - Type = "RenderableLabels", + Type = "RenderableLabel", Text = "JWST", FontSize = 50, Size = 6.5, diff --git a/data/assets/scene/solarsystem/missions/jwst/timelapse.asset b/data/assets/scene/solarsystem/missions/jwst/timelapse.asset index 9efb08325c..8ebc3c0956 100644 --- a/data/assets/scene/solarsystem/missions/jwst/timelapse.asset +++ b/data/assets/scene/solarsystem/missions/jwst/timelapse.asset @@ -50,13 +50,15 @@ local function createForwardTimelapse() -- array complete openspace.scriptScheduler.loadScheduledScript("]] .. advance(launchTime, 0, 0, 30, 42) .. [[", - "openspace.time.interpolateDeltaTime(7200)" .. - "openspace.setPropertyValueSingle(\"Dashboard.JWSTStateText.Text\", \"Time speed: 2 hours/second\")" + "openspace.time.interpolateDeltaTime(2400)" .. + "openspace.setPropertyValueSingle(\"Dashboard.JWSTStateText.Text\", \"Time speed: 40 minutes/second\")" ) -- Make night layer more visible, at around 14:00 openspace.scriptScheduler.loadScheduledScript("]] .. advance(detachTime, 0, 1, 10, 0) .. [[", + "openspace.time.interpolateDeltaTime(7200)" .. + "openspace.setPropertyValueSingle(\"Dashboard.JWSTStateText.Text\", \"Time speed: 2 hours/second\")" .. "openspace.setPropertyValueSingle(\"Scene.Earth.Renderable.Layers.NightLayers.Earth_at_Night_2012.Settings.Gamma\", 0.7)" .. "openspace.setPropertyValueSingle(\"Scene.EarthAtmosphere.Renderable.Enabled\", false)" ) @@ -280,8 +282,10 @@ local function createBackwardTimelapse() -- Reset night layer, at around 14:00 openspace.scriptScheduler.loadScheduledScript("]] .. - advance(detachTime, 0, 1, 10, 0) .. [[", + advance(detachTime, 0, 1 + 1, 10, 0) .. [[", -- 1h pre delay so time to interpolate "", + "openspace.time.interpolateDeltaTime(-2400)" .. + "openspace.setPropertyValueSingle(\"Dashboard.JWSTStateText.Text\", \"Time speed: -40 minutes/second\")" .. "openspace.setPropertyValueSingle(\"Scene.Earth.Renderable.Layers.NightLayers.Earth_at_Night_2012.Settings.Gamma\", 1.0)" .. "openspace.setPropertyValueSingle(\"Scene.EarthAtmosphere.Renderable.Enabled\", true)" ) @@ -520,6 +524,8 @@ local function createActions() openspace.scriptScheduler.clear(0) openspace.time.setDeltaTime(1) openspace.setPropertyValueSingle("Dashboard.JWSTStateText.Text", "") + openspace.setPropertyValueSingle("Scene.Earth.Renderable.Layers.NightLayers.Earth_at_Night_2012.Settings.Gamma", 1.0) + openspace.setPropertyValueSingle("Scene.EarthAtmosphere.Renderable.Enabled", true) openspace.time.setTime("]] .. detachTime .. [[") ]] .. createForwardTimelapse() .. [[ openspace.time.setDeltaTime(1) diff --git a/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset b/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset index 9f8d42dc16..37c8900d1c 100644 --- a/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset +++ b/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset @@ -16,7 +16,7 @@ local toggle_trail = { local launchTrail = "JWSTTrailLaunch" local cruiseTrail = "JWSTTrailCruise" - local orbitTrail = "JWSTTrailOrbit" + local coRevOrbitTrail = "JWSTTrailCoRevOrbit" local visibility if is_declared("args") then @@ -31,7 +31,7 @@ local toggle_trail = { visibility = not ( openspace.getPropertyValue("Scene." .. launchTrail .. ".Renderable.Enabled") or openspace.getPropertyValue("Scene." .. cruiseTrail .. ".Renderable.Enabled") or - openspace.getPropertyValue("Scene." .. orbitTrail .. ".Renderable.Enabled") + openspace.getPropertyValue("Scene." .. coRevOrbitTrail .. ".Renderable.Enabled") ) end @@ -44,7 +44,7 @@ local toggle_trail = { visibility ) openspace.setPropertyValueSingle( - "Scene." .. orbitTrail .. ".Renderable.Enabled", + "Scene." .. coRevOrbitTrail .. ".Renderable.Enabled", visibility ) ]], diff --git a/data/assets/scene/solarsystem/missions/jwst/trail.asset b/data/assets/scene/solarsystem/missions/jwst/trail.asset index 15fb544305..ab74967e98 100644 --- a/data/assets/scene/solarsystem/missions/jwst/trail.asset +++ b/data/assets/scene/solarsystem/missions/jwst/trail.asset @@ -28,12 +28,12 @@ local JWSTTrailLaunch = { Renderable = { Type = "RenderableTrailTrajectory", Translation = { - Type = 'SpiceTranslation', - Target = 170, -- JWST - Observer = 'EARTH', - Frame = 'IAU_EARTH', - Kernels = { kernels .. "webb.bsp" } - }, + Type = 'SpiceTranslation', + Target = 170, -- JWST + Observer = 'EARTH', + Frame = 'IAU_EARTH', + Kernels = { kernels .. "webb.bsp" } + }, Color = { 0.9, 0.9, 0.0 }, StartTime = launchTime, EndTime = detachTime, @@ -61,12 +61,12 @@ local JWSTTrailCruise = { Renderable = { Type = "RenderableTrailTrajectory", Translation = { - Type = 'SpiceTranslation', - Target = 170, -- JWST - Observer = 'EARTH', - Frame = 'GALACTIC', - Kernels = { kernels .. "webb.bsp" } - }, + Type = 'SpiceTranslation', + Target = 170, -- JWST + Observer = 'EARTH', + Frame = 'GALACTIC', + Kernels = { kernels .. "webb.bsp" } + }, Color = { 0.9, 0.9, 0.0 }, StartTime = detachTime, EndTime = L2orbitInsertionTime, @@ -83,9 +83,10 @@ local JWSTTrailCruise = { -- Trail of JWST relative to L2 after first month to reach L2 -- Gives a better trail history of the orbit around L2 than if it was relative to Earth +-- This does NOT co-rotate with L2 and gives a saddle look of the trail local JWSTTrailOrbit = { Identifier = "JWSTTrailOrbit", - Parent = transforms.L2.Identifier, + Parent = transforms.L2Position.Identifier, TimeFrame = { Type = "TimeFrameInterval", Start = L2orbitInsertionTime, @@ -94,13 +95,13 @@ local JWSTTrailOrbit = { Renderable = { Type = "RenderableTrailOrbit", Translation = { - Type = 'SpiceTranslation', - Target = 170, -- JWST - Observer = 392, -- L2 - Frame = 'GALACTIC', - Kernels = { kernels .. "webb.bsp" } - }, - Color = { 0.9, 0.9, 0.0 }, + Type = 'SpiceTranslation', + Target = 170, -- JWST + Observer = 392, -- L2 + Frame = 'GALACTIC', + Kernels = { kernels .. "webb.bsp" } + }, + Color = { 0.863, 0.0, 0.902 }, Period = 182.621099, -- About 6 months Resolution = 183 -- About a sample rate of once per day }, @@ -113,6 +114,38 @@ local JWSTTrailOrbit = { } } +-- Trail of JWST in orbit around L2 that co-revolves with L2 around the Sun +-- This gives the trail a look of a wheel going along L2 around the Sun +local JWSTTrailCoRevOrbit = { + Identifier = "JWSTTrailCoRevOrbit", + Parent = transforms.L2CoRevFrame.Identifier, + TimeFrame = { + Type = "TimeFrameInterval", + Start = L2orbitInsertionTime, + End = endTime + }, + Renderable = { + Type = "RenderableTrailOrbit", + Translation = { + Type = 'SpiceTranslation', + Target = 170, -- JWST + Observer = 392, -- L2 + Frame = 'L2_COREV', + Kernels = { kernels .. "webb.bsp" } + }, + Color = { 1.0, 0.663, 0.157 }, + Period = 365.242198, -- About a year, 2 orbits. 1 orbit would be 182.621099 (6 months) + Resolution = 365 -- About a sample rate of once per day + }, + GUI = { + Name = "JWST L2 Co-revolving Orbit Trail", + Path = "/Solar System/Missions/JWST/Trails", + Description = [[ + James Webb Space Telescope Orbit Trail that Co-revolves with L2. + ]], + } +} + local JWSTSunTrail = { Identifier = "JWSTSunTrail", Parent = sunTransforms.SolarSystemBarycenter.Identifier, @@ -124,12 +157,12 @@ local JWSTSunTrail = { Renderable = { Type = "RenderableTrailOrbit", Translation = { - Type = 'SpiceTranslation', - Target = 170, -- JWST - Observer = 'SSB', - Frame = 'GALACTIC', - Kernels = { kernels .. "webb.bsp" } - }, + Type = 'SpiceTranslation', + Target = 170, -- JWST + Observer = 'SSB', + Frame = 'GALACTIC', + Kernels = { kernels .. "webb.bsp" } + }, Color = { 0.0, 0.9, 0.9 }, Period = 365.242, Resolution = 365 -- About a sample rate of once per day @@ -147,11 +180,13 @@ asset.onInitialize(function() openspace.addSceneGraphNode(JWSTTrailLaunch) openspace.addSceneGraphNode(JWSTTrailCruise) openspace.addSceneGraphNode(JWSTTrailOrbit) + openspace.addSceneGraphNode(JWSTTrailCoRevOrbit) openspace.addSceneGraphNode(JWSTSunTrail) end) asset.onDeinitialize(function() openspace.removeSceneGraphNode(JWSTSunTrail) + openspace.removeSceneGraphNode(JWSTTrailCoRevOrbit) openspace.removeSceneGraphNode(JWSTTrailOrbit) openspace.removeSceneGraphNode(JWSTTrailCruise) openspace.removeSceneGraphNode(JWSTTrailLaunch) @@ -160,6 +195,7 @@ end) asset.export(JWSTTrailLaunch) asset.export(JWSTTrailCruise) asset.export(JWSTTrailOrbit) +asset.export(JWSTTrailCoRevOrbit) asset.export(JWSTSunTrail) diff --git a/data/assets/scene/solarsystem/planets/earth/earth.asset b/data/assets/scene/solarsystem/planets/earth/earth.asset index dfa2afafc9..bf366bd6ef 100644 --- a/data/assets/scene/solarsystem/planets/earth/earth.asset +++ b/data/assets/scene/solarsystem/planets/earth/earth.asset @@ -53,7 +53,7 @@ local EarthLabel = { Parent = Earth.Identifier, Renderable = { Enabled = false, - Type = "RenderableLabels", + Type = "RenderableLabel", Text = "Earth", FontSize = 70.0, Size = 8.77, diff --git a/data/assets/scene/solarsystem/planets/earth/lagrange_points/L1.asset b/data/assets/scene/solarsystem/planets/earth/lagrange_points/L1.asset index 290b9518de..82a0506fe3 100644 --- a/data/assets/scene/solarsystem/planets/earth/lagrange_points/L1.asset +++ b/data/assets/scene/solarsystem/planets/earth/lagrange_points/L1.asset @@ -56,7 +56,7 @@ local L1Label = { Identifier = "L1Label", Parent = L1Position.Identifier, Renderable = { - Type = "RenderableLabels", + Type = "RenderableLabel", Text = "L1", FontSize = 50, Size = 7.5, diff --git a/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset b/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset index 62a317284a..9f97bb8603 100644 --- a/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset +++ b/data/assets/scene/solarsystem/planets/earth/lagrange_points/L2.asset @@ -12,7 +12,7 @@ local kernels = asset.syncedResource({ Name = "Lagrange Kernels", Type = "HttpSynchronization", Identifier = "earth_lagrange_kernels", - Version = 1 + Version = 2 }) local L2Position = { @@ -34,6 +34,30 @@ local L2Position = { } } +-- This ref. frame co-revolves with L2 and is needed for a more intuitive trail of JWST in +-- relation to L2 +local L2CoRevFrame = { + Identifier = "L2CoRevFrame", + Parent = L2Position.Identifier, + Transform = { + Rotation = { + Type = "SpiceRotation", + SourceFrame = "L2_COREV", + DestinationFrame = 'GALACTIC', + Kernels = { + kernels .. "L2_de431.bsp", + kernels .. "L2_corev.tf" + } + } + }, + Tag = { "lagrange_points_earth", "lagrange_points_earth_l2" }, + GUI = { + Name = "L2 Co-revolving Reference Frame", + Path = "/Solar System/Planets/Earth/Lagrange points", + Hidden = true + } +} + local L2Small = { Identifier = "L2Small", Parent = L2Position.Identifier, @@ -74,7 +98,7 @@ local L2SmallLabel = { Identifier = "L2SmallLabel", Parent = L2Position.Identifier, Renderable = { - Type = "RenderableLabels", + Type = "RenderableLabel", Text = "L2", FontSize = 50.0, Size = 6.0, @@ -95,7 +119,7 @@ local L2Label = { Identifier = "L2Label", Parent = L2Position.Identifier, Renderable = { - Type = "RenderableLabels", + Type = "RenderableLabel", Text = "L2", FontSize = 50, Size = 7.5, @@ -131,6 +155,7 @@ local L2SunLine = { local nodes = { L2Position, + L2CoRevFrame, L2Small, L2, L2SunLine, diff --git a/data/assets/scene/solarsystem/planets/earth/lagrange_points/L4.asset b/data/assets/scene/solarsystem/planets/earth/lagrange_points/L4.asset index f1badc1ca5..4acaf26ebf 100644 --- a/data/assets/scene/solarsystem/planets/earth/lagrange_points/L4.asset +++ b/data/assets/scene/solarsystem/planets/earth/lagrange_points/L4.asset @@ -56,7 +56,7 @@ local L4Label = { Identifier = "L4Label", Parent = L4Position.Identifier, Renderable = { - Type = "RenderableLabels", + Type = "RenderableLabel", Text = "L4", FontSize = 50, Size = 8.5, diff --git a/data/assets/scene/solarsystem/planets/earth/lagrange_points/L5.asset b/data/assets/scene/solarsystem/planets/earth/lagrange_points/L5.asset index ef8486dec2..cd66f1bc15 100644 --- a/data/assets/scene/solarsystem/planets/earth/lagrange_points/L5.asset +++ b/data/assets/scene/solarsystem/planets/earth/lagrange_points/L5.asset @@ -56,7 +56,7 @@ local L5Label = { Identifier = "L5Label", Parent = L5Position.Identifier, Renderable = { - Type = "RenderableLabels", + Type = "RenderableLabel", Text = "L5", FontSize = 50, Size = 8.5, diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset b/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset index 1e1b41dea0..65bd7b1e0e 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset @@ -99,7 +99,7 @@ local IssLabel = { Parent = iss.Identifier, Renderable = { Enabled = false, - Type = "RenderableLabels", + Type = "RenderableLabel", Text = "ISS", FontSize = 70.0, Size = 3.4, diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/weather/aqua.asset b/data/assets/scene/solarsystem/planets/earth/satellites/weather/aqua.asset index ef88079ea2..e237bf578a 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/weather/aqua.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/weather/aqua.asset @@ -63,7 +63,7 @@ local AquaLabel = { Parent = Aqua.Identifier, Renderable = { Enabled = false, - Type = "RenderableLabels", + Type = "RenderableLabel", Text = "Aqua", FontSize = 70.0, Size = 4.0, diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/weather/snpp.asset b/data/assets/scene/solarsystem/planets/earth/satellites/weather/snpp.asset index 6d53c08c0f..a1f28bfd33 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/weather/snpp.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/weather/snpp.asset @@ -61,7 +61,7 @@ local SNPPLabel = { Parent = SNPP.Identifier, Renderable = { Enabled = false, - Type = "RenderableLabels", + Type = "RenderableLabel", Text = "SNPP", FontSize = 70.0, Size = 4.0, diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/weather/terra.asset b/data/assets/scene/solarsystem/planets/earth/satellites/weather/terra.asset index 4c256885b8..6e998f1116 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/weather/terra.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/weather/terra.asset @@ -64,7 +64,7 @@ local TerraLabel = { Parent = Terra.Identifier, Renderable = { Enabled = false, - Type = "RenderableLabels", + Type = "RenderableLabel", Text = "Terra", FontSize = 70.0, Size = 4.0, diff --git a/data/assets/scene/solarsystem/planets/jupiter/jupiter.asset b/data/assets/scene/solarsystem/planets/jupiter/jupiter.asset index ad55dbcd35..4ed9f02336 100644 --- a/data/assets/scene/solarsystem/planets/jupiter/jupiter.asset +++ b/data/assets/scene/solarsystem/planets/jupiter/jupiter.asset @@ -45,7 +45,7 @@ local JupiterLabel = { Parent = Jupiter.Identifier, Renderable = { Enabled = false, - Type = "RenderableLabels", + Type = "RenderableLabel", Text = "Jupiter", FontSize = 70.0, Size = 8.77, diff --git a/data/assets/scene/solarsystem/planets/mars/mars.asset b/data/assets/scene/solarsystem/planets/mars/mars.asset index 1734cb053a..f7c65dc58e 100644 --- a/data/assets/scene/solarsystem/planets/mars/mars.asset +++ b/data/assets/scene/solarsystem/planets/mars/mars.asset @@ -58,7 +58,7 @@ local MarsLabel = { Parent = Mars.Identifier, Renderable = { Enabled = false, - Type = "RenderableLabels", + Type = "RenderableLabel", Text = "Mars", FontSize = 70.0, Size = 8.66, diff --git a/data/assets/scene/solarsystem/planets/mercury/mercury.asset b/data/assets/scene/solarsystem/planets/mercury/mercury.asset index e8e0beee5f..9481feb37b 100644 --- a/data/assets/scene/solarsystem/planets/mercury/mercury.asset +++ b/data/assets/scene/solarsystem/planets/mercury/mercury.asset @@ -56,7 +56,7 @@ local MercuryLabel = { Parent = Mercury.Identifier, Renderable = { Enabled = false, - Type = "RenderableLabels", + Type = "RenderableLabel", Text = "Mercury", FontSize = 70.0, Size = 8.46, diff --git a/data/assets/scene/solarsystem/planets/neptune/neptune.asset b/data/assets/scene/solarsystem/planets/neptune/neptune.asset index 92360d16f6..7e5a991e51 100644 --- a/data/assets/scene/solarsystem/planets/neptune/neptune.asset +++ b/data/assets/scene/solarsystem/planets/neptune/neptune.asset @@ -36,7 +36,7 @@ local NeptuneLabel = { Parent = Neptune.Identifier, Renderable = { Enabled = false, - Type = "RenderableLabels", + Type = "RenderableLabel", Text = "Neptune", FontSize = 70.0, Size = 8.96, diff --git a/data/assets/scene/solarsystem/planets/saturn/saturn.asset b/data/assets/scene/solarsystem/planets/saturn/saturn.asset index e5b13c0b6a..7118460ce9 100644 --- a/data/assets/scene/solarsystem/planets/saturn/saturn.asset +++ b/data/assets/scene/solarsystem/planets/saturn/saturn.asset @@ -64,7 +64,7 @@ local SaturnLabel = { Parent = Saturn.Identifier, Renderable = { Enabled = false, - Type = "RenderableLabels", + Type = "RenderableLabel", Text = "Saturn", FontSize = 70.0, Size = 8.85, diff --git a/data/assets/scene/solarsystem/planets/uranus/uranus.asset b/data/assets/scene/solarsystem/planets/uranus/uranus.asset index 3b8581b479..f1d836bc62 100644 --- a/data/assets/scene/solarsystem/planets/uranus/uranus.asset +++ b/data/assets/scene/solarsystem/planets/uranus/uranus.asset @@ -36,7 +36,7 @@ local UranusLabel = { Parent = Uranus.Identifier, Renderable = { Enabled = false, - Type = "RenderableLabels", + Type = "RenderableLabel", Text = "Uranus", FontSize = 70.0, Size = 8.86, diff --git a/data/assets/scene/solarsystem/planets/venus/venus.asset b/data/assets/scene/solarsystem/planets/venus/venus.asset index b027f82d51..bc4f227572 100644 --- a/data/assets/scene/solarsystem/planets/venus/venus.asset +++ b/data/assets/scene/solarsystem/planets/venus/venus.asset @@ -61,7 +61,7 @@ local VenusLabel = { Parent = Venus.Identifier, Renderable = { Enabled = false, - Type = "RenderableLabels", + Type = "RenderableLabel", Text = "Venus", FontSize = 70.0, Size = 8.54, diff --git a/data/assets/scene/solarsystem/sun/sun.asset b/data/assets/scene/solarsystem/sun/sun.asset index 2fe5742c43..a94e568b1b 100644 --- a/data/assets/scene/solarsystem/sun/sun.asset +++ b/data/assets/scene/solarsystem/sun/sun.asset @@ -25,7 +25,7 @@ local SunLabel = { Parent = Sun.Identifier, Renderable = { Enabled = false, - Type = "RenderableLabels", + Type = "RenderableLabel", Text = "Sun", FontSize = 70.0, Size = 14.17, @@ -48,7 +48,7 @@ local SunLabel = { local LightSource = { Type = "SceneGraphLightSource", Identifier = "Sun", - Node = transforms.SolarSystemBarycenter.Identifier, + Node = Sun.Identifier, Intensity = 1.0 } @@ -56,12 +56,12 @@ asset.onInitialize(function() openspace.addSceneGraphNode(Sun) openspace.addSceneGraphNode(SunLabel) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(SunLabel) openspace.removeSceneGraphNode(Sun) end) - + asset.export(Sun) asset.export(SunLabel) asset.export("LightSource", LightSource) diff --git a/data/assets/util/webgui.asset b/data/assets/util/webgui.asset index 440e8f6e93..046e87c494 100644 --- a/data/assets/util/webgui.asset +++ b/data/assets/util/webgui.asset @@ -3,7 +3,7 @@ asset.require("./static_server") local guiCustomization = asset.require("customization/gui") -- Select which commit hashes to use for the frontend and backend -local frontendHash = "aeffda7eef46f4eaddfebcb41389672d2c473b35" +local frontendHash = "9f0298993d738f487c93c559084593945b5e093e" local dataProvider = "data.openspaceproject.com/files/webgui" local frontend = asset.syncedResource({ diff --git a/data/profiles/jwst.profile b/data/profiles/jwst.profile index 38fb91dbd1..ecf38ad0f5 100644 --- a/data/profiles/jwst.profile +++ b/data/profiles/jwst.profile @@ -73,12 +73,12 @@ "script": "local list = openspace.getProperty('{planetTrail_solarSystem}.Renderable.Enabled'); for _,v in pairs(list) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)) end local moonlist = openspace.getProperty('{moonTrail_solarSystem}.Renderable.Enabled') for _,v in pairs(moonlist) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)) end openspace.setPropertyValueSingle('Scene.MoonTrail.Renderable.Enabled', true)" }, { - "documentation": "Toggle JWST launch, cruise and orbit trails, not the Sun trail", + "documentation": "Toggle JWST launch, cruise and L2 co-revolving orbit trails, not the Sun trail", "gui_path": "/JWST", "identifier": "profile.toggle.jwst_trails", "is_local": false, "name": "Toggle JWST trail", - "script": "local list = {'Scene.JWSTTrailLaunch.Renderable.Enabled', 'Scene.JWSTTrailCruise.Renderable.Enabled', 'Scene.JWSTTrailOrbit.Renderable.Enabled'}; for _,v in pairs(list) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)); end" + "script": "local list = {'Scene.JWSTTrailLaunch.Renderable.Enabled', 'Scene.JWSTTrailCruise.Renderable.Enabled', 'Scene.JWSTTrailCoRevOrbit.Renderable.Enabled'}; for _,v in pairs(list) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)); end" } ], "additional_scripts": [ @@ -294,6 +294,11 @@ "type": "setPropertyValueSingle", "value": "false" }, + { + "name": "Scene.JWSTTrailOrbit.Renderable.Enabled", + "type": "setPropertyValueSingle", + "value": "false" + }, { "name": "Scene.JWSTSunTrail.Renderable.Enabled", "type": "setPropertyValueSingle", diff --git a/data/tasks/sessRecConvertVersion.task b/data/tasks/sessRecConvertVersion.task new file mode 100644 index 0000000000..b854e5feac --- /dev/null +++ b/data/tasks/sessRecConvertVersion.task @@ -0,0 +1,6 @@ +return { + { + Type = "ConvertRecFileVersionTask", + InputFilePath = "../../user/recordings/input.osrec" + } +} diff --git a/ext/CMakeLists.txt b/ext/CMakeLists.txt index 079c95117b..3e17fac68d 100644 --- a/ext/CMakeLists.txt +++ b/ext/CMakeLists.txt @@ -62,13 +62,19 @@ end_dependency() # Curl begin_dependency("CURL") -add_library(external-curl INTERFACE) if (WIN32) - target_include_directories(external-curl INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/curl/include") - target_link_libraries(external-curl INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/curl/lib/libcurl.lib") + add_library(external-curl SHARED IMPORTED GLOBAL) + target_include_directories(external-curl INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/curl/include) + set_property(TARGET external-curl PROPERTY IMPORTED_IMPLIB ${CMAKE_CURRENT_SOURCE_DIR}/curl/lib/libcurl.lib) + set_property(TARGET external-curl PROPERTY IMPORTED_LOCATION + ${CMAKE_CURRENT_SOURCE_DIR}/curl/lib/libcurl.dll + ${CMAKE_CURRENT_SOURCE_DIR}/curl/lib/libeay32.dll + ${CMAKE_CURRENT_SOURCE_DIR}/curl/lib/ssleay32.dll + ) else () find_package(CURL) if (CURL_FOUND) + add_library(external-curl INTERFACE) target_include_directories(external-curl INTERFACE ${CURL_INCLUDE_DIRS}) target_link_libraries(external-curl INTERFACE ${CURL_LIBRARIES}) endif () diff --git a/ext/ghoul b/ext/ghoul index 1f420ed0f0..b676d66bc0 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 1f420ed0f03347ed3c8bb7550d58798f9a02cbc0 +Subproject commit b676d66bc028e26dbf2fa0a39c67e35667df13f9 diff --git a/ext/spice b/ext/spice index bb7eded3a4..5dba0f3269 160000 --- a/ext/spice +++ b/ext/spice @@ -1 +1 @@ -Subproject commit bb7eded3a4c45eff33cee41f4d24fffe5248d01a +Subproject commit 5dba0f32690dd49f29adbbf618a69e5709cdc405 diff --git a/include/openspace/interaction/sessionrecording.h b/include/openspace/interaction/sessionrecording.h index b1981a8e3a..b7bf00fb52 100644 --- a/include/openspace/interaction/sessionrecording.h +++ b/include/openspace/interaction/sessionrecording.h @@ -550,6 +550,16 @@ public: */ std::string convertFile(std::string filename, int depth = 0); + /** + * Converts file format of a session recording file to the current format version + * (will determine the file format conversion to convert from based on the file's + * header version number). Accepts a relative path (currently from task runner dir) + * rather than a path assumed to be relative to ${RECORDINGS}. + * + * \param filename name of the file to convert + */ + void convertFileRelativePath(std::string filenameRelative); + /** * Goes to legacy session recording inherited class, and calls its convertFile() * method, and then returns the resulting conversion filename. @@ -617,7 +627,6 @@ protected: bool handleRecordingFile(std::string filenameIn); static bool isPath(std::string& filename); void removeTrailingPathSlashes(std::string& filename); - void extractFilenameFromPath(std::string& filename); bool playbackCamera(); bool playbackTimeChange(); bool playbackScript(); diff --git a/modules/base/CMakeLists.txt b/modules/base/CMakeLists.txt index 35a1526a97..cb0f531ca0 100644 --- a/modules/base/CMakeLists.txt +++ b/modules/base/CMakeLists.txt @@ -44,7 +44,7 @@ set(HEADER_FILES rendering/grids/renderablesphericalgrid.h rendering/renderablecartesianaxes.h rendering/renderabledisc.h - rendering/renderablelabels.h + rendering/renderablelabel.h rendering/renderablemodel.h rendering/renderablenodeline.h rendering/renderableplane.h @@ -98,7 +98,7 @@ set(SOURCE_FILES rendering/grids/renderablesphericalgrid.cpp rendering/renderablecartesianaxes.cpp rendering/renderabledisc.cpp - rendering/renderablelabels.cpp + rendering/renderablelabel.cpp rendering/renderablemodel.cpp rendering/renderablenodeline.cpp rendering/renderableplane.cpp diff --git a/modules/base/basemodule.cpp b/modules/base/basemodule.cpp index b952604ea5..5dbbcd999e 100644 --- a/modules/base/basemodule.cpp +++ b/modules/base/basemodule.cpp @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include #include @@ -129,7 +129,7 @@ void BaseModule::internalInitialize(const ghoul::Dictionary&) { fRenderable->registerClass("RenderableCartesianAxes"); fRenderable->registerClass("RenderableDisc"); fRenderable->registerClass("RenderableGrid"); - fRenderable->registerClass("RenderableLabels"); + fRenderable->registerClass("RenderableLabel"); fRenderable->registerClass("RenderableModel"); fRenderable->registerClass("RenderableNodeLine"); fRenderable->registerClass("RenderablePlaneImageLocal"); @@ -212,7 +212,7 @@ std::vector BaseModule::documentations() const { RenderableCartesianAxes::Documentation(), RenderableDisc::Documentation(), RenderableGrid::Documentation(), - RenderableLabels::Documentation(), + RenderableLabel::Documentation(), RenderableModel::Documentation(), RenderableNodeLine::Documentation(), RenderablePlane::Documentation(), diff --git a/modules/base/rendering/grids/renderableboxgrid.cpp b/modules/base/rendering/grids/renderableboxgrid.cpp index 35a173e45e..7496c00467 100644 --- a/modules/base/rendering/grids/renderableboxgrid.cpp +++ b/modules/base/rendering/grids/renderableboxgrid.cpp @@ -54,6 +54,19 @@ namespace { "This value species the size of each dimensions of the box" }; + constexpr openspace::properties::Property::PropertyInfo DrawLabelInfo = { + "DrawLabels", + "Draw Labels", + "Determines whether labels should be drawn or hidden" + }; + + static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo = + { + "Labels", + "Labels", + "The labels for the grid" + }; + struct [[codegen::Dictionary(RenderableBoxGrid)]] Parameters { // [[codegen::verbatim(ColorInfo.description)]] std::optional color [[codegen::color()]]; @@ -63,6 +76,13 @@ namespace { // [[codegen::verbatim(SizeInfo.description)]] std::optional size; + + // [[codegen::verbatim(DrawLabelInfo.description)]] + std::optional drawLabels; + + // [[codegen::verbatim(LabelsInfo.description)]] + std::optional labels + [[codegen::reference("space_labelscomponent")]]; }; #include "renderableboxgrid_codegen.cpp" } // namespace @@ -78,6 +98,7 @@ RenderableBoxGrid::RenderableBoxGrid(const ghoul::Dictionary& dictionary) , _color(ColorInfo, glm::vec3(0.5f), glm::vec3(0.f), glm::vec3(1.f)) , _lineWidth(LineWidthInfo, 0.5f, 1.f, 20.f) , _size(SizeInfo, glm::vec3(1.f), glm::vec3(1.f), glm::vec3(100.f)) + , _drawLabels(DrawLabelInfo, false) { const Parameters p = codegen::bake(dictionary); @@ -94,10 +115,26 @@ RenderableBoxGrid::RenderableBoxGrid(const ghoul::Dictionary& dictionary) _size = p.size.value_or(_size); _size.onChange([&]() { _gridIsDirty = true; }); addProperty(_size); + + if (p.labels.has_value()) { + _drawLabels = p.drawLabels.value_or(_drawLabels); + addProperty(_drawLabels); + + _labels = std::make_unique(*p.labels); + _hasLabels = true; + addPropertySubOwner(_labels.get()); + } } bool RenderableBoxGrid::isReady() const { - return _gridProgram != nullptr; + return _hasLabels ? _gridProgram && _labels->isReady() : _gridProgram != nullptr; +} + +void RenderableBoxGrid::initialize() { + if (_hasLabels) { + _labels->initialize(); + _labels->loadLabels(); + } } void RenderableBoxGrid::initializeGL() { @@ -146,12 +183,12 @@ void RenderableBoxGrid::render(const RenderData& data, RendererTasks&){ glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)); glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform; + const glm::dmat4 projectionMatrix = data.camera.projectionMatrix(); + + const glm::dmat4 modelViewProjectionMatrix = projectionMatrix * modelViewTransform; _gridProgram->setUniform("modelViewTransform", modelViewTransform); - _gridProgram->setUniform( - "MVPTransform", - glm::dmat4(data.camera.projectionMatrix()) * modelViewTransform - ); + _gridProgram->setUniform("MVPTransform", modelViewProjectionMatrix); _gridProgram->setUniform("opacity", opacity()); _gridProgram->setUniform("gridColor", _color); @@ -176,6 +213,31 @@ void RenderableBoxGrid::render(const RenderData& data, RendererTasks&){ global::renderEngine->openglStateCache().resetBlendState(); global::renderEngine->openglStateCache().resetLineState(); global::renderEngine->openglStateCache().resetDepthState(); + + // Draw labels + if (_drawLabels && _hasLabels) { + const glm::vec3 lookup = data.camera.lookUpVectorWorldSpace(); + const glm::vec3 viewDirection = data.camera.viewDirectionWorldSpace(); + glm::vec3 right = glm::cross(viewDirection, lookup); + const glm::vec3 up = glm::cross(right, viewDirection); + + const glm::dmat4 worldToModelTransform = glm::inverse(modelTransform); + glm::vec3 orthoRight = glm::normalize( + glm::vec3(worldToModelTransform * glm::vec4(right, 0.0)) + ); + + if (orthoRight == glm::vec3(0.0)) { + glm::vec3 otherVector = glm::vec3(lookup.y, lookup.x, lookup.z); + right = glm::cross(viewDirection, otherVector); + orthoRight = glm::normalize( + glm::vec3(worldToModelTransform * glm::vec4(right, 0.0)) + ); + } + const glm::vec3 orthoUp = glm::normalize( + glm::vec3(worldToModelTransform * glm::dvec4(up, 0.0)) + ); + _labels->render(data, modelViewProjectionMatrix, orthoRight, orthoUp); + } } void RenderableBoxGrid::update(const UpdateData&) { diff --git a/modules/base/rendering/grids/renderableboxgrid.h b/modules/base/rendering/grids/renderableboxgrid.h index 3f4fbc0990..96e43fb73c 100644 --- a/modules/base/rendering/grids/renderableboxgrid.h +++ b/modules/base/rendering/grids/renderableboxgrid.h @@ -27,6 +27,7 @@ #include +#include #include #include #include @@ -43,6 +44,7 @@ class RenderableBoxGrid : public Renderable { public: RenderableBoxGrid(const ghoul::Dictionary& dictionary); + void initialize() override; void initializeGL() override; void deinitializeGL() override; @@ -71,6 +73,11 @@ protected: GLenum _mode = GL_LINE_STRIP; std::vector _varray; + + // Labels + bool _hasLabels = false; + properties::BoolProperty _drawLabels; + std::unique_ptr _labels; }; }// namespace openspace diff --git a/modules/base/rendering/grids/renderablegrid.cpp b/modules/base/rendering/grids/renderablegrid.cpp index eb472e597f..5cb75ed431 100644 --- a/modules/base/rendering/grids/renderablegrid.cpp +++ b/modules/base/rendering/grids/renderablegrid.cpp @@ -42,6 +42,12 @@ namespace { "This value determines the color of the grid lines that are rendered" }; + constexpr openspace::properties::Property::PropertyInfo HighlightColorInfo = { + "HighlightColor", + "Highlight Color", + "This value determines the color of the highlighted lines in the grid" + }; + constexpr openspace::properties::Property::PropertyInfo SegmentsInfo = { "Segments", "Number of Segments", @@ -49,30 +55,73 @@ namespace { "grid in each direction" }; + constexpr openspace::properties::Property::PropertyInfo HighlightRateInfo = { + "HighlightRate", + "Highlight Rate", + "The rate that the columns and rows are highlighted, counted with respect to the " + "center of the grid. If the number of segments in the grid is odd, the " + "highlighting might be offset from the center." + }; + constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = { "LineWidth", "Line Width", "This value specifies the line width of the grid" }; + constexpr openspace::properties::Property::PropertyInfo HighlightLineWidthInfo = { + "HighlightLineWidth", + "Highlight Line Width", + "This value specifies the line width of the highlighted lines in the grid" + }; + constexpr openspace::properties::Property::PropertyInfo SizeInfo = { "Size", "Grid Size", "This value species the size of each dimensions of the grid" }; + constexpr openspace::properties::Property::PropertyInfo DrawLabelInfo = { + "DrawLabels", + "Draw Labels", + "Determines whether labels should be drawn or hidden" + }; + + static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo = + { + "Labels", + "Labels", + "The labels for the grid" + }; + struct [[codegen::Dictionary(RenderableGrid)]] Parameters { // [[codegen::verbatim(ColorInfo.description)]] std::optional color [[codegen::color()]]; + // [[codegen::verbatim(HighlightColorInfo.description)]] + std::optional highlightColor [[codegen::color()]]; + // [[codegen::verbatim(SegmentsInfo.description)]] std::optional segments; + // [[codegen::verbatim(HighlightRateInfo.description)]] + std::optional highlightRate; + // [[codegen::verbatim(LineWidthInfo.description)]] std::optional lineWidth; + // [[codegen::verbatim(HighlightLineWidthInfo.description)]] + std::optional highlightLineWidth; + // [[codegen::verbatim(SizeInfo.description)]] std::optional size; + + // [[codegen::verbatim(DrawLabelInfo.description)]] + std::optional drawLabels; + + // [[codegen::verbatim(LabelsInfo.description)]] + std::optional labels + [[codegen::reference("space_labelscomponent")]]; }; #include "renderablegrid_codegen.cpp" } // namespace @@ -86,9 +135,13 @@ documentation::Documentation RenderableGrid::Documentation() { RenderableGrid::RenderableGrid(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _color(ColorInfo, glm::vec3(0.5f), glm::vec3(0.f), glm::vec3(1.f)) + , _highlightColor(HighlightColorInfo, glm::vec3(0.8f), glm::vec3(0.f), glm::vec3(1.f)) , _segments(SegmentsInfo, glm::uvec2(10), glm::uvec2(1), glm::uvec2(200)) + , _highlightRate(HighlightRateInfo, glm::uvec2(0), glm::uvec2(0), glm::uvec2(200)) , _lineWidth(LineWidthInfo, 0.5f, 1.f, 20.f) + , _highlightLineWidth(HighlightLineWidthInfo, 0.5f, 1.f, 20.f) , _size(SizeInfo, glm::vec2(1.f), glm::vec2(1.f), glm::vec2(1e11f)) + , _drawLabels(DrawLabelInfo, false) { const Parameters p = codegen::bake(dictionary); @@ -99,21 +152,50 @@ RenderableGrid::RenderableGrid(const ghoul::Dictionary& dictionary) _color.setViewOption(properties::Property::ViewOptions::Color); addProperty(_color); + // If no highlight color is specified then use the base color + _highlightColor = p.highlightColor.value_or(_color); + _highlightColor.setViewOption(properties::Property::ViewOptions::Color); + addProperty(_highlightColor); + _segments = p.segments.value_or(_segments); _segments.onChange([&]() { _gridIsDirty = true; }); addProperty(_segments); + _highlightRate = p.highlightRate.value_or(_highlightRate); + _highlightRate.onChange([&]() { _gridIsDirty = true; }); + addProperty(_highlightRate); + _lineWidth = p.lineWidth.value_or(_lineWidth); addProperty(_lineWidth); + // If no highlight line width is specified then use the base line width + _highlightLineWidth = p.highlightLineWidth.value_or(_lineWidth); + addProperty(_highlightLineWidth); + _size.setExponent(10.f); _size = p.size.value_or(_size); _size.onChange([&]() { _gridIsDirty = true; }); addProperty(_size); + + if (p.labels.has_value()) { + _drawLabels = p.drawLabels.value_or(_drawLabels); + addProperty(_drawLabels); + + _labels = std::make_unique(*p.labels); + _hasLabels = true; + addPropertySubOwner(_labels.get()); + } } bool RenderableGrid::isReady() const { - return _gridProgram != nullptr; + return _hasLabels ? _gridProgram && _labels->isReady() : _gridProgram != nullptr; +} + +void RenderableGrid::initialize() { + if (_hasLabels) { + _labels->initialize(); + _labels->loadLabels(); + } } void RenderableGrid::initializeGL() { @@ -130,9 +212,14 @@ void RenderableGrid::initializeGL() { glGenVertexArrays(1, &_vaoID); glGenBuffers(1, &_vBufferID); + glGenVertexArrays(1, &_highlightVaoID); + glGenBuffers(1, &_highlightVBufferID); glBindVertexArray(_vaoID); glBindBuffer(GL_ARRAY_BUFFER, _vBufferID); + glBindVertexArray(_highlightVaoID); + glBindBuffer(GL_ARRAY_BUFFER, _highlightVBufferID); + glEnableVertexAttribArray(0); glBindVertexArray(0); } @@ -140,9 +227,13 @@ void RenderableGrid::initializeGL() { void RenderableGrid::deinitializeGL() { glDeleteVertexArrays(1, &_vaoID); _vaoID = 0; + glDeleteVertexArrays(1, &_highlightVaoID); + _highlightVaoID = 0; glDeleteBuffers(1, &_vBufferID); _vBufferID = 0; + glDeleteBuffers(1, &_highlightVBufferID); + _highlightVBufferID = 0; BaseModule::ProgramObjectManager.release( "GridProgram", @@ -156,18 +247,36 @@ void RenderableGrid::deinitializeGL() { void RenderableGrid::render(const RenderData& data, RendererTasks&){ _gridProgram->activate(); - glm::dmat4 modelTransform = + const glm::dmat4 modelMatrix = glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * // Translation glm::dmat4(data.modelTransform.rotation) * // Spice rotation glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)); - glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform; + const glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelMatrix; + const glm::dmat4 projectionMatrix = data.camera.projectionMatrix(); + + const glm::dmat4 modelViewProjectionMatrix = projectionMatrix * modelViewTransform; + + const glm::vec3 lookup = data.camera.lookUpVectorWorldSpace(); + const glm::vec3 viewDirection = data.camera.viewDirectionWorldSpace(); + glm::vec3 right = glm::cross(viewDirection, lookup); + const glm::vec3 up = glm::cross(right, viewDirection); + + const glm::dmat4 worldToModelTransform = glm::inverse(modelMatrix); + glm::vec3 orthoRight = glm::normalize( + glm::vec3(worldToModelTransform * glm::vec4(right, 0.0)) + ); + + if (orthoRight == glm::vec3(0.0)) { + glm::vec3 otherVector = glm::vec3(lookup.y, lookup.x, lookup.z); + right = glm::cross(viewDirection, otherVector); + orthoRight = glm::normalize( + glm::vec3(worldToModelTransform * glm::vec4(right, 0.0)) + ); + } _gridProgram->setUniform("modelViewTransform", modelViewTransform); - _gridProgram->setUniform( - "MVPTransform", - glm::dmat4(data.camera.projectionMatrix()) * modelViewTransform - ); + _gridProgram->setUniform("MVPTransform", modelViewProjectionMatrix); _gridProgram->setUniform("opacity", opacity()); _gridProgram->setUniform("gridColor", _color); @@ -180,18 +289,37 @@ void RenderableGrid::render(const RenderData& data, RendererTasks&){ glEnablei(GL_BLEND, 0); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_LINE_SMOOTH); - glDepthMask(false); + glEnable(GL_DEPTH_TEST); + // Render minor grid glBindVertexArray(_vaoID); glDrawArrays(_mode, 0, static_cast(_varray.size())); - glBindVertexArray(0); - _gridProgram->deactivate(); + // Render major grid +#ifndef __APPLE__ + glLineWidth(_highlightLineWidth); +#else + glLineWidth(1.f); +#endif + _gridProgram->setUniform("gridColor", _highlightColor); + + glBindVertexArray(_highlightVaoID); + glDrawArrays(_mode, 0, static_cast(_highlightArray.size())); // Restore GL State + glBindVertexArray(0); + _gridProgram->deactivate(); global::renderEngine->openglStateCache().resetBlendState(); global::renderEngine->openglStateCache().resetLineState(); global::renderEngine->openglStateCache().resetDepthState(); + + // Draw labels + if (_drawLabels && _hasLabels) { + const glm::vec3 orthoUp = glm::normalize( + glm::vec3(worldToModelTransform * glm::dvec4(up, 0.0)) + ); + _labels->render(data, modelViewProjectionMatrix, orthoRight, orthoUp); + } } void RenderableGrid::update(const UpdateData&) { @@ -199,50 +327,111 @@ void RenderableGrid::update(const UpdateData&) { return; } - const glm::vec2 halfSize = _size.value() / 2.f; + const glm::dvec2 halfSize = static_cast(_size.value()) / 2.0; const glm::uvec2 nSegments = _segments.value(); - const glm::vec2 step = _size.value() / static_cast(nSegments); + const glm::dvec2 step = + static_cast(_size.value()) / static_cast(nSegments); const int nLines = (2 * nSegments.x * nSegments.y) + nSegments.x + nSegments.y; const int nVertices = 2 * nLines; - _varray.resize(nVertices); + _varray.clear(); + _varray.reserve(nVertices); + _highlightArray.clear(); + _highlightArray.reserve(nVertices); // OBS! Could be optimized further by removing duplicate vertices - int nr = 0; + // If the number of segments are uneven the center won't be completly centered + const glm::uvec2 center = glm::uvec2(nSegments.x / 2.f, nSegments.y / 2.f); for (unsigned int i = 0; i < nSegments.x; ++i) { for (unsigned int j = 0; j < nSegments.y; ++j) { - const float y0 = -halfSize.y + j * step.y; - const float y1 = y0 + step.y; + const double y0 = -halfSize.y + j * step.y; + const double y1 = y0 + step.y; - const float x0 = -halfSize.x + i * step.x; - const float x1 = x0 + step.x; + const double x0 = -halfSize.x + i * step.x; + const double x1 = x0 + step.x; - _varray[nr++] = { x0, y0, 0.f }; - _varray[nr++] = { x0, y1, 0.f }; + // Line in y direction + bool shouldHighlight = false; + if (_highlightRate.value().x != 0) { + int dist = abs(static_cast(i) - static_cast(center.x)); + int rest = dist % _highlightRate.value().x; + shouldHighlight = rest == 0; + } - _varray[nr++] = { x0, y0, 0.f }; - _varray[nr++] = { x1, y0, 0.f }; + if (shouldHighlight) { + _highlightArray.push_back({ x0, y0, 0.0 }); + _highlightArray.push_back({ x0, y1, 0.0 }); + } + else { + _varray.push_back({ x0, y0, 0.0 }); + _varray.push_back({ x0, y1, 0.0 }); + } + + // Line in x direction + shouldHighlight = false; + if (_highlightRate.value().y != 0) { + int dist = abs(static_cast(j) - static_cast(center.y)); + int rest = dist % _highlightRate.value().y; + shouldHighlight = abs(rest) == 0; + } + + if (shouldHighlight) { + _highlightArray.push_back({ x0, y0, 0.0 }); + _highlightArray.push_back({ x1, y0, 0.0 }); + } + else { + _varray.push_back({ x0, y0, 0.0 }); + _varray.push_back({ x1, y0, 0.0 }); + } } } // last x row for (unsigned int i = 0; i < nSegments.x; ++i) { - const float x0 = -halfSize.x + i * step.x; - const float x1 = x0 + step.x; - _varray[nr++] = { x0, halfSize.y, 0.f }; - _varray[nr++] = { x1, halfSize.y, 0.f }; + const double x0 = -halfSize.x + i * step.x; + const double x1 = x0 + step.x; + + bool shouldHighlight = false; + if (_highlightRate.value().y != 0) { + int dist = abs(static_cast(nSegments.y) - static_cast(center.y)); + int rest = dist % _highlightRate.value().y; + shouldHighlight = abs(rest) == 0; + } + + if (shouldHighlight) { + _highlightArray.push_back({ x0, halfSize.y, 0.0 }); + _highlightArray.push_back({ x1, halfSize.y, 0.0 }); + } + else { + _varray.push_back({ x0, halfSize.y, 0.0 }); + _varray.push_back({ x1, halfSize.y, 0.0 }); + } } // last y col - for (unsigned int i = 0; i < nSegments.y; ++i) { - const float y0 = -halfSize.y + i * step.y; - const float y1 = y0 + step.y; - _varray[nr++] = { halfSize.x, y0, 0.f }; - _varray[nr++] = { halfSize.x, y1, 0.f }; + for (unsigned int j = 0; j < nSegments.y; ++j) { + const double y0 = -halfSize.y + j * step.y; + const double y1 = y0 + step.y; + + bool shouldHighlight = false; + if (_highlightRate.value().x != 0) { + int dist = abs(static_cast(nSegments.x) - static_cast(center.x)); + int rest = dist % _highlightRate.value().x; + shouldHighlight = abs(rest) == 0; + } + if (shouldHighlight) { + _highlightArray.push_back({ halfSize.x, y0, 0.0 }); + _highlightArray.push_back({ halfSize.x, y1, 0.0 }); + } + else { + _varray.push_back({ halfSize.x, y0, 0.0 }); + _varray.push_back({ halfSize.x, y1, 0.0 }); + } } setBoundingSphere(glm::length(glm::dvec2(halfSize))); + // Minor grid glBindVertexArray(_vaoID); glBindBuffer(GL_ARRAY_BUFFER, _vBufferID); glBufferData( @@ -251,8 +440,19 @@ void RenderableGrid::update(const UpdateData&) { _varray.data(), GL_STATIC_DRAW ); + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 3, GL_DOUBLE, GL_FALSE, sizeof(Vertex), nullptr); - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), nullptr); + // Major grid + glBindVertexArray(_highlightVaoID); + glBindBuffer(GL_ARRAY_BUFFER, _highlightVBufferID); + glBufferData( + GL_ARRAY_BUFFER, + _highlightArray.size() * sizeof(Vertex), + _highlightArray.data(), + GL_STATIC_DRAW + ); + glVertexAttribPointer(0, 3, GL_DOUBLE, GL_FALSE, sizeof(Vertex), nullptr); glBindVertexArray(0); diff --git a/modules/base/rendering/grids/renderablegrid.h b/modules/base/rendering/grids/renderablegrid.h index 4b9c71701e..9b0eabc890 100644 --- a/modules/base/rendering/grids/renderablegrid.h +++ b/modules/base/rendering/grids/renderablegrid.h @@ -27,6 +27,7 @@ #include +#include #include #include #include @@ -43,6 +44,7 @@ class RenderableGrid : public Renderable { public: RenderableGrid(const ghoul::Dictionary& dictionary); + void initialize() override; void initializeGL() override; void deinitializeGL() override; @@ -55,25 +57,36 @@ public: protected: struct Vertex { - float location[3]; + double location[3]; }; ghoul::opengl::ProgramObject* _gridProgram = nullptr; properties::Vec3Property _color; + properties::Vec3Property _highlightColor; // @TODO (abock, 2021-01-28) This was a UVec2Property before, but it wasn't supported // be the codegen. As soon as it does, this should be changed back properties::IVec2Property _segments; + properties::IVec2Property _highlightRate; properties::FloatProperty _lineWidth; + properties::FloatProperty _highlightLineWidth; properties::Vec2Property _size; bool _gridIsDirty = true; GLuint _vaoID = 0; GLuint _vBufferID = 0; + GLuint _highlightVaoID = 0; + GLuint _highlightVBufferID = 0; GLenum _mode = GL_LINES; std::vector _varray; + std::vector _highlightArray; + + // Labels + bool _hasLabels = false; + properties::BoolProperty _drawLabels; + std::unique_ptr _labels; }; }// namespace openspace diff --git a/modules/base/rendering/grids/renderableradialgrid.cpp b/modules/base/rendering/grids/renderableradialgrid.cpp index aef8bc8609..1c42671fbc 100644 --- a/modules/base/rendering/grids/renderableradialgrid.cpp +++ b/modules/base/rendering/grids/renderableradialgrid.cpp @@ -71,6 +71,19 @@ namespace { "ring" }; + constexpr openspace::properties::Property::PropertyInfo DrawLabelInfo = { + "DrawLabels", + "Draw Labels", + "Determines whether labels should be drawn or hidden" + }; + + static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo = + { + "Labels", + "Labels", + "The labels for the grid" + }; + struct [[codegen::Dictionary(RenderableRadialGrid)]] Parameters { // [[codegen::verbatim(ColorInfo.description)]] std::optional color [[codegen::color()]]; @@ -86,6 +99,13 @@ namespace { // [[codegen::verbatim(RadiiInfo.description)]] std::optional radii; + + // [[codegen::verbatim(DrawLabelInfo.description)]] + std::optional drawLabels; + + // [[codegen::verbatim(LabelsInfo.description)]] + std::optional labels + [[codegen::reference("space_labelscomponent")]]; }; #include "renderableradialgrid_codegen.cpp" } // namespace @@ -103,6 +123,7 @@ RenderableRadialGrid::RenderableRadialGrid(const ghoul::Dictionary& dictionary) , _circleSegments(CircleSegmentsInfo, 36, 4, 200) , _lineWidth(LineWidthInfo, 0.5f, 1.f, 20.f) , _radii(RadiiInfo, glm::vec2(0.f, 1.f), glm::vec2(0.f), glm::vec2(20.f)) + , _drawLabels(DrawLabelInfo, false) { const Parameters p = codegen::bake(dictionary); @@ -134,10 +155,26 @@ RenderableRadialGrid::RenderableRadialGrid(const ghoul::Dictionary& dictionary) _radii.onChange([&]() { _gridIsDirty = true; }); addProperty(_radii); + + if (p.labels.has_value()) { + _drawLabels = p.drawLabels.value_or(_drawLabels); + addProperty(_drawLabels); + + _labels = std::make_unique(*p.labels); + _hasLabels = true; + addPropertySubOwner(_labels.get()); + } } bool RenderableRadialGrid::isReady() const { - return _gridProgram != nullptr; + return _hasLabels ? _gridProgram && _labels->isReady() : _gridProgram != nullptr; +} + +void RenderableRadialGrid::initialize() { + if (_hasLabels) { + _labels->initialize(); + _labels->loadLabels(); + } } void RenderableRadialGrid::initializeGL() { @@ -171,14 +208,14 @@ void RenderableRadialGrid::render(const RenderData& data, RendererTasks&) { glm::dmat4(data.modelTransform.rotation) * // Spice rotation glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)); - const glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * - modelTransform; + const glm::dmat4 modelViewTransform = + data.camera.combinedViewMatrix() * modelTransform; + const glm::dmat4 projectionMatrix = data.camera.projectionMatrix(); + + const glm::dmat4 modelViewProjectionMatrix = projectionMatrix * modelViewTransform; _gridProgram->setUniform("modelViewTransform", modelViewTransform); - _gridProgram->setUniform( - "MVPTransform", - glm::dmat4(data.camera.projectionMatrix()) * modelViewTransform - ); + _gridProgram->setUniform("MVPTransform", modelViewProjectionMatrix); _gridProgram->setUniform("opacity", opacity()); _gridProgram->setUniform("gridColor", _color); @@ -205,6 +242,31 @@ void RenderableRadialGrid::render(const RenderData& data, RendererTasks&) { global::renderEngine->openglStateCache().resetBlendState(); global::renderEngine->openglStateCache().resetLineState(); global::renderEngine->openglStateCache().resetDepthState(); + + // Draw labels + if (_drawLabels && _hasLabels) { + const glm::vec3 lookup = data.camera.lookUpVectorWorldSpace(); + const glm::vec3 viewDirection = data.camera.viewDirectionWorldSpace(); + glm::vec3 right = glm::cross(viewDirection, lookup); + const glm::vec3 up = glm::cross(right, viewDirection); + + const glm::dmat4 worldToModelTransform = glm::inverse(modelTransform); + glm::vec3 orthoRight = glm::normalize( + glm::vec3(worldToModelTransform * glm::vec4(right, 0.0)) + ); + + if (orthoRight == glm::vec3(0.0)) { + glm::vec3 otherVector = glm::vec3(lookup.y, lookup.x, lookup.z); + right = glm::cross(viewDirection, otherVector); + orthoRight = glm::normalize( + glm::vec3(worldToModelTransform * glm::vec4(right, 0.0)) + ); + } + const glm::vec3 orthoUp = glm::normalize( + glm::vec3(worldToModelTransform * glm::dvec4(up, 0.0)) + ); + _labels->render(data, modelViewProjectionMatrix, orthoRight, orthoUp); + } } void RenderableRadialGrid::update(const UpdateData&) { diff --git a/modules/base/rendering/grids/renderableradialgrid.h b/modules/base/rendering/grids/renderableradialgrid.h index 93187dfb9f..2a1545bb40 100644 --- a/modules/base/rendering/grids/renderableradialgrid.h +++ b/modules/base/rendering/grids/renderableradialgrid.h @@ -27,6 +27,7 @@ #include +#include #include #include #include @@ -46,6 +47,7 @@ public: RenderableRadialGrid(const ghoul::Dictionary& dictionary); ~RenderableRadialGrid() override = default; + void initialize() override; void initializeGL() override; void deinitializeGL() override; @@ -85,6 +87,11 @@ protected: std::vector _circles; GeometryData _lines{GL_LINES}; + + // Labels + bool _hasLabels = false; + properties::BoolProperty _drawLabels; + std::unique_ptr _labels; }; }// namespace openspace diff --git a/modules/base/rendering/grids/renderablesphericalgrid.cpp b/modules/base/rendering/grids/renderablesphericalgrid.cpp index 4b58b488dd..e60c334bee 100644 --- a/modules/base/rendering/grids/renderablesphericalgrid.cpp +++ b/modules/base/rendering/grids/renderablesphericalgrid.cpp @@ -55,6 +55,19 @@ namespace { "This value specifies the line width of the spherical grid" }; + constexpr openspace::properties::Property::PropertyInfo DrawLabelInfo = { + "DrawLabels", + "Draw Labels", + "Determines whether labels should be drawn or hidden" + }; + + static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo = + { + "Labels", + "Labels", + "The labels for the grid" + }; + struct [[codegen::Dictionary(RenderableSphericalGrid)]] Parameters { // [[codegen::verbatim(ColorInfo.description)]] std::optional color [[codegen::color()]]; @@ -64,6 +77,13 @@ namespace { // [[codegen::verbatim(LineWidthInfo.description)]] std::optional lineWidth; + + // [[codegen::verbatim(DrawLabelInfo.description)]] + std::optional drawLabels; + + // [[codegen::verbatim(LabelsInfo.description)]] + std::optional labels + [[codegen::reference("space_labelscomponent")]]; }; #include "renderablesphericalgrid_codegen.cpp" } // namespace @@ -80,6 +100,7 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio , _color(ColorInfo, glm::vec3(0.5f), glm::vec3(0.f), glm::vec3(1.f)) , _segments(SegmentsInfo, 36, 4, 200) , _lineWidth(LineWidthInfo, 0.5f, 1.f, 20.f) + , _drawLabels(DrawLabelInfo, false) { const Parameters p = codegen::bake(dictionary); @@ -104,12 +125,26 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio // Radius is always 1 setBoundingSphere(1.0); + + if (p.labels.has_value()) { + _drawLabels = p.drawLabels.value_or(_drawLabels); + addProperty(_drawLabels); + + _labels = std::make_unique(*p.labels); + _hasLabels = true; + addPropertySubOwner(_labels.get()); + } } bool RenderableSphericalGrid::isReady() const { - bool ready = true; - ready &= (_gridProgram != nullptr); - return ready; + return _hasLabels ? _gridProgram && _labels->isReady() : _gridProgram != nullptr; +} + +void RenderableSphericalGrid::initialize() { + if (_hasLabels) { + _labels->initialize(); + _labels->loadLabels(); + } } void RenderableSphericalGrid::initializeGL() { @@ -162,14 +197,14 @@ void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){ glm::dmat4(data.modelTransform.rotation) * // Spice rotation glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)); - const glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * - modelTransform; + const glm::dmat4 modelViewTransform = + data.camera.combinedViewMatrix() * modelTransform; + const glm::dmat4 projectionMatrix = data.camera.projectionMatrix(); + + const glm::dmat4 modelViewProjectionMatrix = projectionMatrix * modelViewTransform; _gridProgram->setUniform("modelViewTransform", modelViewTransform); - _gridProgram->setUniform( - "MVPTransform", - glm::dmat4(data.camera.projectionMatrix()) * modelViewTransform - ); + _gridProgram->setUniform("MVPTransform", modelViewProjectionMatrix); _gridProgram->setUniform("opacity", opacity()); _gridProgram->setUniform("gridColor", _color); @@ -195,6 +230,31 @@ void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){ global::renderEngine->openglStateCache().resetBlendState(); global::renderEngine->openglStateCache().resetLineState(); global::renderEngine->openglStateCache().resetDepthState(); + + // Draw labels + if (_drawLabels && _hasLabels) { + const glm::vec3 lookup = data.camera.lookUpVectorWorldSpace(); + const glm::vec3 viewDirection = data.camera.viewDirectionWorldSpace(); + glm::vec3 right = glm::cross(viewDirection, lookup); + const glm::vec3 up = glm::cross(right, viewDirection); + + const glm::dmat4 worldToModelTransform = glm::inverse(modelTransform); + glm::vec3 orthoRight = glm::normalize( + glm::vec3(worldToModelTransform * glm::vec4(right, 0.0)) + ); + + if (orthoRight == glm::vec3(0.0)) { + glm::vec3 otherVector = glm::vec3(lookup.y, lookup.x, lookup.z); + right = glm::cross(viewDirection, otherVector); + orthoRight = glm::normalize( + glm::vec3(worldToModelTransform * glm::vec4(right, 0.0)) + ); + } + const glm::vec3 orthoUp = glm::normalize( + glm::vec3(worldToModelTransform * glm::dvec4(up, 0.0)) + ); + _labels->render(data, modelViewProjectionMatrix, orthoRight, orthoUp); + } } void RenderableSphericalGrid::update(const UpdateData&) { diff --git a/modules/base/rendering/grids/renderablesphericalgrid.h b/modules/base/rendering/grids/renderablesphericalgrid.h index 8fbf77ea03..cbb4ffea63 100644 --- a/modules/base/rendering/grids/renderablesphericalgrid.h +++ b/modules/base/rendering/grids/renderablesphericalgrid.h @@ -27,6 +27,7 @@ #include +#include #include #include #include @@ -43,6 +44,7 @@ public: RenderableSphericalGrid(const ghoul::Dictionary& dictionary); ~RenderableSphericalGrid() override = default; + void initialize() override; void initializeGL() override; void deinitializeGL() override; @@ -75,6 +77,11 @@ protected: unsigned int _vsize = 0; std::vector _varray; std::vector _iarray; + + // Labels + bool _hasLabels = false; + properties::BoolProperty _drawLabels; + std::unique_ptr _labels; }; }// namespace openspace diff --git a/modules/base/rendering/renderablelabels.cpp b/modules/base/rendering/renderablelabel.cpp similarity index 95% rename from modules/base/rendering/renderablelabels.cpp rename to modules/base/rendering/renderablelabel.cpp index 9a0b556b73..fb5338a13f 100644 --- a/modules/base/rendering/renderablelabels.cpp +++ b/modules/base/rendering/renderablelabel.cpp @@ -22,7 +22,7 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include #include #include @@ -166,7 +166,7 @@ namespace { "Distance unit for fade-in/-out distance calculations. Defaults to \"au\"" }; - struct [[codegen::Dictionary(RenderableLabels)]] Parameters { + struct [[codegen::Dictionary(RenderableLabel)]] Parameters { enum class [[codegen::map(BlendMode)]] BlendMode { Normal, Additive @@ -228,16 +228,16 @@ namespace { // [[codegen::verbatim(FadeWidthsInfo.description)]] std::optional fadeWidths; }; -#include "renderablelabels_codegen.cpp" +#include "renderablelabel_codegen.cpp" } // namespace namespace openspace { -documentation::Documentation RenderableLabels::Documentation() { +documentation::Documentation RenderableLabel::Documentation() { return codegen::doc("base_renderable_labels"); } -RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary) +RenderableLabel::RenderableLabel(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _blendMode(BlendModeInfo, properties::OptionProperty::DisplayType::Dropdown) , _color(ColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) @@ -357,17 +357,17 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary) addProperty(_fadeWidths); } -bool RenderableLabels::isReady() const { +bool RenderableLabel::isReady() const { return true; } -void RenderableLabels::initialize() { +void RenderableLabel::initialize() { ZoneScoped setRenderBin(Renderable::RenderBin::PreDeferredTransparent); } -void RenderableLabels::initializeGL() { +void RenderableLabel::initializeGL() { if (_font == nullptr) { _font = global::fontManager->font( "Mono", @@ -378,9 +378,9 @@ void RenderableLabels::initializeGL() { } } -void RenderableLabels::deinitializeGL() {} +void RenderableLabel::deinitializeGL() {} -void RenderableLabels::render(const RenderData& data, RendererTasks&) { +void RenderableLabel::render(const RenderData& data, RendererTasks&) { glDepthMask(true); glBlendFunc(GL_SRC_ALPHA, GL_ONE); @@ -421,11 +421,11 @@ void RenderableLabels::render(const RenderData& data, RendererTasks&) { } -void RenderableLabels::setLabelText(const std::string & newText) { +void RenderableLabel::setLabelText(const std::string & newText) { _text = newText; } -void RenderableLabels::renderLabels(const RenderData& data, +void RenderableLabel::renderLabels(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix, const glm::dvec3& orthoRight, const glm::dvec3& orthoUp, float fadeInVariable) @@ -463,7 +463,7 @@ void RenderableLabels::renderLabels(const RenderData& data, ); } -float RenderableLabels::computeFadeFactor(float distanceNodeToCamera) const { +float RenderableLabel::computeFadeFactor(float distanceNodeToCamera) const { float distanceUnit = unit(_fadeUnitOption); float x = distanceNodeToCamera; @@ -487,7 +487,7 @@ float RenderableLabels::computeFadeFactor(float distanceNodeToCamera) const { } } -float RenderableLabels::unit(int unit) const { +float RenderableLabel::unit(int unit) const { switch (static_cast(unit)) { case Meter: return 1.f; case Kilometer: return 1e3f; @@ -505,7 +505,7 @@ float RenderableLabels::unit(int unit) const { } } -std::string_view RenderableLabels::toString(int unit) const { +std::string_view RenderableLabel::toString(int unit) const { switch (static_cast(unit)) { case Meter: return MeterUnit; case Kilometer: return KilometerUnit; diff --git a/modules/base/rendering/renderablelabels.h b/modules/base/rendering/renderablelabel.h similarity index 94% rename from modules/base/rendering/renderablelabels.h rename to modules/base/rendering/renderablelabel.h index cf77a20730..312e93282e 100644 --- a/modules/base/rendering/renderablelabels.h +++ b/modules/base/rendering/renderablelabel.h @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_BASE___RENDERABLELABELS___H__ -#define __OPENSPACE_MODULE_BASE___RENDERABLELABELS___H__ +#ifndef __OPENSPACE_MODULE_BASE___RENDERABLELABEL___H__ +#define __OPENSPACE_MODULE_BASE___RENDERABLELABEL___H__ #include @@ -54,9 +54,9 @@ namespace documentation { struct Documentation; } struct LinePoint; -class RenderableLabels : public Renderable { +class RenderableLabel : public Renderable { public: - RenderableLabels(const ghoul::Dictionary& dictionary); + RenderableLabel(const ghoul::Dictionary& dictionary); void initialize() override; void initializeGL() override; @@ -111,4 +111,4 @@ private: } // namespace openspace -#endif // __OPENSPACE_MODULE_BASE___RENDERABLELABELS___H__ +#endif // __OPENSPACE_MODULE_BASE___RENDERABLELABEL___H__ diff --git a/modules/base/shaders/grid_vs.glsl b/modules/base/shaders/grid_vs.glsl index e2528c3de4..027bc20032 100644 --- a/modules/base/shaders/grid_vs.glsl +++ b/modules/base/shaders/grid_vs.glsl @@ -37,11 +37,11 @@ void main() { dvec4 objPosDouble = dvec4(in_position, 1.0); dvec4 positionViewSpace = modelViewTransform * objPosDouble; dvec4 positionClipSpace = MVPTransform * objPosDouble; - + positionClipSpace.z = 0.0; - + vs_depthClipSpace = float(positionClipSpace.w); vs_positionViewSpace = vec4(positionViewSpace); - + gl_Position = vec4(positionClipSpace); } diff --git a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp index 33850c8bc3..b432c985ae 100644 --- a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp +++ b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp @@ -32,8 +32,6 @@ #include #include #include -#include -#include #include #include #include @@ -102,32 +100,6 @@ namespace { "The path to the color map file of the astronomical object" }; - constexpr openspace::properties::Property::PropertyInfo TextColorInfo = { - "TextColor", - "Text Color", - "The text color for the astronomical object" - }; - - constexpr openspace::properties::Property::PropertyInfo TextOpacityInfo = { - "TextOpacity", - "Text Opacity", - "Determines the transparency of the text label, where 1 is completely opaque " - "and 0 fully transparent" - }; - - constexpr openspace::properties::Property::PropertyInfo TextSizeInfo = { - "TextSize", - "Text Size", - "The text size for the astronomical object labels" - }; - - constexpr openspace::properties::Property::PropertyInfo LabelMinMaxSizeInfo = { - "TextMinMaxSize", - "Text Min/Max Size", - "The minimal and maximal size (in pixels) of the text for the labels for the " - "astronomical objects being rendered" - }; - constexpr openspace::properties::Property::PropertyInfo DrawElementsInfo = { "DrawElements", "Draw Elements", @@ -140,6 +112,13 @@ namespace { "Determines whether labels should be drawn or hidden" }; + static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo = + { + "Labels", + "Labels", + "The labels for the astronomical objects" + }; + constexpr openspace::properties::Property::PropertyInfo ColorOptionInfo = { "ColorOption", "Color Option", @@ -163,7 +142,8 @@ namespace { constexpr openspace::properties::Property::PropertyInfo RenderOptionInfo = { "RenderOption", "Render Option", - "Debug option for rendering of billboards and texts" + "Option wether the billboards should face the camera or not. Used for " + "non-linear display envierments such as fisheye." }; constexpr openspace::properties::Property::PropertyInfo FadeInDistancesInfo = { @@ -274,21 +254,9 @@ namespace { // [[codegen::verbatim(DrawLabelInfo.description)]] std::optional drawLabels; - // [[codegen::verbatim(TextColorInfo.description)]] - std::optional textColor [[codegen::color()]]; - - // [[codegen::verbatim(TextOpacityInfo.description)]] - std::optional textOpacity; - - // [[codegen::verbatim(TextSizeInfo.description)]] - std::optional textSize; - - // The path to the label file that contains information about the astronomical - // objects being rendered - std::optional labelFile; - - // [[codegen::verbatim(LabelMinMaxSizeInfo.description)]] - std::optional textMinMaxSize; + // [[codegen::verbatim(LabelsInfo.description)]] + std::optional labels + [[codegen::reference("space_labelscomponent")]]; // [[codegen::verbatim(ColorOptionInfo.description)]] std::optional> colorOption; @@ -339,15 +307,6 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di , _useColorMap(UseColorMapInfo, true) , _pointColor(ColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) , _spriteTexturePath(SpriteTextureInfo) - , _textColor(TextColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) - , _textOpacity(TextOpacityInfo, 1.f, 0.f, 1.f) - , _textSize(TextSizeInfo, 8.f, 0.5f, 24.f) - , _textMinMaxSize( - LabelMinMaxSizeInfo, - glm::ivec2(8, 20), - glm::ivec2(0), - glm::ivec2(100) - ) , _drawElements(DrawElementsInfo, true) , _drawLabels(DrawLabelInfo, false) , _pixelSizeControl(PixelSizeControlInfo, false) @@ -481,28 +440,13 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di _polygonSides = p.polygonSides.value_or(_polygonSides); _hasPolygon = p.polygonSides.has_value(); - if (p.labelFile.has_value()) { + if (p.labels.has_value()) { _drawLabels = p.drawLabels.value_or(_drawLabels); addProperty(_drawLabels); - _labelFile = absPath(*p.labelFile).string(); - _hasLabel = true; - - _textColor = p.textColor.value_or(_textColor); - _hasLabel = p.textColor.has_value(); - _textColor.setViewOption(properties::Property::ViewOptions::Color); - addProperty(_textColor); - _textColor.onChange([&]() { _textColorIsDirty = true; }); - - _textOpacity = p.textOpacity.value_or(_textOpacity); - addProperty(_textOpacity); - - _textSize = p.textSize.value_or(_textSize); - addProperty(_textSize); - - _textMinMaxSize = p.textMinMaxSize.value_or(_textMinMaxSize); - _textMinMaxSize.setViewOption(properties::Property::ViewOptions::MinMaxRange); - addProperty(_textMinMaxSize); + _labels = std::make_unique(*p.labels); + _hasLabels = true; + addPropertySubOwner(_labels.get()); } _transformationMatrix = p.transformationMatrix.value_or(_transformationMatrix); @@ -557,7 +501,13 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di } bool RenderableBillboardsCloud::isReady() const { - return (_program && (!_dataset.entries.empty())) || (!_labelset.entries.empty()); + bool isReady = _program && !_dataset.entries.empty(); + + // If we have labels, they also need to be loaded + if (_hasLabels) { + isReady = isReady || _labels->isReady(); + } + return isReady; } void RenderableBillboardsCloud::initialize() { @@ -571,11 +521,9 @@ void RenderableBillboardsCloud::initialize() { _colorMap = speck::color::loadFileWithCache(_colorMapFile); } - if (!_labelFile.empty()) { - _labelset = speck::label::loadFileWithCache(_labelFile); - for (speck::Labelset::Entry& e : _labelset.entries) { - e.position = glm::vec3(_transformationMatrix * glm::dvec4(e.position, 1.0)); - } + if (_hasLabels) { + _labels->initialize(); + _labels->loadLabels(); } if (!_colorOptionString.empty() && (_colorRangeData.size() > 1)) { @@ -619,18 +567,6 @@ void RenderableBillboardsCloud::initializeGL() { if (_hasPolygon) { createPolygonTexture(); } - - if (_hasLabel) { - if (!_font) { - size_t _fontSize = 50; - _font = global::fontManager->font( - "Mono", - static_cast(_fontSize), - ghoul::fontrendering::FontManager::Outline::Yes, - ghoul::fontrendering::FontManager::LoadGlyphs::No - ); - } - } } void RenderableBillboardsCloud::deinitializeGL() { @@ -739,40 +675,6 @@ void RenderableBillboardsCloud::renderBillboards(const RenderData& data, global::renderEngine->openglStateCache().resetDepthState(); } -void RenderableBillboardsCloud::renderLabels(const RenderData& data, - const glm::dmat4& modelViewProjectionMatrix, - const glm::dvec3& orthoRight, - const glm::dvec3& orthoUp, - float fadeInVariable) -{ - glm::vec4 textColor = glm::vec4(glm::vec3(_textColor), _textOpacity * fadeInVariable); - - ghoul::fontrendering::FontRenderer::ProjectedLabelsInformation labelInfo; - labelInfo.orthoRight = orthoRight; - labelInfo.orthoUp = orthoUp; - labelInfo.minSize = _textMinMaxSize.value().x; - labelInfo.maxSize = _textMinMaxSize.value().y; - labelInfo.cameraPos = data.camera.positionVec3(); - labelInfo.cameraLookUp = data.camera.lookUpVectorWorldSpace(); - labelInfo.renderType = _renderOption; - labelInfo.mvpMatrix = modelViewProjectionMatrix; - labelInfo.scale = pow(10.f, _textSize); - labelInfo.enableDepth = true; - labelInfo.enableFalseDepth = false; - - for (const speck::Labelset::Entry& e : _labelset.entries) { - glm::vec3 scaledPos(e.position); - scaledPos *= toMeter(_unit); - ghoul::fontrendering::FontRenderer::defaultProjectionRenderer().render( - *_font, - scaledPos, - e.text, - textColor, - labelInfo - ); - } -} - void RenderableBillboardsCloud::render(const RenderData& data, RendererTasks&) { float fadeInVar = 1.f; if (!_disableFadeInDistance) { @@ -806,7 +708,7 @@ void RenderableBillboardsCloud::render(const RenderData& data, RendererTasks&) { glm::cross(cameraUpDirectionWorld, cameraViewDirectionWorld) ); if (orthoRight == glm::dvec3(0.0)) { - glm::dvec3 otherVector( + glm::dvec3 otherVector = glm::vec3( cameraUpDirectionWorld.y, cameraUpDirectionWorld.x, cameraUpDirectionWorld.z @@ -819,8 +721,8 @@ void RenderableBillboardsCloud::render(const RenderData& data, RendererTasks&) { renderBillboards(data, modelMatrix, orthoRight, orthoUp, fadeInVar); } - if (_drawLabels && _hasLabel) { - renderLabels(data, modelViewProjectionMatrix, orthoRight, orthoUp, fadeInVar); + if (_drawLabels && _hasLabels) { + _labels->render(data, modelViewProjectionMatrix, orthoRight, orthoUp, fadeInVar); } } diff --git a/modules/digitaluniverse/rendering/renderablebillboardscloud.h b/modules/digitaluniverse/rendering/renderablebillboardscloud.h index d944b2adb9..5639d4c303 100644 --- a/modules/digitaluniverse/rendering/renderablebillboardscloud.h +++ b/modules/digitaluniverse/rendering/renderablebillboardscloud.h @@ -27,7 +27,7 @@ #include -#include +#include #include #include #include @@ -43,7 +43,6 @@ #include namespace ghoul::filesystem { class File; } -namespace ghoul::fontrendering { class Font; } namespace ghoul::opengl { class ProgramObject; class Texture; @@ -79,19 +78,16 @@ private: void renderPolygonGeometry(GLuint vao); void renderBillboards(const RenderData& data, const glm::dmat4& modelMatrix, const glm::dvec3& orthoRight, const glm::dvec3& orthoUp, float fadeInVariable); - void renderLabels(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix, - const glm::dvec3& orthoRight, const glm::dvec3& orthoUp, float fadeInVariable); bool _hasSpeckFile = false; bool _dataIsDirty = true; - bool _textColorIsDirty = true; bool _hasSpriteTexture = false; bool _spriteTextureIsDirty = true; bool _hasColorMapFile = false; bool _isColorMapExact = false; bool _hasDatavarSize = false; bool _hasPolygon = false; - bool _hasLabel = false; + bool _hasLabels = false; int _polygonSides = 0; @@ -101,10 +97,6 @@ private: properties::BoolProperty _useColorMap; properties::Vec3Property _pointColor; properties::StringProperty _spriteTexturePath; - properties::Vec3Property _textColor; - properties::FloatProperty _textOpacity; - properties::FloatProperty _textSize; - properties::IVec2Property _textMinMaxSize; properties::BoolProperty _drawElements; properties::BoolProperty _drawLabels; properties::BoolProperty _pixelSizeControl; @@ -133,20 +125,19 @@ private: hasDvarScaling ) _uniformCache; - std::shared_ptr _font; - std::string _speckFile; std::string _colorMapFile; - std::string _labelFile; std::string _colorOptionString; std::string _datavarSizeOptionString; DistanceUnit _unit = DistanceUnit::Parsec; speck::Dataset _dataset; - speck::Labelset _labelset; speck::ColorMap _colorMap; + // Everything related to the labels is handled by LabelsComponent + std::unique_ptr _labels; + std::vector _colorRangeData; std::unordered_map _optionConversionMap; std::unordered_map _optionConversionSizeMap; diff --git a/modules/digitaluniverse/rendering/renderableplanescloud.cpp b/modules/digitaluniverse/rendering/renderableplanescloud.cpp index 390a9d9733..82232f1773 100644 --- a/modules/digitaluniverse/rendering/renderableplanescloud.cpp +++ b/modules/digitaluniverse/rendering/renderableplanescloud.cpp @@ -31,8 +31,6 @@ #include #include #include -#include -#include #include #include #include @@ -67,44 +65,11 @@ namespace { "size of each point" }; - constexpr openspace::properties::Property::PropertyInfo TextColorInfo = { - "TextColor", - "Text Color", - "The text color for the astronomical object" - }; - - constexpr openspace::properties::Property::PropertyInfo TextOpacityInfo = { - "TextOpacity", - "Text Opacity", - "Determines the transparency of the text label, where 1 is completely opaque " - "and 0 fully transparent" - }; - - constexpr openspace::properties::Property::PropertyInfo TextSizeInfo = { - "TextSize", - "Text Size", - "The text size for the astronomical object labels" - }; - - constexpr openspace::properties::Property::PropertyInfo LabelFileInfo = { - "LabelFile", - "Label File", - "The path to the label file that contains information about the astronomical " - "objects being rendered" - }; - - constexpr openspace::properties::Property::PropertyInfo LabelMinSizeInfo = { - "TextMinSize", - "Text Min Size", - "The minimal size (in pixels) of the text for the labels for the astronomical " - "objects being rendered" - }; - - constexpr openspace::properties::Property::PropertyInfo LabelMaxSizeInfo = { - "TextMaxSize", - "Text Max Size", - "The maximum size (in pixels) of the text for the labels for the astronomical " - "objects being rendered" + static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo = + { + "Labels", + "Labels", + "The labels for the astronomical objects" }; constexpr openspace::properties::Property::PropertyInfo DrawElementsInfo = { @@ -176,23 +141,9 @@ namespace { // [[codegen::verbatim(ScaleFactorInfo.description)]] std::optional scaleFactor; - // [[codegen::verbatim(TextColorInfo.description)]] - std::optional textColor [[codegen::color()]]; - - // [[codegen::verbatim(TextOpacityInfo.description)]] - std::optional textOpacity; - - // [[codegen::verbatim(TextSizeInfo.description)]] - std::optional textSize; - - // [[codegen::verbatim(LabelFileInfo.description)]] - std::optional labelFile; - - // [[codegen::verbatim(LabelMinSizeInfo.description)]] - std::optional textMinSize; - - // [[codegen::verbatim(LabelMaxSizeInfo.description)]] - std::optional textMaxSize; + // [[codegen::verbatim(LabelsInfo.description)]] + std::optional labels + [[codegen::reference("space_labelscomponent")]]; // [[codegen::verbatim(TransformationMatrixInfo.description)]] std::optional transformationMatrix; @@ -246,9 +197,6 @@ documentation::Documentation RenderablePlanesCloud::Documentation() { RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _scaleFactor(ScaleFactorInfo, 1.f, 0.f, 300000.f) - , _textColor(TextColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) - , _textOpacity(TextOpacityInfo, 1.f, 0.f, 1.f) - , _textSize(TextSizeInfo, 8.0, 0.5, 24.0) , _drawElements(DrawElementsInfo, true) , _blendMode(BlendModeInfo, properties::OptionProperty::DisplayType::Dropdown) , _fadeInDistances( @@ -290,23 +238,10 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary addProperty(_scaleFactor); _scaleFactor.onChange([&]() { _dataIsDirty = true; }); - if (p.labelFile.has_value()) { - _labelFile = absPath(*p.labelFile); - _hasLabel = true; - - _textColor = p.textColor.value_or(_textColor); - _textColor.setViewOption(properties::Property::ViewOptions::Color); - addProperty(_textColor); - _textColor.onChange([&]() { _textColorIsDirty = true; }); - - _textOpacity = p.textOpacity.value_or(_textOpacity); - addProperty(_textOpacity); - - _textSize = p.textSize.value_or(_textSize); - addProperty(_textSize); - - _textMinSize = p.textMinSize.value_or(_textMinSize); - _textMaxSize = p.textMaxSize.value_or(_textMaxSize); + if (p.labels.has_value()) { + _labels = std::make_unique(*p.labels); + _hasLabels = true; + addPropertySubOwner(_labels.get()); } _transformationMatrix = p.transformationMatrix.value_or(_transformationMatrix); @@ -360,7 +295,13 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary } bool RenderablePlanesCloud::isReady() const { - return (_program && (!_dataset.entries.empty())) || (!_labelset.entries.empty()); + bool isReady = _program && !_dataset.entries.empty(); + + // If we have labels, they also need to be loaded + if (_hasLabels) { + isReady = isReady || _labels->isReady(); + } + return isReady; } void RenderablePlanesCloud::initialize() { @@ -373,12 +314,9 @@ void RenderablePlanesCloud::initialize() { } } - if (!_labelFile.empty()) { - LINFO(fmt::format("Loading Label file {}", _labelFile)); - _labelset = speck::label::loadFileWithCache(_labelFile); - for (speck::Labelset::Entry& e : _labelset.entries) { - e.position = glm::vec3(_transformationMatrix * glm::dvec4(e.position, 1.0)); - } + if (_hasLabels) { + _labels->initialize(); + _labels->loadLabels(); } } @@ -400,18 +338,6 @@ void RenderablePlanesCloud::initializeGL() { createPlanes(); loadTextures(); - - if (_hasLabel) { - if (!_font) { - constexpr int FontSize = 30; - _font = global::fontManager->font( - "Mono", - static_cast(FontSize), - ghoul::fontrendering::FontManager::Outline::Yes, - ghoul::fontrendering::FontManager::LoadGlyphs::No - ); - } - } } void RenderablePlanesCloud::deleteDataGPUAndCPU() { @@ -488,39 +414,6 @@ void RenderablePlanesCloud::renderPlanes(const RenderData&, global::renderEngine->openglStateCache().resetPolygonAndClippingState(); } -void RenderablePlanesCloud::renderLabels(const RenderData& data, - const glm::dmat4& modelViewProjectionMatrix, - const glm::dvec3& orthoRight, - const glm::dvec3& orthoUp, float fadeInVariable) -{ - double scale = toMeter(_unit); - glm::vec4 textColor = glm::vec4(glm::vec3(_textColor), _textOpacity * fadeInVariable); - - ghoul::fontrendering::FontRenderer::ProjectedLabelsInformation labelInfo; - labelInfo.orthoRight = orthoRight; - labelInfo.orthoUp = orthoUp; - labelInfo.minSize = _textMinSize; - labelInfo.maxSize = _textMaxSize; - labelInfo.cameraPos = data.camera.positionVec3(); - labelInfo.cameraLookUp = data.camera.lookUpVectorWorldSpace(); - labelInfo.renderType = _renderOption; - labelInfo.mvpMatrix = modelViewProjectionMatrix; - labelInfo.scale = pow(10.f, _textSize); - labelInfo.enableDepth = true; - labelInfo.enableFalseDepth = false; - - for (const speck::Labelset::Entry& e : _labelset.entries) { - glm::dvec3 scaledPos = glm::dvec3(e.position) * scale; - ghoul::fontrendering::FontRenderer::defaultProjectionRenderer().render( - *_font, - scaledPos, - e.text, - textColor, - labelInfo - ); - } -} - void RenderablePlanesCloud::render(const RenderData& data, RendererTasks&) { const double scale = toMeter(_unit); @@ -547,24 +440,25 @@ void RenderablePlanesCloud::render(const RenderData& data, RendererTasks&) { const glm::dmat4 modelViewMatrix = data.camera.combinedViewMatrix() * modelMatrix; const glm::mat4 projectionMatrix = data.camera.projectionMatrix(); - const glm::dmat4 mvpMatrix = glm::dmat4(projectionMatrix) * modelViewMatrix; - - const glm::dmat4 invMVPParts = glm::inverse(modelMatrix) * - glm::inverse(data.camera.combinedViewMatrix()) * - glm::inverse(glm::dmat4(projectionMatrix)); - const glm::dvec3 orthoRight = glm::normalize( - glm::dvec3(invMVPParts * glm::dvec4(1.0, 0.0, 0.0, 0.0)) - ); - const glm::dvec3 orthoUp = glm::normalize( - glm::dvec3(invMVPParts * glm::dvec4(0.0, 1.0, 0.0, 0.0)) - ); if (_hasSpeckFile) { renderPlanes(data, modelViewMatrix, projectionMatrix, fadeInVariable); } - if (_hasLabel) { - renderLabels(data, mvpMatrix, orthoRight, orthoUp, fadeInVariable); + if (_hasLabels) { + const glm::dmat4 mvpMatrix = glm::dmat4(projectionMatrix) * modelViewMatrix; + + const glm::dmat4 invMVPParts = glm::inverse(modelMatrix) * + glm::inverse(data.camera.combinedViewMatrix()) * + glm::inverse(glm::dmat4(projectionMatrix)); + const glm::dvec3 orthoRight = glm::normalize( + glm::dvec3(invMVPParts * glm::dvec4(1.0, 0.0, 0.0, 0.0)) + ); + const glm::dvec3 orthoUp = glm::normalize( + glm::dvec3(invMVPParts * glm::dvec4(0.0, 1.0, 0.0, 0.0)) + ); + + _labels->render(data, mvpMatrix, orthoRight, orthoUp, fadeInVariable); } } @@ -753,10 +647,6 @@ void RenderablePlanesCloud::createPlanes() { setBoundingSphere(maxRadius * _scaleFactor); _fadeInDistances.setMaxValue(glm::vec2(10.f * maxSize)); } - - if (_hasLabel && _labelDataIsDirty) { - _labelDataIsDirty = false; - } } } // namespace openspace diff --git a/modules/digitaluniverse/rendering/renderableplanescloud.h b/modules/digitaluniverse/rendering/renderableplanescloud.h index d155556251..417caa81bb 100644 --- a/modules/digitaluniverse/rendering/renderableplanescloud.h +++ b/modules/digitaluniverse/rendering/renderableplanescloud.h @@ -27,7 +27,7 @@ #include -#include +#include #include #include #include @@ -42,7 +42,6 @@ #include namespace ghoul::filesystem { class File; } -namespace ghoul::fontrendering { class Font; } namespace ghoul::opengl { class ProgramObject; class Texture; @@ -83,25 +82,15 @@ private: void createPlanes(); void renderPlanes(const RenderData& data, const glm::dmat4& modelViewMatrix, const glm::dmat4& projectionMatrix, float fadeInVariable); - void renderLabels(const RenderData& data, - const glm::dmat4& modelViewProjectionMatrix, const glm::dvec3& orthoRight, - const glm::dvec3& orthoUp, float fadeInVariable); void loadTextures(); bool _hasSpeckFile = false; bool _dataIsDirty = true; bool _textColorIsDirty = true; - bool _hasLabel = false; - bool _labelDataIsDirty = true; - - int _textMinSize = 0; - int _textMaxSize = 200; + bool _hasLabels = false; properties::FloatProperty _scaleFactor; - properties::Vec3Property _textColor; - properties::FloatProperty _textOpacity; - properties::FloatProperty _textSize; properties::BoolProperty _drawElements; properties::OptionProperty _blendMode; properties::Vec2Property _fadeInDistances; @@ -113,20 +102,20 @@ private: UniformCache( modelViewProjectionTransform, alphaValue, fadeInValue, galaxyTexture ) _uniformCache; - std::shared_ptr _font = nullptr; std::unordered_map> _textureMap; std::unordered_map _textureFileMap; std::unordered_map _planesMap; std::filesystem::path _speckFile; - std::filesystem::path _labelFile; std::filesystem::path _texturesPath; std::string _luminosityVar; DistanceUnit _unit = DistanceUnit::Parsec; speck::Dataset _dataset; - speck::Labelset _labelset; + + // Everything related to the labels is handled by LabelsComponent + std::unique_ptr _labels; float _sluminosity = 1.f; diff --git a/modules/exoplanets/exoplanetsmodule_lua.inl b/modules/exoplanets/exoplanetsmodule_lua.inl index bb1fde8d1a..61e9604eed 100644 --- a/modules/exoplanets/exoplanetsmodule_lua.inl +++ b/modules/exoplanets/exoplanetsmodule_lua.inl @@ -22,6 +22,10 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ +#include +#include +#include + namespace { constexpr std::string_view _loggerCat = "ExoplanetsModule"; diff --git a/modules/globebrowsing/CMakeLists.txt b/modules/globebrowsing/CMakeLists.txt index 3c8b3cd8b3..e5624ee444 100644 --- a/modules/globebrowsing/CMakeLists.txt +++ b/modules/globebrowsing/CMakeLists.txt @@ -198,9 +198,11 @@ endif () # WIN32 install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/gdal_data DESTINATION modules/globebrowsing) if (WIN32) - target_include_directories(openspace-module-globebrowsing SYSTEM PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/ext/gdal/include) - target_link_libraries(openspace-module-globebrowsing PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/ext/gdal/lib/gdal_i.lib) - register_external_libraries("${CMAKE_CURRENT_SOURCE_DIR}/ext/gdal/lib/gdal241.dll") + add_library(gdal SHARED IMPORTED) + target_include_directories(gdal SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/ext/gdal/include) + set_target_properties(gdal PROPERTIES IMPORTED_IMPLIB ${CMAKE_CURRENT_SOURCE_DIR}/ext/gdal/lib/gdal_i.lib) + set_target_properties(gdal PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/ext/gdal/lib/gdal241.dll) + target_link_libraries(openspace-module-globebrowsing PRIVATE gdal) else (WIN32) find_package(GDAL REQUIRED) diff --git a/modules/globebrowsing/shaders/renderer_fs.glsl b/modules/globebrowsing/shaders/renderer_fs.glsl index a066251c90..63a81341f5 100644 --- a/modules/globebrowsing/shaders/renderer_fs.glsl +++ b/modules/globebrowsing/shaders/renderer_fs.glsl @@ -55,6 +55,7 @@ uniform vec3 lightDirectionCameraSpace; #if PERFORM_SHADING uniform float orenNayarRoughness; +uniform float ambientIntensity; #endif // PERFORM_SHADING #if SHADOW_MAPPING_ENABLED @@ -205,7 +206,8 @@ Fragment getFragment() { normal, lightDirectionCameraSpace, normalize(positionCameraSpace), - orenNayarRoughness + orenNayarRoughness, + ambientIntensity ); #endif // PERFORM_SHADING diff --git a/modules/globebrowsing/shaders/texturetilemapping.glsl b/modules/globebrowsing/shaders/texturetilemapping.glsl index f6c23bf9eb..43ed4fde28 100644 --- a/modules/globebrowsing/shaders/texturetilemapping.glsl +++ b/modules/globebrowsing/shaders/texturetilemapping.glsl @@ -376,9 +376,9 @@ vec4 calculateNight(vec4 currentColor, vec2 uv, vec3 levelWeights, vec4 calculateShadedColor(vec4 currentColor, vec3 ellipsoidNormalCameraSpace, vec3 lightDirectionCameraSpace, vec3 viewDirectionCameraSpace, - float roughness) + float roughness, float ambientIntensity) { - vec3 shadedColor = currentColor.rgb * 0.05; + vec3 shadedColor = currentColor.rgb * ambientIntensity; vec3 n = normalize(ellipsoidNormalCameraSpace); diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index 99fd66efb2..2144d8739c 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -222,6 +222,12 @@ namespace { "The roughness factor that is used for the Oren-Nayar lighting mode" }; + constexpr openspace::properties::Property::PropertyInfo AmbientIntensityInfo = { + "AmbientIntensity", + "Ambient Intensity", + "The intensity factor for the ambient light used for light shading" + }; + constexpr openspace::properties::Property::PropertyInfo NActiveLayersInfo = { "NActiveLayers", "Number of active layers", @@ -524,6 +530,7 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) FloatProperty(TargetLodScaleFactorInfo, 15.f, 1.f, 50.f), FloatProperty(CurrentLodScaleFactorInfo, 15.f, 1.f, 50.f), FloatProperty(OrenNayarRoughnessInfo, 0.f, 0.f, 1.f), + FloatProperty(AmbientIntensityInfo, 0.05f, 0.f, 1.f), IntProperty(NActiveLayersInfo, 0, 0, OpenGLCap.maxTextureUnits() / 3) }) , _debugPropertyOwner({ "Debug" }) @@ -607,6 +614,7 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) addProperty(_generalProperties.targetLodScaleFactor); addProperty(_generalProperties.currentLodScaleFactor); addProperty(_generalProperties.orenNayarRoughness); + addProperty(_generalProperties.ambientIntensity); _generalProperties.nActiveLayers.setReadOnly(true); addProperty(_generalProperties.nActiveLayers); @@ -964,6 +972,10 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, const float onr = _generalProperties.orenNayarRoughness; _localRenderer.program->setUniform("orenNayarRoughness", onr); _globalRenderer.program->setUniform("orenNayarRoughness", onr); + + const float amb = _generalProperties.ambientIntensity; + _localRenderer.program->setUniform("ambientIntensity", amb); + _globalRenderer.program->setUniform("ambientIntensity", amb); } _localRenderer.program->setUniform("opacity", opacity()); diff --git a/modules/globebrowsing/src/renderableglobe.h b/modules/globebrowsing/src/renderableglobe.h index e25ecae39d..409b9a7441 100644 --- a/modules/globebrowsing/src/renderableglobe.h +++ b/modules/globebrowsing/src/renderableglobe.h @@ -141,6 +141,7 @@ private: properties::FloatProperty targetLodScaleFactor; properties::FloatProperty currentLodScaleFactor; properties::FloatProperty orenNayarRoughness; + properties::FloatProperty ambientIntensity; properties::IntProperty nActiveLayers; } _generalProperties; diff --git a/modules/space/CMakeLists.txt b/modules/space/CMakeLists.txt index 5beecefda0..73673fffd0 100644 --- a/modules/space/CMakeLists.txt +++ b/modules/space/CMakeLists.txt @@ -27,6 +27,7 @@ include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) set(HEADER_FILES horizonsfile.h kepler.h + labelscomponent.h speckloader.h rendering/renderableconstellationsbase.h rendering/renderableconstellationbounds.h @@ -49,6 +50,7 @@ set(SOURCE_FILES horizonsfile.cpp kepler.cpp spacemodule_lua.inl + labelscomponent.cpp speckloader.cpp rendering/renderableconstellationsbase.cpp rendering/renderableconstellationbounds.cpp diff --git a/modules/space/kepler.cpp b/modules/space/kepler.cpp index 32b2c67769..08a75b267b 100644 --- a/modules/space/kepler.cpp +++ b/modules/space/kepler.cpp @@ -499,7 +499,7 @@ std::vector readOmmFile(std::filesystem::path file) { std::optional current = std::nullopt; std::string line; while (std::getline(f, line)) { - if (line.empty()) { + if (line.empty() || line == "\r") { continue; } diff --git a/modules/space/labelscomponent.cpp b/modules/space/labelscomponent.cpp new file mode 100644 index 0000000000..5d6a6572d6 --- /dev/null +++ b/modules/space/labelscomponent.cpp @@ -0,0 +1,258 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + constexpr std::string_view _loggerCat = "LabelsComponent"; + + constexpr int RenderOptionFaceCamera = 0; + constexpr int RenderOptionPositionNormal = 1; + + constexpr openspace::properties::Property::PropertyInfo FileInfo = { + "File", + "File", + "The speck label file with tha data for the labels" + }; + + constexpr openspace::properties::Property::PropertyInfo UnitInfo = { + "Unit", + "Unit", + "Distance unit for the label data" + }; + + constexpr openspace::properties::Property::PropertyInfo OpacityInfo = { + "Opacity", + "Opacity", + "Determines the transparency of the labels, where 1 is completely opaque " + "and 0 fully transparent" + }; + + constexpr openspace::properties::Property::PropertyInfo ColorInfo = { + "Color", + "Color", + "The color of the labels" + }; + + constexpr openspace::properties::Property::PropertyInfo SizeInfo = { + "Size", + "Size", + "The size of the labels in pixels" + }; + + constexpr openspace::properties::Property::PropertyInfo FontSizeInfo = { + "FontSize", + "Font Size", + "Font size for the labels. This is different from the text size" + }; + + constexpr openspace::properties::Property::PropertyInfo MinMaxInfo = { + "MinMaxSize", + "Min/Max Size", + "The minimum and maximum size (in pixels) of the labels" + }; + + constexpr openspace::properties::Property::PropertyInfo FaceCameraInfo = { + "FaceCamera", + "Face Camera", + "If enabled, the labels will be rotated to face the camera. " + "For non-linear display rendering (for example fisheye) this should be set to " + "false." + }; + + struct [[codegen::Dictionary(LabelsComponent)]] Parameters { + // [[codegen::verbatim(FileInfo.description)]] + std::filesystem::path file; + + // [[codegen::verbatim(OpacityInfo.description)]] + std::optional opacity [[codegen::inrange(0.0, 1.0)]]; + + // [[codegen::verbatim(ColorInfo.description)]] + std::optional color [[codegen::color()]]; + + // [[codegen::verbatim(SizeInfo.description)]] + std::optional size; + + // [[codegen::verbatim(FontSizeInfo.description)]] + std::optional fontSize; + + // [[codegen::verbatim(MinMaxInfo.description)]] + std::optional minMaxSize; + + enum class [[codegen::map(openspace::DistanceUnit)]] Unit { + Meter [[codegen::key("m")]], + Kilometer [[codegen::key("Km")]], + Parsec [[codegen::key("pc")]], + Kiloparsec [[codegen::key("Kpc")]], + Megaparsec [[codegen::key("Mpc")]], + Gigaparsec [[codegen::key("Gpc")]], + Gigalightyear [[codegen::key("Gly")]] + }; + std::optional unit; + + // [[codegen::verbatim(FaceCameraInfo.description)]] + std::optional faceCamera; + }; +#include "labelscomponent_codegen.cpp" +} // namespace + +namespace openspace { + +documentation::Documentation LabelsComponent::Documentation() { + return codegen::doc("space_labelscomponent"); +} + +LabelsComponent::LabelsComponent(const ghoul::Dictionary& dictionary) + : properties::PropertyOwner({ "Labels" }) + , _opacity(OpacityInfo, 1.f, 0.f, 1.f) + , _color(ColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) + , _size(SizeInfo, 8.f, 0.5f, 24.f) + , _fontSize(FontSizeInfo, 50.f, 1.f, 300.f) + , _minMaxSize( + MinMaxInfo, + glm::ivec2(8, 500), + glm::ivec2(0), + glm::ivec2(1000) + ) + , _faceCamera(FaceCameraInfo, true) +{ + const Parameters p = codegen::bake(dictionary); + + _labelFile = absPath(p.file); + + if (p.unit.has_value()) { + _unit = codegen::map(*p.unit); + } + else { + _unit = DistanceUnit::Meter; + } + + _opacity = p.opacity.value_or(_opacity); + addProperty(_opacity); + + _color = p.color.value_or(_color); + _color.setViewOption(properties::Property::ViewOptions::Color); + addProperty(_color); + + _size = p.size.value_or(_size); + addProperty(_size); + + _fontSize = p.fontSize.value_or(_fontSize); + _fontSize.onChange([this]() { initialize(); }); + addProperty(_fontSize); + // @TODO (emmbr, 2021-05-31): Temporarily set as read only, to avoid errors from font + // rendering (avoid filling font atlas) + _fontSize.setReadOnly(true); + + _minMaxSize = p.minMaxSize.value_or(_minMaxSize); + _minMaxSize.setViewOption(properties::Property::ViewOptions::MinMaxRange); + addProperty(_minMaxSize); + + if (p.faceCamera.has_value()) { + _faceCamera = *p.faceCamera; + } + else { + // @TODO (abock. 2021-01-31) In the other DU classes, this is done with an enum, and + // doing it based on the fisheye rendering seems a bit brittle? + + // (malej 2022-SEP-14) + // For non-linear display rendering (for example fisheye) _faceCamera should be false, + // otherwise true. + _faceCamera = !global::windowDelegate->isFisheyeRendering(); + } + addProperty(_faceCamera); +} + +speck::Labelset& LabelsComponent::labelSet() { + return _labelset; +} + +const speck::Labelset& LabelsComponent::labelSet() const { + return _labelset; +} + +void LabelsComponent::initialize() { + _font = global::fontManager->font( + "Mono", + _fontSize, + ghoul::fontrendering::FontManager::Outline::Yes, + ghoul::fontrendering::FontManager::LoadGlyphs::No + ); +} + +void LabelsComponent::loadLabels() { + LINFO(fmt::format("Loading label file {}", _labelFile)); + _labelset = speck::label::loadFileWithCache(_labelFile); +} + +bool LabelsComponent::isReady() const { + return !(_labelset.entries.empty()); +} + +void LabelsComponent::render(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix, + const glm::vec3& orthoRight, const glm::vec3& orthoUp, + float fadeInVariable) +{ + float scale = static_cast(toMeter(_unit)); + + int renderOption = _faceCamera ? RenderOptionFaceCamera : RenderOptionPositionNormal; + + ghoul::fontrendering::FontRenderer::ProjectedLabelsInformation labelInfo; + labelInfo.orthoRight = orthoRight; + labelInfo.orthoUp = orthoUp; + labelInfo.minSize = _minMaxSize.value().x; + labelInfo.maxSize = _minMaxSize.value().y; + labelInfo.cameraPos = data.camera.positionVec3(); + labelInfo.cameraLookUp = data.camera.lookUpVectorWorldSpace(); + labelInfo.renderType = renderOption; + labelInfo.mvpMatrix = modelViewProjectionMatrix; + labelInfo.scale = pow(10.f, _size); + labelInfo.enableDepth = true; + labelInfo.enableFalseDepth = false; + + glm::vec4 textColor = glm::vec4(glm::vec3(_color), _opacity * fadeInVariable); + + for (const speck::Labelset::Entry& e : _labelset.entries) { + glm::vec3 scaledPos(e.position); + scaledPos *= scale; + ghoul::fontrendering::FontRenderer::defaultProjectionRenderer().render( + *_font, + scaledPos, + e.text, + textColor, + labelInfo + ); + } +} + +} // namespace openspace diff --git a/modules/space/labelscomponent.h b/modules/space/labelscomponent.h new file mode 100644 index 0000000000..88443b570c --- /dev/null +++ b/modules/space/labelscomponent.h @@ -0,0 +1,84 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2022 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __OPENSPACE_MODULE_SPACE___LABELSCOMPONENT___H__ +#define __OPENSPACE_MODULE_SPACE___LABELSCOMPONENT___H__ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace ghoul::fontrendering { class Font; } + +namespace openspace { +struct RenderData; + +namespace documentation { struct Documentation; } + +class LabelsComponent : public properties::PropertyOwner { +public: + explicit LabelsComponent(const ghoul::Dictionary& dictionary); + ~LabelsComponent() override = default; + + speck::Labelset& labelSet(); + const speck::Labelset& labelSet() const; + + void initialize(); + + void loadLabels(); + + bool isReady() const; + + void render(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix, + const glm::vec3& orthoRight, const glm::vec3& orthoUp, + float fadeInVariable = 1.f); + + static documentation::Documentation Documentation(); + +private: + std::filesystem::path _labelFile; + DistanceUnit _unit = DistanceUnit::Parsec; + speck::Labelset _labelset; + + std::shared_ptr _font = nullptr; + + // Properties + properties::FloatProperty _opacity; + properties::Vec3Property _color; + properties::FloatProperty _size; + properties::FloatProperty _fontSize; + properties::IVec2Property _minMaxSize; + properties::BoolProperty _faceCamera; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_SPACE___LABELSCOMPONENT___H__ diff --git a/modules/space/rendering/renderableconstellationbounds.cpp b/modules/space/rendering/renderableconstellationbounds.cpp index db292afaab..e9e6890719 100644 --- a/modules/space/rendering/renderableconstellationbounds.cpp +++ b/modules/space/rendering/renderableconstellationbounds.cpp @@ -157,8 +157,8 @@ bool RenderableConstellationBounds::isReady() const { bool isReady = _program && _vao != 0 && _vbo != 0; // If we have labels, they also need to be loaded - if (_hasLabel) { - return isReady && !_labelset.entries.empty(); + if (_hasLabels) { + isReady = isReady && RenderableConstellationsBase::isReady(); } return isReady; } diff --git a/modules/space/rendering/renderableconstellationlines.cpp b/modules/space/rendering/renderableconstellationlines.cpp index a0c6a1a23d..8ed5943dbf 100644 --- a/modules/space/rendering/renderableconstellationlines.cpp +++ b/modules/space/rendering/renderableconstellationlines.cpp @@ -59,9 +59,9 @@ namespace { "Enables/Disables the drawing of the constellations" }; - constexpr openspace::properties::Property::PropertyInfo LineUnitInfo = { - "LineUnit", - "Line Unit", + constexpr openspace::properties::Property::PropertyInfo UnitInfo = { + "Unit", + "Unit", "The distance unit used for the constellation lines data" }; @@ -85,8 +85,8 @@ namespace { Gigaparsec [[codegen::key("Gpc")]], Gigalightyear [[codegen::key("Gly")]] }; - // [[codegen::verbatim(LineUnitInfo.description)]] - std::optional lineUnit; + // [[codegen::verbatim(UnitInfo.description)]] + std::optional unit; // [[codegen::verbatim(ColorsInfo.description)]] std::optional> colors; @@ -115,8 +115,8 @@ RenderableConstellationLines::RenderableConstellationLines( addProperty(_drawElements); - if (p.lineUnit.has_value()) { - _constellationUnit = codegen::map(*p.lineUnit); + if (p.unit.has_value()) { + _constellationUnit = codegen::map(*p.unit); } else { _constellationUnit = DistanceUnit::Meter; @@ -153,8 +153,8 @@ bool RenderableConstellationLines::isReady() const { bool isReady = _program && !_renderingConstellationsMap.empty(); // If we have labels, they also need to be loaded - if (_hasLabel) { - return isReady && !_labelset.entries.empty(); + if (_hasLabels) { + return isReady && RenderableConstellationsBase::isReady(); } return isReady; } diff --git a/modules/space/rendering/renderableconstellationsbase.cpp b/modules/space/rendering/renderableconstellationsbase.cpp index 6d6ca5d06b..bb8ca8f7c1 100644 --- a/modules/space/rendering/renderableconstellationsbase.cpp +++ b/modules/space/rendering/renderableconstellationsbase.cpp @@ -30,8 +30,6 @@ #include #include #include -#include -#include #include #include #include @@ -39,41 +37,6 @@ #include namespace { - constexpr int RenderOptionViewDirection = 0; - constexpr int RenderOptionPositionNormal = 1; - - constexpr openspace::properties::Property::PropertyInfo TextColorInfo = { - "TextColor", - "Text Color", - "The text color of the labels for the constellations" - }; - - constexpr openspace::properties::Property::PropertyInfo TextOpacityInfo = { - "TextOpacity", - "Text Opacity", - "Determines the transparency of the text label, where 1 is completely opaque " - "and 0 fully transparent" - }; - - constexpr openspace::properties::Property::PropertyInfo TextSizeInfo = { - "TextSize", - "Text Size", - "The text size of the labels for the constellations" - }; - - constexpr openspace::properties::Property::PropertyInfo LabelFileInfo = { - "LabelFile", - "Label File", - "The path to the label file that contains information about the constellations" - }; - - constexpr openspace::properties::Property::PropertyInfo LabelMinMaxSizeInfo = { - "TextMinMaxSize", - "Text Min/Max Size", - "The minimum and maximum size (in pixels) for the text of the labels for the " - "constellations" - }; - constexpr openspace::properties::Property::PropertyInfo NamesFileInfo = { "NamesFile", "Constellation Names File Path", @@ -94,24 +57,19 @@ namespace { "Determines whether labels should be drawn or hidden" }; - constexpr openspace::properties::Property::PropertyInfo RenderOptionInfo = { - "RenderOption", - "Render Option", - "Debug option for rendering of billboards and texts" - }; - - constexpr openspace::properties::Property::PropertyInfo LabelUnitInfo = { - "LabelUnit", - "Label Unit", - "The unit used for the label data" - }; - constexpr openspace::properties::Property::PropertyInfo SelectionInfo = { "ConstellationSelection", "Constellation Selection", "The constellations that are selected are displayed on the celestial sphere" }; + static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo = + { + "Labels", + "Labels", + "The labels for the constellations" + }; + struct [[codegen::Dictionary(RenderableConstellationsBase)]] Parameters { // [[codegen::verbatim(DrawLabelInfo.description)]] std::optional drawLabels; @@ -119,38 +77,15 @@ namespace { // [[codegen::verbatim(NamesFileInfo.description)]] std::optional namesFile; - // [[codegen::verbatim(TextColorInfo.description)]] - std::optional textColor [[codegen::color()]]; - - // [[codegen::verbatim(TextOpacityInfo.description)]] - std::optional textOpacity; - - // [[codegen::verbatim(TextSizeInfo.description)]] - std::optional textSize; - - // [[codegen::verbatim(LabelFileInfo.description)]] - std::optional labelFile; - - // [[codegen::verbatim(LabelMinMaxSizeInfo.description)]] - std::optional textMinMaxSize; - // [[codegen::verbatim(LineWidthInfo.description)]] std::optional lineWidth; - enum class [[codegen::map(openspace::DistanceUnit)]] Unit { - Meter [[codegen::key("m")]], - Kilometer [[codegen::key("Km")]], - Parsec [[codegen::key("pc")]], - Kiloparsec [[codegen::key("Kpc")]], - Megaparsec [[codegen::key("Mpc")]], - Gigaparsec [[codegen::key("Gpc")]], - Gigalightyear [[codegen::key("Gly")]] - }; - // [[codegen::verbatim(LabelUnitInfo.description)]] - std::optional labelUnit; - // [[codegen::verbatim(SelectionInfo.description)]] std::optional> selection; + + // [[codegen::verbatim(LabelsInfo.description)]] + std::optional labels + [[codegen::reference("space_labelscomponent")]]; }; #include "renderableconstellationsbase_codegen.cpp" } // namespace @@ -163,18 +98,8 @@ documentation::Documentation RenderableConstellationsBase::Documentation() { RenderableConstellationsBase::RenderableConstellationsBase(const ghoul::Dictionary& dictionary) : Renderable(dictionary) - , _textColor(TextColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) - , _textOpacity(TextOpacityInfo, 1.f, 0.f, 1.f) - , _textSize(TextSizeInfo, 8.f, 0.5f, 24.f) , _drawLabels(DrawLabelInfo, false) - , _textMinMaxSize( - LabelMinMaxSizeInfo, - glm::ivec2(8, 500), - glm::ivec2(0), - glm::ivec2(1000) - ) , _lineWidth(LineWidthInfo, 2.f, 1.f, 16.f) - , _renderOption(RenderOptionInfo, properties::OptionProperty::DisplayType::Dropdown) , _namesFilename(NamesFileInfo) , _selection(SelectionInfo) { @@ -183,18 +108,6 @@ RenderableConstellationsBase::RenderableConstellationsBase(const ghoul::Dictiona addProperty(_opacity); registerUpdateRenderBinFromOpacity(); - _renderOption.addOption(RenderOptionViewDirection, "Camera View Direction"); - _renderOption.addOption(RenderOptionPositionNormal, "Camera Position Normal"); - // @TODO (abock. 2021-01-31) In the other classes, this is done with an enum, and - // doing it based on the fisheye rendering seems a bit brittle? - if (global::windowDelegate->isFisheyeRendering()) { - _renderOption = RenderOptionPositionNormal; - } - else { - _renderOption = RenderOptionViewDirection; - } - addProperty(_renderOption); - // Avoid reading files here, instead do it in multithreaded initialize() if (p.namesFile.has_value()) { _namesFilename = absPath(p.namesFile.value().string()).string(); @@ -205,34 +118,13 @@ RenderableConstellationsBase::RenderableConstellationsBase(const ghoul::Dictiona _lineWidth = p.lineWidth.value_or(_lineWidth); addProperty(_lineWidth); - if (p.labelFile.has_value()) { - _labelFile = absPath(*p.labelFile).string(); - _hasLabel = true; - + if (p.labels.has_value()) { _drawLabels = p.drawLabels.value_or(_drawLabels); addProperty(_drawLabels); - _textColor = p.textColor.value_or(_textColor); - _hasLabel = p.textColor.has_value(); - _textColor.setViewOption(properties::Property::ViewOptions::Color); - addProperty(_textColor); - - _textOpacity = p.textOpacity.value_or(_textOpacity); - addProperty(_textOpacity); - - _textSize = p.textSize.value_or(_textSize); - addProperty(_textSize); - - _textMinMaxSize = p.textMinMaxSize.value_or(_textMinMaxSize); - _textMinMaxSize.setViewOption(properties::Property::ViewOptions::MinMaxRange); - addProperty(_textMinMaxSize); - - if (p.labelUnit.has_value()) { - _labelUnit = codegen::map(*p.labelUnit); - } - else { - _labelUnit = DistanceUnit::Meter; - } + _labels = std::make_unique(*p.labels); + _hasLabels = true; + addPropertySubOwner(_labels.get()); } _selection.onChange([this]() { selectionPropertyHasChanged(); }); @@ -270,6 +162,7 @@ void RenderableConstellationsBase::loadConstellationFile() { _selection.clearOptions(); _namesTranslation.clear(); + // Load the constellation names file std::ifstream file; file.exceptions(std::ifstream::goodbit); file.open(absPath(_namesFilename)); @@ -303,26 +196,14 @@ void RenderableConstellationsBase::fillSelectionProperty() { void RenderableConstellationsBase::initialize() { loadConstellationFile(); - if (!_hasLabel) { + if (!_hasLabels) { return; } - if (!_font) { - constexpr int FontSize = 50; - _font = global::fontManager->font( - "Mono", - static_cast(FontSize), - ghoul::fontrendering::FontManager::Outline::Yes, - ghoul::fontrendering::FontManager::LoadGlyphs::No - ); - } + _labels->initialize(); + _labels->loadLabels(); - std::string labelFile = _labelFile; - if (!labelFile.empty()) { - _labelset = speck::label::loadFileWithCache(_labelFile); - } - - for (speck::Labelset::Entry& entry : _labelset.entries) { + for (speck::Labelset::Entry& entry : _labels->labelSet().entries) { if (!entry.identifier.empty()) { std::string fullName = constellationFullName(entry.identifier); if (!fullName.empty()) { @@ -332,8 +213,12 @@ void RenderableConstellationsBase::initialize() { } } +bool RenderableConstellationsBase::isReady() const { + return _hasLabels ? _labels->isReady() : true; +} + void RenderableConstellationsBase::render(const RenderData& data, RendererTasks&) { - if (!_hasLabel || !_drawLabels) { + if (!_hasLabels || !_drawLabels) { return; } @@ -367,46 +252,7 @@ void RenderableConstellationsBase::render(const RenderData& data, RendererTasks& const glm::vec3 orthoUp = glm::normalize( glm::vec3(worldToModelTransform * glm::dvec4(up, 0.f)) ); - renderLabels(data, modelViewProjectionMatrix, orthoRight, orthoUp); -} - -void RenderableConstellationsBase::renderLabels(const RenderData& data, - const glm::dmat4& modelViewProjectionMatrix, - const glm::vec3& orthoRight, - const glm::vec3& orthoUp) -{ - float scale = static_cast(toMeter(_labelUnit)); - - ghoul::fontrendering::FontRenderer::ProjectedLabelsInformation labelInfo; - labelInfo.orthoRight = orthoRight; - labelInfo.orthoUp = orthoUp; - labelInfo.minSize = _textMinMaxSize.value().x; - labelInfo.maxSize = _textMinMaxSize.value().y; - labelInfo.cameraPos = data.camera.positionVec3(); - labelInfo.cameraLookUp = data.camera.lookUpVectorWorldSpace(); - labelInfo.renderType = _renderOption; - labelInfo.mvpMatrix = modelViewProjectionMatrix; - labelInfo.scale = pow(10.f, _textSize); - labelInfo.enableDepth = true; - labelInfo.enableFalseDepth = false; - - glm::vec4 textColor = glm::vec4(glm::vec3(_textColor), _textOpacity); - - for (const speck::Labelset::Entry& e : _labelset.entries) { - if (_selection.hasSelected() && !_selection.isSelected(e.text)) { - continue; - } - - glm::vec3 scaledPos(e.position); - scaledPos *= scale; - ghoul::fontrendering::FontRenderer::defaultProjectionRenderer().render( - *_font, - scaledPos, - e.text, - textColor, - labelInfo - ); - } + _labels->render(data, modelViewProjectionMatrix, orthoRight, orthoUp); } } // namespace openspace diff --git a/modules/space/rendering/renderableconstellationsbase.h b/modules/space/rendering/renderableconstellationsbase.h index 3752201577..1987750db0 100644 --- a/modules/space/rendering/renderableconstellationsbase.h +++ b/modules/space/rendering/renderableconstellationsbase.h @@ -27,17 +27,17 @@ #include -#include +#include #include #include #include #include #include +#include #include #include #include -namespace ghoul::fontrendering { class Font; } namespace ghoul::opengl { class ProgramObject; } namespace openspace { @@ -55,11 +55,9 @@ public: virtual void initializeGL() override = 0; virtual void deinitializeGL() override = 0; - virtual bool isReady() const override = 0; + virtual bool isReady() const override; virtual void render(const RenderData& data, RendererTasks& rendererTask) override; - void renderLabels(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix, - const glm::vec3& orthoRight, const glm::vec3& orthoUp); static documentation::Documentation Documentation(); @@ -86,9 +84,8 @@ protected: // asset file std::vector _assetSelection; - // Label text settings - bool _hasLabel = false; - speck::Labelset _labelset; + // Labels + bool _hasLabels = false; properties::BoolProperty _drawLabels; private: @@ -108,16 +105,8 @@ private: // The file containing constellation names and abbreviations properties::StringProperty _namesFilename; - // Label text settings - std::string _labelFile; - std::shared_ptr _font = nullptr; - DistanceUnit _labelUnit = DistanceUnit::Parsec; - properties::Vec3Property _textColor; - properties::FloatProperty _textOpacity; - properties::FloatProperty _textSize; - properties::IVec2Property _textMinMaxSize; - - properties::OptionProperty _renderOption; + // Everything related to the labels is handled by LabelsComponent + std::unique_ptr _labels; }; } // namespace openspace diff --git a/modules/space/rendering/renderableorbitalkepler.cpp b/modules/space/rendering/renderableorbitalkepler.cpp index 0baecf37dd..95e7dc70e4 100644 --- a/modules/space/rendering/renderableorbitalkepler.cpp +++ b/modules/space/rendering/renderableorbitalkepler.cpp @@ -160,7 +160,7 @@ RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dict) addProperty(_opacity); _segmentQuality = static_cast(p.segmentQuality); - _segmentQuality.onChange([this]() { initializeGL(); }); + _segmentQuality.onChange([this]() { updateBuffers(); }); addProperty(_segmentQuality); _appearance.lineColor = p.color; @@ -169,7 +169,7 @@ RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dict) addPropertySubOwner(_appearance); _path = p.path.string(); - _path.onChange([this]() { initializeGL(); }); + _path.onChange([this]() { updateBuffers(); }); addProperty(_path); _format = codegen::map(p.format); diff --git a/modules/space/spacemodule.cpp b/modules/space/spacemodule.cpp index bb06bed639..72e479040d 100644 --- a/modules/space/spacemodule.cpp +++ b/modules/space/spacemodule.cpp @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -128,6 +129,7 @@ std::vector SpaceModule::documentations() const { RenderableTravelSpeed::Documentation(), SpiceRotation::Documentation(), SpiceTranslation::Documentation(), + LabelsComponent::Documentation(), GPTranslation::Documentation() }; } diff --git a/modules/spout/CMakeLists.txt b/modules/spout/CMakeLists.txt index ae1cdfc329..e603a0fc57 100644 --- a/modules/spout/CMakeLists.txt +++ b/modules/spout/CMakeLists.txt @@ -50,8 +50,13 @@ create_new_module( ${HEADER_FILES} ${SOURCE_FILES} ) -target_include_directories(openspace-module-spout SYSTEM PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/ext/spout) -target_link_libraries(openspace-module-spout PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/ext/spout/SpoutLibrary.lib) -register_external_libraries("${CMAKE_CURRENT_SOURCE_DIR}/ext/spout/SpoutLibrary.dll") +add_library(spout SHARED IMPORTED) +target_include_directories(spout SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/ext/spout) +set_target_properties( + spout PROPERTIES + IMPORTED_IMPLIB ${CMAKE_CURRENT_SOURCE_DIR}/ext/spout/SpoutLibrary.lib + IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/ext/spout/SpoutLibrary.dll +) +target_link_libraries(openspace-module-spout PRIVATE spout) target_compile_definitions(openspace-module-spout PUBLIC "OPENSPACE_HAS_SPOUT") diff --git a/modules/vislab/rendering/renderabledistancelabel.cpp b/modules/vislab/rendering/renderabledistancelabel.cpp index 1833a452f9..6b4a06a28c 100644 --- a/modules/vislab/rendering/renderabledistancelabel.cpp +++ b/modules/vislab/rendering/renderabledistancelabel.cpp @@ -78,7 +78,7 @@ documentation::Documentation RenderableDistanceLabel::Documentation() { } RenderableDistanceLabel::RenderableDistanceLabel(const ghoul::Dictionary& dictionary) - : RenderableLabels(dictionary) + : RenderableLabel(dictionary) , _nodelineId(NodeLineInfo) , _distanceUnit(DistanceUnitInfo, 1, 0, 11) , _customUnitDescriptor(CustomUnitDescriptorInfo) diff --git a/modules/vislab/rendering/renderabledistancelabel.h b/modules/vislab/rendering/renderabledistancelabel.h index 3a0b765aad..b10fa9bff1 100644 --- a/modules/vislab/rendering/renderabledistancelabel.h +++ b/modules/vislab/rendering/renderabledistancelabel.h @@ -25,13 +25,13 @@ #ifndef __OPENSPACE_MODULE_VISLAB___RENDERABLEDISTANCELABEL___H__ #define __OPENSPACE_MODULE_VISLAB___RENDERABLEDISTANCELABEL___H__ -#include +#include namespace openspace { namespace documentation { struct Documentation; } -class RenderableDistanceLabel : public RenderableLabels { +class RenderableDistanceLabel : public RenderableLabel { public: RenderableDistanceLabel(const ghoul::Dictionary& dictionary); diff --git a/modules/webbrowser/CMakeLists.txt b/modules/webbrowser/CMakeLists.txt index bd01c449f9..dfd808aed5 100644 --- a/modules/webbrowser/CMakeLists.txt +++ b/modules/webbrowser/CMakeLists.txt @@ -202,8 +202,8 @@ if (OS_MACOSX) endif () endforeach() - set_property(TARGET ${CEF_HELPER_TARGET_GPU} PROPERTY FOLDER "Helper") - set_property(TARGET ${CEF_HELPER_TARGET_RENDERER} PROPERTY FOLDER "Helper") + set_target_properties(${CEF_HELPER_TARGET_GPU} PROPERTIES FOLDER "Helper") + set_target_properties(${CEF_HELPER_TARGET_RENDERER} PROPERTIES FOLDER "Helper") else() message(STATUS "Setting up WebBrowser CEF helper executable: ${CEF_HELPER_TARGET}") set_openspace_cef_target_out_dir() @@ -219,7 +219,7 @@ else() endif (OS_WINDOWS) endif () -set_property(TARGET ${CEF_HELPER_TARGET} PROPERTY FOLDER "Helper") +set_target_properties(${CEF_HELPER_TARGET} PROPERTIES FOLDER "Helper") ########################################################################################## # Create OpenSpace module. @@ -292,13 +292,4 @@ if (UNIX AND NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")) DESTINATION ${CEF_ROOT}/${CMAKE_BUILD_TYPE}/ FILES_MATCHING PATTERN * ) - endif () - -# Rename to "OpenSpace Helper" after build & link as spaces in targets are not allowed -# add_custom_command( -# TARGET ${CEF_HELPER_TARGET} POST_BUILD -# COMMAND ${CMAKE_COMMAND} -E rename -# "$/${CEF_HELPER_TARGET}" -# "$/OpenSpace Helper" -# COMMENT "Renaming ${CEF_HELPER_TARGET} to 'OpenSpace Helper'" -# ) +endif () diff --git a/src/interaction/sessionrecording.cpp b/src/interaction/sessionrecording.cpp index 0eadd4499e..365fd801f4 100644 --- a/src/interaction/sessionrecording.cpp +++ b/src/interaction/sessionrecording.cpp @@ -143,15 +143,6 @@ void SessionRecording::removeTrailingPathSlashes(std::string& filename) { } } -void SessionRecording::extractFilenameFromPath(std::string& filename) { - size_t unixDelimiter = filename.find_last_of("/"); - if (unixDelimiter != std::string::npos) - filename = filename.substr(unixDelimiter + 1); - size_t windowsDelimiter = filename.find_last_of("\\"); - if (windowsDelimiter != std::string::npos) - filename = filename.substr(windowsDelimiter + 1); -} - bool SessionRecording::handleRecordingFile(std::string filenameIn) { if (isPath(filenameIn)) { LERROR("Recording filename must not contain path (/) elements"); @@ -1624,7 +1615,7 @@ std::string SessionRecording::isolateTermFromQuotes(std::string s) { } //If no quotes found, remove other possible characters from end std::string unwantedChars = " );"; - while (unwantedChars.find(s.back()) != std::string::npos) { + while (!s.empty() && (unwantedChars.find(s.back()) != std::string::npos)) { s.pop_back(); } return s; @@ -2303,6 +2294,10 @@ void SessionRecording::readFileIntoStringStream(std::string filename, inputFstream.close(); } +void SessionRecording::convertFileRelativePath(std::string filenameRelative) { + convertFile(absPath(filenameRelative).string()); +} + std::string SessionRecording::convertFile(std::string filename, int depth) { std::string conversionOutFilename = filename; std::ifstream conversionInFile; @@ -2331,9 +2326,6 @@ std::string SessionRecording::convertFile(std::string filename, int depth) { //conversionInStream.seekg(conversionInStream.beg); newFilename = getLegacyConversionResult(filename, depth + 1); removeTrailingPathSlashes(newFilename); - if (isPath(newFilename)) { - extractFilenameFromPath(newFilename); - } if (filename == newFilename) { return filename; } @@ -2572,7 +2564,7 @@ std::string SessionRecording::determineConversionOutFilename(const std::string f filenameSansExtension = filename.substr(0, filename.find_last_of(".")); } filenameSansExtension += "_" + fileFormatVersion() + "-" + targetFileFormatVersion(); - return absPath("${RECORDINGS}/" + filenameSansExtension + fileExtension).string(); + return filenameSansExtension + fileExtension; } bool SessionRecording_legacy_0085::convertScript(std::stringstream& inStream, diff --git a/src/interaction/tasks/convertrecfileversiontask.cpp b/src/interaction/tasks/convertrecfileversiontask.cpp index 1255d3ee0a..61f3e31c61 100644 --- a/src/interaction/tasks/convertrecfileversiontask.cpp +++ b/src/interaction/tasks/convertrecfileversiontask.cpp @@ -52,11 +52,6 @@ ConvertRecFileVersionTask::ConvertRecFileVersionTask(const ghoul::Dictionary& di _inFilename = dictionary.value(KeyInFilePath); _inFilePath = absPath(_inFilename); - std::string::size_type idx = _inFilename.find_last_of('/'); - if (idx != std::string::npos) { - _inFilename = _inFilename.substr(idx + 1); - } - ghoul_assert(std::filesystem::is_regular_file(_inFilePath), "The file must exist"); if (!std::filesystem::is_regular_file(_inFilePath)) { LERROR(fmt::format("Failed to load session recording file: {}", _inFilePath)); @@ -100,7 +95,7 @@ void ConvertRecFileVersionTask::convert() { )); return; } - sessRec->convertFile(_inFilename); + sessRec->convertFileRelativePath(_inFilename); } documentation::Documentation ConvertRecFileVersionTask::documentation() { diff --git a/src/rendering/renderable.cpp b/src/rendering/renderable.cpp index 90db17c018..3b54240258 100644 --- a/src/rendering/renderable.cpp +++ b/src/rendering/renderable.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -207,7 +207,7 @@ Renderable::Renderable(const ghoul::Dictionary& dictionary) if (p.renderBinMode.has_value()) { setRenderBin(codegen::map(*p.renderBinMode)); } - + _dimInAtmosphere = p.dimInAtmosphere.value_or(_dimInAtmosphere); addProperty(_dimInAtmosphere); } @@ -313,7 +313,7 @@ void Renderable::registerUpdateRenderBinFromOpacity() { } float Renderable::opacity() const { - // Rendering should depend on if camera is in the atmosphere and if camera is at the + // Rendering should depend on if camera is in the atmosphere and if camera is at the // dark part of the globe return _dimInAtmosphere ? _opacity * _fade * global::navigationHandler->camera()->atmosphereDimmingFactor() : diff --git a/src/scene/assetmanager.cpp b/src/scene/assetmanager.cpp index b0c6409174..ddac86157b 100644 --- a/src/scene/assetmanager.cpp +++ b/src/scene/assetmanager.cpp @@ -489,10 +489,14 @@ void AssetManager::setUpAssetLuaTable(Asset* asset) { ZoneScoped Asset* thisAsset = ghoul::lua::userData(L, 1); - ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::localResourceLua"); + ghoul::lua::checkArgumentsAndThrow(L, { 0, 1 }, "lua::localResourceLua"); + + auto [name] = ghoul::lua::values>(L); + std::filesystem::path path = + name.has_value() ? + thisAsset->path().parent_path() / *name : + thisAsset->path().parent_path(); - std::string name = ghoul::lua::value(L); - std::filesystem::path path = thisAsset->path().parent_path() / name; ghoul::lua::push(L, path); return 1; }, @@ -514,7 +518,7 @@ void AssetManager::setUpAssetLuaTable(Asset* asset) { ghoul::Dictionary d = ghoul::lua::value(L); std::unique_ptr s = ResourceSynchronization::createFromDictionary(d); - + std::string uid = d.value("Type") + "/" + s->generateUid(); SyncItem* syncItem = nullptr; auto it = manager->_synchronizations.find(uid); diff --git a/support/cmake/application_definition.cmake b/support/cmake/application_definition.cmake index 100f51f740..6705639450 100644 --- a/support/cmake/application_definition.cmake +++ b/support/cmake/application_definition.cmake @@ -27,39 +27,9 @@ include(${OPENSPACE_CMAKE_EXT_DIR}/global_variables.cmake) function (create_new_application application_name) add_executable(${application_name} MACOSX_BUNDLE ${ARGN}) set_openspace_compile_settings(${application_name}) - - # We currently can't reuse the precompiled header because that one has the Kameleon - # definition stuck into it - #target_precompile_headers(${library_name} REUSE_FROM openspace-core) - #target_precompile_headers(${application_name} PRIVATE - # [["ghoul/fmt.h"]] - # [["ghoul/glm.h"]] - # [["ghoul/misc/assert.h"]] - # [["ghoul/misc/boolean.h"]] - # [["ghoul/misc/exception.h"]] - # [["ghoul/misc/invariants.h"]] - # [["ghoul/misc/profiling.h"]] - # - # - # - # - # - # - # - # - # - #) - if (WIN32) get_external_library_dependencies(ext_lib) - ghl_copy_files( - ${application_name} - "${OPENSPACE_BASE_DIR}/ext/curl/lib/libcurl.dll" - "${OPENSPACE_BASE_DIR}/ext/curl/lib/libeay32.dll" - "${OPENSPACE_BASE_DIR}/ext/curl/lib/ssleay32.dll" - ${ext_lib} - ) - ghl_copy_shared_libraries(${application_name} ${OPENSPACE_BASE_DIR}/ext/ghoul) + ghl_copy_files(${application_name} ${ext_lib}) endif () target_link_libraries(${application_name} PUBLIC openspace-module-base) diff --git a/support/cmake/module_definition.cmake b/support/cmake/module_definition.cmake index 34dbd45be8..96cbeb1934 100644 --- a/support/cmake/module_definition.cmake +++ b/support/cmake/module_definition.cmake @@ -74,20 +74,6 @@ endfunction () -function (register_external_libraries libraries) - # This is an ugly hack as we can't inject a variable into a scope two parents above - # would love to: set(${module_external_librarys} "${libraries}" PARENT_PARENT_SCOPE) - # instead - set(libs "") - foreach (library ${libraries}) - get_filename_component(lib ${library} ABSOLUTE) - list(APPEND libs ${lib}) - endforeach() - - set_property(GLOBAL PROPERTY CurrentModuleExternalLibraries ${libs}) -endfunction () - - # Gets and returns the module.h and module.cpp files and provides them with a # source group function (get_module_files module_name module_files)