diff --git a/.gitmodules b/.gitmodules index 112e7a1300..3632c848dd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -9,7 +9,7 @@ url = https://github.com/OpenSpace/Spice.git [submodule "modules/touch/ext/libTUIO11"] path = modules/touch/ext/libTUIO11 - url = https://github.com/mkalten/TUIO11_CPP + url = https://github.com/OpenSpace/TUIO11_CPP.git [submodule "apps/OpenSpace-MinVR/ext/minvr"] path = apps/OpenSpace-MinVR/ext/minvr url = https://github.com/OpenSpace/minvr 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/OpenSpace/ext/launcher/CMakeLists.txt b/apps/OpenSpace/ext/launcher/CMakeLists.txt index 033750ebbf..1c85bd7569 100644 --- a/apps/OpenSpace/ext/launcher/CMakeLists.txt +++ b/apps/OpenSpace/ext/launcher/CMakeLists.txt @@ -127,11 +127,24 @@ target_link_libraries( Qt${QT_VERSION_MAJOR}::Network ) -if (MSVC) -set(MSVC_WARNINGS - "/wd4619" # #pragma warning: there is no warning number (raised by Qt headers) - "/wd4946" # reinterpret_cast used between related classes: +target_precompile_headers(openspace-ui-launcher PRIVATE + + + + + + + + + + + ) -target_compile_options(openspace-ui-launcher INTERFACE ${MSVC_WARNINGS}) +if (MSVC) + set(MSVC_WARNINGS + "/wd4619" # #pragma warning: there is no warning number (raised by Qt headers) + "/wd4946" # reinterpret_cast used between related classes: + ) + target_compile_options(openspace-ui-launcher INTERFACE ${MSVC_WARNINGS}) endif () diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index 6ab4ac31bf..e40111d616 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit 6ab4ac31bf24dd7e60e58d8eedd37e4c2cc6df08 +Subproject commit e40111d616e85b61632b74a6b900fe6b88d2b74b diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index 1a9700ce4b..0799a706b6 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -28,21 +28,15 @@ #include #include #include -#include -#include +#include #include -#include +#include +#include #include #include -#include #include -#include -#include #include -#include -#include -#include -#include +#include #ifdef WIN32 #define GLFW_EXPOSE_NATIVE_WIN32 #endif @@ -54,25 +48,17 @@ #include #include #include -#include #include #include -#include +#include #include #include -#include -#include -#include -#include +#include +#include #ifdef WIN32 -#include -#include -#include #include #include -#include -#include #endif // WIN32 #ifdef OPENVR_SUPPORT 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/constellationbounds.asset b/data/assets/scene/digitaluniverse/constellationbounds.asset index c53f0bead2..346e516c7e 100644 --- a/data/assets/scene/digitaluniverse/constellationbounds.asset +++ b/data/assets/scene/digitaluniverse/constellationbounds.asset @@ -1,7 +1,7 @@ local data = asset.syncedResource({ - Name = "Constellation Bounds Data", + Name = "Constellation Files", Type = "HttpSynchronization", - Identifier = "digitaluniverse_constellationbounds_data", + Identifier = "digitaluniverse_constellations_data", Version = 1 }) @@ -16,8 +16,8 @@ local object = { Type = "RenderableConstellationBounds", Enabled = false, File = data .. "bound_20.dat", - ConstellationFile = data .. "constellations.dat" - -- ConstellationSelection = zodiacs + NamesFile = data .. "constellations.dat", + -- Selection = zodiacs }, Transform = { Rotation = { @@ -41,18 +41,18 @@ local object = { asset.onInitialize(function() openspace.addSceneGraphNode(object) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(object) end) - + asset.export(object) asset.meta = { Name = "Constellation Bounds", - Version = "1.1", + Version = "1.2", Description = [[DU asset providing a Spherical mesh dividing the sky into regions that fit the constellations]], Author = "Brian Abbott (AMNH)", diff --git a/data/assets/scene/digitaluniverse/constellations.asset b/data/assets/scene/digitaluniverse/constellations.asset index 9bd8d72f18..8707c05e4a 100644 --- a/data/assets/scene/digitaluniverse/constellations.asset +++ b/data/assets/scene/digitaluniverse/constellations.asset @@ -1,24 +1,34 @@ local speck = asset.syncedResource({ - Name = "Constellation Speck Files", + Name = "Constellation Files", Type = "HttpSynchronization", - Identifier = "digitaluniverse_constellations_speck", - Version = 2 + Identifier = "digitaluniverse_constellations_data", + Version = 1 }) +local zodiacs = { + "Cancer", "Taurus", "Pisces", "Aries", "Libra", "Aquarius", "Capricornus", "Scorpius", + "Virgo", "Sagittarius", "Gemini", "Leo" +} + local constellationsExtragalactic = { Identifier = "ConstellationsExtragalactic", Renderable = { - Type = "RenderableDUMeshes", + 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", - TextColor = { 0.8, 0.8, 0.8 }, - TextOpacity = 0.4, - TextSize = 20.0, - TextMinMaxSize = { 20, 30 }, - MeshColor = { { 0.6, 0.4, 0.4 }, { 0.8, 0.0, 0.0 }, { 0.0, 0.3, 0.8 } }, - Unit = "Mpc" + NamesFile = speck .. "constellations.dat", + Colors = { { 0.6, 0.4, 0.4 }, { 0.8, 0.0, 0.0 }, { 0.0, 0.3, 0.8 } }, + Unit = "Mpc", + -- Selection = zodiacs }, GUI = { Name = "Constellations (Extragalactic)", @@ -29,20 +39,25 @@ local constellationsExtragalactic = { local constellations = { Identifier = "Constellations", Renderable = { - Type = "RenderableDUMeshes", + 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", - TextColor = { 0.8, 0.8, 0.8 }, - TextOpacity = 0.3, - TextSize = 14.5, - TextMinMaxSize = { 8, 170 }, - MeshColor = { { 0.6, 0.4, 0.4 }, { 0.8, 0.0, 0.0 }, { 0.0, 0.3, 0.8 } }, - Unit = "pc" + NamesFile = speck .. "constellations.dat", + Colors = { { 0.6, 0.4, 0.4 }, { 0.8, 0.0, 0.0 }, { 0.0, 0.3, 0.8 } }, + Unit = "pc", + -- Selection = zodiacs }, GUI = { - Name = "Constellations", + Name = "Constellations", Path = "/Milky Way/Constellations", Description = [[Census 88 constellations and labels. DU Version 2.3.
These modern constellations are largely based on those of the Babylonians and @@ -60,12 +75,12 @@ asset.onInitialize(function() openspace.addSceneGraphNode(constellationsExtragalactic) openspace.addSceneGraphNode(constellations) end) - + asset.onDeinitialize(function() openspace.removeSceneGraphNode(constellations) openspace.removeSceneGraphNode(constellationsExtragalactic) end) - + asset.export(constellationsExtragalactic) asset.export(constellations) @@ -73,7 +88,7 @@ asset.export(constellations) asset.meta = { Name = "Constellations", - Version = "1.1", + Version = "1.2", Description = "Digital Universe asset for constellation lines", Author = "Brian Abbott (AMNH)", URL = "https://www.amnh.org/research/hayden-planetarium/digital-universe", 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/milkyway/constellations/constellation_art.asset b/data/assets/scene/milkyway/constellations/constellation_art.asset index d96754f498..0bf65abd00 100644 --- a/data/assets/scene/milkyway/constellations/constellation_art.asset +++ b/data/assets/scene/milkyway/constellations/constellation_art.asset @@ -2,12 +2,48 @@ local constellationsCSV = asset.localResource("constellation_data.csv") local transforms = asset.require("scene/solarsystem/sun/transforms") local images = asset.syncedResource({ - Name = "Constellation Images", - Type = "HttpSynchronization", - Identifier = "constellation_images", - Version = 4 + Name = "Constellation Images", + Type = "HttpSynchronization", + Identifier = "constellation_images", + Version = 4 }) +local data = asset.syncedResource({ + Name = "Constellation Files", + Type = "HttpSynchronization", + Identifier = "digitaluniverse_constellations_data", + Version = 1 +}) + + +-- Function that returns the full name of a constellation given its abbreviation +-- The function uses the constellations.dat file to find the name +-- If the file does not exist or if a match could not be found, it returns nil +local findFullName = function(abbreviation) + local namesFile = data .. "constellations.dat" + + local file = io.open(namesFile, "r") + if file ~= nil then + io.close(file) + for line in io.lines(namesFile) do + local index, length = string.find(line, abbreviation) + + if index ~= nil and index < 4 then + return string.sub(line, length + 1) + end + + local fullLine = line + local lowerLine = string.lower(line) + index, length = string.find(lowerLine, string.lower(abbreviation)) + if index ~= nil and index < 4 then + return string.sub(fullLine, length + 1) + end + end + end + return nil +end + + --function that reads the file local createConstellations = function (baseIdentifier, guiPath, constellationfile) local genConstellations = {}; @@ -30,6 +66,13 @@ local createConstellations = function (baseIdentifier, guiPath, constellationfil local normy = y/magVec local normz = z/magVec + -- Use the full name in the data constellations.dat if possible + -- Otherwise, use the given name in the constellation_data.csv file + local foundName = findFullName(abbreviation) + if foundName ~= nil then + name = foundName + end + group = (group == "" and globe or group) local aconstellation = { @@ -172,7 +215,7 @@ end asset.meta = { Name = "Constellation Images", - Version = "1.1", + Version = "1.2", Description = "Artistic images depicting the constellations", Author = "James Hedberg", URL = "http://jameshedberg.com", 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/ipac.asset b/data/assets/util/ipac.asset index 34d9d79272..50019e38cc 100644 --- a/data/assets/util/ipac.asset +++ b/data/assets/util/ipac.asset @@ -1,30 +1,175 @@ +local orbit_right = { + Identifier = "ipac.orbit_right", + Name = "Orbit right", + Command = [[ openspace.navigation.addGlobalRotation(-5.0, 0.0) ]], + Documentation = "Orbits the camera to the right around the current focus", + GuiPath = "/Ipac", + IsLocal = false +} +asset.export("IpacOrbitRight", orbit_right) + +local orbit_left = { + Identifier = "ipac.orbit_left", + Name = "Orbit left", + Command = [[ openspace.navigation.addGlobalRotation(5.0, 0.0) ]], + Documentation = "Orbits the camera to the left around the current focus", + GuiPath = "/Ipac", + IsLocal = false +} +asset.export("IpacOrbitLeft", orbit_left) + +local orbit_up = { + Identifier = "ipac.orbit_up", + Name = "Orbit up", + Command = [[ openspace.navigation.addGlobalRotation(0.0, 5.0) ]], + Documentation = "Orbits the camera up around the current focus", + GuiPath = "/Ipac", + IsLocal = false +} +asset.export("IpacOrbitUp", orbit_up) + +local orbit_down = { + Identifier = "ipac.orbit_down", + Name = "Orbit down", + Command = [[ openspace.navigation.addGlobalRotation(0.0, -5.0) ]], + Documentation = "Orbits the camera down around the current focus", + GuiPath = "/Ipac", + IsLocal = false +} +asset.export("IpacOrbitDown", orbit_down) + + +local pan_right = { + Identifier = "ipac.pan_right", + Name = "Pan right", + Command = [[ openspace.navigation.addLocalRotation(-5.0, 0.0) ]], + Documentation = "Pans the camera to the right", + GuiPath = "/Ipac", + IsLocal = false +} +asset.export("IpacPanRight", pan_right) + +local pan_left = { + Identifier = "ipac.pan_left", + Name = "Pan left", + Command = [[ openspace.navigation.addLocalRotation(5.0, 0.0) ]], + Documentation = "Pans the camera to the left", + GuiPath = "/Ipac", + IsLocal = false +} +asset.export("IpacPanLeft", pan_left) + +local pan_up = { + Identifier = "ipac.pan_up", + Name = "Pan up", + Command = [[ openspace.navigation.addLocalRotation(0.0, 5.0) ]], + Documentation = "Pans the camera up", + GuiPath = "/Ipac", + IsLocal = false +} +asset.export("IpacPanUp", pan_up) + +local pan_down = { + Identifier = "ipac.pan_down", + Name = "Pan down", + Command = [[ openspace.navigation.addLocalRotation(0.0, -5.0) ]], + Documentation = "Pans the camera down", + GuiPath = "/Ipac", + IsLocal = false +} +asset.export("IpacPanDown", pan_down) + + +local zoom_in = { + Identifier = "ipac.zoom_in", + Name = "Zoom in", + Command = [[ openspace.navigation.addTruckMovement(0.0, 5.0) ]], + Documentation = "Zooms the camera in, towards the current focus", + GuiPath = "/Ipac", + IsLocal = false +} +asset.export("IpacZoomIn", zoom_in) + +local zoom_out = { + Identifier = "ipac.zoom_out", + Name = "Zoom out", + Command = [[ openspace.navigation.addTruckMovement(0.0, -5.0) ]], + Documentation = "Zooms the camera out, away form the current focus", + GuiPath = "/Ipac", + IsLocal = false +} +asset.export("IpacZoomOut", zoom_out) + + +local focus_moon = { + Identifier = "ipac.focus_moon", + Name = "Focus on the Moon", + Command = [[ + openspace.setPropertyValueSingle("NavigationHandler.OrbitalNavigator.Aim", ""); + openspace.setPropertyValueSingle("NavigationHandler.OrbitalNavigator.Anchor", "Moon"); + openspace.setPropertyValueSingle("NavigationHandler.OrbitalNavigator.RetargetAnchor", nil); + ]], + Documentation = "Focuses the camera on the Moon", + GuiPath = "/Ipac", + IsLocal = false +} +asset.export("IpacFocusMoon", focus_moon) + +local focus_earth = { + Identifier = "ipac.focus_earth", + Name = "Focus on the Earth", + Command = [[ + openspace.setPropertyValueSingle("NavigationHandler.OrbitalNavigator.Aim", ""); + openspace.setPropertyValueSingle("NavigationHandler.OrbitalNavigator.Anchor", "Earth"); + openspace.setPropertyValueSingle("NavigationHandler.OrbitalNavigator.RetargetAnchor", nil) + ]], + Documentation = "Focuses the camera on Earth", + GuiPath = "/Ipac", + IsLocal = false +} +asset.export("IpacFocusEarth", focus_earth) + + +local actions = { + orbit_right, + orbit_left, + orbit_up, + orbit_down, + pan_right, + pan_left, + pan_up, + pan_down, + zoom_in, + zoom_out, + focus_moon, + focus_earth +} + asset.onInitialize(function() + for _, a in ipairs(actions) do + openspace.action.registerAction(a) + end + openspace.clearKeys() - openspace.bindKey("RIGHT", "openspace.navigation.addGlobalRotation(-5.0, 0.0)"); - openspace.bindKey("LEFT", "openspace.navigation.addGlobalRotation(5.0, 0.0)"); - openspace.bindKey("UP", "openspace.navigation.addGlobalRotation(0.0, 5.0)"); - openspace.bindKey("DOWN", "openspace.navigation.addGlobalRotation(0.0, -5.0)"); + openspace.bindKey("RIGHT", orbit_right.Identifier) + openspace.bindKey("LEFT", orbit_left.Identifier) + openspace.bindKey("UP", orbit_up.Identifier) + openspace.bindKey("DOWN", orbit_down.Identifier) - openspace.bindKey("CTRL+RIGHT", "openspace.navigation.addLocalRotation(-5.0, 0.0)"); - openspace.bindKey("CTRL+LEFT", "openspace.navigation.addLocalRotation(5.0, 0.0)"); - openspace.bindKey("CTRL+UP", "openspace.navigation.addLocalRotation(0.0, 5.0)"); - openspace.bindKey("CTRL+DOWN", "openspace.navigation.addLocalRotation(0.0, -5.0)"); + openspace.bindKey("CTRL+RIGHT", pan_right.Identifier) + openspace.bindKey("CTRL+LEFT", pan_left.Identifier) + openspace.bindKey("CTRL+UP", pan_up.Identifier) + openspace.bindKey("CTRL+DOWN", pan_down.Identifier) - openspace.bindKey("ALT+UP", "openspace.navigation.addTruckMovement(0.0, 5.0)"); - openspace.bindKey("ALT+DOWN", "openspace.navigation.addTruckMovement(0.0, -5.0)"); + openspace.bindKey("ALT+UP", zoom_in.Identifier) + openspace.bindKey("ALT+DOWN", zoom_out.Identifier) - openspace.bindKey( - "SPACE", - [[ - openspace.setPropertyValueSingle("NavigationHandler.OrbitalNavigator.Aim", ""); - openspace.setPropertyValueSingle("NavigationHandler.OrbitalNavigator.Anchor", "Moon"); - openspace.setPropertyValueSingle("NavigationHandler.OrbitalNavigator.RetargetAnchor", nil) - ]]) - openspace.bindKey( - "Z", - [[ - openspace.setPropertyValueSingle("NavigationHandler.OrbitalNavigator.Aim", ""); - openspace.setPropertyValueSingle("NavigationHandler.OrbitalNavigator.Anchor", "Earth"); - openspace.setPropertyValueSingle("NavigationHandler.OrbitalNavigator.RetargetAnchor", nil) - ]]) + openspace.bindKey("SPACE", focus_moon.Identifier) + openspace.bindKey("Z", focus_earth.Identifier) +end) + +asset.onDeinitialize(function () + for i = #actions, 1, -1 do + openspace.action.removeAction(actions[i]) + end end) 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/empty.profile b/data/profiles/empty.profile new file mode 100644 index 0000000000..da68f0065a --- /dev/null +++ b/data/profiles/empty.profile @@ -0,0 +1,42 @@ +{ + "assets": [ + "base_blank" + ], + "camera": { + "aim": "", + "anchor": "Root", + "frame": "", + "position": { + "x": 20.0, + "y": 20.0, + "z": 20.0 + }, + "type": "setNavigationState", + "up": { + "x": 0.0, + "y": 1.0, + "z": 0.0 + }, + "yaw": 0.0 + }, + "delta_times": [ + 1.0 + ], + "mark_nodes": [], + "meta": { + "author": "OpenSpace Team", + "description": "An empty profile, without anything special at all.", + "license": "MIT License", + "name": "Empty", + "url": "https://www.openspaceproject.com", + "version": "1.0" + }, + "time": { + "type": "relative", + "value": "-1d" + }, + "version": { + "major": 1, + "minor": 0 + } +} \ No newline at end of file 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 1cf2528db1..3e17fac68d 100644 --- a/ext/CMakeLists.txt +++ b/ext/CMakeLists.txt @@ -56,18 +56,25 @@ set_folder_location(GhoulTest "Unit Tests") begin_dependency("Spice") set(SPICE_BUILD_SHARED_LIBRARY OFF CACHE BOOL "" FORCE) add_subdirectory(spice) +target_compile_features(spice PUBLIC cxx_std_20) set_folder_location(spice "External") 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 7d53430d8c..b676d66bc0 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 7d53430d8c0c810baffdb7b636e195957360e812 +Subproject commit b676d66bc028e26dbf2fa0a39c67e35667df13f9 diff --git a/ext/spice b/ext/spice index 82e9b1fb97..5dba0f3269 160000 --- a/ext/spice +++ b/ext/spice @@ -1 +1 @@ -Subproject commit 82e9b1fb978c42161edc535949d0fd6186e5a38c +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/include/openspace/util/histogram.h b/include/openspace/util/histogram.h index 047fa43ac8..828be5609e 100644 --- a/include/openspace/util/histogram.h +++ b/include/openspace/util/histogram.h @@ -80,11 +80,9 @@ private: float _minValue = 0.f; float _maxValue = 0.f; - float* _data = nullptr; std::vector _equalizer; int _numValues = 0; - }; } // namespace openspace diff --git a/modules/atmosphere/rendering/renderableatmosphere.cpp b/modules/atmosphere/rendering/renderableatmosphere.cpp index a9adf06243..6dc5035c7b 100644 --- a/modules/atmosphere/rendering/renderableatmosphere.cpp +++ b/modules/atmosphere/rendering/renderableatmosphere.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include diff --git a/modules/base/CMakeLists.txt b/modules/base/CMakeLists.txt index 4f975e1b8d..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 @@ -165,3 +165,14 @@ create_new_module( STATIC ${HEADER_FILES} ${SOURCE_FILES} ${SHADER_FILES} ) +target_precompile_headers(${base_module} PRIVATE + + + + + + + + + +) 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/cefwebgui/CMakeLists.txt b/modules/cefwebgui/CMakeLists.txt index e664632cf4..d398c0926b 100644 --- a/modules/cefwebgui/CMakeLists.txt +++ b/modules/cefwebgui/CMakeLists.txt @@ -48,4 +48,18 @@ create_new_module( ${OPENSPACE_HEADER_FILES} ${OPENSPACE_SOURCE_FILES} ) +target_precompile_headers(${cefwebgui_module} PRIVATE + [["include/capi/cef_base_capi.h"]] + [["include/cef_render_handler.h"]] + + + + +) +if (WIN32) + target_precompile_headers(${cefwebgui_module} PRIVATE + + ) +endif () + set_modules_dependency_on_cef_libraries(${cefwebgui_module}) 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/renderabledumeshes.cpp b/modules/digitaluniverse/rendering/renderabledumeshes.cpp index 1ac9ebdf62..367d2ac91b 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.cpp +++ b/modules/digitaluniverse/rendering/renderabledumeshes.cpp @@ -255,6 +255,13 @@ bool RenderableDUMeshes::isReady() const { (!_renderingMeshesMap.empty() || (!_labelset.entries.empty())); } +void RenderableDUMeshes::initialize() { + bool success = loadData(); + if (!success) { + throw ghoul::RuntimeError("Error loading data"); + } +} + void RenderableDUMeshes::initializeGL() { _program = DigitalUniverseModule::ProgramObjectManager.request( "RenderableDUMeshes", @@ -269,11 +276,6 @@ void RenderableDUMeshes::initializeGL() { ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames); - bool success = loadData(); - if (!success) { - throw ghoul::RuntimeError("Error loading data"); - } - createMeshes(); if (_hasLabel) { @@ -536,8 +538,7 @@ bool RenderableDUMeshes::readSpeckFile() { std::getline(file, line); std::stringstream dim(line); - dim >> mesh.numU; // numU - dim >> mesh.numV; // numV + dim >> mesh.numU >> mesh.numV; // We can now read the vertices data: for (int l = 0; l < mesh.numU * mesh.numV; ++l) { @@ -602,7 +603,6 @@ bool RenderableDUMeshes::readSpeckFile() { } } } - setBoundingSphere(maxRadius); return true; @@ -636,7 +636,7 @@ void RenderableDUMeshes::createMeshes() { // in_position glEnableVertexAttribArray(0); // (2022-03-23, emmbr) This code was actually never used. We only read three - // values per line and di not handle any texture cooridnates, even if there + // values per line and did not handle any texture cooridnates, even if there // would have been some in the file //// U and V may not be given by the user //if (p.second.vertices.size() / (p.second.numU * p.second.numV) > 3) { diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.h b/modules/digitaluniverse/rendering/renderabledumeshes.h index 5c6222abeb..afdf483479 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.h +++ b/modules/digitaluniverse/rendering/renderabledumeshes.h @@ -55,6 +55,7 @@ public: explicit RenderableDUMeshes(const ghoul::Dictionary& dictionary); ~RenderableDUMeshes() override = default; + void initialize() override; void initializeGL() override; void deinitializeGL() override; @@ -84,7 +85,7 @@ private: // "If you wish to draw a line between points, then numU will be 1 while // numV will equal the number of points to connect. // If you want a square, 4000×4000 grid with lines every 200 units, - // then numU numU will both equal 21 + // then numU numV will both equal 21 int numU; int numV; MeshType style; 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/exoplanets/rendering/renderableorbitdisc.cpp b/modules/exoplanets/rendering/renderableorbitdisc.cpp index c244d82654..6325e93486 100644 --- a/modules/exoplanets/rendering/renderableorbitdisc.cpp +++ b/modules/exoplanets/rendering/renderableorbitdisc.cpp @@ -40,9 +40,9 @@ #include namespace { - constexpr std::array UniformNames = { + constexpr std::array UniformNames = { "modelViewProjectionTransform", "offset", "opacity", - "discTexture", "eccentricity", "semiMajorAxis" + "discTexture", "eccentricity", "semiMajorAxis", "multiplyColor" }; constexpr openspace::properties::Property::PropertyInfo TextureInfo = { @@ -74,6 +74,13 @@ namespace { "from the semi-major axis and 1 is a whole semi-major axis's worth of deviation" }; + constexpr openspace::properties::Property::PropertyInfo MultiplyColorInfo = { + "MultiplyColor", + "Multiply Color", + "If set, the disc's texture is multiplied with this color. " + "Useful for applying a color grayscale images" + }; + struct [[codegen::Dictionary(RenderableOrbitDisc)]] Parameters { // [[codegen::verbatim(TextureInfo.description)]] std::filesystem::path texture; @@ -86,6 +93,9 @@ namespace { // [[codegen::verbatim(OffsetInfo.description)]] std::optional offset; + + // [[codegen::verbatim(MultiplyColorInfo.description)]] + std::optional multiplyColor [[codegen::color()]]; }; #include "renderableorbitdisc_codegen.cpp" } // namespace @@ -102,6 +112,7 @@ RenderableOrbitDisc::RenderableOrbitDisc(const ghoul::Dictionary& dictionary) , _size(SizeInfo, 1.f, 0.f, 3.0e12f) , _eccentricity(EccentricityInfo, 0.f, 0.f, 1.f) , _offset(OffsetInfo, glm::vec2(0.f), glm::vec2(0.f), glm::vec2(1.f)) + , _multiplyColor(MultiplyColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) { const Parameters p = codegen::bake(dictionary); @@ -119,6 +130,10 @@ RenderableOrbitDisc::RenderableOrbitDisc(const ghoul::Dictionary& dictionary) _texturePath.onChange([&]() { _texture->loadFromFile(_texturePath.value()); }); addProperty(_texturePath); + _multiplyColor = p.multiplyColor.value_or(_multiplyColor); + _multiplyColor.setViewOption(properties::Property::ViewOptions::Color); + addProperty(_multiplyColor); + _eccentricity = p.eccentricity; _eccentricity.onChange([&]() { _planeIsDirty = true; }); addProperty(_eccentricity); @@ -179,6 +194,7 @@ void RenderableOrbitDisc::render(const RenderData& data, RendererTasks&) { _shader->setUniform(_uniformCache.opacity, opacity()); _shader->setUniform(_uniformCache.eccentricity, _eccentricity); _shader->setUniform(_uniformCache.semiMajorAxis, _size); + _shader->setUniform(_uniformCache.multiplyColor, _multiplyColor); ghoul::opengl::TextureUnit unit; unit.activate(); diff --git a/modules/exoplanets/rendering/renderableorbitdisc.h b/modules/exoplanets/rendering/renderableorbitdisc.h index e20fdd7b24..0320e8dc62 100644 --- a/modules/exoplanets/rendering/renderableorbitdisc.h +++ b/modules/exoplanets/rendering/renderableorbitdisc.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -64,10 +65,11 @@ private: properties::FloatProperty _size; properties::FloatProperty _eccentricity; properties::Vec2Property _offset; + properties::Vec3Property _multiplyColor; std::unique_ptr _shader = nullptr; UniformCache(modelViewProjection, offset, opacity, texture, - eccentricity, semiMajorAxis) _uniformCache; + eccentricity, semiMajorAxis, multiplyColor) _uniformCache; std::unique_ptr _plane; std::unique_ptr _texture; diff --git a/modules/exoplanets/shaders/orbitdisc_fs.glsl b/modules/exoplanets/shaders/orbitdisc_fs.glsl index 9dc3209e2d..bf2a53ce46 100644 --- a/modules/exoplanets/shaders/orbitdisc_fs.glsl +++ b/modules/exoplanets/shaders/orbitdisc_fs.glsl @@ -32,6 +32,7 @@ uniform vec2 offset; // relative to semi major axis uniform float opacity; uniform float eccentricity; uniform float semiMajorAxis; +uniform vec3 multiplyColor = vec3(1.0); const float Epsilon = 0.0000001; @@ -122,6 +123,7 @@ Fragment getFragment() { vec4 diffuse = texture(discTexture, textureCoord); diffuse.a *= opacity; + diffuse.rgb *= multiplyColor; Fragment frag; frag.color = diffuse; diff --git a/modules/fieldlinessequence/util/kameleonfieldlinehelper.cpp b/modules/fieldlinessequence/util/kameleonfieldlinehelper.cpp index c7c8fe9a5e..0811dba583 100644 --- a/modules/fieldlinessequence/util/kameleonfieldlinehelper.cpp +++ b/modules/fieldlinessequence/util/kameleonfieldlinehelper.cpp @@ -41,6 +41,7 @@ #include #include +#include #include #ifdef _MSC_VER diff --git a/modules/fitsfilereader/CMakeLists.txt b/modules/fitsfilereader/CMakeLists.txt index d849ea9d41..d111d5b60a 100644 --- a/modules/fitsfilereader/CMakeLists.txt +++ b/modules/fitsfilereader/CMakeLists.txt @@ -64,3 +64,8 @@ disable_external_warnings(CCfits) target_include_directories(openspace-module-fitsfilereader SYSTEM PRIVATE ${INCLUDES_FOR_TARGET}) target_link_libraries(openspace-module-fitsfilereader PRIVATE cfitsio CCfits) + +target_precompile_headers(CCfits PRIVATE + + +) diff --git a/modules/globebrowsing/CMakeLists.txt b/modules/globebrowsing/CMakeLists.txt index 70085041b4..72598ce00b 100644 --- a/modules/globebrowsing/CMakeLists.txt +++ b/modules/globebrowsing/CMakeLists.txt @@ -139,13 +139,21 @@ create_new_module( STATIC ${HEADER_FILES} ${SOURCE_FILES} ${SHADER_FILES} ) +target_precompile_headers(${globebrowsing_module} PRIVATE + + + + +) 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 7995291c79..c591d38dcb 100644 --- a/modules/globebrowsing/shaders/texturetilemapping.glsl +++ b/modules/globebrowsing/shaders/texturetilemapping.glsl @@ -374,9 +374,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 2570f96c3c..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()); @@ -2271,7 +2283,7 @@ int RenderableGlobe::desiredLevelByAvailableTileData(const Chunk& chunk) const { ZoneScoped const int currLevel = chunk.tileIndex.level; - + for (const layers::Group& gi : layers::Groups) { const std::vector& lyrs = _layerManager.layerGroup(gi.id).activeLayers(); for (Layer* layer : lyrs) { 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/globebrowsing/src/shadowcomponent.cpp b/modules/globebrowsing/src/shadowcomponent.cpp index ccff3cb64d..6f3ba1871c 100644 --- a/modules/globebrowsing/src/shadowcomponent.cpp +++ b/modules/globebrowsing/src/shadowcomponent.cpp @@ -512,7 +512,7 @@ void ShadowComponent::saveDepthBuffer() { << std::endl; ppmFile << "255" << std::endl; - std::cout << "\n\nSaving depth texture to file depthBufferShadowMapping.ppm\n\n"; + LDEBUG("Saving depth texture to file depthBufferShadowMapping.ppm"); int k = 0; for (int i = 0; i < _shadowDepthTextureWidth; i++) { for (int j = 0; j < _shadowDepthTextureHeight; j++, k++) { @@ -523,8 +523,7 @@ void ShadowComponent::saveDepthBuffer() { } ppmFile.close(); - - std::cout << "Texture saved to file depthBufferShadowMapping.ppm\n\n"; + LDEBUG("Texture saved to file depthBufferShadowMapping.ppm"); } buffer.clear(); @@ -552,7 +551,7 @@ void ShadowComponent::saveDepthBuffer() { << std::endl; ppmFile << "255" << std::endl; - std::cout << "\n\nSaving texture position to positionBufferShadowMapping.ppm\n\n"; + LDEBUG("Saving texture position to positionBufferShadowMapping.ppm"); float biggestValue = 0.f; @@ -580,7 +579,7 @@ void ShadowComponent::saveDepthBuffer() { ppmFile.close(); - LINFO("Texture saved to file positionBufferShadowMapping.ppm"); + LDEBUG("Texture saved to file positionBufferShadowMapping.ppm"); } } diff --git a/modules/iswa/CMakeLists.txt b/modules/iswa/CMakeLists.txt index 7d670e07b6..e547537a34 100644 --- a/modules/iswa/CMakeLists.txt +++ b/modules/iswa/CMakeLists.txt @@ -80,3 +80,7 @@ create_new_module( STATIC ${HEADER_FILES} ${SOURCE_FILES} ${SHADER_FILES} ) +target_precompile_headers(${iswa_module} PRIVATE + + +) diff --git a/modules/iswa/rendering/iswacygnet.h b/modules/iswa/rendering/iswacygnet.h index 7d1e355f89..dcd1dfa345 100644 --- a/modules/iswa/rendering/iswacygnet.h +++ b/modules/iswa/rendering/iswacygnet.h @@ -93,6 +93,7 @@ protected: * \return \c true if update was successful */ virtual bool updateTexture() = 0; + /** * Is called before updateTexture. For IswaCygnets getting data from a HTTP request, * this function should get the dataFile from the future object. @@ -100,6 +101,7 @@ protected: * \return \c true if update was successful */ virtual bool updateTextureResource() = 0; + /** * Should send a HTTP request to get the resource it needs to create a texture. For * Texture cygnets, this should be an image. For DataCygnets, this should be the data diff --git a/modules/iswa/util/iswamanager.cpp b/modules/iswa/util/iswamanager.cpp index dc7440f1f8..62a23c63ad 100644 --- a/modules/iswa/util/iswamanager.cpp +++ b/modules/iswa/util/iswamanager.cpp @@ -64,27 +64,25 @@ #endif // OPENSPACE_MODULE_KAMELEON_ENABLED -constexpr std::string_view monthNumber(std::string_view month) { - if (month == "JAN") return "01"; - else if (month == "FEB") return "02"; - else if (month == "MAR") return "03"; - else if (month == "APR") return "04"; - else if (month == "MAY") return "05"; - else if (month == "JUN") return "06"; - else if (month == "JUL") return "07"; - else if (month == "AUG") return "08"; - else if (month == "SEP") return "09"; - else if (month == "OCT") return "10"; - else if (month == "NOV") return "11"; - else if (month == "DEC") return "12"; - else return ""; -} - - namespace { - using json = nlohmann::json; constexpr std::string_view _loggerCat = "IswaManager"; + constexpr std::string_view monthNumber(std::string_view month) { + if (month == "JAN") return "01"; + else if (month == "FEB") return "02"; + else if (month == "MAR") return "03"; + else if (month == "APR") return "04"; + else if (month == "MAY") return "05"; + else if (month == "JUN") return "06"; + else if (month == "JUL") return "07"; + else if (month == "AUG") return "08"; + else if (month == "SEP") return "09"; + else if (month == "OCT") return "10"; + else if (month == "NOV") return "11"; + else if (month == "DEC") return "12"; + else return ""; + } + void createScreenSpace(int id) { std::string idStr = std::to_string(id); openspace::global::scriptEngine->queueScript( @@ -92,7 +90,6 @@ namespace { openspace::scripting::ScriptEngine::RemoteScripting::Yes ); } - } // namespace namespace openspace { @@ -178,7 +175,7 @@ void IswaManager::addIswaCygnet(int id, const std::string& type, std::string gro metaFuture.json = res; //convert to json - json j = json::parse(res); + nlohmann::json j = nlohmann::json::parse(res); // Check what kind of geometry here if (j["Coordinate Type"].is_null()) { @@ -357,7 +354,7 @@ std::string IswaManager::jsonPlaneToLuaTable(MetadataFuture& data) { if (data.json.empty()) { return ""; } - json j = json::parse(data.json); + nlohmann::json j = nlohmann::json::parse(data.json); std::string parent = j["Central Body"]; std::string frame = j["Coordinates"]; @@ -473,7 +470,7 @@ std::string IswaManager::jsonSphereToLuaTable(MetadataFuture& data) { return ""; } - json j = json::parse(data.json); + nlohmann::json j = nlohmann::json::parse(data.json); j = j["metadata"]; std::string parent = j["central_body"]; parent[0] = static_cast(toupper(static_cast(parent[0]))); @@ -667,16 +664,16 @@ void IswaManager::createFieldline(std::string name, std::string cdfPath, void IswaManager::fillCygnetInfo(std::string jsonString) { if (jsonString != "") { - json j = json::parse(jsonString); + nlohmann::json j = nlohmann::json::parse(jsonString); std::set lists = {"listOfPriorityCygnets", "listOfOKCygnets" // ,"listOfStaleCygnets", "listOfInactiveCygnets", }; for (const std::string& list : lists) { - json jsonList = j[list]; + nlohmann::json jsonList = j[list]; for (size_t i = 0; i < jsonList.size(); ++i) { - json jCygnet = jsonList.at(i); + nlohmann::json jCygnet = jsonList.at(i); std::string name = jCygnet["cygnetDisplayTitle"]; std::replace(name.begin(), name.end(),'.', ','); @@ -706,9 +703,9 @@ void IswaManager::addCdfFiles(std::string cdfpath) { std::ifstream jsonFile(cdfFile); if (jsonFile.is_open()) { - json cdfGroups = json::parse(jsonFile); + nlohmann::json cdfGroups = nlohmann::json::parse(jsonFile); for(size_t i = 0; i < cdfGroups.size(); ++i) { - json cdfGroup = cdfGroups.at(i); + nlohmann::json cdfGroup = cdfGroups.at(i); std::string groupName = cdfGroup["group"]; std::string fieldlineSeedsIndexFile = cdfGroup["fieldlinefile"]; @@ -720,9 +717,9 @@ void IswaManager::addCdfFiles(std::string cdfpath) { _cdfInformation[groupName] = std::vector(); - json cdfs = cdfGroup["cdfs"]; + nlohmann::json cdfs = cdfGroup["cdfs"]; for (size_t j = 0; j < cdfs.size(); j++) { - json cdf = cdfs.at(j); + nlohmann::json cdf = cdfs.at(j); std::string name = cdf["name"]; std::string path = cdf["path"]; diff --git a/modules/kameleon/CMakeLists.txt b/modules/kameleon/CMakeLists.txt index 51d5344b3a..1eb778e449 100644 --- a/modules/kameleon/CMakeLists.txt +++ b/modules/kameleon/CMakeLists.txt @@ -71,6 +71,20 @@ if (TARGET cdf) set_folder_location(cdf "External") endif () +target_precompile_headers(cdf PRIVATE + [["stdio.h"]] + [["stdlib.h"]] + [["string.h"]] +) + +target_precompile_headers(ccmc PRIVATE + "$<$:iostream>" + "$<$:map>" + "$<$:unordered_map>" + "$<$:vector>" + "$<$:boost/unordered_map.hpp>" +) + if (WIN32) target_compile_options(ccmc PRIVATE /MP) if (TARGET cdf) diff --git a/modules/kameleon/ext/kameleon b/modules/kameleon/ext/kameleon index 606edb945b..08b0e5dbfc 160000 --- a/modules/kameleon/ext/kameleon +++ b/modules/kameleon/ext/kameleon @@ -1 +1 @@ -Subproject commit 606edb945b62d0151f20270ddb2db4a9f558aaa1 +Subproject commit 08b0e5dbfc142ebb77d05409115d9df335d8abf7 diff --git a/modules/kameleon/src/kameleonhelper.cpp b/modules/kameleon/src/kameleonhelper.cpp index 95ca9bf3f2..cba12da3b1 100644 --- a/modules/kameleon/src/kameleonhelper.cpp +++ b/modules/kameleon/src/kameleonhelper.cpp @@ -35,6 +35,7 @@ #endif // _MSC_VER #include +#include #ifdef _MSC_VER #pragma warning (pop) diff --git a/modules/kameleon/src/kameleonwrapper.cpp b/modules/kameleon/src/kameleonwrapper.cpp index 654df4e8d1..774d146136 100644 --- a/modules/kameleon/src/kameleonwrapper.cpp +++ b/modules/kameleon/src/kameleonwrapper.cpp @@ -39,6 +39,8 @@ #endif // WIN32 #include +#include +#include #include #include #include diff --git a/modules/kameleonvolume/kameleonvolumereader.cpp b/modules/kameleonvolume/kameleonvolumereader.cpp index 841fb06e08..e3c0bb5530 100644 --- a/modules/kameleonvolume/kameleonvolumereader.cpp +++ b/modules/kameleonvolume/kameleonvolumereader.cpp @@ -42,6 +42,7 @@ #include #include +#include #include #include #include diff --git a/modules/multiresvolume/rendering/histogrammanager.h b/modules/multiresvolume/rendering/histogrammanager.h index 5500f98480..40f3ff9838 100644 --- a/modules/multiresvolume/rendering/histogrammanager.h +++ b/modules/multiresvolume/rendering/histogrammanager.h @@ -27,7 +27,6 @@ #include #include -#include namespace openspace { diff --git a/modules/server/CMakeLists.txt b/modules/server/CMakeLists.txt index 63fb71d65a..c7749c31d4 100644 --- a/modules/server/CMakeLists.txt +++ b/modules/server/CMakeLists.txt @@ -82,3 +82,10 @@ create_new_module( server_module ${HEADER_FILES} ${SOURCE_FILES} ) + +target_precompile_headers(${server_module} PRIVATE + + + + +) diff --git a/modules/skybrowser/CMakeLists.txt b/modules/skybrowser/CMakeLists.txt index 6746d36731..af3b6c6045 100644 --- a/modules/skybrowser/CMakeLists.txt +++ b/modules/skybrowser/CMakeLists.txt @@ -63,3 +63,7 @@ create_new_module( STATIC ${HEADER_FILES} ${SOURCE_FILES} ${SHADER_FILES} ) +target_precompile_headers(${skybrowser_module} PRIVATE + [["include/cef_accessibility_handler.h"]] + [["include/cef_render_handler.h"]] +) diff --git a/modules/space/CMakeLists.txt b/modules/space/CMakeLists.txt index 3337872afe..73673fffd0 100644 --- a/modules/space/CMakeLists.txt +++ b/modules/space/CMakeLists.txt @@ -27,8 +27,11 @@ 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 + rendering/renderableconstellationlines.h rendering/renderablefluxnodes.h rendering/renderablehabitablezone.h rendering/renderablerings.h @@ -47,8 +50,11 @@ set(SOURCE_FILES horizonsfile.cpp kepler.cpp spacemodule_lua.inl + labelscomponent.cpp speckloader.cpp + rendering/renderableconstellationsbase.cpp rendering/renderableconstellationbounds.cpp + rendering/renderableconstellationlines.cpp rendering/renderablefluxnodes.cpp rendering/renderablehabitablezone.cpp rendering/renderablerings.cpp @@ -66,6 +72,8 @@ source_group("Source Files" FILES ${SOURCE_FILES}) set(SHADER_FILES shaders/constellationbounds_fs.glsl shaders/constellationbounds_vs.glsl + shaders/constellationlines_fs.glsl + shaders/constellationlines_vs.glsl shaders/debrisViz_fs.glsl shaders/debrisViz_vs.glsl shaders/fluxnodes_fs.glsl @@ -88,3 +96,12 @@ create_new_module( STATIC ${HEADER_FILES} ${SOURCE_FILES} ${SHADER_FILES} ) +target_precompile_headers(${space_module} PRIVATE + + + + + + + +) 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 6a1c798c5c..e9e6890719 100644 --- a/modules/space/rendering/renderableconstellationbounds.cpp +++ b/modules/space/rendering/renderableconstellationbounds.cpp @@ -25,13 +25,11 @@ #include #include -#include #include #include #include #include #include -#include #include #include #include @@ -50,14 +48,6 @@ namespace { "constellations" }; - constexpr openspace::properties::Property::PropertyInfo ConstellationInfo = { - "ConstellationFile", - "Constellation File Path", - "Specifies the file that contains the mapping between constellation " - "abbreviations and full name of the constellation. If this value is empty, the " - "abbreviations are used as the full names" - }; - constexpr openspace::properties::Property::PropertyInfo ColorInfo = { "Color", "Color of constellation lines", @@ -65,33 +55,12 @@ namespace { "full opacity" }; - constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = { - "LineWidth", - "Line Width", - "The line width of the constellation bounds" - }; - - constexpr openspace::properties::Property::PropertyInfo SelectionInfo = { - "ConstellationSelection", - "Constellation Selection", - "The constellations that are selected are displayed on the celestial sphere" - }; - struct [[codegen::Dictionary(RenderableConstellationBounds)]] Parameters { // [[codegen::verbatim(VertexInfo.description)]] - std::string file; - - // [[codegen::verbatim(ConstellationInfo.description)]] - std::optional constellationFile; + std::filesystem::path file; // [[codegen::verbatim(ColorInfo.description)]] std::optional color [[codegen::color()]]; - - // [[codegen::verbatim(LineWidthInfo.description)]] - std::optional lineWidth; - - // [[codegen::verbatim(SelectionInfo.description)]] - std::optional> constellationSelection; }; #include "renderableconstellationbounds_codegen.cpp" } // namespace @@ -103,53 +72,46 @@ documentation::Documentation RenderableConstellationBounds::Documentation() { } RenderableConstellationBounds::RenderableConstellationBounds( - const ghoul::Dictionary& dictionary) - : Renderable(dictionary) + const ghoul::Dictionary& dictionary) + : RenderableConstellationsBase(dictionary) , _vertexFilename(VertexInfo) - , _constellationFilename(ConstellationInfo) , _color(ColorInfo, glm::vec3(1.f, 0.f, 0.f), glm::vec3(0.f), glm::vec3(1.f)) - , _lineWidth(LineWidthInfo, 2.f, 1.f, 32.f) - , _constellationSelection(SelectionInfo) { const Parameters p = codegen::bake(dictionary); - _vertexFilename.onChange([&](){ loadVertexFile(); }); + // Avoid reading files here, instead do it in multithreaded initialize() + _vertexFilename = absPath(p.file.string()).string(); + _vertexFilename.onChange([&](){ loadData(); }); addProperty(_vertexFilename); - _vertexFilename = p.file; - - _constellationFilename.onChange([&](){ loadConstellationFile(); }); - _constellationFilename = p.constellationFile.value_or(_constellationFilename); - addProperty(_constellationFilename); _color.setViewOption(properties::Property::ViewOptions::Color); _color = p.color.value_or(_color); addProperty(_color); +} - _lineWidth = p.lineWidth.value_or(_lineWidth); - addProperty(_lineWidth); +void RenderableConstellationBounds::initialize() { + RenderableConstellationsBase::initialize(); - fillSelectionProperty(); - _constellationSelection.onChange([this]() { selectionPropertyHasChanged(); }); - addProperty(_constellationSelection); + loadData(); - if (p.constellationSelection.has_value()) { - const std::vector options = _constellationSelection.options(); + if (!_assetSelection.empty()) { + const std::vector options = _selection.options(); + std::set selectedConstellations; - std::set selectedNames; - for (const std::string& s : *p.constellationSelection) { + for (const std::string& s : _assetSelection) { const auto it = std::find(options.begin(), options.end(), s); if (it == options.end()) { // The user has specified a constellation name that doesn't exist LWARNINGC( - "RenderableConstellationBounds", + "RenderableConstellationsBase", fmt::format("Option '{}' not found in list of constellations", s) ); } else { - selectedNames.insert(s); + selectedConstellations.insert(s); } } - _constellationSelection = selectedNames; + _selection = selectedConstellations; } } @@ -192,10 +154,16 @@ void RenderableConstellationBounds::deinitializeGL() { } bool RenderableConstellationBounds::isReady() const { - return (_vao != 0) && (_vbo != 0) && _program; + bool isReady = _program && _vao != 0 && _vbo != 0; + + // If we have labels, they also need to be loaded + if (_hasLabels) { + isReady = isReady && RenderableConstellationsBase::isReady(); + } + return isReady; } -void RenderableConstellationBounds::render(const RenderData& data, RendererTasks&) { +void RenderableConstellationBounds::render(const RenderData& data, RendererTasks& tasks) { _program->activate(); _program->setUniform("campos", glm::vec4(data.camera.positionVec3(), 1.f)); @@ -212,6 +180,7 @@ void RenderableConstellationBounds::render(const RenderData& data, RendererTasks _program->setUniform("ViewProjection", data.camera.viewProjectionMatrix()); _program->setUniform("ModelTransform", glm::mat4(modelTransform)); _program->setUniform("color", _color); + _program->setUniform("opacity", opacity()); glLineWidth(_lineWidth); @@ -223,6 +192,16 @@ void RenderableConstellationBounds::render(const RenderData& data, RendererTasks } glBindVertexArray(0); _program->deactivate(); + + RenderableConstellationsBase::render(data, tasks); +} + +bool RenderableConstellationBounds::loadData() { + bool success = loadVertexFile(); + if (!success) { + throw ghoul::RuntimeError("Error loading data"); + } + return success; } bool RenderableConstellationBounds::loadVertexFile() { @@ -261,8 +240,8 @@ bool RenderableConstellationBounds::loadVertexFile() { float dec; s >> dec; - std::string constellationName; - s >> constellationName; + std::string abbreviation; + s >> abbreviation; if (!s.good()) { // If this evaluates to true, the stream was not completely filled, which @@ -277,7 +256,7 @@ bool RenderableConstellationBounds::loadVertexFile() { } // Did we arrive at a new constellation? - if (constellationName != currentBound.constellationAbbreviation) { + if (abbreviation != currentBound.constellationAbbreviation) { // Store how many vertices we read during the active time of the constellation currentBound.nVertices = static_cast( _vertexValues.size() - currentBound.startIndex @@ -286,8 +265,9 @@ bool RenderableConstellationBounds::loadVertexFile() { _constellationBounds.push_back(currentBound); currentBound = ConstellationBound(); currentBound.isEnabled = true; - currentBound.constellationAbbreviation = constellationName; - currentBound.constellationFullName = constellationName; + currentBound.constellationAbbreviation = abbreviation; + std::string name = constellationFullName(abbreviation); + currentBound.constellationFullName = name.empty() ? abbreviation : name; currentBound.startIndex = static_cast(_vertexValues.size()); } @@ -326,64 +306,9 @@ bool RenderableConstellationBounds::loadVertexFile() { return true; } -bool RenderableConstellationBounds::loadConstellationFile() { - if (_constellationFilename.value().empty()) { - return true; - } - - std::ifstream file; - file.exceptions(std::ifstream::goodbit); - file.open(absPath(_constellationFilename)); - - std::string line; - int index = 0; - while (file.good()) { - std::getline(file, line); - if (line.empty()) { - continue; - } - - std::string abbreviation; - std::stringstream s(line); - s >> abbreviation; - - const auto it = std::find_if( - _constellationBounds.begin(), - _constellationBounds.end(), - [abbreviation](const ConstellationBound& bound) { - return bound.constellationAbbreviation == abbreviation; - } - ); - if (it == _constellationBounds.end()) { - LERRORC( - "RenderableConstellationBounds", - fmt::format("Could not find constellation '{}' in list", abbreviation) - ); - return false; - } - - // Update the constellations full name - std::string fullName; - std::getline(s, fullName); - ghoul::trimWhitespace(fullName); - it->constellationFullName = std::move(fullName); - - ++index; - } - - return true; -} - -void RenderableConstellationBounds::fillSelectionProperty() { - for (int i = 0 ; i < static_cast(_constellationBounds.size()); ++i) { - const ConstellationBound& bound = _constellationBounds[i]; - _constellationSelection.addOption(bound.constellationFullName); - } -} - void RenderableConstellationBounds::selectionPropertyHasChanged() { // If no values are selected (the default), we want to show all constellations - if (!_constellationSelection.hasSelected()) { + if (!_selection.hasSelected()) { for (ConstellationBound& b : _constellationBounds) { b.isEnabled = true; } @@ -391,7 +316,7 @@ void RenderableConstellationBounds::selectionPropertyHasChanged() { else { // Enable all constellations that are selected for (ConstellationBound& b : _constellationBounds) { - b.isEnabled = _constellationSelection.isSelected(b.constellationFullName); + b.isEnabled = _selection.isSelected(b.constellationFullName); } } } diff --git a/modules/space/rendering/renderableconstellationbounds.h b/modules/space/rendering/renderableconstellationbounds.h index bf52622de4..f6486a50de 100644 --- a/modules/space/rendering/renderableconstellationbounds.h +++ b/modules/space/rendering/renderableconstellationbounds.h @@ -25,13 +25,7 @@ #ifndef __OPENSPACE_MODULE_SPACE___RENDERABLECONSTELLATIONBOUNDS___H__ #define __OPENSPACE_MODULE_SPACE___RENDERABLECONSTELLATIONBOUNDS___H__ -#include - -#include -#include -#include -#include -#include +#include namespace ghoul::opengl { class ProgramObject; } @@ -48,10 +42,11 @@ namespace documentation { struct Documentation; } * _distance property. Currently, all constellation bounds are lines, which * leads to artifacts if the radius is very small. */ -class RenderableConstellationBounds : public Renderable { +class RenderableConstellationBounds : public RenderableConstellationsBase { public: RenderableConstellationBounds(const ghoul::Dictionary& dictionary); + void initialize() override; void initializeGL() override; void deinitializeGL() override; @@ -79,41 +74,25 @@ private: * \return \c true if the loading succeeded, \c false otherwise */ bool loadVertexFile(); - - /** - * Loads the file specified in _constellationFilename that contains the mapping - * between abbreviations and full names of constellations. - * - * \return true if the loading succeeded, false otherwise - */ - bool loadConstellationFile(); - - /// Fills the _constellationSelection property with all constellations - void fillSelectionProperty(); + bool loadData(); /** * Callback method that gets triggered when _constellationSelection * changes. */ - void selectionPropertyHasChanged(); + void selectionPropertyHasChanged() override; /// The filename containing the constellation bounds properties::StringProperty _vertexFilename; - /// The file containing constellation names - properties::StringProperty _constellationFilename; - /// Determines the color of the constellation lines properties::Vec3Property _color; - // Linewidth for the constellation bounds - properties::FloatProperty _lineWidth; - - std::unique_ptr _program; - /// The list of all loaded constellation bounds std::vector _constellationBounds; + std::unique_ptr _program; + struct Vertex { float x; float y; @@ -121,9 +100,6 @@ private: }; std::vector _vertexValues; ///< A list of all vertices of all bounds - /// The property that stores all indices of constellations that should be drawn - properties::SelectionProperty _constellationSelection; - GLuint _vao = 0; GLuint _vbo = 0; }; diff --git a/modules/space/rendering/renderableconstellationlines.cpp b/modules/space/rendering/renderableconstellationlines.cpp new file mode 100644 index 0000000000..8ed5943dbf --- /dev/null +++ b/modules/space/rendering/renderableconstellationlines.cpp @@ -0,0 +1,448 @@ +/***************************************************************************************** + * * + * 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 +#include +#include +#include +#include +#include +#include +#include + +namespace { + constexpr std::string_view _loggerCat = "RenderableConstellationLines"; + + constexpr std::array UniformNames = { + "modelViewTransform", "projectionTransform", "opacity", "color" + }; + + constexpr openspace::properties::Property::PropertyInfo SpeckInfo = { + "File", + "Constellation Data File Path", + "The file that contains the data for the constellation lines" + }; + + constexpr openspace::properties::Property::PropertyInfo DrawElementsInfo = { + "DrawElements", + "Draw Elements", + "Enables/Disables the drawing of the constellations" + }; + + constexpr openspace::properties::Property::PropertyInfo UnitInfo = { + "Unit", + "Unit", + "The distance unit used for the constellation lines data" + }; + + constexpr openspace::properties::Property::PropertyInfo ColorsInfo = { + "Colors", + "Constellation Colors", + "The defined colors for the constellations to be rendered. " + "There can be several groups of constellaitons that can have distinct colors." + }; + + struct [[codegen::Dictionary(RenderableConstellationLines)]] Parameters { + // The path to the SPECK file that contains constellation lines data + std::filesystem::path file; + + 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(UnitInfo.description)]] + std::optional unit; + + // [[codegen::verbatim(ColorsInfo.description)]] + std::optional> colors; + }; +#include "renderableconstellationlines_codegen.cpp" +} // namespace + +namespace openspace { + +documentation::Documentation RenderableConstellationLines::Documentation() { + return codegen::doc("space_renderable_constellationlines"); +} + +RenderableConstellationLines::RenderableConstellationLines( + const ghoul::Dictionary& dictionary) + : RenderableConstellationsBase(dictionary) + , _speckFile(SpeckInfo) + , _drawElements(DrawElementsInfo, true) +{ + const Parameters p = codegen::bake(dictionary); + + // Avoid reading files here, instead do it in multithreaded initialize() + _speckFile = absPath(p.file.string()).string(); + _speckFile.onChange([&]() { loadData(); }); + addProperty(_speckFile); + + addProperty(_drawElements); + + if (p.unit.has_value()) { + _constellationUnit = codegen::map(*p.unit); + } + else { + _constellationUnit = DistanceUnit::Meter; + } + + if (p.colors.has_value()) { + std::vector ops = *p.colors; + for (size_t i = 0; i < ops.size(); ++i) { + _constellationColorMap.insert({ static_cast(i) + 1, ops[i] }); + } + } +} + +void RenderableConstellationLines::selectionPropertyHasChanged() { + using ConstellationKeyValuePair = std::pair; + + // If no values are selected (the default), we want to show all constellations + if (!_selection.hasSelected()) { + for (ConstellationKeyValuePair& pair : _renderingConstellationsMap) + { + pair.second.isEnabled = true; + } + } + else { + // Enable all constellations that are selected + for (ConstellationKeyValuePair& pair : _renderingConstellationsMap) + { + pair.second.isEnabled = _selection.isSelected(pair.second.name); + } + } +} + +bool RenderableConstellationLines::isReady() const { + bool isReady = _program && !_renderingConstellationsMap.empty(); + + // If we have labels, they also need to be loaded + if (_hasLabels) { + return isReady && RenderableConstellationsBase::isReady(); + } + return isReady; +} + +void RenderableConstellationLines::initialize() { + RenderableConstellationsBase::initialize(); + + loadData(); + + if (!_assetSelection.empty()) { + const std::vector options = _selection.options(); + std::set selectedConstellations; + + for (const std::string& s : _assetSelection) { + const auto it = std::find(options.begin(), options.end(), s); + if (it == options.end()) { + // The user has specified a constellation name that doesn't exist + LWARNINGC( + "RenderableConstellationsBase", + fmt::format("Option '{}' not found in list of constellations", s) + ); + } + else { + selectedConstellations.insert(s); + } + } + _selection = selectedConstellations; + } +} + +void RenderableConstellationLines::initializeGL() { + _program = global::renderEngine->buildRenderProgram( + "RenderableConstellationLines", + absPath("${MODULE_SPACE}/shaders/constellationlines_vs.glsl"), + absPath("${MODULE_SPACE}/shaders/constellationlines_fs.glsl") + ); + + ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames); + + createConstellations(); +} + +void RenderableConstellationLines::deinitializeGL() { + using ConstellationKeyValuePair = std::pair; + for (const ConstellationKeyValuePair& pair : _renderingConstellationsMap) + { + glDeleteVertexArrays(1, &pair.second.vaoArray); + glDeleteBuffers(1, &pair.second.vboArray); + } + + if (_program) { + global::renderEngine->removeRenderProgram(_program.get()); + _program = nullptr; + } +} + +void RenderableConstellationLines::renderConstellations(const RenderData&, + const glm::dmat4& modelViewMatrix, + const glm::dmat4& projectionMatrix) +{ + glEnablei(GL_BLEND, 0); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glDepthMask(false); + glEnable(GL_DEPTH_TEST); + + _program->activate(); + + _program->setUniform(_uniformCache.modelViewTransform, modelViewMatrix); + _program->setUniform(_uniformCache.projectionTransform, projectionMatrix); + _program->setUniform(_uniformCache.opacity, opacity()); + + using ConstellationKeyValuePair = std::pair; + for (const ConstellationKeyValuePair& pair : _renderingConstellationsMap) + { + if (!pair.second.isEnabled) { + continue; + } + + _program->setUniform( + _uniformCache.color, + _constellationColorMap[pair.second.colorIndex] + ); + + glBindVertexArray(pair.second.vaoArray); + + glLineWidth(_lineWidth); + glDrawArrays(GL_LINE_STRIP, 0, pair.second.numV); + global::renderEngine->openglStateCache().resetLineState(); + } + + glBindVertexArray(0); + _program->deactivate(); + + // Restores GL State + global::renderEngine->openglStateCache().resetDepthState(); + global::renderEngine->openglStateCache().resetBlendState(); +} + +void RenderableConstellationLines::render(const RenderData& data, RendererTasks& tasks) { + 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)); + + const glm::dmat4 modelViewMatrix = data.camera.combinedViewMatrix() * modelMatrix; + const glm::dmat4 projectionMatrix = data.camera.projectionMatrix(); + + if (_drawElements) { + renderConstellations(data, modelViewMatrix, projectionMatrix); + } + + RenderableConstellationsBase::render(data, tasks); +} + +void RenderableConstellationLines::update(const UpdateData&) { + if (_program->isDirty()) { + _program->rebuildFromFile(); + ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames); + } +} + +bool RenderableConstellationLines::loadData() { + bool success = readSpeckFile(); + if (!success) { + throw ghoul::RuntimeError("Error loading data"); + } + return success; +} + +bool RenderableConstellationLines::readSpeckFile() { + if (_speckFile.value().empty()) { + return false; + } + std::filesystem::path fileName = absPath(_speckFile); + + LINFO(fmt::format("Loading Speck file {}", fileName)); + std::ifstream file(fileName); + if (!file.good()) { + LERROR(fmt::format("Failed to open Speck file {}", fileName)); + return false; + } + + const float scale = static_cast(toMeter(_constellationUnit)); + double maxRadius = 0.0; + + int lineIndex = 0; + + // The beginning of the speck file has a header that either contains comments + // (signaled by a preceding '#') or information about the structure of the file + // (signaled by the keywords 'datavar', 'texturevar', and 'texture') + std::string line; + while (true) { + std::getline(file, line); + + if (file.eof()) { + break; + } + + // Guard against wrong line endings (copying files from Windows to Mac) causes + // lines to have a final \r + if (!line.empty() && line.back() == '\r') { + line = line.substr(0, line.length() - 1); + } + + if (line.empty() || line[0] == '#') { + continue; + } + + std::size_t found = line.find("mesh"); + if (found == std::string::npos) { + continue; + } + else { + // mesh lines are structured as follows: + // mesh -c colorindex { + // colorindex is the index of the color for the mesh + std::stringstream str(line); + + ConstellationLine constellationLine; + constellationLine.lineIndex = lineIndex; + + std::string dummy; + str >> dummy; // mesh command + dummy.clear(); + str >> dummy; // color index command + do { + if (dummy == "-c") { + str >> constellationLine.colorIndex; // color index + } + else { + std::string message = fmt::format("Unknown command '{}' found in " + "constellation file '{}'", dummy, fileName); + LWARNING(message); + } + dummy.clear(); + str >> dummy; + } while (dummy != "{"); + + std::getline(file, line); + + // Read the identifier + std::stringstream id(line); + std::string identifier; + + id >> dummy; // id command + dummy.clear(); + std::getline(id, identifier); // identifier + ghoul::trimWhitespace(identifier); + std::string name = constellationFullName(identifier); + if (!name.empty()) { + constellationLine.name = name; + } + + // Read the number of vertices + std::getline(file, line); + std::stringstream dim(line); + dim >> constellationLine.numV; + + // We can now read the vertices data: + for (int l = 0; l < constellationLine.numV; ++l) { + std::getline(file, line); + if (line.substr(0, 1) == "}") { + break; + } + + // Try to read three values for the position + glm::vec3 pos; + bool success = true; + auto reading = scn::scan(line, "{} {} {}", pos.x, pos.y, pos.z); + if (reading) { + pos *= scale; + constellationLine.vertices.push_back(pos.x); + constellationLine.vertices.push_back(pos.y); + constellationLine.vertices.push_back(pos.z); + } + else { + success = false; + LERROR(fmt::format( + "Failed reading position on line {} of mesh {} in file: '{}'. " + "Stopped reading constellation data", l, lineIndex, fileName + )); + } + + // Check if new max radius + const double r = glm::length(glm::dvec3(pos)); + maxRadius = std::max(maxRadius, r); + } + + std::getline(file, line); + if (line.substr(0, 1) == "}") { + _renderingConstellationsMap.insert({ lineIndex++, constellationLine }); + } + else { + return false; + } + } + } + setBoundingSphere(maxRadius); + + return true; +} + +void RenderableConstellationLines::createConstellations() { + LDEBUG("Creating constellations"); + + for (std::pair& p : _renderingConstellationsMap) { + GLuint vao; + glGenVertexArrays(1, &vao); + p.second.vaoArray = vao; + + GLuint vbo; + glGenBuffers(1, &vbo); + p.second.vboArray = vbo; + + glBindVertexArray(vao); + glBindBuffer(GL_ARRAY_BUFFER, vbo); + glBufferData( + GL_ARRAY_BUFFER, + p.second.vertices.size() * sizeof(GLfloat), + p.second.vertices.data(), + GL_STATIC_DRAW + ); + // in_position + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, nullptr); + } + + glBindVertexArray(0); +} + +} // namespace openspace diff --git a/modules/space/rendering/renderableconstellationlines.h b/modules/space/rendering/renderableconstellationlines.h new file mode 100644 index 0000000000..8453fc5dc5 --- /dev/null +++ b/modules/space/rendering/renderableconstellationlines.h @@ -0,0 +1,102 @@ +/***************************************************************************************** + * * + * 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___RENDERABLECONSTELLATIONLINES___H__ +#define __OPENSPACE_MODULE_SPACE___RENDERABLECONSTELLATIONLINES___H__ + +#include + +#include +#include + +namespace ghoul::filesystem { class File; } +namespace ghoul::fontrendering { class Font; } +namespace ghoul::opengl { + class ProgramObject; + class Texture; +} // namespace ghoul::opengl + +namespace openspace { + +namespace documentation { struct Documentation; } + +class RenderableConstellationLines : public RenderableConstellationsBase { +public: + explicit RenderableConstellationLines(const ghoul::Dictionary& dictionary); + ~RenderableConstellationLines() override = default; + + void initialize() override; + void initializeGL() override; + void deinitializeGL() override; + + bool isReady() const override; + + void render(const RenderData& data, RendererTasks& rendererTask) override; + void update(const UpdateData& data) override; + + static documentation::Documentation Documentation(); + +private: + struct ConstellationLine { + bool isEnabled = true; + std::string name; + int lineIndex; + int colorIndex; + int numV; + GLuint vaoArray; + GLuint vboArray; + std::vector vertices; + }; + + void createConstellations(); + void renderConstellations(const RenderData& data, const glm::dmat4& modelViewMatrix, + const glm::dmat4& projectionMatrix); + + bool loadData(); + bool readSpeckFile(); + + /** + * Callback method that gets triggered when _constellationSelection + * changes + */ + void selectionPropertyHasChanged() override; + + properties::BoolProperty _drawElements; + + std::unique_ptr _program = nullptr; + UniformCache(modelViewTransform, projectionTransform, opacity, + color) _uniformCache; + + properties::StringProperty _speckFile; + + DistanceUnit _constellationUnit = DistanceUnit::Parsec; + + std::vector _fullData; + + std::unordered_map _constellationColorMap; + std::unordered_map _renderingConstellationsMap; +}; +} // namespace openspace + +#endif // __OPENSPACE_MODULE_SPACE___RENDERABLECONSTELLATIONLINES___H__ diff --git a/modules/space/rendering/renderableconstellationsbase.cpp b/modules/space/rendering/renderableconstellationsbase.cpp new file mode 100644 index 0000000000..bb8ca8f7c1 --- /dev/null +++ b/modules/space/rendering/renderableconstellationsbase.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 +#include +#include +#include + +namespace { + constexpr openspace::properties::Property::PropertyInfo NamesFileInfo = { + "NamesFile", + "Constellation Names File Path", + "Specifies the file that contains the mapping between constellation " + "abbreviations and full names of the constellations. If this value is empty, the " + "abbreviations are used as the full names" + }; + + constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = { + "LineWidth", + "Line Width", + "The line width of the constellation" + }; + + constexpr openspace::properties::Property::PropertyInfo DrawLabelInfo = { + "DrawLabels", + "Draw Labels", + "Determines whether labels should be drawn or hidden" + }; + + 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; + + // [[codegen::verbatim(NamesFileInfo.description)]] + std::optional namesFile; + + // [[codegen::verbatim(LineWidthInfo.description)]] + std::optional lineWidth; + + // [[codegen::verbatim(SelectionInfo.description)]] + std::optional> selection; + + // [[codegen::verbatim(LabelsInfo.description)]] + std::optional labels + [[codegen::reference("space_labelscomponent")]]; + }; +#include "renderableconstellationsbase_codegen.cpp" +} // namespace + +namespace openspace { + +documentation::Documentation RenderableConstellationsBase::Documentation() { + return codegen::doc("space_renderable_constellationsbase"); +} + +RenderableConstellationsBase::RenderableConstellationsBase(const ghoul::Dictionary& dictionary) + : Renderable(dictionary) + , _drawLabels(DrawLabelInfo, false) + , _lineWidth(LineWidthInfo, 2.f, 1.f, 16.f) + , _namesFilename(NamesFileInfo) + , _selection(SelectionInfo) +{ + const Parameters p = codegen::bake(dictionary); + + addProperty(_opacity); + registerUpdateRenderBinFromOpacity(); + + // Avoid reading files here, instead do it in multithreaded initialize() + if (p.namesFile.has_value()) { + _namesFilename = absPath(p.namesFile.value().string()).string(); + } + _namesFilename.onChange([&]() { loadConstellationFile(); }); + addProperty(_namesFilename); + + _lineWidth = p.lineWidth.value_or(_lineWidth); + addProperty(_lineWidth); + + if (p.labels.has_value()) { + _drawLabels = p.drawLabels.value_or(_drawLabels); + addProperty(_drawLabels); + + _labels = std::make_unique(*p.labels); + _hasLabels = true; + addPropertySubOwner(_labels.get()); + } + + _selection.onChange([this]() { selectionPropertyHasChanged(); }); + addProperty(_selection); + + _assetSelection = p.selection.value_or(_assetSelection); +} + +std::string RenderableConstellationsBase::constellationFullName( + const std::string& identifier) const +{ + if (_namesTranslation.empty() || identifier.empty()) { + std::string message = "List of constellations or the given identifier was empty"; + LWARNINGC("RenderableConstellationsBase", message); + return ""; + } + + if (_namesTranslation.contains(identifier)) { + return _namesTranslation.at(identifier); + } + + std::string message = fmt::format( + "Identifier '{}' could not be found in list of constellations", identifier + ); + LERRORC("RenderableConstellationsBase", message); + return ""; +} + +void RenderableConstellationsBase::loadConstellationFile() { + if (_namesFilename.value().empty()) { + return; + } + + // Reset + _selection.clearOptions(); + _namesTranslation.clear(); + + // Load the constellation names file + std::ifstream file; + file.exceptions(std::ifstream::goodbit); + file.open(absPath(_namesFilename)); + + std::string line; + while (file.good()) { + std::getline(file, line); + if (line.empty()) { + continue; + } + + std::string abbreviation; + std::stringstream s(line); + s >> abbreviation; + + std::string fullName; + std::getline(s, fullName); + ghoul::trimWhitespace(fullName); + _namesTranslation[abbreviation] = fullName; + } + + fillSelectionProperty(); +} + +void RenderableConstellationsBase::fillSelectionProperty() { + for (const std::pair& pair : _namesTranslation) { + _selection.addOption(pair.second); + } +} + +void RenderableConstellationsBase::initialize() { + loadConstellationFile(); + + if (!_hasLabels) { + return; + } + + _labels->initialize(); + _labels->loadLabels(); + + for (speck::Labelset::Entry& entry : _labels->labelSet().entries) { + if (!entry.identifier.empty()) { + std::string fullName = constellationFullName(entry.identifier); + if (!fullName.empty()) { + entry.text = fullName; + } + } + } +} + +bool RenderableConstellationsBase::isReady() const { + return _hasLabels ? _labels->isReady() : true; +} + +void RenderableConstellationsBase::render(const RenderData& data, RendererTasks&) { + if (!_hasLabels || !_drawLabels) { + return; + } + + 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)); + + const glm::dmat4 modelViewMatrix = data.camera.combinedViewMatrix() * modelMatrix; + const glm::dmat4 projectionMatrix = data.camera.projectionMatrix(); + const glm::dmat4 modelViewProjectionMatrix = projectionMatrix * modelViewMatrix; + + 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.f)) + ); + + if (orthoRight == glm::vec3(0.f)) { + glm::vec3 otherVector(lookup.y, lookup.x, lookup.z); + right = glm::cross(viewDirection, otherVector); + orthoRight = glm::normalize( + glm::vec3(worldToModelTransform * glm::vec4(right, 0.f)) + ); + } + + const glm::vec3 orthoUp = glm::normalize( + glm::vec3(worldToModelTransform * glm::dvec4(up, 0.f)) + ); + _labels->render(data, modelViewProjectionMatrix, orthoRight, orthoUp); +} + +} // namespace openspace diff --git a/modules/space/rendering/renderableconstellationsbase.h b/modules/space/rendering/renderableconstellationsbase.h new file mode 100644 index 0000000000..1987750db0 --- /dev/null +++ b/modules/space/rendering/renderableconstellationsbase.h @@ -0,0 +1,114 @@ +/***************************************************************************************** + * * + * 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___RENDERABLECONSTELLATIONSBASE___H__ +#define __OPENSPACE_MODULE_SPACE___RENDERABLECONSTELLATIONSBASE___H__ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace ghoul::opengl { class ProgramObject; } + +namespace openspace { + +namespace documentation { struct Documentation; } + +/** + * This is a base class for constellation lines and bounds + */ +class RenderableConstellationsBase : public Renderable { +public: + virtual ~RenderableConstellationsBase() override = default; + + virtual void initialize() override; + virtual void initializeGL() override = 0; + virtual void deinitializeGL() override = 0; + + virtual bool isReady() const override; + + virtual void render(const RenderData& data, RendererTasks& rendererTask) override; + + static documentation::Documentation Documentation(); + +protected: + explicit RenderableConstellationsBase(const ghoul::Dictionary& dictionary); + + /** + * Callback method that gets triggered when _constellationSelection + * changes + */ + virtual void selectionPropertyHasChanged() = 0; + + /// Takes the given constellation identifier and returns the coresponding + /// full name + std::string constellationFullName(const std::string& identifier) const; + + // Width for the rendered lines + properties::FloatProperty _lineWidth; + + // Property that stores all constellations chosen by the user to be drawn + properties::SelectionProperty _selection; + + // Temporary storage of which constellations should be rendered as stated in the + // asset file + std::vector _assetSelection; + + // Labels + bool _hasLabels = false; + properties::BoolProperty _drawLabels; + +private: + // Map over the constellations names and their abbreviations + // key = abbreviation, value = full name + std::map _namesTranslation; + + /** + * Loads the file specified in _constellationNamesFilename that contains + * the mapping between abbreviations and full names of constellations + */ + void loadConstellationFile(); + + /// Fills the _constellationSelection property with all constellations + void fillSelectionProperty(); + + // The file containing constellation names and abbreviations + properties::StringProperty _namesFilename; + + // Everything related to the labels is handled by LabelsComponent + std::unique_ptr _labels; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_SPACE___RENDERABLECONSTELLATIONSBASE___H__ 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/shaders/constellationbounds_fs.glsl b/modules/space/shaders/constellationbounds_fs.glsl index 52237023b8..ce1a490d4e 100644 --- a/modules/space/shaders/constellationbounds_fs.glsl +++ b/modules/space/shaders/constellationbounds_fs.glsl @@ -28,13 +28,18 @@ in vec4 vs_position; uniform vec3 color; +uniform float opacity; Fragment getFragment() { - vec4 position = vs_position; - Fragment frag; - frag.color = vec4(color, 1.0); + if (opacity == 0.0) { + discard; + } + + vec4 position = vs_position; + + frag.color = vec4(color, opacity); frag.depth = pscDepth(position); return frag; diff --git a/modules/space/shaders/constellationlines_fs.glsl b/modules/space/shaders/constellationlines_fs.glsl new file mode 100644 index 0000000000..06311674c6 --- /dev/null +++ b/modules/space/shaders/constellationlines_fs.glsl @@ -0,0 +1,47 @@ +/***************************************************************************************** + * * + * 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 "fragment.glsl" + +in float vs_screenSpaceDepth; +in vec4 vs_positionViewSpace; + +uniform vec3 color; +uniform float opacity; + + +Fragment getFragment() { + Fragment frag; + if (opacity == 0.0) { + discard; + } + + frag.color = vec4(color, opacity); + frag.depth = vs_screenSpaceDepth; + + frag.gPosition = vs_positionViewSpace; + frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0); + + return frag; +} diff --git a/modules/space/shaders/constellationlines_vs.glsl b/modules/space/shaders/constellationlines_vs.glsl new file mode 100644 index 0000000000..1fa6aa80fe --- /dev/null +++ b/modules/space/shaders/constellationlines_vs.glsl @@ -0,0 +1,47 @@ +/***************************************************************************************** + * * + * 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. * + ****************************************************************************************/ + +#version __CONTEXT__ + +#include "PowerScaling/powerScaling_vs.hglsl" + +in vec3 in_position; + +out float vs_screenSpaceDepth; +out vec4 vs_positionViewSpace; + +uniform dmat4 modelViewTransform; +uniform dmat4 projectionTransform; + + +void main() { + dvec4 positionViewSpace = modelViewTransform * dvec4(in_position, 1.0); + vec4 positionClipSpace = vec4(projectionTransform * positionViewSpace); + vec4 positionScreenSpace = vec4(z_normalization(positionClipSpace)); + + vs_screenSpaceDepth = positionScreenSpace.w; + vs_positionViewSpace = vec4(positionViewSpace); + + gl_Position = positionScreenSpace; +} diff --git a/modules/space/spacemodule.cpp b/modules/space/spacemodule.cpp index 23ecd700f4..72e479040d 100644 --- a/modules/space/spacemodule.cpp +++ b/modules/space/spacemodule.cpp @@ -24,7 +24,9 @@ #include +#include #include +#include #include #include #include @@ -79,6 +81,9 @@ void SpaceModule::internalInitialize(const ghoul::Dictionary& dictionary) { fRenderable->registerClass( "RenderableConstellationBounds" ); + fRenderable->registerClass( + "RenderableConstellationLines" + ); fRenderable->registerClass("RenderableFluxNodes"); fRenderable->registerClass("RenderableHabitableZone"); fRenderable->registerClass("RenderableRings"); @@ -115,6 +120,7 @@ std::vector SpaceModule::documentations() const { HorizonsTranslation::Documentation(), KeplerTranslation::Documentation(), RenderableConstellationBounds::Documentation(), + RenderableConstellationLines::Documentation(), RenderableFluxNodes::Documentation(), RenderableHabitableZone::Documentation(), RenderableRings::Documentation(), @@ -123,6 +129,7 @@ std::vector SpaceModule::documentations() const { RenderableTravelSpeed::Documentation(), SpiceRotation::Documentation(), SpiceTranslation::Documentation(), + LabelsComponent::Documentation(), GPTranslation::Documentation() }; } diff --git a/modules/space/speckloader.cpp b/modules/space/speckloader.cpp index 05fa8fb817..889be4b38e 100644 --- a/modules/space/speckloader.cpp +++ b/modules/space/speckloader.cpp @@ -37,7 +37,7 @@ namespace { constexpr int8_t DataCacheFileVersion = 10; - constexpr int8_t LabelCacheFileVersion = 10; + constexpr int8_t LabelCacheFileVersion = 11; constexpr int8_t ColorCacheFileVersion = 10; bool startsWith(std::string lhs, std::string_view rhs) noexcept { @@ -321,7 +321,7 @@ Dataset loadFile(std::filesystem::path path, SkipAllZeroLines skipAllZeroLines) if (!str.good()) { // Need to subtract one of the line number here as we increase the current - // line count in the beginning of the while loop we are currently in + // line count in the beginning of the while loop we are currently in throw ghoul::RuntimeError(fmt::format( "Error loading position information out of data line {} in file {}. " "Value was not a number", @@ -346,7 +346,7 @@ Dataset loadFile(std::filesystem::path path, SkipAllZeroLines skipAllZeroLines) if (valueStream.fail()) { // Need to subtract one of the line number here as we increase the // current line count in the beginning of the while loop we are - // currently in + // currently in throw ghoul::RuntimeError(fmt::format( "Error loading data value {} out of data line {} in file {}. " "Value was not a number", @@ -674,10 +674,20 @@ Labelset loadFile(std::filesystem::path path, SkipAllZeroLines) { std::getline(str, rest); strip(rest); + if (startsWith(rest, "id")) { + // optional arument with identifier + // Remove the 'id' text + rest = rest.substr(std::string_view("id ").size()); + size_t index = rest.find("text"); + entry.identifier = rest.substr(0, index - 1); + + // update the rest, remove the identifier + rest = rest.substr(index); + } if (!startsWith(rest, "text")) { throw ghoul::RuntimeError(fmt::format( - "Error loading label file {}: File contains some value between " - "positions and text label, which is unsupported", path + "Error loading label file {}: File contains an unsupported value " + "between positions and text label", path )); } @@ -731,6 +741,13 @@ std::optional loadCachedFile(std::filesystem::path path) { file.read(reinterpret_cast(&e.position.y), sizeof(float)); file.read(reinterpret_cast(&e.position.z), sizeof(float)); + // Identifier + uint8_t idLen; + file.read(reinterpret_cast(&idLen), sizeof(uint8_t)); + e.identifier.resize(idLen); + file.read(e.identifier.data(), idLen); + + // Text uint16_t len; file.read(reinterpret_cast(&len), sizeof(uint16_t)); e.text.resize(len); @@ -763,6 +780,13 @@ void saveCachedFile(const Labelset& labelset, std::filesystem::path path) { file.write(reinterpret_cast(&e.position.y), sizeof(float)); file.write(reinterpret_cast(&e.position.z), sizeof(float)); + // Identifier + checkSize(e.identifier.size(), "Identifier too long"); + uint8_t idLen = static_cast(e.identifier.size()); + file.write(reinterpret_cast(&idLen), sizeof(uint8_t)); + file.write(e.identifier.data(), idLen); + + // Text checkSize(e.text.size(), "Text too long"); uint16_t len = static_cast(e.text.size()); file.write(reinterpret_cast(&len), sizeof(uint16_t)); diff --git a/modules/space/speckloader.h b/modules/space/speckloader.h index 0cc13c686e..8e48dbd764 100644 --- a/modules/space/speckloader.h +++ b/modules/space/speckloader.h @@ -68,6 +68,7 @@ struct Labelset { struct Entry { glm::vec3 position = glm::vec3(0.f); + std::string identifier; std::string text; }; std::vector entries; diff --git a/modules/spacecraftinstruments/CMakeLists.txt b/modules/spacecraftinstruments/CMakeLists.txt index 8e9d526d79..9e7ab871b8 100644 --- a/modules/spacecraftinstruments/CMakeLists.txt +++ b/modules/spacecraftinstruments/CMakeLists.txt @@ -91,3 +91,6 @@ create_new_module( STATIC ${HEADER_FILES} ${SOURCE_FILES} ${SHADER_FILES} ) + +target_precompile_headers(${spacecraftinstruments_module} PRIVATE +) 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/statemachine/CMakeLists.txt b/modules/statemachine/CMakeLists.txt index a5f946dbe1..5af6de1297 100644 --- a/modules/statemachine/CMakeLists.txt +++ b/modules/statemachine/CMakeLists.txt @@ -25,23 +25,30 @@ include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) set(HEADER_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/include/state.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/transition.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/statemachine.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/state.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/transition.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/statemachine.h ) source_group("Header Files" FILES ${HEADER_FILES}) set(SOURCE_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/statemachinemodule_lua.inl - ${CMAKE_CURRENT_SOURCE_DIR}/src/state.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/transition.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/statemachine.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/statemachinemodule_lua.inl + ${CMAKE_CURRENT_SOURCE_DIR}/src/state.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/transition.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/statemachine.cpp ) source_group("Source Files" FILES ${SOURCE_FILES}) create_new_module( - "StateMachine" - statemachine_module - STATIC - ${HEADER_FILES} ${SOURCE_FILES} + "StateMachine" + statemachine_module + STATIC + ${HEADER_FILES} ${SOURCE_FILES} +) +target_precompile_headers(${statemachine_module} PRIVATE + + + + + ) diff --git a/modules/statemachine/src/statemachine.cpp b/modules/statemachine/src/statemachine.cpp index 81d5bf6ba7..e563d9a6c5 100644 --- a/modules/statemachine/src/statemachine.cpp +++ b/modules/statemachine/src/statemachine.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include diff --git a/modules/touch/ext/CMakeLists.txt b/modules/touch/ext/CMakeLists.txt index 8dde1535d6..b6d3927102 100644 --- a/modules/touch/ext/CMakeLists.txt +++ b/modules/touch/ext/CMakeLists.txt @@ -76,6 +76,23 @@ target_include_directories(libTUIO11 SYSTEM "${PROJECT_SOURCE_DIR}/libTUIO11/" "${PROJECT_SOURCE_DIR}/libTUIO11/oscpack" ) +target_precompile_headers(libTUIO11 PRIVATE + + + + +) +# # [["tuiopoint.h"]] +# # [["tuiocontainer.h"]] +# # [["tuiotime.h"]] +# # [["tuioobject.h"]] +# # [["tuiodispatcher.h"]] +# # [["tuiolistener.h"]] +# # [["tuioclient.h"]] +# # [["oscreceiver.h"]] +# +# +# ) if (WIN32) # Tuio dependencies diff --git a/modules/touch/ext/libTUIO11 b/modules/touch/ext/libTUIO11 index a164db7a95..9c543bc229 160000 --- a/modules/touch/ext/libTUIO11 +++ b/modules/touch/ext/libTUIO11 @@ -1 +1 @@ -Subproject commit a164db7a95420aa1cdcb7aec1b2cdf64827ebc57 +Subproject commit 9c543bc229cc99dcf9628f6e401287af54bc533d diff --git a/modules/touch/touchmodule.cpp b/modules/touch/touchmodule.cpp index 1aaf939bc5..e1b8742671 100644 --- a/modules/touch/touchmodule.cpp +++ b/modules/touch/touchmodule.cpp @@ -28,16 +28,9 @@ #include #include #include -#include #include #include #include -#include -#include -#include -#include -#include -#include using namespace TUIO; 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 3ab05c1f10..dfd808aed5 100644 --- a/modules/webbrowser/CMakeLists.txt +++ b/modules/webbrowser/CMakeLists.txt @@ -99,6 +99,25 @@ if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") target_compile_options(libcef_dll_wrapper PRIVATE "-w") endif () +target_precompile_headers(libcef_dll_wrapper PRIVATE + [["include/cef_client.h"]] + [["include/capi/cef_browser_capi.h"]] + [["include/capi/cef_client_capi.h"]] + [["include/cef_client.h"]] + [["include/capi/cef_base_capi.h"]] + [["include/cef_render_handler.h"]] + + + + +) + +if (WIN32) + target_precompile_headers(libcef_dll_wrapper PRIVATE + + ) +endif () + ########################################################################################## # Add CEF client files @@ -183,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() @@ -200,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. @@ -241,10 +260,15 @@ create_new_module( ${HEADER_FILES} ${SOURCE_FILES} ) +target_precompile_headers(${webbrowser_module} PRIVATE + + + +) + set_folder_location(libcef_dll_wrapper "Helper") set_folder_location(openspace_web_helper "Helper") - # Display CEF configuration settings. # PRINT_CEF_CONFIG() @@ -268,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/CMakeLists.txt b/src/CMakeLists.txt index 383edb9306..af3748c61d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -446,6 +446,8 @@ target_include_directories(openspace-core ) target_precompile_headers(openspace-core PRIVATE + + [["ghoul/fmt.h"]] [["ghoul/glm.h"]] [["ghoul/misc/assert.h"]] @@ -453,12 +455,19 @@ target_precompile_headers(openspace-core PRIVATE [["ghoul/misc/exception.h"]] [["ghoul/misc/invariants.h"]] [["ghoul/misc/profiling.h"]] + [["ghoul/opengl/ghoul_gl.h"]] + + + + + + ) diff --git a/src/engine/downloadmanager.cpp b/src/engine/downloadmanager.cpp index de84c4bd03..7b57907d13 100644 --- a/src/engine/downloadmanager.cpp +++ b/src/engine/downloadmanager.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include namespace { diff --git a/src/engine/globalscallbacks.cpp b/src/engine/globalscallbacks.cpp index e7e871e42b..819ec6e4a8 100644 --- a/src/engine/globalscallbacks.cpp +++ b/src/engine/globalscallbacks.cpp @@ -66,75 +66,75 @@ void create() { #endif // WIN32 #ifdef WIN32 - initialize = new (currentPos) std::vector>; + initialize = new (currentPos) std::vector>(); ghoul_assert(initialize, "No initialize"); currentPos += sizeof(std::vector>); #else // ^^^ WIN32 / !WIN32 vvv - initialize = new std::vector>; + initialize = new std::vector>(); #endif // WIN32 #ifdef WIN32 - deinitialize = new (currentPos) std::vector>; + deinitialize = new (currentPos) std::vector>(); ghoul_assert(deinitialize, "No deinitialize"); currentPos += sizeof(std::vector>); #else // ^^^ WIN32 / !WIN32 vvv - deinitialize = new std::vector>; + deinitialize = new std::vector>(); #endif // WIN32 #ifdef WIN32 - initializeGL = new (currentPos) std::vector>; + initializeGL = new (currentPos) std::vector>(); ghoul_assert(initializeGL, "No initializeGL"); currentPos += sizeof(std::vector>); #else // ^^^ WIN32 / !WIN32 vvv - initializeGL = new std::vector>; + initializeGL = new std::vector>(); #endif // WIN32 #ifdef WIN32 - deinitializeGL = new (currentPos) std::vector>; + deinitializeGL = new (currentPos) std::vector>(); ghoul_assert(deinitializeGL, "No deinitializeGL"); currentPos += sizeof(std::vector>); #else // ^^^ WIN32 / !WIN32 vvv - deinitializeGL = new std::vector>; + deinitializeGL = new std::vector>(); #endif // WIN32 #ifdef WIN32 - preSync = new (currentPos) std::vector>; + preSync = new (currentPos) std::vector>(); ghoul_assert(preSync, "No preSync"); currentPos += sizeof(std::vector>); #else // ^^^ WIN32 / !WIN32 vvv - preSync = new std::vector>; + preSync = new std::vector>(); #endif // WIN32 #ifdef WIN32 - postSyncPreDraw = new (currentPos) std::vector>; + postSyncPreDraw = new (currentPos) std::vector>(); ghoul_assert(postSyncPreDraw, "No postSyncPreDraw"); currentPos += sizeof(std::vector>); #else // ^^^ WIN32 / !WIN32 vvv - postSyncPreDraw = new std::vector>; + postSyncPreDraw = new std::vector>(); #endif // WIN32 #ifdef WIN32 - render = new (currentPos) std::vector>; + render = new (currentPos) std::vector>(); ghoul_assert(render, "No render"); currentPos += sizeof(std::vector>); #else // ^^^ WIN32 / !WIN32 vvv - render = new std::vector>; + render = new std::vector>(); #endif // WIN32 #ifdef WIN32 - draw2D = new (currentPos) std::vector>; + draw2D = new (currentPos) std::vector>(); ghoul_assert(draw2D, "No draw2D"); currentPos += sizeof(std::vector>); #else // ^^^ WIN32 / !WIN32 vvv - draw2D = new std::vector>; + draw2D = new std::vector>(); #endif // WIN32 #ifdef WIN32 - postDraw = new (currentPos) std::vector>; + postDraw = new (currentPos) std::vector>(); ghoul_assert(postDraw, "No postDraw"); currentPos += sizeof(std::vector>); #else // ^^^ WIN32 / !WIN32 vvv - postDraw = new std::vector>; + postDraw = new std::vector>(); #endif // WIN32 #ifdef WIN32 @@ -142,64 +142,64 @@ void create() { ghoul_assert(keyboard, "No keyboard"); currentPos += sizeof(std::vector); #else // ^^^ WIN32 / !WIN32 vvv - keyboard = new std::vector; + keyboard = new std::vector(); #endif // WIN32 #ifdef WIN32 - character = new (currentPos) std::vector; + character = new (currentPos) std::vector(); ghoul_assert(character, "No character"); currentPos += sizeof(std::vector); #else // ^^^ WIN32 / !WIN32 vvv - character = new std::vector; + character = new std::vector(); #endif // WIN32 #ifdef WIN32 - mouseButton = new (currentPos) std::vector; + mouseButton = new (currentPos) std::vector(); ghoul_assert(mouseButton, "No mouseButton"); currentPos += sizeof(std::vector); #else // ^^^ WIN32 / !WIN32 vvv - mouseButton = new std::vector; + mouseButton = new std::vector(); #endif // WIN32 #ifdef WIN32 mousePosition = - new (currentPos) std::vector; + new (currentPos) std::vector(); ghoul_assert(mousePosition, "No mousePosition"); currentPos += sizeof(std::vector); #else // ^^^ WIN32 / !WIN32 vvv - mousePosition = new std::vector; + mousePosition = new std::vector(); #endif // WIN32 #ifdef WIN32 - mouseScrollWheel = new (currentPos) std::vector; + mouseScrollWheel = new (currentPos) std::vector(); ghoul_assert(mouseScrollWheel, "No mouseScrollWheel"); currentPos += sizeof(std::vector); #else // ^^^ WIN32 / !WIN32 vvv - mouseScrollWheel = new std::vector; + mouseScrollWheel = new std::vector(); #endif // WIN32 #ifdef WIN32 - touchDetected = new (currentPos) std::vector>; + touchDetected = new (currentPos) std::vector>(); ghoul_assert(touchDetected, "No touchDetected"); currentPos += sizeof(std::vector>); #else // ^^^ WIN32 / !WIN32 vvv - touchDetected = new std::vector>; + touchDetected = new std::vector>(); #endif // WIN32 #ifdef WIN32 - touchUpdated = new (currentPos) std::vector>; + touchUpdated = new (currentPos) std::vector>(); ghoul_assert(touchUpdated, "No touchUpdated"); currentPos += sizeof(std::vector>); #else // ^^^ WIN32 / !WIN32 vvv - touchUpdated = new std::vector>; + touchUpdated = new std::vector>(); #endif // WIN32 #ifdef WIN32 - touchExit = new (currentPos) std::vector>; + touchExit = new (currentPos) std::vector>(); ghoul_assert(touchExit, "No touchExit"); //currentPos += sizeof(std::vector>); #else // ^^^ WIN32 / !WIN32 vvv - touchExit = new std::vector>; + touchExit = new std::vector>(); #endif // WIN32 } diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 8e9308742a..17d75934b3 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -82,6 +82,7 @@ #include #include #include +#include #include #include #include @@ -94,6 +95,10 @@ #include #include +#ifdef WIN32 +#include +#endif // WIN32 + #ifdef __APPLE__ #include #endif // __APPLE__ diff --git a/src/interaction/sessionrecording.cpp b/src/interaction/sessionrecording.cpp index 070d6a60fd..365fd801f4 100644 --- a/src/interaction/sessionrecording.cpp +++ b/src/interaction/sessionrecording.cpp @@ -55,7 +55,7 @@ #include #ifdef WIN32 -#include +#include #endif // WIN32 #include "sessionrecording_lua.inl" @@ -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/helper.cpp b/src/rendering/helper.cpp index 956b388dc4..57e067c3a7 100644 --- a/src/rendering/helper.cpp +++ b/src/rendering/helper.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rendering/loadingscreen.cpp b/src/rendering/loadingscreen.cpp index 59cba07b89..1be8d567d6 100644 --- a/src/rendering/loadingscreen.cpp +++ b/src/rendering/loadingscreen.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rendering/luaconsole.cpp b/src/rendering/luaconsole.cpp index 06b16d2bf3..e4bcd43207 100644 --- a/src/rendering/luaconsole.cpp +++ b/src/rendering/luaconsole.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include 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/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 4803954ae2..19ab3b5ae9 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -63,6 +63,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rendering/screenspacerenderable.cpp b/src/rendering/screenspacerenderable.cpp index 0dd57fb310..3969ea00cc 100644 --- a/src/rendering/screenspacerenderable.cpp +++ b/src/rendering/screenspacerenderable.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rendering/transferfunction.cpp b/src/rendering/transferfunction.cpp index d802b6188c..891c58c0a1 100644 --- a/src/rendering/transferfunction.cpp +++ b/src/rendering/transferfunction.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include namespace { 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/src/scene/scene.cpp b/src/scene/scene.cpp index 4f460e4bb4..6e4390e277 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include diff --git a/src/util/blockplaneintersectiongeometry.cpp b/src/util/blockplaneintersectiongeometry.cpp index bfeed98405..13e26b16a7 100644 --- a/src/util/blockplaneintersectiongeometry.cpp +++ b/src/util/blockplaneintersectiongeometry.cpp @@ -25,6 +25,7 @@ #include #include +#include #include namespace { diff --git a/src/util/boxgeometry.cpp b/src/util/boxgeometry.cpp index 37e5d50554..5d39116390 100644 --- a/src/util/boxgeometry.cpp +++ b/src/util/boxgeometry.cpp @@ -25,6 +25,7 @@ #include #include +#include #include namespace { diff --git a/src/util/planegeometry.cpp b/src/util/planegeometry.cpp index bef8ca990e..10edcb77ae 100644 --- a/src/util/planegeometry.cpp +++ b/src/util/planegeometry.cpp @@ -25,6 +25,7 @@ #include #include +#include #include namespace openspace { diff --git a/src/util/sphere.cpp b/src/util/sphere.cpp index 87e0b04e44..c1c1fc01ce 100644 --- a/src/util/sphere.cpp +++ b/src/util/sphere.cpp @@ -25,6 +25,7 @@ #include #include +#include #include namespace { diff --git a/support/cmake/application_definition.cmake b/support/cmake/application_definition.cmake index 2df5522f95..6705639450 100644 --- a/support/cmake/application_definition.cmake +++ b/support/cmake/application_definition.cmake @@ -27,37 +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 808dfce1e4..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) @@ -108,9 +94,6 @@ endfunction () function (handle_module_dependencies target_name module_name) # We always want to link against Ghoul and the core library target_link_libraries(${library_name} PRIVATE Ghoul openspace-core) - # 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(${library_name} PRIVATE [["ghoul/fmt.h"]] [["ghoul/glm.h"]] @@ -119,12 +102,13 @@ function (handle_module_dependencies target_name module_name) [["ghoul/misc/exception.h"]] [["ghoul/misc/invariants.h"]] [["ghoul/misc/profiling.h"]] - + [["ghoul/opengl/ghoul_gl.h"]] - + - + + ) diff --git a/support/cmake/set_openspace_compile_settings.cmake b/support/cmake/set_openspace_compile_settings.cmake index fd7f0fde1e..668107cf1b 100644 --- a/support/cmake/set_openspace_compile_settings.cmake +++ b/support/cmake/set_openspace_compile_settings.cmake @@ -23,7 +23,7 @@ ########################################################################################## function (set_openspace_compile_settings target) - target_compile_features(${target} PRIVATE cxx_std_20) + target_compile_features(${target} PUBLIC cxx_std_20) set(MSVC_WARNINGS "/MP" # Multi-threading support @@ -195,6 +195,8 @@ function (set_openspace_compile_settings target) # Boost as of 1.64 still uses unary_function unless we define this target_compile_definitions(${target} PRIVATE "_HAS_AUTO_PTR_ETC") target_compile_definitions(${target} PRIVATE "NOMINMAX") + target_compile_definitions(${target} PRIVATE "WIN32_LEAN_AND_MEAN") + target_compile_definitions(${target} PRIVATE "VC_EXTRALEAN") elseif (NOT LINUX AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") if (OPENSPACE_WARNINGS_AS_ERRORS) target_compile_options(${target} PRIVATE "-Werror") diff --git a/support/coding/codegen b/support/coding/codegen index 8ee86de09a..93fb390f1b 160000 --- a/support/coding/codegen +++ b/support/coding/codegen @@ -1 +1 @@ -Subproject commit 8ee86de09a2c902448d37d1a2828130839e2582d +Subproject commit 93fb390f1b239f737346a42e06dcf7815fdaa77c