diff --git a/.gitmodules b/.gitmodules index 3e4cfb738b..516a853c2b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,7 +16,7 @@ branch = OpenSpace [submodule "apps/OpenSpace/ext/sgct"] path = apps/OpenSpace/ext/sgct - url = https://github.com/opensgct/sgct + url = https://github.com/sgct/sgct [submodule "modules/fitsfilereader/ext/CCfits"] path = modules/fitsfilereader/ext/CCfits url = https://github.com/OpenSpace/CCfits.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e20b7b0ff..ee78a175b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2019 # +# Copyright (c) 2014-2020 # # # # 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 # @@ -28,7 +28,7 @@ project(OpenSpace) set(OPENSPACE_VERSION_MAJOR 0) set(OPENSPACE_VERSION_MINOR 15) -set(OPENSPACE_VERSION_PATCH 0) +set(OPENSPACE_VERSION_PATCH 1) set(OPENSPACE_VERSION_STRING "Beta-5") @@ -43,7 +43,6 @@ include(${OPENSPACE_CMAKE_EXT_DIR}/handle_modules.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) -include(${GHOUL_BASE_DIR}/support/cmake/include_gtest.cmake) begin_header("Configuring OpenSpace project") message(STATUS "CMake version: ${CMAKE_VERSION}") @@ -51,7 +50,7 @@ message(STATUS "CMake version: ${CMAKE_VERSION}") # Bail out if the user tries to generate a 32 bit project. if (NOT ${CMAKE_SIZEOF_VOID_P} EQUAL 8) message(FATAL_ERROR "OpenSpace can only be generated for 64 bit architectures.") -endif() +endif () ########################################################################################## # Cleanup project # @@ -64,7 +63,7 @@ if (NOT EXISTS ${OPENSPACE_EXT_DIR}/ghoul/CMakeLists.txt) "git submodule update --init --recursive \n" "to download the missing dependencies." ) -endif() +endif () set_property(GLOBAL PROPERTY USE_FOLDERS On) set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER CMake) @@ -107,10 +106,34 @@ if (NOT OPENSPACE_GIT_STATUS_RETURN EQUAL 0) set(OPENSPACE_GIT_STATUS "uncommitted changes") else() set(OPENSPACE_GIT_STATUS "") -endif() +endif () option(OPENSPACE_WARNINGS_AS_ERRORS "Treat warnings as errors" OFF) +if (MSVC) + option(OPENSPACE_OPTIMIZATION_ENABLE_AVX "Enable AVX instruction set for compilation" OFF) + option(OPENSPACE_OPTIMIZATION_ENABLE_AVX2 "Enable AVX2 instruction set for compilation" OFF) + option(OPENSPACE_OPTIMIZATION_ENABLE_AVX512 "Enable AVX2 instruction set for compilation" OFF) + option(OPENSPACE_OPTIMIZATION_ENABLE_OTHER_OPTIMIZATIONS "Enable other optimizations, like LTCG, intrinsics, etc") + + if (OPENSPACE_OPTIMIZATION_ENABLE_AVX AND OPENSPACE_OPTIMIZATION_ENABLE_AVX2) + message(FATAL_ERROR "Cannot enable AVX and AVX2 instructions simultaneously") + endif () + + if (OPENSPACE_OPTIMIZATION_ENABLE_AVX AND OPENSPACE_OPTIMIZATION_ENABLE_AVX512) + message(FATAL_ERROR "Cannot enable AVX and AVX512 instructions simultaneously") + endif () + + if (OPENSPACE_OPTIMIZATION_ENABLE_AVX2 AND OPENSPACE_OPTIMIZATION_ENABLE_AVX512) + message(FATAL_ERROR "Cannot enable AVX2 and AVX512 instructions simultaneously") + endif () + + set(GHOUL_OPTIMIZATION_ENABLE_AVX ${OPENSPACE_OPTIMIZATION_ENABLE_AVX} CACHE BOOL "" FORCE) + set(GHOUL_OPTIMIZATION_ENABLE_AVX2 ${OPENSPACE_OPTIMIZATION_ENABLE_AVX2} CACHE BOOL "" FORCE) + set(GHOUL_OPTIMIZATION_ENABLE_AVX512 ${OPENSPACE_OPTIMIZATION_ENABLE_AVX512} CACHE BOOL "" FORCE) + set(GHOUL_OPTIMIZATION_ENABLE_OTHER_OPTIMIZATIONS ${OPENSPACE_OPTIMIZATION_ENABLE_OTHER_OPTIMIZATIONS} CACHE BOOL "" FORCE) +endif () + include(src/CMakeLists.txt) ########################################################################################## @@ -128,11 +151,12 @@ if (APPLE) target_link_libraries(openspace-core ${CARBON_LIBRARY} ${COREFOUNDATION_LIBRARY} ${COCOA_LIBRARY} ${APP_SERVICES_LIBRARY}) end_dependency() -endif() +endif () # Ghoul add_subdirectory(${OPENSPACE_EXT_DIR}/ghoul) target_link_libraries(openspace-core Ghoul) +set_openspace_compile_settings(Ghoul) set_folder_location(Lua "External") set_folder_location(lz4 "External") set_folder_location(GhoulTest "Unit Tests") @@ -159,7 +183,7 @@ else () target_link_libraries(openspace-core ${CURL_LIBRARIES}) target_compile_definitions(openspace-core PUBLIC "OPENSPACE_CURL_ENABLED") endif () -endif() +endif () end_dependency() # Qt @@ -205,40 +229,8 @@ if (MSVC) target_include_directories(openspace-core PUBLIC "${OPENSPACE_NVTOOLS_PATH}/include") end_dependency() endif () - endif () -########################################################################################## -# Tests # -########################################################################################## -option(OPENSPACE_HAVE_TESTS "Activate the OpenSpace unit tests" ON) -if (OPENSPACE_HAVE_TESTS) - include_gtest("${GHOUL_BASE_DIR}/ext/googletest") - - file(GLOB_RECURSE OPENSPACE_TEST_FILES ${OPENSPACE_BASE_DIR}/tests/*.inl) - add_executable(OpenSpaceTest ${OPENSPACE_BASE_DIR}/tests/main.cpp ${OPENSPACE_TEST_FILES}) - - target_include_directories(OpenSpaceTest PUBLIC - "${OPENSPACE_BASE_DIR}/include" - "${OPENSPACE_BASE_DIR}/tests" - "${OPENSPACE_EXT_DIR}/ghoul/ext/googletest/googletest/include" - ) - target_compile_definitions(OpenSpaceTest PUBLIC - "GHL_THROW_ON_ASSERT" "GTEST_HAS_TR1_TUPLE=0" - ) - target_link_libraries(OpenSpaceTest gtest openspace-core) - - set_folder_location(OpenSpaceTest "Unit Tests") - - if (MSVC) - set_target_properties(OpenSpaceTest PROPERTIES LINK_FLAGS - "/NODEFAULTLIB:LIBCMTD.lib /NODEFAULTLIB:LIBCMT.lib" - ) - endif () - set_openspace_compile_settings(OpenSpaceTest) -endif (OPENSPACE_HAVE_TESTS) - - begin_header("Configuring Modules") set(OPENSPACE_EXTERNAL_MODULES_PATHS "" CACHE STRING "List of external modules") handle_modules("${OPENSPACE_BASE_DIR}/modules" "${OPENSPACE_EXTERNAL_MODULES_PATHS}") @@ -250,6 +242,13 @@ handle_applications() end_header("End: Configuring Applications") message(STATUS "") +option(OPENSPACE_HAVE_TESTS "Activate the OpenSpace unit tests" ON) +if (OPENSPACE_HAVE_TESTS) + begin_header("Generating OpenSpace unit test") + add_subdirectory("${OPENSPACE_BASE_DIR}/tests") + end_header() +endif (OPENSPACE_HAVE_TESTS) + # Web Browser and Web gui # Why not put these in the module's path? Because they do not have access to the @@ -268,11 +267,6 @@ if (OPENSPACE_MODULE_WEBBROWSER AND CEF_ROOT) # find CEF to initialize it properly. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${WEBBROWSER_MODULE_PATH}/cmake") include(webbrowser_helpers) - - if (TARGET OpenSpaceTest) - set_cef_targets("${CEF_ROOT}" OpenSpaceTest) - run_cef_platform_config("${CEF_ROOT}" "${CEF_TARGET}" "${WEBBROWSER_MODULE_PATH}") - endif () elseif (OPENSPACE_MODULE_WEBBROWSER) message(WARNING "Web configured to be included, but no CEF_ROOT was found, please try configuring CMake again.") endif () diff --git a/LICENSE.md b/LICENSE.md index 65a49a2e5b..4e0881c01c 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2014-2019 +Copyright (c) 2014-2020 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 diff --git a/apps/OpenSpace-MinVR/CMakeLists.txt b/apps/OpenSpace-MinVR/CMakeLists.txt index f58a2a13cc..a13829c550 100644 --- a/apps/OpenSpace-MinVR/CMakeLists.txt +++ b/apps/OpenSpace-MinVR/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2019 # +# Copyright (c) 2014-2020 # # # # 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 # diff --git a/apps/OpenSpace-MinVR/main.cpp b/apps/OpenSpace-MinVR/main.cpp index c2d857cc7c..cd1191434b 100644 --- a/apps/OpenSpace-MinVR/main.cpp +++ b/apps/OpenSpace-MinVR/main.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/apps/OpenSpace/CMakeLists.txt b/apps/OpenSpace/CMakeLists.txt index ba74ba4315..267eb2c182 100644 --- a/apps/OpenSpace/CMakeLists.txt +++ b/apps/OpenSpace/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2019 # +# Copyright (c) 2014-2020 # # # # 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 # @@ -61,7 +61,7 @@ if (OPENSPACE_OPENVR_SUPPORT) ) endif () end_header("Dependency: OpenVR") -endif() +endif () ##### # Spout @@ -72,7 +72,15 @@ if (SGCT_SPOUT_SUPPORT AND NOT OPENSPACE_MODULE_SPOUT) set(OPENSPACE_MODULE_SPOUT ON CACHE BOOL "Build OPENSPACE_MODULE_SPOUTModule" FORCE) endif () -set(MACOSX_BUNDLE_ICON_FILE openspace.icns) + +##### +# macos +##### +if (APPLE) + set(MACOSX_BUNDLE_ICON_FILE openspace.icns) + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "Minimum OS X deployment version" FORCE) + set(CMAKE_XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "--deep" CACHE STRING "Other Code Signing Flags" FORCE) +endif () create_new_application(OpenSpace ${SGCT_OPENVR_FILES} diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index 25c8d30bde..3622605062 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit 25c8d30bde216066840d197e4443def196c70e17 +Subproject commit 3622605062ae61736426e3d8d26e98524ec1fc97 diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index 1be2584abe..ec47265306 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -45,6 +45,8 @@ #include #include #include +#include +#include #ifdef WIN32 #include @@ -249,11 +251,20 @@ std::pair supportedOpenGLVersion() { return { major, minor }; } +// +// Context creation function +// +void mainContextCreationFunc(GLFWwindow* win) { + // @TODO (abock, 2020-02-10) Remove this after updating SGCT to 3.0 + TracyGpuContext +} // // Init function // void mainInitFunc() { + ZoneScoped + #ifdef OPENSPACE_HAS_VTUNE if (EnableDetailedVtune) { __itt_frame_begin_v3(_vTune.init, nullptr); @@ -383,7 +394,10 @@ void mainInitFunc() { for (size_t i = 0; i < nWindows; ++i) { sgct::SGCTWindow* w = SgctEngine->getWindowPtr(i); - constexpr const char* screenshotNames = "OpenSpace"; + const std::string screenshotNames = nWindows > 1 ? + fmt::format("OpenSpace_{}", i) : + "OpenSpace"; + sgct_core::ScreenCapture* cpt0 = w->getScreenCapturePointer(0); sgct_core::ScreenCapture* cpt1 = w->getScreenCapturePointer(1); @@ -407,6 +421,12 @@ void mainInitFunc() { void mainPreSyncFunc() { + // @TODO (abock, 2020-02-10) Remove this after merging SGCT version 3.0 + FrameMark + + + ZoneScoped + #ifdef OPENSPACE_HAS_VTUNE if (EnableDetailedVtune) { __itt_frame_begin_v3(_vTune.preSync, nullptr); @@ -414,12 +434,20 @@ void mainPreSyncFunc() { #endif // OPENSPACE_HAS_VTUNE LTRACE("main::mainPreSyncFunc(begin)"); - global::openSpaceEngine.preSynchronization(); + try { + global::openSpaceEngine.preSynchronization(); + } + catch (const ghoul::RuntimeError& e) { + LFATALC(e.component, e.message); + sgct::Engine::instance()->terminate(); + } // Query joystick status using namespace interaction; for (int i = GLFW_JOYSTICK_1; i <= GLFW_JOYSTICK_LAST; ++i) { + ZoneScopedN("Joystick state"); + JoystickInputState& state = global::joystickInputStates[i]; int present = glfwJoystickPresent(i); @@ -503,6 +531,8 @@ void mainPreSyncFunc() { void mainPostSyncPreDrawFunc() { + ZoneScoped + #ifdef OPENSPACE_HAS_VTUNE if (EnableDetailedVtune) { __itt_frame_begin_v3(_vTune.postSyncPreDraw, nullptr); @@ -537,6 +567,8 @@ void mainPostSyncPreDrawFunc() { void mainRenderFunc() { + ZoneScoped + #ifdef OPENSPACE_HAS_VTUNE if (EnableDetailedVtune) { __itt_frame_begin_v3(_vTune.render, nullptr); @@ -585,6 +617,8 @@ void mainRenderFunc() { void mainDraw2DFunc() { + ZoneScoped + #ifdef OPENSPACE_HAS_VTUNE if (EnableDetailedVtune) { __itt_frame_begin_v3(_vTune.draw2D, nullptr); @@ -615,6 +649,8 @@ void mainDraw2DFunc() { void mainPostDrawFunc() { + ZoneScoped + #ifdef OPENSPACE_HAS_VTUNE if (EnableDetailedVtune) { __itt_frame_begin_v3(_vTune.postDraw, nullptr); @@ -670,6 +706,8 @@ void mainPostDrawFunc() { void mainKeyboardCallback(int key, int, int action, int modifiers) { + ZoneScoped + #ifdef OPENSPACE_HAS_VTUNE if (EnableDetailedVtune) { __itt_frame_begin_v3(_vTune.keyboard, nullptr); @@ -693,6 +731,8 @@ void mainKeyboardCallback(int key, int, int action, int modifiers) { void mainMouseButtonCallback(int key, int action, int modifiers) { + ZoneScoped + #ifdef OPENSPACE_HAS_VTUNE if (EnableDetailedVtune) { __itt_frame_begin_v3(_vTune.mouseButton, nullptr); @@ -716,6 +756,8 @@ void mainMouseButtonCallback(int key, int action, int modifiers) { void mainMousePosCallback(double x, double y) { + ZoneScoped + #ifdef OPENSPACE_HAS_VTUNE if (EnableDetailedVtune) { __itt_frame_begin_v3(_vTune.mousePos, nullptr); @@ -734,6 +776,8 @@ void mainMousePosCallback(double x, double y) { void mainMouseScrollCallback(double posX, double posY) { + ZoneScoped + #ifdef OPENSPACE_HAS_VTUNE if (EnableDetailedVtune) { __itt_frame_begin_v3(_vTune.mouseScroll, nullptr); @@ -754,6 +798,8 @@ void mainMouseScrollCallback(double posX, double posY) { void mainCharCallback(unsigned int codepoint, int modifiers) { + ZoneScoped + #ifdef OPENSPACE_HAS_VTUNE if (EnableDetailedVtune) { __itt_frame_begin_v3(_vTune.character, nullptr); @@ -773,6 +819,8 @@ void mainCharCallback(unsigned int codepoint, int modifiers) { void mainEncodeFun() { + ZoneScoped + #ifdef OPENSPACE_HAS_VTUNE if (EnableDetailedVtune) { __itt_frame_begin_v3(_vTune.encode, nullptr); @@ -795,6 +843,8 @@ void mainEncodeFun() { void mainDecodeFun() { + ZoneScoped + #ifdef OPENSPACE_HAS_VTUNE if (EnableDetailedVtune) { __itt_frame_begin_v3(_vTune.decode, nullptr); @@ -817,6 +867,8 @@ void mainDecodeFun() { void mainLogCallback(const char* msg) { + ZoneScoped + std::string message = msg; if (message.empty() || message == ".") { // We don't want the empty '.' message that SGCT sends while it is waiting for @@ -834,12 +886,18 @@ void setSgctDelegateFunctions() { WindowDelegate& sgctDelegate = global::windowDelegate; sgctDelegate.terminate = []() { sgct::Engine::instance()->terminate(); }; sgctDelegate.setBarrier = [](bool enabled) { + ZoneScoped + sgct::SGCTWindow::setBarrier(enabled); }; sgctDelegate.setSynchronization = [](bool enabled) { + ZoneScoped + sgct_core::ClusterManager::instance()->setUseIgnoreSync(enabled); }; sgctDelegate.clearAllWindows = [](const glm::vec4& clearColor) { + ZoneScoped + size_t n = sgct::Engine::instance()->getNumberOfWindows(); for (size_t i = 0; i < n; ++i) { glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a); @@ -849,27 +907,51 @@ void setSgctDelegateFunctions() { } }; sgctDelegate.windowHasResized = []() { + ZoneScoped + return sgct::Engine::instance()->getCurrentWindowPtr()->isWindowResized(); }; - sgctDelegate.averageDeltaTime = []() { return sgct::Engine::instance()->getAvgDt(); }; + sgctDelegate.averageDeltaTime = []() { + ZoneScoped + + return sgct::Engine::instance()->getAvgDt(); + }; sgctDelegate.deltaTimeStandardDeviation = []() { + ZoneScoped + return sgct::Engine::instance()->getDtStandardDeviation(); }; sgctDelegate.minDeltaTime = []() { + ZoneScoped + return sgct::Engine::instance()->getMinDt(); }; sgctDelegate.maxDeltaTime = []() { + ZoneScoped + return sgct::Engine::instance()->getMaxDt(); }; - sgctDelegate.deltaTime = []() { return sgct::Engine::instance()->getDt(); }; - sgctDelegate.applicationTime = []() { return sgct::Engine::getTime(); }; + sgctDelegate.deltaTime = []() { + ZoneScoped + + return sgct::Engine::instance()->getDt(); + }; + sgctDelegate.applicationTime = []() { + ZoneScoped + + return sgct::Engine::getTime(); + }; sgctDelegate.mousePosition = []() { + ZoneScoped + int id = sgct::Engine::instance()->getCurrentWindowPtr()->getId(); double posX, posY; sgct::Engine::getMousePos(id, &posX, &posY); return glm::vec2(posX, posY); }; sgctDelegate.mouseButtons = [](int maxNumber) { + ZoneScoped + int id = sgct::Engine::instance()->getCurrentWindowPtr()->getId(); uint32_t result = 0; for (int i = 0; i < maxNumber; ++i) { @@ -881,12 +963,21 @@ void setSgctDelegateFunctions() { return result; }; sgctDelegate.currentWindowSize = []() { + ZoneScoped + return glm::ivec2( sgct::Engine::instance()->getCurrentWindowPtr()->getXResolution(), sgct::Engine::instance()->getCurrentWindowPtr()->getYResolution()); }; sgctDelegate.currentSubwindowSize = []() { + ZoneScoped + auto window = sgct::Engine::instance()->getCurrentWindowPtr(); + if (sgct::Engine::instance()->getCurrentWindowPtr()->getNumberOfViewports() > 1) { + sgct_core::Viewport* viewport = + sgct::Engine::instance()->getCurrentWindowPtr()->getViewport(0); + return glm::ivec2(window->getXResolution()*viewport->getXSize(), window->getYResolution()*viewport->getYSize()); + } switch (window->getStereoMode()) { case sgct::SGCTWindow::Side_By_Side_Stereo: case sgct::SGCTWindow::Side_By_Side_Inverted_Stereo: @@ -899,12 +990,16 @@ void setSgctDelegateFunctions() { } }; sgctDelegate.currentWindowResolution = []() { + ZoneScoped + int x, y; auto window = sgct::Engine::instance()->getCurrentWindowPtr(); window->getFinalFBODimensions(x, y); return glm::ivec2(x, y); }; sgctDelegate.currentDrawBufferResolution = []() { + ZoneScoped + sgct_core::Viewport* viewport = sgct::Engine::instance()->getCurrentWindowPtr()->getViewport(0); if (viewport != nullptr) { @@ -912,6 +1007,12 @@ void setSgctDelegateFunctions() { int res = viewport->getNonLinearProjectionPtr()->getCubemapResolution(); return glm::ivec2(res, res); } + else if (sgct::Engine::instance()->getCurrentWindowPtr()->getNumberOfViewports() > 1) { + int x, y; + auto window = sgct::Engine::instance()->getCurrentWindowPtr(); + window->getFinalFBODimensions(x, y); + return glm::ivec2(x*viewport->getXSize(), y*viewport->getYSize()); + } else { int x, y; auto window = sgct::Engine::instance()->getCurrentWindowPtr(); @@ -922,6 +1023,8 @@ void setSgctDelegateFunctions() { return glm::ivec2(-1, -1); }; sgctDelegate.currentViewportSize = []() { + ZoneScoped + sgct_core::Viewport* viewport = sgct::Engine::instance()->getCurrentWindowPtr()->getViewport(0); if (viewport != nullptr) { @@ -933,25 +1036,21 @@ void setSgctDelegateFunctions() { return glm::ivec2(-1, -1); }; sgctDelegate.dpiScaling = []() { + ZoneScoped + return glm::vec2( sgct::Engine::instance()->getCurrentWindowPtr()->getXScale(), sgct::Engine::instance()->getCurrentWindowPtr()->getYScale() ); }; sgctDelegate.currentNumberOfAaSamples = []() { + ZoneScoped + return sgct::Engine::instance()->getCurrentWindowPtr()->getNumberOfAASamples(); }; - sgctDelegate.isRegularRendering = []() { - sgct::SGCTWindow* w = sgct::Engine::instance()->getCurrentWindowPtr(); - ghoul_assert( - w->getNumberOfViewports() > 0, - "At least one viewport must exist at this time" - ); - sgct_core::Viewport* vp = w->getViewport(0); - sgct_core::NonLinearProjection* nlp = vp->getNonLinearProjectionPtr(); - return nlp == nullptr; - }; sgctDelegate.hasGuiWindow = []() { + ZoneScoped + auto engine = sgct::Engine::instance(); for (size_t i = 0; i < engine->getNumberOfWindows(); ++i) { if (engine->getWindowPtr(i)->checkIfTagExists("GUI")) { @@ -961,84 +1060,130 @@ void setSgctDelegateFunctions() { return false; }; sgctDelegate.isGuiWindow = []() { + ZoneScoped + return sgct::Engine::instance()->getCurrentWindowPtr()->checkIfTagExists("GUI"); }; - sgctDelegate.isMaster = []() { return sgct::Engine::instance()->isMaster(); }; + sgctDelegate.isMaster = []() { + ZoneScoped + + return sgct::Engine::instance()->isMaster(); + }; sgctDelegate.isUsingSwapGroups = []() { + ZoneScoped + return sgct::SGCTWindow::isUsingSwapGroups(); }; sgctDelegate.isSwapGroupMaster = []() { + ZoneScoped + return sgct::SGCTWindow::isSwapGroupMaster(); }; sgctDelegate.viewProjectionMatrix = []() { + ZoneScoped + return sgct::Engine::instance()->getCurrentModelViewProjectionMatrix(); }; sgctDelegate.modelMatrix = []() { + ZoneScoped + return sgct::Engine::instance()->getModelMatrix(); }; sgctDelegate.setNearFarClippingPlane = [](float nearPlane, float farPlane) { + ZoneScoped + sgct::Engine::instance()->setNearAndFarClippingPlanes(nearPlane, farPlane); }; sgctDelegate.setEyeSeparationDistance = [](float distance) { + ZoneScoped + sgct::Engine::instance()->setEyeSeparation(distance); }; sgctDelegate.viewportPixelCoordinates = []() { + ZoneScoped + sgct::SGCTWindow* window = sgct::Engine::instance()->getCurrentWindowPtr(); if (!window || !window->getCurrentViewport()) { - return glm::ivec4(0, 0, 0, 0); + return glm::ivec4(0); } else { const int* data = sgct::Engine::instance()->getCurrentViewportPixelCoords(); return glm::ivec4(data[0], data[2], data[1], data[3]); } }; - sgctDelegate.isExternalControlConnected = []() { - return sgct::Engine::instance()->isExternalControlConnected(); - }; sgctDelegate.sendMessageToExternalControl = [](const std::vector& message) { + ZoneScoped + sgct::Engine::instance()->sendMessageToExternalControl( message.data(), static_cast(message.size()) ); }; - sgctDelegate.isSimpleRendering = []() { - return (sgct::Engine::instance()->getCurrentRenderTarget() != - sgct::Engine::NonLinearBuffer); - }; sgctDelegate.isFisheyeRendering = []() { + ZoneScoped + sgct::SGCTWindow* w = sgct::Engine::instance()->getCurrentWindowPtr(); return dynamic_cast( w->getViewport(0)->getNonLinearProjectionPtr() ) != nullptr; }; sgctDelegate.takeScreenshot = [](bool applyWarping) { + ZoneScoped + sgct::SGCTSettings::instance()->setCaptureFromBackBuffer(applyWarping); sgct::Engine::instance()->takeScreenshot(); + return sgct::Engine::instance()->getScreenShotNumber(); }; sgctDelegate.swapBuffer = []() { + ZoneScoped + GLFWwindow* w = glfwGetCurrentContext(); glfwSwapBuffers(w); glfwPollEvents(); }; sgctDelegate.nWindows = []() { + ZoneScoped + return static_cast(sgct::Engine::instance()->getNumberOfWindows()); }; sgctDelegate.currentWindowId = []() { + ZoneScoped + return sgct::Engine::instance()->getCurrentWindowPtr()->getId(); }; sgctDelegate.openGLProcedureAddress = [](const char* func) { + ZoneScoped + return glfwGetProcAddress(func); }; sgctDelegate.getHorizFieldOfView = []() { + ZoneScoped + return static_cast( sgct::Engine::instance()->getWindowPtr(0)->getHorizFieldOfViewDegrees() ); }; sgctDelegate.setHorizFieldOfView = [](float hFovDeg) { + ZoneScoped + sgct::SGCTWindow* w = sgct::Engine::instance()->getWindowPtr(0); w->setHorizFieldOfView(hFovDeg); }; + #ifdef WIN32 + sgctDelegate.getNativeWindowHandle = [](size_t windowIndex) -> void* { + ZoneScoped + + sgct::SGCTWindow* w = sgct::Engine::instance()->getWindowPtr(windowIndex); + if (w) { + HWND hWnd = glfwGetWin32Window(w->getWindowHandle()); + return reinterpret_cast(hWnd); + } + return nullptr; + }; + #endif // WIN32 sgctDelegate.frustumMode = []() { + ZoneScoped + using FM = sgct_core::Frustum::FrustumMode; switch (sgct::Engine::instance()->getCurrentFrustumMode()) { case FM::MonoEye: return WindowDelegate::Frustum::Mono; @@ -1047,6 +1192,8 @@ void setSgctDelegateFunctions() { } }; sgctDelegate.swapGroupFrameNumber = []() { + ZoneScoped + unsigned int fn = 0; sgct::Engine::instance()->getCurrentWindowPtr()->getSwapGroupFrameNumber(fn); return static_cast(fn); @@ -1172,7 +1319,7 @@ int main(int argc, char** argv) { configurationFilePath ); - // If the user requested a commandline-based configuation script that should + // If the user requested a commandline-based configuration script that should // overwrite some of the values, this is the time to do it if (!commandlineArguments.configurationOverride.empty()) { LDEBUG("Executing Lua script passed through the commandline:"); @@ -1232,6 +1379,7 @@ int main(int argc, char** argv) { SgctEngine = new sgct::Engine(arguments); // Bind functions + SgctEngine->setContextCreationCallback(mainContextCreationFunc); SgctEngine->setInitOGLFunction(mainInitFunc); SgctEngine->setPreSyncFunction(mainPreSyncFunc); SgctEngine->setPostSyncPreDrawFunction(mainPostSyncPreDrawFunc); diff --git a/apps/Sync/CMakeLists.txt b/apps/Sync/CMakeLists.txt index 25a04ceb01..57b41bce3e 100644 --- a/apps/Sync/CMakeLists.txt +++ b/apps/Sync/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2018 # +# Copyright (c) 2014-2020 # # # # 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 # diff --git a/apps/Sync/main.cpp b/apps/Sync/main.cpp index 8661f900af..7ea54a745a 100644 --- a/apps/Sync/main.cpp +++ b/apps/Sync/main.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/apps/TaskRunner/CMakeLists.txt b/apps/TaskRunner/CMakeLists.txt index ed1b9e7066..e5eba87469 100644 --- a/apps/TaskRunner/CMakeLists.txt +++ b/apps/TaskRunner/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2018 # +# Copyright (c) 2014-2020 # # # # 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 # diff --git a/apps/TaskRunner/main.cpp b/apps/TaskRunner/main.cpp index c7b89253c5..f41d8105ab 100644 --- a/apps/TaskRunner/main.cpp +++ b/apps/TaskRunner/main.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/apps/TimelineView/configurationwidget.cpp b/apps/TimelineView/configurationwidget.cpp deleted file mode 100644 index d7833c6125..0000000000 --- a/apps/TimelineView/configurationwidget.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2019 * - * * - * 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 "configurationwidget.h" - -#include -#include -#include -#include - -ConfigurationWidget::ConfigurationWidget(QWidget* parent) - : QWidget(parent) - , _ipAddress(new QLineEdit("localhost")) - , _port(new QLineEdit("20500")) - , _connect(new QPushButton("Connect")) -{ - _connect->setObjectName("connection"); - QGroupBox* box = new QGroupBox("Connection", this); - - QGridLayout* layout = new QGridLayout; - layout->setVerticalSpacing(0); - { - QLabel* t = new QLabel("IP Address"); - t->setObjectName("label"); - layout->addWidget(t, 0, 0); - } - layout->addWidget(_ipAddress, 1, 0); - - { - QLabel* t = new QLabel("Port"); - t->setObjectName("label"); - layout->addWidget(t, 0, 1); - } - layout->addWidget(_port, 1, 1); - layout->addWidget(_connect, 1, 2, 1, 1); - - box->setLayout(layout); - - QHBoxLayout* l = new QHBoxLayout; - l->addWidget(box); - setLayout(l); - QObject::connect(_connect, SIGNAL(clicked()), this, SLOT(onConnectButton())); - - QTimer::singleShot(100, this, SLOT(onConnectButton())); -} - -void ConfigurationWidget::onConnectButton() { - emit connect(_ipAddress->text(), _port->text()); -} - -void ConfigurationWidget::socketConnected() { - _ipAddress->setEnabled(false); - _port->setEnabled(false); - _connect->setText("Disconnect"); - QObject::disconnect(_connect, SIGNAL(clicked()), this, SLOT(onConnectButton())); - QObject::connect(_connect, SIGNAL(clicked()), this, SIGNAL(disconnect())); -} - -void ConfigurationWidget::socketDisconnected() { - _ipAddress->setEnabled(true); - _port->setEnabled(true); - _connect->setText("Connect"); - QObject::disconnect(_connect, SIGNAL(clicked()), this, SIGNAL(disconnect())); - QObject::connect(_connect, SIGNAL(clicked()), this, SLOT(onConnectButton())); -} diff --git a/apps/TimelineView/controlwidget.cpp b/apps/TimelineView/controlwidget.cpp deleted file mode 100644 index 29125e8752..0000000000 --- a/apps/TimelineView/controlwidget.cpp +++ /dev/null @@ -1,319 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2019 * - * * - * 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 "controlwidget.h" - -#include "mainwindow.h" - -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace { - struct ImportantDate { - QString date; - QString focus; - QString coordinateSystem; - }; - - const ImportantDate ImportantDates[] = { - { "", "", "" }, - { "2007-02-27T16:40:00.00", "JupiterProjection", "Jupiter" }, - { "2015-07-14T10:10:00.00", "PlutoProjection", "Pluto" }, - { "2015-07-14T10:50:00.00", "PlutoProjection", "Pluto" }, - { "2015-07-14T11:22:00.00", "PlutoProjection", "Pluto" }, - { "2015-07-14T11:36:40.00", "PlutoProjection", "Pluto" }, - { "2015-07-14T11:48:43.00", "PlutoProjection", "Pluto" }, - { "2015-07-14T12:04:35.00", "PlutoProjection", "Pluto" }, - { "2015-07-14T15:02:46.00", "PlutoProjection", "Pluto" } - }; - - struct FocusNode { - QString guiName; - QString name; - QString coordinateSystem; - }; - const FocusNode FocusNodes[] = { - { "Earth", "Earth", "Sun" }, - { "Sun", "Sun", "Sun" }, - { "Pluto", "PlutoProjection", "Pluto" }, - { "Charon", "Charon", "Pluto" }, - { "Jupiter", "JupiterProjection", "Jupiter" }, - { "Nix", "Nix", "Pluto" }, - { "Kerberos", "Kerberos", "Pluto" }, - { "Hydra", "Hydra", "Pluto" }, - }; -} - -ControlWidget::ControlWidget(QWidget* parent) - : QWidget(parent) - , _currentTime(new QLabel("")) - , _setTime(new QComboBox) - , _currentDelta(new QLabel("")) - , _setDelta(new QSlider(Qt::Horizontal)) - , _pause(new QPushButton("Pause")) - , _play(new QPushButton("Play")) - , _focusNode(new QComboBox) - , _setFocusToNextTarget(new QPushButton("Set Focus to the next Target")) - , _setFocusToNewHorizons(new QPushButton("Set Focus to New Horizons")) -{ - _pause->setObjectName("pause"); - _play->setObjectName("play"); - - _currentTime->setObjectName("value"); - _currentDelta->setObjectName("value"); - - for (const ImportantDate& d : ImportantDates) - _setTime->addItem(d.date); - QObject::connect( - _setTime, - SIGNAL(currentIndexChanged(int)), - this, - SLOT(onDateChange()) - ); - - for (const FocusNode& f : FocusNodes) - _focusNode->addItem(f.guiName); - QObject::connect( - _focusNode, - SIGNAL(currentIndexChanged(int)), - this, - SLOT(onFocusChange()) - ); - - _setDelta->setMinimum(-100); - _setDelta->setMaximum(100); - _setDelta->setValue(0); - QObject::connect( - _setDelta, - SIGNAL(valueChanged(int)), - this, - SLOT(onValueChange()) - ); - - QObject::connect( - _pause, - SIGNAL(clicked()), - this, - SLOT(onPauseButton()) - ); - - QObject::connect( - _play, - SIGNAL(clicked()), - this, - SLOT(onPlayButton()) - ); - - QObject::connect( - _setFocusToNextTarget, - SIGNAL(clicked()), - this, - SLOT(onFocusToTargetButton()) - ); - - QObject::connect( - _setFocusToNewHorizons, - SIGNAL(clicked()), - this, - SLOT(onFocusToNewHorizonsButton()) -); - - QVBoxLayout* mainLayout = new QVBoxLayout; - - { - QGroupBox* box = new QGroupBox("Time", this); - QGridLayout* layout = new QGridLayout; - - //layout->setRowStretch(1, 5); - box->setLayout(layout); - - { - QLabel* l = new QLabel("Current Time (UTC):"); - l->setObjectName("label"); - layout->addWidget(l, 0, 0, Qt::AlignLeft); - layout->addWidget(_currentTime, 0, 1, Qt::AlignRight); - } - { - QLabel* l = new QLabel("Bookmarked Times:"); - l->setObjectName("label"); - layout->addWidget(l, 1, 0, Qt::AlignLeft); - layout->addWidget(_setTime, 1, 1, Qt::AlignRight); - } - layout->addItem(new QSpacerItem(0, 7), 2, 0, 1, 2); - { - QLabel* l = new QLabel("Current Time Increment\n(seconds per second):"); - l->setObjectName("label"); - layout->addWidget(l, 3, 0, Qt::AlignLeft); - layout->addWidget(_currentDelta, 3, 1, Qt::AlignRight); - } - - _setDelta->setObjectName("background"); - layout->addWidget(_setDelta, 4, 0, 1, 2); - - QWidget* controlContainer = new QWidget; - controlContainer->setObjectName("background"); - QHBoxLayout* controlContainerLayout = new QHBoxLayout; - controlContainerLayout->addWidget(_pause); - controlContainerLayout->addWidget(_play); - controlContainer->setLayout(controlContainerLayout); - layout->addWidget(controlContainer, 5, 0, 1, 2); - - mainLayout->addWidget(box); - } - - { - QGroupBox* box = new QGroupBox("Focus"); - QGridLayout* layout = new QGridLayout; - box->setLayout(layout); - - { - QLabel* l = new QLabel("Set Focus:"); - l->setObjectName("label"); - layout->addWidget(l, 0, 0, Qt::AlignLeft); - _focusNode->setMinimumWidth(200); - layout->addWidget(_focusNode, 0, 1, Qt::AlignRight); - } - layout->addWidget(_setFocusToNextTarget, 1, 0, 1, 2); - layout->addWidget(_setFocusToNewHorizons, 2, 0, 1, 2); - - mainLayout->addWidget(box); - } - - setLayout(mainLayout); -} - -void ControlWidget::update(QString currentTime, QString currentDelta) { - currentTime.replace("T", " "); - _currentTime->setText(currentTime); - _currentDelta->setText(currentDelta); -} - -void ControlWidget::onValueChange() { - float value = static_cast(_setDelta->value()); - - float delta; - if (value < 0.f) { - value = -value; - float d = pow(3, value / 10) - 1.f; - delta = -d; - } - else { - float d = pow(3, value / 10) - 1.f; - delta = d; - } - - QString script = "openspace.time.setDeltaTime(" + QString::number(delta) + ");"; - emit scriptActivity(script); -} - -void ControlWidget::onPauseButton() { - QString script = "openspace.time.setPause(true);"; - emit scriptActivity(script); -} - -void ControlWidget::onPlayButton() { - QString script = "openspace.time.setPause(false);"; - emit scriptActivity(script); -} - -void ControlWidget::onDateChange() { - int index = _setTime->currentIndex(); - if (index != 0) { - QString date = ImportantDates[index].date; - QString focus = ImportantDates[index].focus; - QString coordinateSystem = ImportantDates[index].coordinateSystem; - QString script = - "openspace.time.setTime('" + date + "');\ - openspace.setPropertyValue('Interaction.origin', '" + focus + "');\ - openspace.setPropertyValue('Interaction.coordinateSystem', '" + - coordinateSystem + "')"; - emit scriptActivity(script); - } - _setTime->blockSignals(true); - _setTime->setCurrentIndex(0); - _setTime->blockSignals(false); -} - -void ControlWidget::onFocusChange() { - int index = _focusNode->currentIndex(); - QString name = FocusNodes[index].name; - QString coordinateSystem = FocusNodes[index].coordinateSystem; - QString script = "openspace.setPropertyValue('Interaction.origin', '" + name + - "');openspace.setPropertyValue('Interaction.coordinateSystem', '" + - coordinateSystem + "');"; - emit scriptActivity(script); -} - -void ControlWidget::onFocusToTargetButton() { - std::string target = reinterpret_cast(parent())->nextTarget(); - if (!target.empty()) { - auto it = std::find_if( - std::begin(FocusNodes), - std::end(FocusNodes), - [target](const FocusNode& n) { - return n.guiName.toLower() == QString::fromStdString(target).toLower(); - }); - if (it != std::end(FocusNodes)) { - QString name = it->name; - QString coordinateSystem = it->coordinateSystem; - QString script = - "openspace.setPropertyValue('Interaction.origin', '" + name + - "');openspace.setPropertyValue('Interaction.coordinateSystem', '" + - coordinateSystem + "');"; - emit scriptActivity(script); - } - } -} - -void ControlWidget::onFocusToNewHorizonsButton() { - QString coordinateSystem; - int date = _currentTime->text().left(4).toInt(); - if (date < 2008) - coordinateSystem = "Jupiter"; - else if (date < 2014) - coordinateSystem = "Sun"; - else - coordinateSystem = "Pluto"; - - QString script = "openspace.setPropertyValue('Interaction.origin', 'NewHorizons');\ - openspace.setPropertyValue('Interaction.coordinateSystem', '" + coordinateSystem + - "');"; - emit scriptActivity(script); -} - -void ControlWidget::socketConnected() { - setDisabled(false); -} - -void ControlWidget::socketDisconnected() { - setDisabled(true); -} - diff --git a/apps/TimelineView/controlwidget.h b/apps/TimelineView/controlwidget.h deleted file mode 100644 index 7d0017a28b..0000000000 --- a/apps/TimelineView/controlwidget.h +++ /dev/null @@ -1,69 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2019 * - * * - * 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_APP_TIMELINEVIEW___CONTROLWIDGET___H__ -#define __OPENSPACE_APP_TIMELINEVIEW___CONTROLWIDGET___H__ - -#include - -class QComboBox; -class QLabel; -class QPushButton; -class QSlider; - -class ControlWidget : public QWidget { -Q_OBJECT -public: - ControlWidget(QWidget* parent); - - void update(QString currentTime, QString currentDelta); - - void socketConnected(); - void socketDisconnected(); - -signals: - void scriptActivity(QString script); - -private slots: - void onValueChange(); - void onDateChange(); - void onFocusChange(); - void onPauseButton(); - void onPlayButton(); - void onFocusToTargetButton(); - void onFocusToNewHorizonsButton(); - -private: - QLabel* _currentTime; - QComboBox* _setTime; - QLabel* _currentDelta; - QSlider* _setDelta; - QPushButton* _pause; - QPushButton* _play; - QComboBox* _focusNode; - QPushButton* _setFocusToNextTarget; - QPushButton* _setFocusToNewHorizons; -}; - -#endif // __OPENSPACE_APP_TIMELINEVIEW___CONTROLWIDGET___H__ diff --git a/apps/TimelineView/main.cpp b/apps/TimelineView/main.cpp deleted file mode 100644 index 79bd875cec..0000000000 --- a/apps/TimelineView/main.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2019 * - * * - * 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 "mainwindow.h" - -static const QString style = R"style( -QWidget { - background-color: rgb(80, 80, 80); - font-family: Helvetica; -} - -QGroupBox { - background-color: qlineargradient( - x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #858585, - stop: 1 #959595); - border: 2px solid gray; - border-radius: 5px; - margin-top: 4ex; - font-size: bold 12px; -} - -QGroupBox::title { - background-color: #E0E0E0; - border: 2px solid gray; - border-radius: 5px; - subcontrol-origin: margin; - subcontrol-position: top center; - padding: 0 10px; -} - -QLineEdit { - color: lightgray; -} - -QSlider::groove:horizontal { - border: 1px solid #999999; - /* the groove expands to the size of the slider by default. by giving it a height, - it has a fixed size */ - height: 8px; - background: qlineargradient( - x1:0, y1:0, x2:1, y2:0, - stop:0 #c4c4c4, - stop:0.5 #555555, - stop:1 #c4c4c4 - ); - margin: 2px 0; -} - -QSlider::handle:horizontal { - background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f); - border: 1px solid #5c5c5c; - width: 18px; - /* handle is placed by default on the contents rect of the groove. - Expand outside the groove */ - margin: -2px 0; - border-radius: 3px; -} - -QPushButton { - background-color: lightgray; - border-style: outset; - border-width: 0.5px; - border-radius: 5px; - border-color: black; - font: bold 12px; - min-width: 10em; -} - -QPushButton#connection { - background-color: lightgreen; -} - -QPushButton#connection:pressed { - background-color: green; -} - - -QPushButton#pause, QPushButton#play { - padding: 5px; -} - -QPushButton#pause:pressed, QPushButton#play:pressed, QPushButton:pressed { - background-color: darkgray; - border-style: inset; -} - -QCombobox { - border: 1px solid gray; - border-radius: 3px; - padding: 1px 18px 1px 3px; - min-width: 6em; -} - -QComboBox:editable { - background: lightgrey; -} - -QComboBox QAbstractItemView { - border: 2px solid darkgray; - border-radius: 5px; - background-color: #a8a8a8; - selection-background-color: #a8a8a8; -} - -QLabel#label { - font-size: 13px; - background-color: transparent; - font-variant: small-caps; -} - -QLabel#value { - font-family: monospace; - font-weight: bold; - font-size: 14px; - background-color: transparent; -} - -QWidget#background { - background-color: transparent; -} - -QTextEdit { - font-family: monospace; -} -)style"; - -int main(int argc, char** argv) { - QApplication app(argc, argv); - - app.setStyleSheet(style); - - MainWindow window; - window.show(); - - return app.exec(); -} diff --git a/apps/TimelineView/mainwindow.cpp b/apps/TimelineView/mainwindow.cpp deleted file mode 100644 index e7241f80a2..0000000000 --- a/apps/TimelineView/mainwindow.cpp +++ /dev/null @@ -1,398 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2019 * - * * - * 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 "mainwindow.h" - -#include "configurationwidget.h" -#include "controlwidget.h" -#include "informationwidget.h" -#include "timelinewidget.h" - -#include -#include -#include -#include - -#include -#include - -namespace { - QByteArray continuousData; -} - -template -T readFromBuffer(char* buffer, size_t& currentReadLocation) { - union { - T value; - std::array data; - } b; - std::memmove(b.data.data(), buffer + currentReadLocation, sizeof(T)); - currentReadLocation += sizeof(T); - return b.value; -} - -template <> -std::string readFromBuffer(char* buffer, size_t& currentReadLocation) { - uint8_t size = readFromBuffer(buffer, currentReadLocation); - - std::string result(buffer + currentReadLocation, buffer + currentReadLocation + size); - currentReadLocation += size; - return result; -} - -MainWindow::MainWindow() - : QWidget(nullptr) - , _configurationWidget(nullptr) - , _timeControlWidget(nullptr) - , _informationWidget(nullptr) - , _timelineWidget(nullptr) - , _socket(nullptr) -{ - setWindowTitle("OpenSpace Timeline"); - - _configurationWidget = new ConfigurationWidget(this); - _configurationWidget->setMinimumWidth(350); - _timeControlWidget = new ControlWidget(this); - _timeControlWidget->setMinimumWidth(350); - _informationWidget = new InformationWidget(this); - _informationWidget->setMinimumWidth(350); - _timelineWidget = new TimelineWidget(this); - - QGridLayout* layout = new QGridLayout; - layout->addWidget(_configurationWidget, 0, 0); - layout->addWidget(_timeControlWidget, 1, 0); - layout->addWidget(_informationWidget, 2, 0); - layout->addWidget(_timelineWidget, 0, 1, 3, 1); - - layout->setColumnStretch(1, 5); - - - QObject::connect( - _configurationWidget, SIGNAL(connect(QString, QString)), - this, SLOT(onConnect(QString, QString)) - ); - QObject::connect( - _configurationWidget, SIGNAL(disconnect()), - this, SLOT(onDisconnect()) - ); - - QObject::connect( - _timeControlWidget, SIGNAL(scriptActivity(QString)), - this, SLOT(sendScript(QString)) - ); - - setLayout(layout); - - _configurationWidget->socketDisconnected(); - _timeControlWidget->socketDisconnected(); - _informationWidget->socketDisconnected(); - _timelineWidget->socketDisconnected(); -} - -MainWindow::~MainWindow() { - delete _socket; -} - -void MainWindow::onConnect(QString host, QString port) { - delete _socket; - - _socket = new QTcpSocket(this); - QObject::connect(_socket, SIGNAL(readyRead()), SLOT(readTcpData())); - QObject::connect(_socket, SIGNAL(connected()), SLOT(onSocketConnected())); - QObject::connect(_socket, SIGNAL(disconnected()), SLOT(onSocketDisconnected())); - - _socket->connectToHost(host, port.toUInt()); -} - -void MainWindow::onDisconnect() { - delete _socket; - _socket = nullptr; -} - -void MainWindow::readTcpData() { - static const uint16_t MessageTypeStatus = 0; - static const uint16_t MessageTypeMappingIdentifier = 1; - static const uint16_t MessageTypeInitialMessageFinished = 2; - static const uint16_t MessageTypePlayBookLabel = 3; - static const uint16_t MessageTypePlayBookHongKang = 4; - - QByteArray data = continuousData.append(_socket->readAll()); -// int d = data.size(); - - if (QString(data) == "Connected to SGCT!\r\n") { - continuousData.clear(); - return; - } - if (QString(data) == "OK\r\n") { - continuousData.clear(); - return; - } - - if (data.size() != 42) - qDebug() << QString(data); - - QByteArray messageTypeData = data.left(2); - union { - uint16_t value; - std::array data; - } messageType; - std::memcpy(messageType.data.data(), messageTypeData.data(), sizeof(uint16_t)); - - switch (messageType.value) { - case MessageTypeStatus: - break; - case MessageTypeMappingIdentifier: - qDebug() << "Mapping Identifier received"; - printMapping(data.mid(2)); - continuousData.clear(); - break; - case MessageTypeInitialMessageFinished: - qDebug() << "InitialMessageFinished received"; - break; - case MessageTypePlayBookHongKang: - qDebug() << "Hong Kang Playbook received"; - break; - case MessageTypePlayBookLabel: - qDebug() << "Label Playbook received"; - break; - default: - qDebug() << "Unknown message of type '" << messageType.value << "'"; - } - - switch (messageType.value) { - case MessageTypeStatus: - { - if (_isConnected) - handleStatusMessage(data.mid(2)); - continuousData.clear(); - break; - } - case MessageTypePlayBookHongKang: - case MessageTypePlayBookLabel: - { -// const char* payloadDebug = data.mid(2).data(); - - size_t beginning = 0; - uint32_t size = readFromBuffer(data.mid(2).data(), beginning); - - //qDebug() << "Begin reading data"; - while (_socket->waitForReadyRead() && data.size() < int(size)) { - //qDebug() << "."; - //_socket->read - //data = data.append(_socket->re) - data = data.append(_socket->readAll()); - //data = data.append(_socket->read(int(size) - data.size())); - //QThread::msleep(50); - } - //qDebug() << "Finished reading data. Handling playbook"; - - continuousData = handlePlaybook(data.mid(2)); - - - //qDebug() << "Finished handling playbook"; - - //if (messageType.value == MessageTypePlayBookHongKang) - // _hasHongKangTimeline = true; - //if (messageType.value == MessageTypePlayBookLabel) - // _hasLabelTimeline = true; - - //if (_hasHongKangTimeline && _hasLabelTimeline) { - // fullyConnected(); - //} - - break; - } - case MessageTypeInitialMessageFinished: - _isConnected = true; - fullyConnected(); - continuousData.clear(); - break; - - default: - qDebug() << QString(data); - } - -} - -void MainWindow::handleStatusMessage(QByteArray data) { - const char* buffer = data.data(); - - union { - double value; - std::array buffer; - } et; - std::memmove(et.buffer.data(), buffer, sizeof(double)); - - std::vector timeString(24); - std::memmove(timeString.data(), buffer + sizeof(double), 24); - - union { - double value; - std::array buffer; - } delta; - std::memmove(delta.buffer.data(), buffer + sizeof(double) + 24, sizeof(double)); - - _timeControlWidget->update( - QString::fromStdString(std::string(timeString.begin(), timeString.end())), - QString::number(delta.value) - ); - _timelineWidget->setCurrentTime( - std::string(timeString.begin(), timeString.end()), - et.value - ); -} - -std::vector instrumentsFromId(uint16_t instrumentId, - std::map instrumentMap) -{ - std::vector results; - for (int i = 0; i < 16; ++i) { - uint16_t testValue = 1 << i; - if ((testValue & instrumentId) != 0) { - std::string t = instrumentMap.at(testValue); - if (t.empty()) { - qDebug() << "Empty instrument"; - } - results.push_back(t); - } - } - return results; -} - -QByteArray MainWindow::handlePlaybook(QByteArray data) { - char* buffer = data.data(); - size_t currentReadLocation = 0; - - uint32_t totalData = readFromBuffer(buffer, currentReadLocation); - - uint8_t nTargets = readFromBuffer(buffer, currentReadLocation); - qDebug() << "Targets: " << nTargets; - std::map targetMap; - for (uint8_t i = 0; i < nTargets; ++i) { - uint8_t id = readFromBuffer(buffer, currentReadLocation); - std::string value = readFromBuffer(buffer, currentReadLocation); - qDebug() << QString::fromStdString(value); - targetMap[id] = value; - } - - uint8_t nInstruments = readFromBuffer(buffer, currentReadLocation); - qDebug() << "Instruments: " << nInstruments; - std::map instrumentMap; - for (uint8_t i = 0; i < nInstruments; ++i) { - uint16_t id = readFromBuffer(buffer, currentReadLocation); - std::string value = readFromBuffer(buffer, currentReadLocation); - qDebug() << QString::fromStdString(value); - instrumentMap[id] = value; - } - - uint32_t nImages = readFromBuffer(buffer, currentReadLocation); - std::vector images; - for (uint32_t i = 0; i < nImages; ++i) { - Image image; - image.beginning = readFromBuffer(buffer, currentReadLocation); - image.ending = readFromBuffer(buffer, currentReadLocation); - - image.beginningString = readFromBuffer(buffer, currentReadLocation); - image.endingString = readFromBuffer(buffer, currentReadLocation); - - uint8_t targetId = readFromBuffer(buffer, currentReadLocation); - uint16_t instrumentId = readFromBuffer(buffer, currentReadLocation); - image.target = targetMap[targetId]; - image.instruments = instrumentsFromId(instrumentId, instrumentMap); - if (image.instruments.empty()) - qDebug() << "Instruments were empty"; - images.push_back(image); - } - _timelineWidget->setData( - std::move(images), - std::move(targetMap), - std::move(instrumentMap) - ); - - auto dataSize = data.size(); - auto readSize = currentReadLocation; - auto extraBytes = dataSize - readSize; - if (extraBytes > 0) { - return data.mid(currentReadLocation); - } - else { - return QByteArray(); - } -} - -void MainWindow::sendScript(QString script) { - if (_socket) { - _socket->write(("0" + script + "\r\n").toLatin1()); - //QByteArray data = (QString("0") + script).toLocal8Bit(); - //qDebug() << data; - //_socket->write(data); - //QThread::msleep(25); - } - //_socket->write(("0" + script + "\r\n").toLatin1()); - //_socket->write(("0" + script + "\0").toLatin1()); -} - -void MainWindow::onSocketConnected() { - _socket->write(QString("1\r\n").toLatin1()); - //_socket->write(QString("1").toLatin1()); - -} - -void MainWindow::onSocketDisconnected() { - _configurationWidget->socketDisconnected(); - _timeControlWidget->socketDisconnected(); - _informationWidget->socketDisconnected(); - _timelineWidget->socketDisconnected(); - - _informationWidget->logInformation("Disconnected."); -} - -std::string MainWindow::nextTarget() const { - return _timelineWidget->nextTarget(); -} - -void MainWindow::fullyConnected() { - _informationWidget->logInformation( - "Connected to " + _socket->peerName() + " on port " + - QString::number(_socket->peerPort()) + "." - ); - - _configurationWidget->socketConnected(); - _timeControlWidget->socketConnected(); - _informationWidget->socketConnected(); - _timelineWidget->socketConnected(); -} - -void MainWindow::printMapping(QByteArray data) { - char* buffer = data.data(); - size_t currentReadPosition = 0; - - uint16_t size = readFromBuffer(buffer, currentReadPosition); - for (uint16_t i = 0; i < size; ++i) { - uint16_t identifier = readFromBuffer(buffer, currentReadPosition); - std::string mapping = readFromBuffer(buffer, currentReadPosition); - - qDebug() << identifier << ": " << QString::fromStdString(mapping); - } -} diff --git a/apps/TimelineView/timelinewidget.cpp b/apps/TimelineView/timelinewidget.cpp deleted file mode 100644 index f529663eb1..0000000000 --- a/apps/TimelineView/timelinewidget.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2019 * - * * - * 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 "timelinewidget.h" - -#include -#include -#include -#include - -#include -#include - -namespace { - static const int LegendHeight = 105; - static const int TimeWidth = 200; - - static const int TextOffset = 5; - - QMap InstrumentColors = { - { "NH_ALICE_AIRGLOW", QColor(40, 130, 200) }, - { "NH_ALICE_SOC", QColor(49, 234, 219) }, - { "NH_RALPH_LEISA", QColor(139, 86, 152) }, - { "NH_RALPH_MVIC_NIR", QColor(100, 14, 14) }, - { "NH_RALPH_MVIC_METHANE", QColor(211, 154, 31) }, - { "NH_RALPH_MVIC_RED", QColor(175, 18, 18) }, - { "NH_RALPH_MVIC_BLUE", QColor(84, 79, 149) }, - { "NH_LORRI", QColor(149, 219, 32) }, - { "NH_REX", QColor(35, 185, 125) }, - - { "NH_RALPH_MVIC_PAN1", QColor(203, 153, 200) }, - { "NH_RALPH_MVIC_FT", QColor(242, 101, 74) }, - { "NH_RALPH_MVIC_PAN2", QColor(180, 180, 140) } - }; - - //{ "NH_ALICE_AIRGLOW", QColor(82, 145, 57) }, - //{ "NH_ALICE_SOC", QColor(241, 231, 48) }, - - - QMap InstrumentConversion = { - { "NH_ALICE_AIRGLOW", "ALICE Airglow" }, - { "NH_RALPH_LEISA", "RALPH LEISA" }, - { "NH_RALPH_MVIC_NIR", "RALPH MVIC NIR" }, - { "NH_ALICE_SOC", "ALICE SOC" }, - { "NH_RALPH_MVIC_BLUE", "RALPH MVIC Blue" }, - { "NH_RALPH_MVIC_PAN1" , "RALPH MVIC Pan1" }, - { "NH_LORRI", "LORRI" }, - { "NH_RALPH_MVIC_FT", "RALPH MVIC FT" }, - { "NH_RALPH_MVIC_PAN2", "RALPH MVIC Pan2" }, - { "NH_RALPH_MVIC_METHANE", "RALPH MVIC Methane" }, - { "NH_RALPH_MVIC_RED", "RALPH MVIC Red" }, - { "NH_REX", "REX" } - }; - - const double etSpread = 100.0; -} - -TimelineWidget::TimelineWidget(QWidget* parent) - : QWidget(parent) - , _currentTime{"", 0.0} -{ - setMinimumWidth(600); - setMinimumHeight(600); -} - -void TimelineWidget::paintEvent(QPaintEvent* event) { - QPainter painter(this); - - QRectF fullRect = contentsRect(); - QRectF contentRect(0, 0, fullRect.width() - 1, fullRect.height() - LegendHeight); - QRectF legendRect( - 0, - fullRect.bottom() - LegendHeight, - fullRect.right(), - fullRect.bottom() - ); - - painter.save(); - drawContent(painter, contentRect); - painter.restore(); - - painter.save(); - painter.translate(0, fullRect.height() - LegendHeight); - drawLegend(painter, QRectF(legendRect)); - painter.restore(); -} - -void TimelineWidget::setData(std::vector images, - std::map targetMap, - std::map instrumentMap) -{ - _images.insert(_images.end(), images.begin(), images.end()); - - std::sort( - _images.begin(), - _images.end(), - [](const Image& a, const Image& b) { return a.beginning < b.beginning; } - ); - - _targetMap.insert(targetMap.begin(), targetMap.end()); - _instrumentMap.insert(instrumentMap.begin(), instrumentMap.end()); - - _instruments.clear(); - std::set instruments; - for (auto p : _instrumentMap) - instruments.insert(p.second); - std::copy(instruments.begin(), instruments.end(), std::back_inserter(_instruments)); - - _targets.clear(); - std::set targets; - for (auto p : _targetMap) - targets.insert(p.second); - std::copy(targets.begin(), targets.end(), std::back_inserter(_targets)); - - repaint(); -} - -void TimelineWidget::drawContent(QPainter& painter, QRectF rect) { - QRectF timelineRect(0, 0, rect.width() - TimeWidth, rect.height()); - QRectF dateRect(rect.width() - TimeWidth, 0, TimeWidth, rect.height()); - - // Draw background - //painter.setBrush(QBrush(Qt::lightGray)); painter.drawRect(timelineRect); - painter.setBrush(QBrush(QColor(85, 85, 85))); painter.drawRect(timelineRect); - painter.setBrush(QBrush(QColor(165, 165, 165))); painter.drawRect(dateRect); - - const double lowerTime = _currentTime.et - etSpread; - const double upperTime = _currentTime.et + etSpread; - - std::vector images; - for (Image& i : _images) { - if (i.beginning <= upperTime && i.ending >= lowerTime) - images.push_back(&i); - } - - drawImages(painter, timelineRect, images, lowerTime, upperTime); - - - // Draw current time - painter.setBrush(QBrush(Qt::black)); - painter.setPen(QPen(Qt::black, 2)); - painter.drawLine( - QPointF(0, timelineRect.height() / 2), - QPointF(timelineRect.width(), timelineRect.height() / 2) - ); - painter.drawText( - timelineRect.width(), - timelineRect.height() / 2 + TextOffset, - QString::fromStdString(_currentTime.time) - ); -} - -void TimelineWidget::drawLegend(QPainter& painter, QRectF rect) { - static const int Padding = 5; - static const int BoxSize = 20; - - int currentHorizontalPosition = Padding; - int currentVerticalPosition = Padding + BoxSize + Padding; - - // Draw Targets - // Draw Instruments - for (int i = 0; i < _instruments.size(); ++i) { - if (i == _instruments.size() / 3 || i == _instruments.size() * 2 / 3) { - currentVerticalPosition += BoxSize + Padding; - currentHorizontalPosition = Padding; - } - - const std::string& instrument = _instruments[i]; - ; - painter.setBrush(QBrush(InstrumentColors[QString::fromStdString(instrument)])); - painter.setPen(QPen(InstrumentColors[QString::fromStdString(instrument)])); - painter.drawRect( - currentHorizontalPosition, - currentVerticalPosition, - BoxSize, - BoxSize - ); - currentHorizontalPosition += BoxSize + Padding; - - painter.setPen(QPen(QColor(200, 200, 200))); - //painter.setPen(QPen(Qt::black)); - painter.drawText( - currentHorizontalPosition, - currentVerticalPosition + BoxSize / 2 + TextOffset, - InstrumentConversion[QString::fromStdString(instrument)] - ); - currentHorizontalPosition += 125; - } -} - -void TimelineWidget::setCurrentTime(std::string currentTime, double et) { - _currentTime.time = std::move(currentTime); - _currentTime.et = std::move(et); - repaint(); - -} - -void TimelineWidget::drawImages( - QPainter& painter, - QRectF timelineRect, - std::vector images, - double minimumTime, double maximumTime) -{ - std::set instrumentSet; - for (Image* i : images) { - for (std::string instrument : i->instruments) { - instrumentSet.insert(instrument); - } - } - std::map instruments; - for (auto it = instrumentSet.begin(); it != instrumentSet.end(); ++it) - instruments[*it] = std::distance(instrumentSet.begin(), it); - - for (Image* i : images) { - double tBeg = (i->beginning - minimumTime) / (maximumTime - minimumTime); - tBeg = std::max(tBeg, 0.0); - double tEnd = (i->ending - minimumTime) / (maximumTime - minimumTime); - tEnd = std::min(tEnd, 1.0); - - int loc = timelineRect.top() + timelineRect.height() * tBeg; - int height = (timelineRect.top() + timelineRect.height() * tEnd) - loc; - height = std::max(height, 5); - - if (loc + height > timelineRect.height()) { - height = timelineRect.height() - loc; - } - - std::string target = i->target; - auto it = std::find(_targets.begin(), _targets.end(), target); -// int iTarget = std::distance(_targets.begin(), it); - - for (std::string instrument : i->instruments) { - auto it = std::find(_instruments.begin(), _instruments.end(), instrument); - if (it == _instruments.end()) { - qDebug() << "Instrument not found"; - } - - painter.setBrush( - QBrush(InstrumentColors[QString::fromStdString(instrument)]) - ); - - double width = timelineRect.width() / instruments.size(); - double pos = instruments[instrument] * width; - - painter.drawRect(pos, loc, width, height); - } - - if (height >= 5) { - painter.setBrush(QBrush(Qt::black)); - painter.setPen(QPen(Qt::black)); - QString line = QString::fromStdString(i->beginningString) + QString(" (") + - QString::fromStdString(i->target) + QString(")"); - - painter.drawText(timelineRect.width(), loc + height / 2 + TextOffset, line); - } - } -} - -void TimelineWidget::socketConnected() { - setDisabled(false); -} - -void TimelineWidget::socketDisconnected() { - setDisabled(true); - _images.clear(); - _instruments.clear(); - _targets.clear(); -} - -std::string TimelineWidget::nextTarget() const { - auto it = std::lower_bound( - _images.begin(), - _images.end(), - _currentTime.et, - [](const Image& i, double et) { return i.beginning < et; } - ); - if (it != _images.end()) { - return it->target; - } - else { - return ""; - } -} diff --git a/apps/Wormhole/CMakeLists.txt b/apps/Wormhole/CMakeLists.txt index 8887417b8d..fb8a75f2cd 100644 --- a/apps/Wormhole/CMakeLists.txt +++ b/apps/Wormhole/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2018 # +# Copyright (c) 2014-2020 # # # # 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 # diff --git a/apps/Wormhole/main.cpp b/apps/Wormhole/main.cpp index a988789255..12b3764abb 100644 --- a/apps/Wormhole/main.cpp +++ b/apps/Wormhole/main.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/config/gui_projector.xml b/config/gui_projector.xml index 3429edb9d6..42c3971235 100644 --- a/config/gui_projector.xml +++ b/config/gui_projector.xml @@ -17,7 +17,7 @@ - + diff --git a/config/single_fisheye_gui.xml b/config/single_fisheye_gui.xml index f6ad4d9dd4..b4a201f4c6 100644 --- a/config/single_fisheye_gui.xml +++ b/config/single_fisheye_gui.xml @@ -34,8 +34,7 @@ - - + diff --git a/config/single_sbs_stereo.xml b/config/single_sbs_stereo.xml new file mode 100644 index 0000000000..87ee3a33ec --- /dev/null +++ b/config/single_sbs_stereo.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/data/assets/apollo8.profile b/data/assets/apollo8.profile new file mode 100644 index 0000000000..f9a9c003fc --- /dev/null +++ b/data/assets/apollo8.profile @@ -0,0 +1,35 @@ +#Version +1.0 + +#Asset +scene/solarsystem/planets/earth/moon/moon required +scene/solarsystem/missions/apollo/apollo8 required +scene/solarsystem/planets/earth/earth required + +#Property +setPropertyValueSingle NavigationHandler.OrbitalNavigator.MinimumAllowedDistance 0.000000 +setPropertyValueSingle Scene.Moon.Renderable.LodScaleFactor 24.0 + +#Keybinding +E Jump to right before the earthrise photo Set Earthrise time /Missions/Apollo/8 false "openspace.time.setPause(true); openspace.time.setDeltaTime(1); openspace.time.setTime('1968 DEC 24 16:37:31'); openspace.navigation.setNavigationState({Anchor = 'Apollo8', Position = { 1.494592E1, 3.236777E1, -4.171296E1 }, ReferenceFrame = 'Root', Up = { 0.960608E0, -0.212013E0, 0.179675E0 }}); openspace.setPropertyValue('*Trail.Renderable.Enabled', false)" +U Jump to time right before Apollo 8 liftoff, with its trail enabled Set Apollo 8 launch time /Missions/Apollo/8 false "openspace.time.setTime('1968-12-21T12:51:37.00'); openspace.setPropertyValueSingle('Scene.Apollo8LaunchTrail.Renderable.Enabled', true)" +K Toggles Moon Kaguya color layer Toggle Kaguya layer on the Moon /Missions/Apollo false propertyHelper.invert('Scene.Moon.Renderable.Layers.ColorLayers.Kaguya_Utah.Enabled') +T Toggles the trails of the Apollo 8 orbits, focused around the Moon Toggle Apollo 8 orbits /Missions/Apollo/8 false propertyHelper.invert('Scene.Apollo8MoonTrail.Renderable.Enabled') +SHIFT+T Toggles the trails of the Apollo 8 Launch, focused around the Earth Toggle Apollo 8 launch trail /Missions/Apollo/8 false propertyHelper.invert('Scene.Apollo8LaunchTrail.Renderable.Enabled') +CTRL+T Toggles the trails of the full Apollo 8, with Earth's frame of reference Toggles Apollo 8 full trail /Missions/Apollo/8 false propertyHelper.invert('Scene.Apollo8EarthBarycenterTrail.Renderable.Enabled') +S Toggles shading for the Moon Toggle Moon shading /Missions/Apollo false propertyHelper.invert('Scene.Moon.Renderable.PerformShading') +PAGE_UP Set camera focus to Apollo 8 Focus on Apollo 8 /Missions/Apollo/8 false "openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Aim', ''); openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Anchor', 'Apollo8'); openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil)" +PAGE_DOWN Set camera focus to the Moon Focus on Moon /Missions/Apollo false "openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Aim', ''); openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Anchor', 'Moon'); openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil)" +HOME Set camera focus to the Earth Focus on Earth /Missions/Apollo false "openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Aim', ''); openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Anchor', 'Earth'); openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil)" + +#Time +absolute 1968-12-21T12:51:51.0 + +#Camera +goToGeo "Earth" 20 -60 15000000 + +#MarkNodes +Earth +Moon +Apollo8 +Apollo8Launch diff --git a/data/assets/apollo_sites.profile b/data/assets/apollo_sites.profile new file mode 100644 index 0000000000..f014e5b36d --- /dev/null +++ b/data/assets/apollo_sites.profile @@ -0,0 +1,36 @@ +#Version +1.0 + +#Asset +scene/solarsystem/planets/earth/moon/moon required +scene/solarsystem/missions/apollo/apollo8 required +scene/solarsystem/missions/apollo/apollo11 required +scene/solarsystem/missions/apollo/a17_lem required +scene/solarsystem/missions/apollo/apollo_globebrowsing required +scene/solarsystem/missions/apollo/apollo_11_lem_flipbook required +scene/solarsystem/missions/apollo/insignias_map required + +#Property +setPropertyValueSingle Scene.Moon.Renderable.Layers.ColorLayers.A17_travmap.BlendMode 0 +setPropertyValueSingle Scene.Apollo11LemDescentModel.Renderable.RotationVector { 273.750,28.0,309.85 } +setPropertyValueSingle Scene.Apollo11LemLandedModel.Renderable.RotationVector { 273.750,28.0,309.85 } +setPropertyValueSingle Scene.Moon.Renderable.PerformShading false + +#Keybinding +m Focus on Moon Focus on Moon /Missions/Apollo false "openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.Anchor', 'Moon'); openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil);" +F9 Disable apollo site on moon when switching Disable Apollo site /Missions/Apollo false "openspace.setPropertyValue('Scene.Moon.Renderable.Layers.ColorLayers.A17_*.Enabled', false); openspace.setPropertyValueSingle('Scene.Moon.Renderable.Layers.HeightLayers.LRO_NAC_Apollo_11.Enabled', false); openspace.setPropertyValueSingle('Scene.Moon.Renderable.Layers.ColorLayers.A11_M177481212_p_longlat.Enabled', false); openspace.setPropertyValueSingle('Scene.Apollo11MoonTrail.Renderable.Enabled', false); openspace.setPropertyValueSingle('Scene.Apollo11LemTrail.Renderable.Enabled', false); openspace.setPropertyValueSingle('Scene.Moon.Renderable.Layers.HeightLayers.LRO_NAC_Apollo_17.Enabled', false);" +F11 Setup for A11 site Setup A11 site /Missions/Apollo/11 false "openspace.time.setTime('1969 JUL 20 20:17:40'); openspace.setPropertyValueSingle('Scene.Moon.Renderable.Layers.HeightLayers.LRO_NAC_Apollo_11.Enabled', true); openspace.setPropertyValueSingle('Scene.Moon.Renderable.Layers.ColorLayers.A11_M177481212_p_longlat.Enabled', true); openspace.setPropertyValueSingle('Scene.Moon.Renderable.LodScaleFactor', 20.11); openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.Anchor', 'Apollo11LemPosition'); openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil); openspace.setPropertyValueSingle('Scene.Apollo11MoonTrail.Renderable.Enabled', true); openspace.setPropertyValueSingle('Scene.Apollo11LemTrail.Renderable.Enabled', true);" +F7 Setup for A17 site Setup A17 site /Missions/Apollo/17 false "openspace.time.setTime('1972 DEC 12 19:47:11'); openspace.setPropertyValueSingle('Scene.Moon.Renderable.Layers.ColorLayers.A17_travmap.BlendMode', 0.000000); openspace.setPropertyValueSingle('Scene.Moon.Renderable.Layers.ColorLayers.A17_travmap.Enabled', true); openspace.setPropertyValueSingle('Scene.Moon.Renderable.Layers.HeightLayers.LRO_NAC_Apollo_17.Enabled', true); openspace.setPropertyValueSingle('Scene.Moon.Renderable.Layers.ColorLayers.A17_LEM.Enabled', true); openspace.setPropertyValueSingle('Scene.Moon.Renderable.Layers.ColorLayers.A17_LEM.BlendMode', 0.000000); openspace.setPropertyValueSingle('Scene.Moon.Renderable.Layers.ColorLayers.A17_NAC_Alt_p.Enabled', true); openspace.setPropertyValueSingle('Scene.Moon.Renderable.Layers.ColorLayers.A17_NAC_Alt_p.BlendMode', 0.000000); openspace.setPropertyValueSingle('Scene.Moon.Renderable.LodScaleFactor', 20.17); openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.Anchor', 'Apollo17LemModel'); openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil); openspace.setPropertyValueSingle('Scene.Moon.Renderable.Layers.ColorLayers.A17_station7.BlendMode', 0.000000);" + +#Time +absolute 1972 DEC 12 19:47:11 + +#Camera +goToGeo "Moon" 20 -60 15000000 + +#MarkNodes +Moon +Apollo11LemModel +Apollo17LemModel +Apollo11 +Apollo11LunarLander diff --git a/data/assets/base.asset b/data/assets/base.asset index 73e2db77ab..3c6406cc80 100644 --- a/data/assets/base.asset +++ b/data/assets/base.asset @@ -58,11 +58,20 @@ local Keybindings = { { Key = "h", Name="Toggle Trails", - Command = "local list = openspace.getProperty('*Trail.Renderable.Enabled'); for _,v in pairs(list) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)) end", - Documentation = "Toggles the visibility of all trails", + Command = "local list = openspace.getProperty('{planetTrail_solarSystem}.Renderable.Enabled'); for _,v in pairs(list) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)) end\n" .. + "local moonlist = openspace.getProperty('{moonTrail_solarSystem}.Renderable.Enabled'); for _,v in pairs(moonlist) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)) end", + Documentation = "Toggles the visibility of planet and moon trails", GuiPath = "/Rendering", Local = false }, + { + Key = "l", + Name = "Toggle planet labels", + Command = "local list = openspace.getProperty('{solarsystem_labels}.Renderable.Enabled'); for _,v in pairs(list) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)) end", + Documentation = "Turns on visibility for all solar system labels", + GuiPath = "/Rendering", + Local = false + } } asset.onInitialize(function () diff --git a/data/assets/base_profile.asset b/data/assets/base_profile.asset index 67e5ba0556..f4a9b7b265 100644 --- a/data/assets/base_profile.asset +++ b/data/assets/base_profile.asset @@ -15,7 +15,6 @@ asset.require('util/default_joystick') -- Load web gui asset.require('util/webgui') -asset.request('customization/globebrowsing') asset.onInitialize(function () openspace.setDefaultGuiSorting() diff --git a/data/assets/customization/globebrowsing.asset b/data/assets/customization/globebrowsing.asset index 679f31166d..bc72ae17b3 100644 --- a/data/assets/customization/globebrowsing.asset +++ b/data/assets/customization/globebrowsing.asset @@ -22,7 +22,6 @@ local vrt_folders = { -- example: 'C:/OpenSpace/GlobeBrowsingData/Mars/CTX' -- We recommend using this folder for CTX - openspace.absPath('${ASSETS}/scene/solarsystem/planets/mars/map_service_configs/ESRI/CTX'), openspace.absPath('${BASE}/../OpenSpaceData/Mars/CTX'), -- if not and you have a custom path for CTX layers, enter it below '', diff --git a/data/assets/customization/localbookmarks.csv b/data/assets/customization/localbookmarks.csv new file mode 100644 index 0000000000..138adef2cf --- /dev/null +++ b/data/assets/customization/localbookmarks.csv @@ -0,0 +1,2 @@ +Group (optional),Name (required),Globe (optional),Lat (required if globe),Lon (required if globe),Altitude (optional if globe),x (required if not globe),y (required if not globe),z (required if not globe),Scale (optional),LineWidth (optional) +NASA,Kenedy Space Center,Earth,28.6658276,-80.70282839,,,,,, diff --git a/data/assets/dawn.profile b/data/assets/dawn.profile new file mode 100644 index 0000000000..533e43d6dc --- /dev/null +++ b/data/assets/dawn.profile @@ -0,0 +1,18 @@ +#Version +1.0 + +#Asset +scene/solarsystem/missions/dawn/ceres required +scene/solarsystem/missions/dawn/dawn required +scene/solarsystem/missions/dawn/vesta required + +#Time +absolute 2011 AUG 06 00:00:00 + +#Camera +setNavigationState "Dawn" 526781518487.171326, 257168309890.072144, -1381125204152.817383 + +#MarkNodes +Dawn +Ceres +Vesta diff --git a/data/assets/default.profile b/data/assets/default.profile new file mode 100644 index 0000000000..b5614baf84 --- /dev/null +++ b/data/assets/default.profile @@ -0,0 +1,21 @@ +#Version +1.0 + +#Asset +scene/solarsystem/planets/earth/earth required +scene/solarsystem/planets/earth/satellites/satellites required + +#Property +setPropertyValue {earth_satellites}.Renderable.Enabled false + +#Time +relative -1d + +#Camera +goToGeo "Earth" 58.5877 16.1924 20000000 + +#MarkNodes +Earth +Mars +Moon +Sun diff --git a/data/assets/default.scene b/data/assets/default.scene index c6d3e2523c..606d5852d5 100644 --- a/data/assets/default.scene +++ b/data/assets/default.scene @@ -1,6 +1,8 @@ asset.require('./base') local earthAsset = asset.require('scene/solarsystem/planets/earth/earth') +asset.require('scene/solarsystem/planets/earth/satellites/satellites.asset') +asset.require('scene/solarsystem/sssb/pha') asset.onInitialize(function () local now = openspace.time.currentWallTime() @@ -10,6 +12,8 @@ asset.onInitialize(function () openspace.globebrowsing.goToGeo("Earth", 58.5877, 16.1924, 20000000) openspace.markInterestingNodes({ "Earth", "Mars", "Moon", "Sun" }) + + openspace.setPropertyValue("{earth_satellites}.Renderable.Enabled", false) end) asset.onDeinitialize(function () diff --git a/data/assets/default_full.profile b/data/assets/default_full.profile new file mode 100644 index 0000000000..e6c2522523 --- /dev/null +++ b/data/assets/default_full.profile @@ -0,0 +1,23 @@ +#Version +1.0 + +#Asset +scene/solarsystem/planets/earth/earth required +scene/solarsystem/planets/jupiter/minor_moons required +scene/solarsystem/planets/saturn/minor_moons required +scene/solarsystem/planets/uranus/minor_moons required +scene/solarsystem/planets/neptune/inner_moons required +scene/solarsystem/planets/neptune/irregular_prograde_moons required +scene/solarsystem/planets/neptune/irregular_retrograde_moons required + +#Time +relative -1d + +#Camera +goToGeo "Earth" 58.5877 16.1924 20000000 + +#MarkNodes +Earth +Mars +Moon +Sun diff --git a/data/assets/gaia.profile b/data/assets/gaia.profile new file mode 100644 index 0000000000..82d54557b1 --- /dev/null +++ b/data/assets/gaia.profile @@ -0,0 +1,22 @@ +#Version +1.0 + +#Module +Gaia openspace.printFatal('Could not load scene due to missing module "gaia"') + +#Asset +scene/solarsystem/planets/earth/earth required +scene/milkyway/gaia/gaiastars required +scene/milkyway/gaia/apogee required +scene/milkyway/gaia/galah required +scene/solarsystem/missions/gaia/gaia required +scene/solarsystem/missions/gaia/trail required + +#Property +setPropertyValueSingle Scene.Stars.Renderable.Enabled false + +#Camera +setNavigationState "Earth" 1000000000000.0, 1000000000000.0, 1000000000000.0 + +#MarkNodes +Gaia diff --git a/data/assets/global/localbookmarks.asset b/data/assets/global/localbookmarks.asset new file mode 100644 index 0000000000..18fd5b408e --- /dev/null +++ b/data/assets/global/localbookmarks.asset @@ -0,0 +1,5 @@ +local assetHelper = asset.require('util/asset_helper') +local bookmarkHelper = asset.require('util/generate_bookmarks') + +local nodes = bookmarkHelper.getBookmarks('Local Bookmarks', '${ASSETS}/customization/localbookmarks.csv') +assetHelper.registerSceneGraphNodesAndExport(asset, nodes); diff --git a/data/assets/global/openspacebookmarks.asset b/data/assets/global/openspacebookmarks.asset new file mode 100644 index 0000000000..8075929c44 --- /dev/null +++ b/data/assets/global/openspacebookmarks.asset @@ -0,0 +1,28 @@ +local assetHelper = asset.require('util/asset_helper') +local bookmarkHelper = asset.require('util/generate_bookmarks') + +local dataProvider = 'http://data.openspaceproject.com/files/bookmarks/v1/bookmarks.csv' + +local bookmarksCSV = asset.syncedResource({ + Identifier = 'openspace_bookmarks', + Name = 'OpenSpace Bookmarks', + Type = 'UrlSynchronization', + UseHash = false, + Override = true, + Url = dataProvider +}) + +local nodes = {} + +asset.onInitialize(function () + nodes = bookmarkHelper.getBookmarks('OpenSpace Bookmarks', bookmarksCSV .. '/bookmarks.csv.txt') + for _, n in ipairs(nodes) do + openspace.addSceneGraphNode(n); + end +end) + +asset.onDeinitialize(function () + for _, n in ipairs(nodes) do + openspace.removeSceneGraphNode(n.Identifier); + end +end) diff --git a/data/assets/insight.profile b/data/assets/insight.profile new file mode 100644 index 0000000000..0491c3e059 --- /dev/null +++ b/data/assets/insight.profile @@ -0,0 +1,29 @@ +#Version +1.0 + +#Asset +scene/solarsystem/missions/insight/edl required + +#Property +setPropertyValueSingle Scene.PlutoBarycenterTrail.Renderable.Enabled false +setPropertyValueSingle Scene.Mars.Renderable.Layers.HeightLayers.Mola_Utah.Settings.Offset -469.300000 +setPropertyValueSingle Scene.Mars.Renderable.Layers.HeightLayers.OnMarsHiRISELS.Settings.Offset -470.800006 +setPropertyValueSingle Scene.Mars.Renderable.Layers.HeightLayers.OnMarsHiRISELS.Enabled true +setPropertyValueSingle Scene.Mars.Renderable.Layers.ColorLayers.MOC_WA_Color_Utah.Settings.Multiplier 2.81690 +setPropertyValueSingle Scene.Mars.Renderable.Layers.ColorLayers.OnMarsHiRISELS.Settings.Gamma 0.938970 +setPropertyValueSingle Scene.Mars.Renderable.Layers.ColorLayers.MOC_WA_Color_Utah.Settings.Gamma 2.394370 +setPropertyValueSingle Scene.Mars.Renderable.Layers.ColorLayers.OnMarsHiRISELS.Enabled true + + +#Keybinding +i Setup Insight landing layers Setup Insight layers /Missions/Insight false "openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.Mola_Utah.Settings.Offset', -469.300000); openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.OnMarsHiRISELS.Settings.Offset', -470.800006); openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.ColorLayers.insight_ctx.Enabled', true); openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.OnMarsHiRISELS.Enabled', true); openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.ColorLayers.MOC_WA_Color_Utah.Settings.Multiplier', 2.816900); openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.ColorLayers.OnMarsHiRISELS.Settings.Gamma', 0.938970); openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.ColorLayers.MOC_WA_Color_Utah.Settings.Gamma', 2.394370); openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.ColorLayers.OnMarsHiRISELS.Enabled', true);" +SHIFT+i Undo Insight landing layers setup Unset Insight layers /Missions/Insight false "openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.Mola_Utah.Settings.Offset', 0); openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.OnMarsHiRISELS.Settings.Offset', 0); openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.ColorLayers.insight_ctx.Enabled', false); openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.OnMarsHiRISELS.Enabled', false); openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.ColorLayers.OnMarsHiRISELS.Enabled', false); openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.ColorLayers.MOC_WA_Color_Utah.Settings.Multiplier', 1.0); openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.ColorLayers.OnMarsHiRISELS.Settings.Gamma', 1.0); openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.ColorLayers.MOC_WA_Color_Utah.Settings.Gamma', 1.0);" + +#Time +absolute 2018 NOV 26 19:39:03.68 + +#Camera +setNavigationState "Insight" "Root" 8.430115E0, -1.791710E1, 2.813660E0 0.494659E0,0.357162E0,0.792306E0 + +#MarkNodes +Insight diff --git a/data/assets/juno.profile b/data/assets/juno.profile new file mode 100644 index 0000000000..d2bb28a316 --- /dev/null +++ b/data/assets/juno.profile @@ -0,0 +1,37 @@ +#Version +1.0 + +#Asset +scene/solarsystem/missions/juno/juno required + +#Keybinding +1 Setting the simulation speed to 1 seconds per realtime second Set sim speed 1 /Simulation Speed false "openspace.time.interpolateDeltaTime(1)" +2 Setting the simulation speed to 5 seconds per realtime second Set sim speed 5 /Simulation Speed false "openspace.time.interpolateDeltaTime(5)" +3 Setting the simulation speed to 10 seconds per realtime second Set sim speed 10 /Simulation Speed false "openspace.time.interpolateDeltaTime(10)" +4 Setting the simulation speed to 20 seconds per realtime second Set sim speed 20 /Simulation Speed false "openspace.time.interpolateDeltaTime(20)" +5 Setting the simulation speed to 40 seconds per realtime second Set sim speed 40 /Simulation Speed false "openspace.time.interpolateDeltaTime(40)" +6 Setting the simulation speed to 90 seconds per realtime second Set sim speed 90 /Simulation Speed false "openspace.time.interpolateDeltaTime(90)" +7 Setting the simulation speed to 360 seconds per realtime second Set sim speed 360 /Simulation Speed false "openspace.time.interpolateDeltaTime(360)" +8 Setting the simulation speed to 720 seconds per realtime second Set sim speed 720 /Simulation Speed false "openspace.time.interpolateDeltaTime(720)" +9 Setting the simulation speed to 2880 seconds per realtime second Set sim speed 2880 /Simulation Speed false "openspace.time.interpolateDeltaTime(2880)" +0 Setting the simulation speed to 14400 seconds per realtime second Set sim speed 14400 /Simulation Speed false "openspace.time.interpolateDeltaTime(14400)" +Shift+1 Setting the simulation speed to 28800 seconds per realtime second Set sim speed 28800 /Simulation Speed false "openspace.time.interpolateDeltaTime(28800)" +Shift+2 Setting the simulation speed to 57600 seconds per realtime second Set sim speed 57600 /Simulation Speed false "openspace.time.interpolateDeltaTime(57600)" +Shift+3 Setting the simulation speed to 115200 seconds per realtime second Set sim speed 115200 /Simulation Speed false "openspace.time.interpolateDeltaTime(115200)" +Shift+4 Setting the simulation speed to 230400 seconds per realtime second Set sim speed 230400 /Simulation Speed false "openspace.time.interpolateDeltaTime(230400)" +Shift+5 Setting the simulation speed to 460800 seconds per realtime second Set sim speed 460800 /Simulation Speed false "openspace.time.interpolateDeltaTime(460800)" +Shift+6 Setting the simulation speed to 921600 seconds per realtime second Set sim speed 921600 /Simulation Speed false "openspace.time.interpolateDeltaTime(921600)" +Shift+7 Setting the simulation speed to 1843200 seconds per realtime second Set sim speed 1843200 /Simulation Speed false "openspace.time.interpolateDeltaTime(1843200)" +Shift+8 Setting the simulation speed to 3686400 seconds per realtime second Set sim speed 3686400 /Simulation Speed false "openspace.time.interpolateDeltaTime(3686400)" +Shift+9 Setting the simulation speed to 7372800 seconds per realtime second Set sim speed 7372800 /Simulation Speed false "openspace.time.interpolateDeltaTime(7372800)" +Shift+0 Setting the simulation speed to 14745600 seconds per realtime second Set sim speed 14745600 /Simulation Speed false "openspace.time.interpolateDeltaTime(14745600)" + +#Time +absolute 2016-07-01T10:05:00.00 + +#Camera +setNavigationState "Juno" "Root" 1.243398E8, 7.176068E7, -1.519733E7 -0.377400E0, 0.764573E0, 0.522492E0 + +#MarkNodes +Jupiter +Juno diff --git a/data/assets/messenger.profile b/data/assets/messenger.profile new file mode 100644 index 0000000000..8a508388d9 --- /dev/null +++ b/data/assets/messenger.profile @@ -0,0 +1,41 @@ +#Version +1.0 + +#Module +Volume asset.require('scene/solarsystem/missions/messenger/mercurymagnetosphere') openspace.printWarning("Volume module is not loaded, skipping asset: mercurymagnetosphere") + +#Asset +scene/solarsystem/missions/messenger/messengerSC required + +#Keybinding +1 Setting the simulation speed to 1 seconds per realtime second Set sim speed 1 /Simulation Speed false "openspace.time.interpolateDeltaTime(1)" +2 Setting the simulation speed to 5 seconds per realtime second Set sim speed 5 /Simulation Speed false "openspace.time.interpolateDeltaTime(5)" +3 Setting the simulation speed to 10 seconds per realtime second Set sim speed 10 /Simulation Speed false "openspace.time.interpolateDeltaTime(10)" +4 Setting the simulation speed to 20 seconds per realtime second Set sim speed 20 /Simulation Speed false "openspace.time.interpolateDeltaTime(20)" +5 Setting the simulation speed to 40 seconds per realtime second Set sim speed 40 /Simulation Speed false "openspace.time.interpolateDeltaTime(40)" +6 Setting the simulation speed to 90 seconds per realtime second Set sim speed 90 /Simulation Speed false "openspace.time.interpolateDeltaTime(90)" +7 Setting the simulation speed to 360 seconds per realtime second Set sim speed 360 /Simulation Speed false "openspace.time.interpolateDeltaTime(360)" +8 Setting the simulation speed to 720 seconds per realtime second Set sim speed 720 /Simulation Speed false "openspace.time.interpolateDeltaTime(720)" +9 Setting the simulation speed to 2880 seconds per realtime second Set sim speed 2880 /Simulation Speed false "openspace.time.interpolateDeltaTime(2880)" +0 Setting the simulation speed to 14400 seconds per realtime second Set sim speed 14400 /Simulation Speed false "openspace.time.interpolateDeltaTime(14400)" +Shift+1 Setting the simulation speed to 28800 seconds per realtime second Set sim speed 28800 /Simulation Speed false "openspace.time.interpolateDeltaTime(28800)" +Shift+2 Setting the simulation speed to 57600 seconds per realtime second Set sim speed 57600 /Simulation Speed false "openspace.time.interpolateDeltaTime(57600)" +Shift+3 Setting the simulation speed to 115200 seconds per realtime second Set sim speed 115200 /Simulation Speed false "openspace.time.interpolateDeltaTime(115200)" +Shift+4 Setting the simulation speed to 230400 seconds per realtime second Set sim speed 230400 /Simulation Speed false "openspace.time.interpolateDeltaTime(230400)" +Shift+5 Setting the simulation speed to 460800 seconds per realtime second Set sim speed 460800 /Simulation Speed false "openspace.time.interpolateDeltaTime(460800)" +Shift+6 Setting the simulation speed to 921600 seconds per realtime second Set sim speed 921600 /Simulation Speed false "openspace.time.interpolateDeltaTime(921600)" +Shift+7 Setting the simulation speed to 1843200 seconds per realtime second Set sim speed 1843200 /Simulation Speed false "openspace.time.interpolateDeltaTime(1843200)" +Shift+8 Setting the simulation speed to 3686400 seconds per realtime second Set sim speed 3686400 /Simulation Speed false "openspace.time.interpolateDeltaTime(3686400)" +Shift+9 Setting the simulation speed to 7372800 seconds per realtime second Set sim speed 7372800 /Simulation Speed false "openspace.time.interpolateDeltaTime(7372800)" +Shift+0 Setting the simulation speed to 14745600 seconds per realtime second Set sim speed 14745600 /Simulation Speed false "openspace.time.interpolateDeltaTime(14745600)" + +#Time +absolute 2011 MAY 13 00:05:18 + +#Camera +setNavigationState "Mercury" "Root" 2.423690E11, 1.979038E11, -2.241483E10 -0.492046E0, 0.666088E0, 0.560551E0 + +#MarkNodes +Mercury +Messenger +Sun diff --git a/data/assets/newhorizons.profile b/data/assets/newhorizons.profile new file mode 100644 index 0000000000..ff3a46a096 --- /dev/null +++ b/data/assets/newhorizons.profile @@ -0,0 +1,60 @@ +#Version +1.0 + +#Asset +scene/solarsystem/missions/newhorizons/newhorizons required +scene/solarsystem/missions/newhorizons/model required + +#Property +setPropertyValueSingle NavigationHandler.OrbitalNavigator.FollowAnchorNodeRotationDistance 20.000000 +setPropertyValueSingle Scene.Pluto.Renderable.Enabled false +setPropertyValueSingle Scene.Charon.Renderable.Enabled false +setPropertyValueSingle Scene.PlutoBarycenterTrail.Renderable.Enabled false + +#Keybinding +a Sets the focus of the camera on 'NewHorizons'. Focus on New Horizons /New Horizons false "openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.Anchor', 'NewHorizons');openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.Aim', '');openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil)" +SHIFT+a Sets the focus of the camera on 'NewHorizons'. Anchor at New Horizons, Aim at Pluto /New Horizons false "openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.Anchor', 'NewHorizons');openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.Aim', 'Pluto');openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil)" +s Sets the focus of the camera on 'Pluto' Focus on Pluto /New Horizons false "openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.Anchor', 'Pluto') ;openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.Aim', ''); openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil)" +d Sets the focus of the camera on 'Charon'. Focus on New Charon /New Horizons false "openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.Anchor', 'Charon');openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.Aim', '');openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil)" +F7 Toggles New Horizons image projection. Toggle NH Image Projection /New Horizons false [[local enabled = openspace.getPropertyValue('Scene.PlutoProjection.Renderable.ProjectionComponent.PerformProjection'); openspace.setPropertyValue('Scene.PlutoProjection.Renderable.ProjectionComponent.PerformProjection', not enabled); openspace.setPropertyValue('Scene.CharonProjection.Renderable.ProjectionComponent.PerformProjection', not enabled)]] +F8 Removes all image projections from Pluto and Charon. Clear image projections /New Horizons false "openspace.setPropertyValue('Scene.PlutoProjection.Renderable.ProjectionComponent.ClearAllProjections', true); openspace.setPropertyValue('Scene.CharonProjection.Renderable.ProjectionComponent.ClearAllProjections', true)" +F9 Jumps to the 14th of July 2015 at 0900 UTC and clears all projections. Reset time and projections /New Horizons false "openspace.time.setTime('2015-07-14T09:00:00.00');openspace.setPropertyValue('Scene.PlutoProjection.Renderable.ProjectionComponent.ClearAllProjections', true);openspace.setPropertyValue('Scene.CharonProjection.Renderable.ProjectionComponent.ClearAllProjections', true)" +KP_8 Increases the height map exaggeration on Pluto. Pluto HeightExaggeration + /New Horizons false propertyHelper.increment('Scene.PlutoProjection.Renderable.HeightExaggeration', 5000) +CTRL+I Increases the height map exaggeration on Pluto. Pluto HeightExaggeration + /New Horizons false propertyHelper.increment('Scene.PlutoProjection.Renderable.HeightExaggeration', 5000) +KP_2 Decreases the height map exaggeration on Pluto. Pluto HeightExaggeration - /New Horizons false propertyHelper.decrement('Scene.PlutoProjection.Renderable.HeightExaggeration', 5000) +CTRL+K Decreases the height map exaggeration on Pluto. Pluto HeightExaggeration - /New Horizons false propertyHelper.decrement('Scene.PlutoProjection.Renderable.HeightExaggeration', 5000) +KP_9 Increases the height map exaggeration on Charon. Charon HeightExaggeration + /New Horizons false propertyHelper.increment('Scene.CharonProjection.Renderable.HeightExaggeration', 5000) +CTRL+O Increases the height map exaggeration on Charon. Charon HeightExaggeration + /New Horizons false propertyHelper.increment('Scene.CharonProjection.Renderable.HeightExaggeration', 5000) +KP_3 Decreases the height map exaggeration on Charon. Charon HeightExaggeration - /New Horizons false propertyHelper.decrement('Scene.CharonProjection.Renderable.HeightExaggeration', 5000) +CTRL+L Decreases the height map exaggeration on Charon. Charon HeightExaggeration - /New Horizons false propertyHelper.decrement('Scene.CharonProjection.Renderable.HeightExaggeration', 5000) +o Toggles the visibility of the trail behind Pluto. Toggle Pluto Trail /New Horizons false propertyHelper.invert('Scene.PlutoBarycentricTrail.Renderable.Enabled') +j Toggles the visibility of the text labels of Pluto, Charon, Hydra, Nix, Kerberos, and Styx. Toggle Pluto Labels /New Horizons false renderableHelper.toggle('Scene.PlutoText') .. renderableHelper.toggle('Scene.CharonText') .. renderableHelper.toggle('Scene.HydraText') .. renderableHelper.toggle('Scene.NixText') .. renderableHelper.toggle('Scene.KerberosText') .. renderableHelper.toggle('Scene.StyxText') +l Toggles the visibility of the labels for the New Horizons instruments. Toggle New Horizons Labels /New Horizons false propertyHelper.fadeInOut('Scene.Labels.Renderable.Opacity', 2.0) +m Draws the instrument field of views in a solid color or as lines. Toggle instrument FOVs /New Horizons false propertyHelper.invert('Scene.NH_LORRI.Renderable.SolidDraw') .. propertyHelper.invert('Scene.NH_RALPH_LEISA.Renderable.SolidDraw') .. propertyHelper.invert('Scene.NH_RALPH_MVIC_PAN1.Renderable.SolidDraw') .. propertyHelper.invert('Scene.NH_RALPH_MVIC_PAN2.Renderable.SolidDraw') .. propertyHelper.invert('Scene.NH_RALPH_MVIC_RED.Renderable.SolidDraw') .. propertyHelper.invert('Scene.NH_RALPH_MVIC_BLUE.Renderable.SolidDraw') .. propertyHelper.invert('Scene.NH_RALPH_MVIC_FT.Renderable.SolidDraw') .. propertyHelper.invert('Scene.NH_RALPH_MVIC_METHANE.Renderable.SolidDraw') .. propertyHelper.invert('Scene.NH_RALPH_MVIC_NIR.Renderable.SolidDraw') .. propertyHelper.invert('Scene.NH_ALICE_AIRGLOW.Renderable.SolidDraw') .. propertyHelper.invert('Scene.NH_ALICE_SOC.Renderable.SolidDraw') +Shift+t Toggles the visibility of the shadow visualization of Pluto and Charon. Toggle Shadows /New Horizons false renderableHelper.toggle('Scene.PlutoShadow') .. renderableHelper.toggle('Scene.CharonShadow') +t Toggles the trail of New Horizons. Toggle NH Trail /New Horizons false renderableHelper.toggle('Scene.NewHorizonsTrailPluto') +h Disables visibility of the trails Hide Trails /Rendering false "local list = openspace.getProperty('*Trail.Renderable.Enabled'); for _,v in pairs(list) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)) end" +1 Setting the simulation speed to 1 seconds per realtime second Set sim speed 1 /Simulation Speed false "openspace.time.interpolateDeltaTime(1)" +2 Setting the simulation speed to 5 seconds per realtime second Set sim speed 5 /Simulation Speed false "openspace.time.interpolateDeltaTime(5)" +3 Setting the simulation speed to 10 seconds per realtime second Set sim speed 10 /Simulation Speed false "openspace.time.interpolateDeltaTime(10)" +4 Setting the simulation speed to 20 seconds per realtime second Set sim speed 20 /Simulation Speed false "openspace.time.interpolateDeltaTime(20)" +5 Setting the simulation speed to 40 seconds per realtime second Set sim speed 40 /Simulation Speed false "openspace.time.interpolateDeltaTime(40)" +6 Setting the simulation speed to 60 seconds per realtime second Set sim speed 60 /Simulation Speed false "openspace.time.interpolateDeltaTime(60)" +7 Setting the simulation speed to 120 seconds per realtime second Set sim speed 120 /Simulation Speed false "openspace.time.interpolateDeltaTime(120)" +8 Setting the simulation speed to 360 seconds per realtime second Set sim speed 360 /Simulation Speed false "openspace.time.interpolateDeltaTime(360)" +9 Setting the simulation speed to 540 seconds per realtime second Set sim speed 540 /Simulation Speed false "openspace.time.interpolateDeltaTime(540)" +0 Setting the simulation speed to 1080 seconds per realtime second Set sim speed 1080 /Simulation Speed false "openspace.time.interpolateDeltaTime(1080)" +Shift+1 Setting the simulation speed to 2160 seconds per realtime second Set sim speed 2160 /Simulation Speed false "openspace.time.interpolateDeltaTime(2160)" +Shift+2 Setting the simulation speed to 4320 seconds per realtime second Set sim speed 4320 /Simulation Speed false "openspace.time.interpolateDeltaTime(4320)" +Shift+3 Setting the simulation speed to 8640 seconds per realtime second Set sim speed 8640 /Simulation Speed false "openspace.time.interpolateDeltaTime(8640)" + +#Time +absolute 2015-07-14T08:00:00.00 + +#Camera +setNavigationState "NewHorizons" "Root" -6.572656E1, -7.239404E1, -2.111890E1 0.102164, -0.362945, 0.926193 + +#MarkNodes +Pluto +NewHorizons +Charon diff --git a/data/assets/osirisrex.profile b/data/assets/osirisrex.profile new file mode 100644 index 0000000000..eec35f2466 --- /dev/null +++ b/data/assets/osirisrex.profile @@ -0,0 +1,45 @@ +#Version +1.0 + +#Asset +scene/solarsystem/missions/osirisrex/model required +scene/solarsystem/missions/osirisrex/osirisrex required + +#Property +setPropertyValueSingle NavigationHandler.OrbitalNavigator.FollowAnchorNodeRotationDistance 20.000000 +setPropertyValueSingle Scene.Pluto.Renderable.Enabled false +setPropertyValueSingle Scene.Charon.Renderable.Enabled false +setPropertyValueSingle Scene.PlutoBarycenterTrail.Renderable.Enabled false + +#Keybinding +a Sets the focus of the camera on 'OsirisRex'. Focus on OsirisRex /Missions/Osiris Rex false "openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.Anchor', 'OsirisRex'); openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.Aim', ''); openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil)" +s Sets the focus of the camera on 'Bennu' Focus on Bennu /Missions/Osiris Rex false "openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.Anchor', 'BennuBarycenter'); openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.Aim', ''); openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil)" +F8 Sets the time to the approach at Bennu. Set Bennu approach time /Missions/Osiris Rex false "openspace.printInfo('Set time: Approach'); openspace.time.setTime('2018-SEP-11 21:31:01.183')" +F9 Sets the time to the preliminary survey of Bennu. Set Bennu survey time /Missions/Osiris Rex false "openspace.printInfo('Set time: Preliminary Survey'); openspace.time.setTime('2018-NOV-20 01:13:12.183')" +F10 Sets the time to the orbital B event. Set orbital B event time /Missions/Osiris Rex false "openspace.printInfo('Set time: Orbital B'); openspace.time.setTime('2019-APR-08 10:35:27.186')" +F11 Sets the time to the recon event. Set recon event time /Missions/Osiris Rex false "openspace.printInfo('Set time: Recon'); openspace.time.setTime('2019-MAY-25 03:50:31.195')" +q Toggles the visibility of the text marking the location of the Sun. Toggle Sun marker /Missions/Osiris Rex false propertyHelper.invert('Scene.SunMarker.Renderable.Enabled') +1 Setting the simulation speed to 1 seconds per realtime second Set sim speed 1 /Simulation Speed false "openspace.time.interpolateDeltaTime(1)" +2 Setting the simulation speed to 5 seconds per realtime second Set sim speed 5 /Simulation Speed false "openspace.time.interpolateDeltaTime(5)" +3 Setting the simulation speed to 10 seconds per realtime second Set sim speed 10 /Simulation Speed false "openspace.time.interpolateDeltaTime(10)" +4 Setting the simulation speed to 20 seconds per realtime second Set sim speed 20 /Simulation Speed false "openspace.time.interpolateDeltaTime(20)" +5 Setting the simulation speed to 40 seconds per realtime second Set sim speed 40 /Simulation Speed false "openspace.time.interpolateDeltaTime(40)" +6 Setting the simulation speed to 60 seconds per realtime second Set sim speed 60 /Simulation Speed false "openspace.time.interpolateDeltaTime(60)" +7 Setting the simulation speed to 120 seconds per realtime second Set sim speed 120 /Simulation Speed false "openspace.time.interpolateDeltaTime(120)" +8 Setting the simulation speed to 360 seconds per realtime second Set sim speed 360 /Simulation Speed false "openspace.time.interpolateDeltaTime(360)" +9 Setting the simulation speed to 540 seconds per realtime second Set sim speed 540 /Simulation Speed false "openspace.time.interpolateDeltaTime(540)" +0 Setting the simulation speed to 1080 seconds per realtime second Set sim speed 1080 /Simulation Speed false "openspace.time.interpolateDeltaTime(1080)" +Shift+1 Setting the simulation speed to 2160 seconds per realtime second Set sim speed 2160 /Simulation Speed false "openspace.time.interpolateDeltaTime(2160)" +Shift+2 Setting the simulation speed to 4320 seconds per realtime second Set sim speed 4320 /Simulation Speed false "openspace.time.interpolateDeltaTime(4320)" +Shift+3 Setting the simulation speed to 8640 seconds per realtime second Set sim speed 8640 /Simulation Speed false "openspace.time.interpolateDeltaTime(8640)" + +#Time +absolute 2018 10 30 23:00:00.500 + +#Camera +setNavigationState "OsirisRex" 26974590199.661884, 76314608558.908020, -127086452897.101791 + +#MarkNodes +OsirisRex +BennuBarycenter +Earth diff --git a/data/assets/rosetta.profile b/data/assets/rosetta.profile new file mode 100644 index 0000000000..0b0bd37881 --- /dev/null +++ b/data/assets/rosetta.profile @@ -0,0 +1,35 @@ +#Version +1.0 + +#Module +Volume asset.require('scene/solarsystem/missions/messenger/mercurymagnetosphere') openspace.printWarning("Volume module is not loaded, skipping asset: mercurymagnetosphere") + +#Asset +scene/solarsystem/missions/rosetta/67p required +scene/solarsystem/missions/rosetta/rosetta required + +#Property +setPropertyValue Scene.67P.Renderable.PerformShading false +setPropertyValue Scene.ImagePlaneRosetta.Renderable.Enabled false + +#Keybinding +a Sets the focus of the camera on '67P'. Focus on 67P /Missions/Rosetta false "openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.Anchor', '67P'); openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.Aim', ''); openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil)" +s Sets the focus of the camera on 'Rosetta' Focus on Rosetta /Missions/Rosetta false "openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.Anchor', 'Rosetta'); openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.Aim', ''); openspace.setPropertyValue('NavigationHandler.OrbitalNavigator.RetargetAnchor', nil)" +F5 Jumps to the time of initial approach of Rosetta to 67P. Set initial approach time /Missions/Rosetta false "openspace.time.setTime('2014-08-01T03:05:18.101')" +F6 Jumps to the time when the Philae lander is released. Set lander release time /Missions/Rosetta false "openspace.time.setTime('2014-11-12T08:20:00.00')" +F8 Removes all image projections from 67P. Clear 67P projections /Missions/Rosetta false "openspace.setPropertyValue('Scene.67P.Renderable.ProjectionComponent.ClearAllProjections', true)" +e Toggles the visibility of all trails further from the Sun than 67P. Toggle outer planetary trails /Missions/Rosetta false renderableHelper.toggle('Scene.JupiterTrail')..renderableHelper.toggle('Scene.SaturnTrail')..renderableHelper.toggle('Scene.UranusTrail')..renderableHelper.toggle('Scene.NeptuneTrail') +i Toggles the visibility of the free floating image plane. Toggle image plane /Missions/Rosetta false renderableHelper.toggle('Scene.ImagePlaneRosetta') +g Toggles the visibility of Philae's trail. Toggle Philae trail /Missions/Rosetta false renderableHelper.toggle('Scene.PhilaeTrail') +p Enables or disables the image projection on 67P. Toggle 67P projection /Missions/Rosetta false propertyHelper.invert('Scene.67P.Renderable.ProjectionComponent.PerformProjection') + +#Time +absolute 2014-08-01T03:05:00.000 + +#Camera +setNavigationState "67P" "Root" -7.294781E5 , -6.657894E5, 2.509047E6 0.146529E0, 0.944727E0, 0.293290E0 + +#MarkNodes +67P +Rosetta +Philae diff --git a/data/assets/rosetta.scene b/data/assets/rosetta.scene index 315c8804fc..f1470372a1 100644 --- a/data/assets/rosetta.scene +++ b/data/assets/rosetta.scene @@ -32,8 +32,8 @@ local Keybindings = { Local = false }, { - Key = "F5", - Command = "openspace.time.setTime('2014-08-01T03:05:18.101')", + Key = "Shift+F6", + Command = "openspace.time.setTime('2014-08-01T03:05:18.10')", Documentation = "Jumps to the time of initial approach of Rosetta to 67P.", Name = "Set initial approach time", GuiPath = "/Missions/Rosetta", @@ -81,7 +81,7 @@ local Keybindings = { Local = false }, { - Key = "g", + Key = "o", Command = renderableHelper.toggle('Scene.PhilaeTrail'), Documentation = "Toggles the visibility of Philae's trail.", Name = "Toggle Philae trail", diff --git a/data/assets/scene/digitaluniverse/2dF.asset b/data/assets/scene/digitaluniverse/2dF.asset index 2b09ab91ff..2da1fb619d 100644 --- a/data/assets/scene/digitaluniverse/2dF.asset +++ b/data/assets/scene/digitaluniverse/2dF.asset @@ -6,7 +6,7 @@ local textures = asset.syncedResource({ Name = "2dF Textures", Type = "HttpSynchronization", Identifier = "digitaluniverse_2dF_textures", - Version = 1 + Version = 2 }) local speck = asset.syncedResource({ @@ -24,7 +24,7 @@ local object = { Color = { 1.0, 1.0, 1.0 }, Opacity = 1.0, File = speck .. "/2dF.speck", - Texture = textures .. "/point3.png", + Texture = textures .. "/point3A.png", ColorMap = speck .. "/2dF.cmap", ColorOption = { "redshift", "proximity" }, ColorRange = { { 0.0, 0.075 }, { 1.0, 25.0 } }, diff --git a/data/assets/scene/digitaluniverse/2mass.asset b/data/assets/scene/digitaluniverse/2mass.asset index b27311229a..c27557c282 100644 --- a/data/assets/scene/digitaluniverse/2mass.asset +++ b/data/assets/scene/digitaluniverse/2mass.asset @@ -6,7 +6,7 @@ local textures = asset.syncedResource({ Name = "2MASS Textures", Type = "HttpSynchronization", Identifier = "digitaluniverse_2mass_textures", - Version = 1 + Version = 2 }) local speck = asset.syncedResource({ @@ -24,7 +24,7 @@ local object = { Color = { 1.0, 0.4, 0.2 }, Opacity = 1.0, File = speck .. "/2MASS.speck", - Texture = textures .. "/point3.png", + Texture = textures .. "/point3A.png", ColorMap = speck .. "/lss.cmap", ColorOption = { "redshift", "prox5Mpc" }, ColorRange = { { 0.0, 0.075 }, { 1.0, 50.0 } }, diff --git a/data/assets/scene/digitaluniverse/6dF.asset b/data/assets/scene/digitaluniverse/6dF.asset index 3f9b74256c..2843b142d4 100644 --- a/data/assets/scene/digitaluniverse/6dF.asset +++ b/data/assets/scene/digitaluniverse/6dF.asset @@ -6,7 +6,7 @@ local textures = asset.syncedResource({ Name = "6dF Textures", Type = "HttpSynchronization", Identifier = "digitaluniverse_6dF_textures", - Version = 1 + Version = 2 }) local speck = asset.syncedResource({ @@ -24,7 +24,7 @@ local object = { Color = { 1.0, 1.0, 0.0 }, Opacity = 1.0, File = speck .. "/6dF.speck", - Texture = textures .. "/point3.png", + Texture = textures .. "/point3A.png", ColorMap = speck .. "/6dF.cmap", ColorOption = { "redshift", "proximity" }, ColorRange = { { 0.0, 0.075 }, { 1.0, 10.0 } }, diff --git a/data/assets/scene/digitaluniverse/abell.asset b/data/assets/scene/digitaluniverse/abell.asset index 673f2f57ac..287eab6c52 100644 --- a/data/assets/scene/digitaluniverse/abell.asset +++ b/data/assets/scene/digitaluniverse/abell.asset @@ -6,7 +6,7 @@ local textures = asset.syncedResource({ Name = "Abell Textures", Type = "HttpSynchronization", Identifier = "digitaluniverse_abell_textures", - Version = 1 + Version = 2 }) local speck = asset.syncedResource({ @@ -25,7 +25,7 @@ local object = { Opacity = 1.0, --ColorMap = speck .. "/abell.cmap", File = speck .. "/abell.speck", - Texture = textures .. "/point3.png", + Texture = textures .. "/point3A.png", LabelFile = speck .. "/abell.label", TextColor = { 0.0, 0.8, 0.0, 1.0 }, TextSize = 22, diff --git a/data/assets/scene/digitaluniverse/quasars.asset b/data/assets/scene/digitaluniverse/quasars.asset index b24f034f7d..be9b11e59b 100644 --- a/data/assets/scene/digitaluniverse/quasars.asset +++ b/data/assets/scene/digitaluniverse/quasars.asset @@ -6,7 +6,7 @@ local textures = asset.syncedResource({ Name = "Quasars Textures", Type = "HttpSynchronization", Identifier = "digitaluniverse_quasars_textures", - Version = 1 + Version = 2 }) local speck = asset.syncedResource({ @@ -24,7 +24,7 @@ local object = { Color = { 1.0, 0.4, 0.2 }, Opacity = 0.95, File = speck .. "/quasars.speck", - Texture = textures .. "/point3.png", + Texture = textures .. "/point3A.png", Unit = "Mpc", ScaleFactor = 540.9, -- Fade in value in the same unit as "Unit" diff --git a/data/assets/scene/digitaluniverse/sdss.asset b/data/assets/scene/digitaluniverse/sdss.asset index 38563ed859..56d92df264 100644 --- a/data/assets/scene/digitaluniverse/sdss.asset +++ b/data/assets/scene/digitaluniverse/sdss.asset @@ -6,7 +6,7 @@ local textures = asset.syncedResource({ Name = "Sloan Digital Sky Survey Textures", Type = "HttpSynchronization", Identifier = "digitaluniverse_sloandss_textures", - Version = 1 + Version = 2 }) local speck = asset.syncedResource({ @@ -28,7 +28,7 @@ local object = { ColorMap = speck .. "/SDSSgals.cmap", ColorOption = { "redshift", "proximity" }, ColorRange = { { 0.0, 0.075 }, { 1.0, 50.0 } }, - Texture = textures .. "/point3.png", + Texture = textures .. "/point3A.png", Unit = "Mpc", -- Fade in value in the same unit as "Unit" FadeInDistances = { 220.0, 650.0 }, diff --git a/data/assets/scene/digitaluniverse/superclusters.asset b/data/assets/scene/digitaluniverse/superclusters.asset index d51868d921..5ce754caa7 100644 --- a/data/assets/scene/digitaluniverse/superclusters.asset +++ b/data/assets/scene/digitaluniverse/superclusters.asset @@ -6,7 +6,7 @@ local textures = asset.syncedResource({ Name = "Galaxy Superclusters Textures", Type = "HttpSynchronization", Identifier = "digitaluniverse_superclusters_textures", - Version = 1 + Version = 2 }) local speck = asset.syncedResource({ @@ -25,7 +25,7 @@ local object = { Color = { 1.0, 1.0, 1.0 }, Opacity = 0.65, File = speck .. "/superclust.speck", - Texture = textures .. "/point3.png", + Texture = textures .. "/point3A.png", LabelFile = speck .. "/superclust.label", TextColor = { 0.9, 0.9, 0.9, 1.0 }, ScaleFactor = 531.0, diff --git a/data/assets/scene/digitaluniverse/tully.asset b/data/assets/scene/digitaluniverse/tully.asset index 59d750c728..e8e515e22b 100644 --- a/data/assets/scene/digitaluniverse/tully.asset +++ b/data/assets/scene/digitaluniverse/tully.asset @@ -6,7 +6,7 @@ local textures = asset.syncedResource({ Name = "Tully Textures", Type = "HttpSynchronization", Identifier = "digitaluniverse_tully_textures", - Version = 2 + Version = 3 }) local speck = asset.syncedResource({ @@ -25,7 +25,7 @@ local tullyPoints = { Opacity = 0.99, ScaleFactor = 500.0, File = speck .. "/tully.speck", - Texture = textures .. "/point3.png", + Texture = textures .. "/point3A.png", --ColorMap = speck .. "/tully.cmap", ColorMap = speck .. "/lss.cmap", --ColorOption = { "proximity" }, diff --git a/data/assets/scene/milkyway/milkyway/volume.asset b/data/assets/scene/milkyway/milkyway/volume.asset index 0d1537d45e..2ae420e931 100644 --- a/data/assets/scene/milkyway/milkyway/volume.asset +++ b/data/assets/scene/milkyway/milkyway/volume.asset @@ -10,21 +10,32 @@ local data = asset.syncedResource({ Version = 1 }) +local kiloparsec = 3.086E19 + local MilkyWayVolumeGalaxy = { - Identifier = "Milky Way Volume", + Identifier = "MilkyWayVolume", Parent = transforms.SolarSystemBarycenter.Identifier, + Transform = { + Translation = { + Type = "StaticTranslation", + -- The center of the Milky Way is approximately 8 kiloparsec from the Sun. + -- The x-axis of galactic coordinates points from the sun towards the center + -- of the galaxy. + Position = { 8 * kiloparsec, 0, 0 } + } + }, Renderable = { Type = "RenderableGalaxy", StepSize = 0.01, AbsorptionMultiply = 200, EmissionMultiply = 250, - Translation = {0.2, 0, 0}, - Rotation = {3.1415926, 3.1248, 4.45741}, + Rotation = { 3.1415926, 3.1248, 4.45741 }, Volume = { Type = "Volume", Filename = data .. "/MilkyWayRGBAVolume1024x1024x128.raw", - Dimensions = {1024, 1024, 128}, - Size = {1.2E21, 1.2E21, 0.15E21} + Dimensions = { 1024, 1024, 128 }, + Size = { 1.2E21, 1.2E21, 0.15E21 }, + Downscale = 0.4, }, Points = { Type = "Points", @@ -34,9 +45,10 @@ local MilkyWayVolumeGalaxy = { } }, GUI = { - Path = "/Milky Way" + Path = "/Milky Way", + Name = "Milky Way Volume" } } local objects = { MilkyWayVolumeGalaxy } -assetHelper.registerSceneGraphNodesAndExport(asset, objects) \ No newline at end of file +assetHelper.registerSceneGraphNodesAndExport(asset, objects) diff --git a/data/assets/scene/solarsystem/dwarf_planets/pluto/charon.asset b/data/assets/scene/solarsystem/dwarf_planets/pluto/charon.asset index c9c58a820f..87139c2b9e 100644 --- a/data/assets/scene/solarsystem/dwarf_planets/pluto/charon.asset +++ b/data/assets/scene/solarsystem/dwarf_planets/pluto/charon.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local transforms = asset.require('./transforms') asset.require("spice/base") asset.request('./trail') -local labelsPath = asset.require('./pluto_labels').LabelsPath +local labelsPath = asset.require('./pluto_globelabels').LabelsPath diff --git a/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto.asset b/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto.asset index 8d2b891b4b..ce98ef30f8 100644 --- a/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto.asset +++ b/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local transforms = asset.require('./transforms') asset.require("spice/base") asset.request('./trail') -local labelsPath = asset.require('./pluto_labels').LabelsPath +local labelsPath = asset.require('./pluto_globelabels').LabelsPath @@ -59,6 +59,25 @@ local Pluto = { } } +local PlutoLabel = { + Identifier = "PlutoLabel", + Parent = Pluto.Identifier, + Renderable = { + Enabled = false, + Type = "RenderableLabels", + LabelText = "Pluto", + FontSize = 100.0, + LabelSize = 8.9, + LabelMaxSize = 100.0, + LabelMinSize = 1.0, + BlendMode = "Additive", + LabelOrientationOption = "Camera View Direction" + }, + Tag = { "solarsystem_labels" }, + GUI = { + Name = "Pluto Label", + Path = "/Solar System/Dwarf Planets/Pluto" + } +} - -assetHelper.registerSceneGraphNodesAndExport(asset, { Pluto }) +assetHelper.registerSceneGraphNodesAndExport(asset, { Pluto, PlutoLabel }) diff --git a/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto_labels.asset b/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto_globelabels.asset similarity index 100% rename from data/assets/scene/solarsystem/dwarf_planets/pluto/pluto_labels.asset rename to data/assets/scene/solarsystem/dwarf_planets/pluto/pluto_globelabels.asset diff --git a/data/assets/scene/solarsystem/interstellar/c-2019_q4_borisov.asset b/data/assets/scene/solarsystem/interstellar/c-2019_q4_borisov.asset new file mode 100644 index 0000000000..7d41e166ec --- /dev/null +++ b/data/assets/scene/solarsystem/interstellar/c-2019_q4_borisov.asset @@ -0,0 +1,46 @@ +local assetHelper = asset.require('util/asset_helper') +local sunTransforms = asset.require('scene/solarsystem/sun/transforms') + +local trajectory = asset.syncedResource({ + Name = "C-2019 Q4 Borisov Trajectory", + Type = "HttpSynchronization", + Identifier = "borisov_horizons", + Version = 1 +}) + +local C2019Q4BorisovTrail = { + Identifier = "C2019Q4BorisovTrail", + Parent = sunTransforms.SolarSystemBarycenter.Identifier, + Renderable = { + Type = "RenderableTrailTrajectory", + Translation = { + Type = "HorizonsTranslation", + HorizonsTextFile = trajectory .. "/horizons_c2019q4borisov.dat" + }, + Color = { 0.9, 0.9, 0.0 }, + StartTime = "2015 JAN 01 00:00:00", + EndTime = "2024 JAN 01 00:00:00", + SampleInterval = 60 + }, + GUI = { + Name = "C-2019 Q4 Borisov Trail", + Path = "/Solar System/Interstellar" + } +} + +local C2019Q4BorisovPosition = { + Identifier = "C2019Q4BorisovPosition", + Parent = sunTransforms.SolarSystemBarycenter.Identifier, + Transform = { + Translation = { + Type = "HorizonsTranslation", + HorizonsTextFile = trajectory .. "/horizons_c2019q4borisov.dat" + }, + }, + GUI = { + Name = "C-2019 Q4 Borisov", + Path = "/Solar System/Interstellar" + } +} + +assetHelper.registerSceneGraphNodesAndExport(asset, { C2019Q4BorisovPosition, C2019Q4BorisovTrail }) diff --git a/data/assets/scene/solarsystem/missions/apollo/apollo8.asset b/data/assets/scene/solarsystem/missions/apollo/apollo8.asset index 27e86fd80d..627d264bef 100644 --- a/data/assets/scene/solarsystem/missions/apollo/apollo8.asset +++ b/data/assets/scene/solarsystem/missions/apollo/apollo8.asset @@ -35,7 +35,7 @@ local Apollo8Launch = { Type = "SpiceTranslation", Target = apolloSpiceId, Observer = "EARTH", - Frame = "IAU_EARTH", + Frame = "IAU_EARTH", Kernels = kernels }, }, @@ -59,7 +59,7 @@ local Apollo8 = { Type = "SpiceTranslation", Target = apolloSpiceId, Observer = "EARTH BARYCENTER", - Frame = "GALACTIC", + Frame = "GALACTIC", Kernels = kernels }, Rotation = { @@ -124,7 +124,7 @@ local Apollo8Model = { } } -local PivotOffset = { 0, 2.5, 0} +local PivotOffset = { 0, 2.5, 0 } -- The pivot node is used for navigation inside the spacecraft @@ -153,7 +153,7 @@ local Apollo8LaunchTrail = { Type = "SpiceTranslation", Target = apolloSpiceId, Observer = "EARTH", - Frame = "IAU_EARTH", + Frame = "IAU_EARTH", Kernels = kernels }, Color = { 0.70, 0.50, 0.20 }, @@ -176,7 +176,7 @@ local Apollo8MoonTrail = { Type = "SpiceTranslation", Target = apolloSpiceId, Observer = "MOON", - Frame = "IAU_MOON", + Frame = "IAU_MOON", Kernels = kernels }, Color = { 0.70, 0.50, 0.20 }, @@ -199,15 +199,15 @@ local Apollo8EarthBarycenterTrail = { Translation = { Type = "SpiceTranslation", Target = apolloSpiceId, - Observer = "EARTH BARYCENTER", - Frame = "GALACTIC", + Observer = "EARTH", + Frame = "GALACTIC", Kernels = kernels }, - Color = { 1, 0.0, 0.0 }, + Color = { 0.8, 0.2, 0.2 }, StartTime = "1968 DEC 21", EndTime = "1968 DEC 28", SampleInterval = 30, - Enabled = false, + Enabled = true, }, GUI = { Name = "Apollo 8 Earth Barycenter Trail", @@ -215,10 +215,11 @@ local Apollo8EarthBarycenterTrail = { } } + local exportList = { - Apollo8, + Apollo8, Apollo8Model, - Apollo8Launch, + Apollo8Launch, Apollo8LaunchModel, Apollo8Pivot, diff --git a/data/assets/scene/solarsystem/missions/dawn/dawn.asset b/data/assets/scene/solarsystem/missions/dawn/dawn.asset index f630ad8b8f..e7fc3a3747 100644 --- a/data/assets/scene/solarsystem/missions/dawn/dawn.asset +++ b/data/assets/scene/solarsystem/missions/dawn/dawn.asset @@ -666,11 +666,17 @@ local Dawn = { local DawnSolarArray1 = { Identifier = "DawnSolar1", Parent = Dawn.Identifier, - Transformation = { + Transform = { + -- JCC: Spice rotations are commented because spice ck files + -- are not present. + -- Rotation = { + -- Type = "SpiceRotation", + -- SourceFrame = "DAWN_SA-Y", + -- DestinationFrame = "DAWN_SPACECRAFT" + -- } Rotation = { - Type = "SpiceRotation", - SourceFrame = "DAWN_SA-Y", - DestinationFrame = "DAWN_SPACECRAFT" + Type = "StaticRotation", + Rotation = {0.0, 4.71225, 0.0} } }, Renderable = { @@ -693,11 +699,15 @@ local DawnSolarArray1 = { local DawnSolarArray2 = { Identifier = "DawnSolar2", Parent = Dawn.Identifier, - Transformation = { + Transform = { + -- Rotation = { + -- Type = "SpiceRotation", + -- SourceFrame = "DAWN_SA+Y", + -- DestinationFrame = "DAWN_SPACECRAFT" + -- } Rotation = { - Type = "SpiceRotation", - SourceFrame = "DAWN_SA+Y", - DestinationFrame = "DAWN_SPACECRAFT" + Type = "StaticRotation", + Rotation = {3.1415, 1.57075, 0.0} } }, Renderable = { diff --git a/data/assets/scene/solarsystem/missions/dawn/dawn_kernels.asset b/data/assets/scene/solarsystem/missions/dawn/dawn_kernels.asset index 6ee7f55abc..bac98c64a6 100644 --- a/data/assets/scene/solarsystem/missions/dawn/dawn_kernels.asset +++ b/data/assets/scene/solarsystem/missions/dawn/dawn_kernels.asset @@ -2,7 +2,7 @@ local Kernels = asset.syncedResource({ Name = "Dawn Kernels", Type = "HttpSynchronization", Identifier = "dawn_kernels", - Version = 1 + Version = 2 }) asset.export("Kernels", Kernels) \ No newline at end of file diff --git a/data/assets/scene/solarsystem/missions/dawn/vesta.asset b/data/assets/scene/solarsystem/missions/dawn/vesta.asset index 64bfabfca8..75c1ed63f1 100644 --- a/data/assets/scene/solarsystem/missions/dawn/vesta.asset +++ b/data/assets/scene/solarsystem/missions/dawn/vesta.asset @@ -47,8 +47,9 @@ local Vesta = { Type = "RenderableModelProjection", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/VestaComet/VestaComet_5000.obj" + GeometryFile = models .. "/VestaComet_5000.obj" }, + BoundingSphereRadius = 10.0, ColorTexture = textures .. "/dummy.jpg", Projection = { Sequence = images, diff --git a/data/assets/scene/solarsystem/missions/messenger/mercurymagnetosphere.asset b/data/assets/scene/solarsystem/missions/messenger/mercurymagnetosphere.asset index 9a8713faf6..35dfbe7110 100644 --- a/data/assets/scene/solarsystem/missions/messenger/mercurymagnetosphere.asset +++ b/data/assets/scene/solarsystem/missions/messenger/mercurymagnetosphere.asset @@ -6,7 +6,7 @@ local localFolder = asset.syncedResource({ Name = "Mercury Magnetosphere", Type = "HttpSynchronization", Identifier = "mercury_magnetosphere", - Version = 1 + Version = 3 }) @@ -22,7 +22,7 @@ local Magnetosphere = { SourceDirectory = localFolder, TransferFunction = localFolder .. "/transferfunction.txt", Variable = "rho", - StepSize = "0.003", + StepSize = 0.003, Dimensions = {64, 64, 64}, GridType = "Cartesian", SecondsBefore = 24*60*60*365*100, diff --git a/data/assets/scene/solarsystem/missions/messenger/openspace_mercury.ti b/data/assets/scene/solarsystem/missions/messenger/openspace_mercury.ti deleted file mode 100644 index 218f8c3ec2..0000000000 --- a/data/assets/scene/solarsystem/missions/messenger/openspace_mercury.ti +++ /dev/null @@ -1,33 +0,0 @@ -OpenSpace ecliptic frames: -Mercury-centric Solar Ecliptic (MERCURYSE) frame - -These frames are only defined as helper frames for OpenSpace. - - +X is parallel to the geometric planet-sun position vector. - - -Y axis is the normalized component of the planet's orbital vector - - +Z axis is parallel to the cross product of the frame's +X axis - and the frame's +Y axis. - -\begindata - - FRAME_MERCURYSE = 4600199 - FRAME_4600199_NAME = 'MERCURYSE' - FRAME_4600199_CLASS = 5 - FRAME_4600199_CLASS_ID = 4600199 - FRAME_4600199_CENTER = 199 - FRAME_4600199_RELATIVE = 'J2000' - FRAME_4600199_DEF_STYLE = 'PARAMETERIZED' - FRAME_4600199_FAMILY = 'TWO-VECTOR' - FRAME_4600199_PRI_AXIS = 'X' - FRAME_4600199_PRI_VECTOR_DEF = 'OBSERVER_TARGET_POSITION' - FRAME_4600199_PRI_OBSERVER = 'MERCURY' - FRAME_4600199_PRI_TARGET = 'SUN' - FRAME_4600199_PRI_ABCORR = 'NONE' - FRAME_4600199_SEC_AXIS = 'Y' - FRAME_4600199_SEC_VECTOR_DEF = 'OBSERVER_TARGET_VELOCITY' - FRAME_4600199_SEC_OBSERVER = 'MERCURY' - FRAME_4600199_SEC_TARGET = 'SUN' - FRAME_4600199_SEC_ABCORR = 'NONE' - FRAME_4600199_SEC_FRAME = 'J2000' diff --git a/data/assets/scene/solarsystem/missions/messenger/transferfunction.txt b/data/assets/scene/solarsystem/missions/messenger/transferfunction.txt deleted file mode 100644 index 7174117a1e..0000000000 --- a/data/assets/scene/solarsystem/missions/messenger/transferfunction.txt +++ /dev/null @@ -1,8 +0,0 @@ -width 1024 -lower 0.0 -upper 0.1 -mappingkey 0.0 255 0 0 0 -mappingkey 0.01 255 0 0 0 -mappingkey 0.1 255 255 0 100 - -mappingkey 0.5 255 255 0 255 \ No newline at end of file diff --git a/data/assets/scene/solarsystem/missions/osirisrex/osirisrex.asset b/data/assets/scene/solarsystem/missions/osirisrex/osirisrex.asset index 1444106adc..ed12d60ba9 100644 --- a/data/assets/scene/solarsystem/missions/osirisrex/osirisrex.asset +++ b/data/assets/scene/solarsystem/missions/osirisrex/osirisrex.asset @@ -1,6 +1,7 @@ asset.request('./bennu') asset.request('./model') asset.request('./trail') +asset.request('scene/solarsystem/sun/marker') asset.require('./script_schedule') diff --git a/data/assets/scene/solarsystem/planets.asset b/data/assets/scene/solarsystem/planets.asset index 8603643031..a631b33339 100644 --- a/data/assets/scene/solarsystem/planets.asset +++ b/data/assets/scene/solarsystem/planets.asset @@ -1,6 +1,7 @@ asset.request('./planets/mercury/mercury') asset.request('./planets/venus/venus') +asset.request('./planets/venus/atmosphere') asset.request('./planets/earth/earth') asset.request('./planets/earth/atmosphere') diff --git a/data/assets/scene/solarsystem/planets/earth/earth.asset b/data/assets/scene/solarsystem/planets/earth/earth.asset index f934b499bd..7b26c55ecc 100644 --- a/data/assets/scene/solarsystem/planets/earth/earth.asset +++ b/data/assets/scene/solarsystem/planets/earth/earth.asset @@ -1,7 +1,7 @@ local transforms = asset.require('./transforms') local assetHelper = asset.require('util/asset_helper') local texturesPath = asset.require('./earth_textures').TexturesPath -local labelsPath = asset.require('./earth_labels').LabelsPath +local labelsPath = asset.require('./earth_globelabels').LabelsPath asset.request('./trail') @@ -91,7 +91,7 @@ local Earth = { Type = "TemporalTileLayer", FilePath = openspace.globebrowsing.createTemporalGibsGdalXml( "MODIS_Aqua_CorrectedReflectance_TrueColor", - "2012-05-08", + "2002-07-04", "Yesterday", "1d", "250m", @@ -104,7 +104,7 @@ local Earth = { Type = "TemporalTileLayer", FilePath = openspace.globebrowsing.createTemporalGibsGdalXml( "MODIS_Terra_CorrectedReflectance_TrueColor", - "2012-05-08", + "2000-02-24", "Yesterday", "1d", "250m", @@ -126,7 +126,7 @@ local Earth = { Name = "AMSR2 GCOM W1 Sea Ice Concentration (Temporal)", Type = "TemporalTileLayer", FilePath = openspace.globebrowsing.createTemporalGibsGdalXml( - "AMSR2_Sea_Ice_Concentration_12km", + "AMSRU2_Sea_Ice_Concentration_12km", "2012-05-08", "Yesterday", "1d", @@ -287,6 +287,45 @@ local Earth = { } } +local EarthLabel = { + Identifier = "EarthLabel", + Parent = Earth.Identifier, + -- Transform = { + -- Translation = { + -- Type = "SpiceTranslation", + -- Target = "EARTH", + -- Observer = "EARTH BARYCENTER" + -- }, + -- -- Rotation = { + -- -- Type = "SpiceRotation", + -- -- SourceFrame = "IAU_MOON", + -- -- DestinationFrame = "GALACTIC" + -- -- } + -- }, + Renderable = { + Enabled = false, + Type = "RenderableLabels", + LabelText = "Earth", + FontSize = 100.0, + LabelSize = 8.6, + LabelMaxSize = 100.0, + LabelMinSize = 1.0, + LabelOrientationOption = "Camera View Direction", + BlendMode = "Additive", + EnableFading = true, + FadeStartUnit = "au", + FadeStartDistance = 1.5, + FadeStartSpeed = 1.0, + FadeEndUnit = "au", + FadeEndDistance = 15.0, + FadeEndSpeed = 25.0 + }, + Tag = { "solarsystem_labels" }, + GUI = { + Name = "Earth Label", + Path = "/Solar System/Planets/Earth" + } +} -assetHelper.registerSceneGraphNodesAndExport(asset, { Earth }) +assetHelper.registerSceneGraphNodesAndExport(asset, { Earth, EarthLabel }) diff --git a/data/assets/scene/solarsystem/planets/earth/earth_labels.asset b/data/assets/scene/solarsystem/planets/earth/earth_globelabels.asset similarity index 100% rename from data/assets/scene/solarsystem/planets/earth/earth_labels.asset rename to data/assets/scene/solarsystem/planets/earth/earth_globelabels.asset diff --git a/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/LiU/Kaguya.vrt b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/LiU/Kaguya.vrt new file mode 100644 index 0000000000..e7ad44a020 --- /dev/null +++ b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/LiU/Kaguya.vrt @@ -0,0 +1,28 @@ + + GEOGCS["GCS_Moon_2000",DATUM["D_Moon_2000",SPHEROID["Moon_2000_IAU_IAG",1737400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + -1.8000000000000000e+02, 2.4414062500000000e-04, 0.0000000000000000e+00, 9.0000000000000000e+01, 0.0000000000000000e+00, -2.4414062500000000e-04 + + Gray + + Kaguya.wms + 1 + + + + + + + Alpha + 0 + + Kaguya.wms + 1 + + + + 255 + 0 + 0 + + + diff --git a/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/Kaguya.vrt b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/Kaguya.vrt new file mode 100644 index 0000000000..e7ad44a020 --- /dev/null +++ b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/Kaguya.vrt @@ -0,0 +1,28 @@ + + GEOGCS["GCS_Moon_2000",DATUM["D_Moon_2000",SPHEROID["Moon_2000_IAU_IAG",1737400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + -1.8000000000000000e+02, 2.4414062500000000e-04, 0.0000000000000000e+00, 9.0000000000000000e+01, 0.0000000000000000e+00, -2.4414062500000000e-04 + + Gray + + Kaguya.wms + 1 + + + + + + + Alpha + 0 + + Kaguya.wms + 1 + + + + 255 + 0 + 0 + + + diff --git a/data/assets/scene/solarsystem/planets/earth/moon/moon.asset b/data/assets/scene/solarsystem/planets/earth/moon/moon.asset index 0b76a74a74..851e8d135c 100644 --- a/data/assets/scene/solarsystem/planets/earth/moon/moon.asset +++ b/data/assets/scene/solarsystem/planets/earth/moon/moon.asset @@ -36,33 +36,39 @@ local Moon = { Name = "WAC [Utah]", FilePath = mapServiceConfigs .. "/Utah/Wac.wms", Enabled = true, - Settings = { Multiplier = 2.0 } + Settings = { Gamma = 0.84 } }, { Identifier = "WAC_Sweden", Name = "WAC [Sweden]", FilePath = mapServiceConfigs .. "/LiU/WAC.wms", - Settings = { Multiplier = 2.0 } + Settings = { Gamma = 0.84 } }, { Identifier = "ClemUvvis_Utah", Name = "Clem Uvvis [Utah]", FilePath = mapServiceConfigs .. "/Utah/ClemUvvis.wms", - Settings = { Multiplier = 2.0 } + Settings = { + Gamma = 1.14, + Multiplier = 1.4 + } }, { Identifier = "ClemUvvis_Sweden", Name = "Clem Uvvis [Sweden]", FilePath = mapServiceConfigs .. "/LiU/Clem_Uvvis.wms", - Settings = { Multiplier = 2.0 } + Settings = { + Gamma = 1.14, + Multiplier = 1.4 + } }, { Identifier = "UvvisHybrid_Utah", Name = "Uvvis Hybrid [Utah]", FilePath = mapServiceConfigs .. "/Utah/UvvisHybrid.wms", Settings = { - Gamma = 0.75, - Multiplier = 1.5 + Gamma = 0.52, + Multiplier = 0.65 } }, { @@ -70,26 +76,26 @@ local Moon = { Name = "Uvvis Hybrid [Sweden]", FilePath = mapServiceConfigs .. "/LiU/Uvvis_Hybrid.wms", Settings = { - Gamma = 0.75, - Multiplier = 1.5 + Gamma = 0.52, + Multiplier = 0.65 } }, { Identifier = "Kaguya_Utah", Name = "Kaguya [Utah]", - FilePath = mapServiceConfigs .. "/Utah/Kaguya.wms", + FilePath = mapServiceConfigs .. "/Utah/Kaguya.vrt", Settings = { - Gamma = 1.12, - Multiplier = 2.7 + Gamma = 1.0, + Multiplier = 1.23 } }, { Identifier = "Kaguya_Sweden", Name = "Kaguya [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Kaguya.wms", + FilePath = mapServiceConfigs .. "/LiU/Kaguya.vrt", Settings = { - Gamma = 1.12, - Multiplier = 2.7 + Gamma = 1.0, + Multiplier = 1.23 } }, { diff --git a/data/assets/scene/solarsystem/planets/earth/moon/trail.asset b/data/assets/scene/solarsystem/planets/earth/moon/trail.asset index fe707fff53..bd96ce84ac 100644 --- a/data/assets/scene/solarsystem/planets/earth/moon/trail.asset +++ b/data/assets/scene/solarsystem/planets/earth/moon/trail.asset @@ -16,7 +16,8 @@ local MoonTrail = { }, Color = { 0.5, 0.3, 0.3 }, Period = 27, - Resolution = 1000 + Resolution = 1000, + Tag = { "moonTrail_solarSystem", "moonTrail_terrestrial", "moonTrail_earth" } }, GUI = { Name = "Moon Trail", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/communications/amateur.asset b/data/assets/scene/solarsystem/planets/earth/satellites/communications/amateur.asset index 253a9f1fdb..93056ec693 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/communications/amateur.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/communications/amateur.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Amateur Radio", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/communications/experimental.asset b/data/assets/scene/solarsystem/planets/earth/satellites/communications/experimental.asset index 7a673b695f..62ddde179b 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/communications/experimental.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/communications/experimental.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Experimental", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/communications/geostationary.asset b/data/assets/scene/solarsystem/planets/earth/satellites/communications/geostationary.asset index 711030e482..5a2b92bbeb 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/communications/geostationary.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/communications/geostationary.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Geostationary", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/communications/globalstar.asset b/data/assets/scene/solarsystem/planets/earth/satellites/communications/globalstar.asset index 32e8edd57d..187da196dc 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/communications/globalstar.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/communications/globalstar.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "GlobalStar", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/communications/gorizont.asset b/data/assets/scene/solarsystem/planets/earth/satellites/communications/gorizont.asset index 10390bba26..968c7a0d52 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/communications/gorizont.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/communications/gorizont.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Gorizont", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/communications/intelsat.asset b/data/assets/scene/solarsystem/planets/earth/satellites/communications/intelsat.asset index a41a34b97d..6c63a7a152 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/communications/intelsat.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/communications/intelsat.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Intelsat", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/communications/iridium.asset b/data/assets/scene/solarsystem/planets/earth/satellites/communications/iridium.asset index bddcc0de0f..9aef4acfa4 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/communications/iridium.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/communications/iridium.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Iridium", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/communications/iridium_next.asset b/data/assets/scene/solarsystem/planets/earth/satellites/communications/iridium_next.asset index 4a515ac51d..0acefd60bb 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/communications/iridium_next.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/communications/iridium_next.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Iridium NEXT", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/communications/molniya.asset b/data/assets/scene/solarsystem/planets/earth/satellites/communications/molniya.asset index 6fb30c28e5..faa5e257cd 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/communications/molniya.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/communications/molniya.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Molniya", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/communications/orbcomm.asset b/data/assets/scene/solarsystem/planets/earth/satellites/communications/orbcomm.asset index 2014a48a2c..46a00682df 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/communications/orbcomm.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/communications/orbcomm.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Orbcomm", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/communications/other_comm.asset b/data/assets/scene/solarsystem/planets/earth/satellites/communications/other_comm.asset index fd0cac7602..a389e514db 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/communications/other_comm.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/communications/other_comm.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Other comm", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/communications/raduga.asset b/data/assets/scene/solarsystem/planets/earth/satellites/communications/raduga.asset index 66c24c8450..61b2511d13 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/communications/raduga.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/communications/raduga.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Raduga", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/communications/ses.asset b/data/assets/scene/solarsystem/planets/earth/satellites/communications/ses.asset index 1866a4a62c..5589bc9f2d 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/communications/ses.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/communications/ses.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "SES", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_asat.asset b/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_asat.asset index c9deee3dc4..0335bc5466 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_asat.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_asat.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../debris_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Indian ASAT test Debris", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_breezem.asset b/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_breezem.asset index d92af9ac09..ca65fa548c 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_breezem.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_breezem.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../debris_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Breeze-M Breakup", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_fengyun.asset b/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_fengyun.asset index df75b229e5..f6ac4c803a 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_fengyun.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_fengyun.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../debris_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Fengyun Debris", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_iridium33.asset b/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_iridium33.asset index 61939fe7b5..4d4ee16f8a 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_iridium33.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_iridium33.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../debris_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Iridium 33 Debris", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_kosmos2251.asset b/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_kosmos2251.asset index b332289cb8..6d84fd8247 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_kosmos2251.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/debris/debris_kosmos2251.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../debris_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Kosmos 2251 Debris", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/debris_shared.asset b/data/assets/scene/solarsystem/planets/earth/satellites/debris_shared.asset deleted file mode 100644 index 1c122b72d5..0000000000 --- a/data/assets/scene/solarsystem/planets/earth/satellites/debris_shared.asset +++ /dev/null @@ -1,74 +0,0 @@ -local transforms = asset.require('scene/solarsystem/planets/earth/transforms') -local assetHelper = asset.require('util/asset_helper') - -local satImageFolder = asset.syncedResource({ - Name = "Satellite Image Files", - Type = "HttpSynchronization", - Identifier = "tle_satellites_images", - Version = 1 -}) - -function downloadTLEFile(sceneAsset, url, name) - local identifier = name - identifier = identifier:gsub(" ", "") - identifier = identifier:gsub("&", "") - identifier = identifier:gsub("-", "") - return sceneAsset.syncedResource({ - Name = "Satellite TLE Data (" .. name .. ")", - Type = "UrlSynchronization", - Identifier = "satellite_tle_data_" .. identifier, - Url = url - }) -end - -local registerSatelliteGroupObjects = function(containingAsset, group, tleFolder, shouldAddDuplicates) - local filename = group.Url:match("([^/]+)$") - local filenameSansExt = filename:gsub(filename:match("(%.%w+)$"), "") - - local path = tleFolder .. "/" .. filename - - function numLinesInFile(filename) - local ctr = 0 - for _ in io.lines(filename) do ctr = ctr + 1 end - return ctr - end - - -- Check format of a set of 3 TLE file lines and return nonzero if there is a format error - function isValidTLEFileFormat(lineArr) - function isEmpty(s) return s == nil or s == '' end - - if isEmpty(lineArr[1]) or isEmpty(lineArr[2]) or isEmpty(lineArr[3]) then - return false - end - if string.sub(lineArr[2], 1, 2) ~= "1 " then - return false - end - if string.sub(lineArr[3], 1, 2) ~= "2 " then - return false - end - return true - end - - function debris(title, file, color) - return { - Identifier = title, - Parent = transforms.EarthInertial.Identifier, - Renderable = { - Type = "RenderableSatellites", - Path = file, - Segments = 160, - Color = color, - Fade = 0.5 - }, - GUI = { - Path = "/Solar System/Planets/Earth/Satellites" - } - } - end - - local Debris = debris(filenameSansExt, path, group.TrailColor) - assetHelper.registerSceneGraphNodesAndExport(containingAsset, { Debris }) -end - -asset.export("downloadTLEFile", downloadTLEFile) -asset.export("registerSatelliteGroupObjects", registerSatelliteGroupObjects) diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/misc/brightest.asset b/data/assets/scene/solarsystem/planets/earth/satellites/misc/brightest.asset index d34a2b705c..6a74e9e875 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/misc/brightest.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/misc/brightest.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "100 Brightest", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/misc/cubesats.asset b/data/assets/scene/solarsystem/planets/earth/satellites/misc/cubesats.asset index afa9e7c501..b53e0fa281 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/misc/cubesats.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/misc/cubesats.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "CubeSat", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset b/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset new file mode 100644 index 0000000000..4f36cfc683 --- /dev/null +++ b/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset @@ -0,0 +1,119 @@ +local assetHelper = asset.require('util/asset_helper') +local satelliteHelper = asset.require('util/tle_helper') +local transforms = asset.require('scene/solarsystem/planets/earth/transforms') +local sunTransforms = asset.require('scene/solarsystem/sun/transforms') + +local url = "https://celestrak.com/satcat/tle.php?CATNR=25544" +local identifier = "ISS" +local filename = "ISS.txt" +local nodes = {} +local tle = satelliteHelper.downloadTLEFile(asset, url, identifier, filename) + +local modelsLocation = asset.syncedResource({ + Name = "ISS Models", + Type = "HttpSynchronization", + Identifier = "iss_model", + Version = 1 +}) + +local initializeAndAddNodes = function() + + local lineElement = satelliteHelper.makeSingleLineElement(tle, filename) + local period = satelliteHelper.getPeriodFromElement(lineElement) + local path = tle .. "/" .. filename + +-- TLE data is only relevant in EarthInertial frame which means the model +-- will inherit some irrelevant rotations from its parent. To get around that +-- we perform the reverse rotation back to EarthBarycenter frame after applying +-- the TLE translation + local iss = { + Identifier = identifier, + Parent = transforms.EarthInertial.Identifier, + Transform = { + Translation = { + Type = "TLETranslation", + Body = identifier, + Observer = transforms.EarthInertial.Identifier, + File = path, + LineNumber = 1 + }, + Rotation = { + Type = "SpiceRotation", + SourceFrame = "GALACTIC", + DestinationFrame = "J2000", + } + }, + Tag = { "earth_satellite", "ISS" }, + GUI = { + Path = "/Solar System/Planets/Earth/Satellites/ISS", + Hiden = true + } + } + + local issModel = { + Identifier = identifier .. "_model", + Parent = iss.Identifier, + Transform = { + Rotation = { + Type = "FixedRotation", + Attached = "ISS_model", + XAxis = { 1.0, 0.0, 0.0 }, + XAxisOrthogonal = true, + ZAxis = transforms.EarthInertial.Identifier + } + }, + Renderable = { + Type = "RenderableModel", + Geometry = { + Type = "MultiModelGeometry", + GeometryFile = modelsLocation .. "/iss.obj" + }, + ColorTexture = modelsLocation .. "/gray.png", + LightSources = assetHelper.getDefaultLightSources(sunTransforms.SolarSystemBarycenter.Identifier) + }, + Tag = { "earth_satellite", "ISS" }, + GUI = { + Path = "/Solar System/Planets/Earth/Satellites/ISS" + } + } + + local issTrail = { + Identifier = identifier .. "_trail", + Parent = transforms.EarthInertial.Identifier, + Renderable = { + Type = "RenderableTrailOrbit", + Translation = { + Type = "TLETranslation", + Body = identifier, + Observer = transforms.EarthInertial.Identifier, + File = path, + LineNumber = 1 + }, + Color = { 0.9, 0.6715, 0.0 }, + Fade = 1.5, + Period = period, + Resolution = 320 + }, + Tag = { "earth_satellite", "ISS" }, + GUI = { + Path = "/Solar System/Planets/Earth/Satellites/ISS" + } + } + + local myNodes = { iss, issModel, issTrail } + + for _, node in ipairs(myNodes) do + openspace.addSceneGraphNode(node) + end + + return myNodes +end + +asset.onInitialize(function () + nodes = initializeAndAddNodes() +end) + +asset.onDeinitialize(function () + openspace.removeSceneGraphNode(nodes[3].Identifier) -- Removing trail + openspace.removeSceneGraphNode(nodes[1].Identifier) -- Removing ISS and model recursively +end) diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/misc/military.asset b/data/assets/scene/solarsystem/planets/earth/satellites/misc/military.asset index 9a254fb16f..eba2695caa 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/misc/military.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/misc/military.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Military", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/misc/other.asset b/data/assets/scene/solarsystem/planets/earth/satellites/misc/other.asset index ef76cbd65e..a389e6510d 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/misc/other.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/misc/other.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Other", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/misc/radar.asset b/data/assets/scene/solarsystem/planets/earth/satellites/misc/radar.asset index 1ddffbac4f..64204ffd3f 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/misc/radar.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/misc/radar.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Radar Calibration", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/misc/spacestations.asset b/data/assets/scene/solarsystem/planets/earth/satellites/misc/spacestations.asset index b98789cb94..f9f974a730 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/misc/spacestations.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/misc/spacestations.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "SpaceStations", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/misc/tle-new.asset b/data/assets/scene/solarsystem/planets/earth/satellites/misc/tle-new.asset index d496ba5cba..506dd7bb48 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/misc/tle-new.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/misc/tle-new.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Last 30 Days", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/navigation/beidou.asset b/data/assets/scene/solarsystem/planets/earth/satellites/navigation/beidou.asset index b07f53283f..47fe0930be 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/navigation/beidou.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/navigation/beidou.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Beidou", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/navigation/galileo.asset b/data/assets/scene/solarsystem/planets/earth/satellites/navigation/galileo.asset index 6db045c232..f3c2d976f3 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/navigation/galileo.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/navigation/galileo.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Galileo", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/navigation/glosnass.asset b/data/assets/scene/solarsystem/planets/earth/satellites/navigation/glosnass.asset index 5e10daa3cf..b0223450c3 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/navigation/glosnass.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/navigation/glosnass.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Glosnass", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/navigation/gps.asset b/data/assets/scene/solarsystem/planets/earth/satellites/navigation/gps.asset index 8859ecce9f..e08e162862 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/navigation/gps.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/navigation/gps.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "GPS", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/navigation/musson.asset b/data/assets/scene/solarsystem/planets/earth/satellites/navigation/musson.asset index 9d267227a4..efccb05950 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/navigation/musson.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/navigation/musson.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Russian LEO Navigation", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/navigation/nnss.asset b/data/assets/scene/solarsystem/planets/earth/satellites/navigation/nnss.asset index 56478a1dd0..3be4a576ec 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/navigation/nnss.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/navigation/nnss.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Navy Navigation Satellite System", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/navigation/sbas.asset b/data/assets/scene/solarsystem/planets/earth/satellites/navigation/sbas.asset index 2c0356abad..58458638c4 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/navigation/sbas.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/navigation/sbas.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Satellite Based Augmentation System", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_interesting.asset b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_interesting.asset index 230ded9c65..7d257cfc8b 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_interesting.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_interesting.asset @@ -2,4 +2,5 @@ asset.request('./misc/brightest') asset.request('./communications/geostationary') asset.request('./navigation/gps') asset.request('./misc/spacestations') +asset.request('./misc/iss') asset.request('./misc/tle-new') diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_shared.asset b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_shared.asset deleted file mode 100644 index 58b3e35ec4..0000000000 --- a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_shared.asset +++ /dev/null @@ -1,75 +0,0 @@ -local transforms = asset.require('scene/solarsystem/planets/earth/transforms') -local assetHelper = asset.require('util/asset_helper') - -local satImageFolder = asset.syncedResource({ - Name = "Satellite Image Files", - Type = "HttpSynchronization", - Identifier = "tle_satellites_images", - Version = 1 -}) - -function downloadTLEFile(sceneAsset, url, name) - local identifier = name - identifier = identifier:gsub(" ", "") - identifier = identifier:gsub("&", "") - identifier = identifier:gsub("-", "") - return sceneAsset.syncedResource({ - Name = "Satellite TLE Data (" .. name .. ")", - Type = "UrlSynchronization", - Identifier = "satellite_tle_data_" .. identifier, - Url = url - }) -end - -local registerSatelliteGroupObjects = function(containingAsset, group, tleFolder, shouldAddDuplicates) - local filename = group.Url:match("([^/]+)$") - local filenameSansExt = filename:gsub(filename:match("(%.%w+)$"), "") - - local path = tleFolder .. "/" .. filename - - function numLinesInFile(filename) - local ctr = 0 - for _ in io.lines(filename) do ctr = ctr + 1 end - return ctr - end - - -- Check format of a set of 3 TLE file lines and return nonzero if there is a format error - function isValidTLEFileFormat(lineArr) - function isEmpty(s) return s == nil or s == '' end - - if isEmpty(lineArr[1]) or isEmpty(lineArr[2]) or isEmpty(lineArr[3]) then - return false - end - if string.sub(lineArr[2], 1, 2) ~= "1 " then - return false - end - if string.sub(lineArr[3], 1, 2) ~= "2 " then - return false - end - return true - end - - function satellites(title, file, color) - return { - Identifier = title, - Parent = transforms.EarthInertial.Identifier, - Renderable = { - Type = "RenderableSatellites", - Path = file, - Segments = 160, - Color = color, - Fade = 0.5 - }, - --Tag = { "earth_satellite_" .. group, "earth_satellite_" .. group .. "_trail"}, - GUI = { - Path = "/Solar System/Planets/Earth/Satellites" - } - } - end - - local SatelliteBatch = satellites(filenameSansExt, path, group.TrailColor) - assetHelper.registerSceneGraphNodesAndExport(containingAsset, { SatelliteBatch }) -end - -asset.export("downloadTLEFile", downloadTLEFile) -asset.export("registerSatelliteGroupObjects", registerSatelliteGroupObjects) diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/science/education.asset b/data/assets/scene/solarsystem/planets/earth/satellites/science/education.asset index c9ff14f021..d7a42c5fde 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/science/education.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/science/education.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Education", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/science/engineering.asset b/data/assets/scene/solarsystem/planets/earth/satellites/science/engineering.asset index ef74f84ffe..faa6febc16 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/science/engineering.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/science/engineering.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Engineering", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/science/geodetic.asset b/data/assets/scene/solarsystem/planets/earth/satellites/science/geodetic.asset index 982072359e..d2613c699e 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/science/geodetic.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/science/geodetic.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Geodect", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/science/spaceearth.asset b/data/assets/scene/solarsystem/planets/earth/satellites/science/spaceearth.asset index 2d459040b4..e6d3513857 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/science/spaceearth.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/science/spaceearth.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Space & Earth Science", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/weather/argos.asset b/data/assets/scene/solarsystem/planets/earth/satellites/weather/argos.asset index c898dd241b..75d572299e 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/weather/argos.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/weather/argos.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "ARGOS", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/weather/dmc.asset b/data/assets/scene/solarsystem/planets/earth/satellites/weather/dmc.asset index 52b6bd7c97..eb95d7e6e1 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/weather/dmc.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/weather/dmc.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Disaster Monitoring", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/weather/earth_resources.asset b/data/assets/scene/solarsystem/planets/earth/satellites/weather/earth_resources.asset index 5da0f4fd4d..e3ad206277 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/weather/earth_resources.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/weather/earth_resources.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Earth Resources", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/weather/goes.asset b/data/assets/scene/solarsystem/planets/earth/satellites/weather/goes.asset index 9c4728de10..55a2584643 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/weather/goes.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/weather/goes.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "GOES", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/weather/noaa.asset b/data/assets/scene/solarsystem/planets/earth/satellites/weather/noaa.asset index 5c6c5a476b..85c7f97798 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/weather/noaa.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/weather/noaa.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "NOAA", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/weather/planet.asset b/data/assets/scene/solarsystem/planets/earth/satellites/weather/planet.asset index 7c242aed52..bb5f00625b 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/weather/planet.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/weather/planet.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Planet", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/weather/sarsat.asset b/data/assets/scene/solarsystem/planets/earth/satellites/weather/sarsat.asset index ce54caa190..64ef4004e5 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/weather/sarsat.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/weather/sarsat.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Search & Rescue (SARSAT)", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/weather/spire.asset b/data/assets/scene/solarsystem/planets/earth/satellites/weather/spire.asset index 8ee080b890..92c25df702 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/weather/spire.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/weather/spire.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Spire", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/weather/tdrss.asset b/data/assets/scene/solarsystem/planets/earth/satellites/weather/tdrss.asset index e26b31acc5..0ec30cab29 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/weather/tdrss.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/weather/tdrss.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Tracking and Data Relay Satellite System (TDRSS)", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/weather/weather.asset b/data/assets/scene/solarsystem/planets/earth/satellites/weather/weather.asset index a867a5ecfb..c23e0910b6 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/weather/weather.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/weather/weather.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local shared = asset.require('../satellites_shared') +local shared = asset.require('util/tle_helper') local group = { Title = "Weather", diff --git a/data/assets/scene/solarsystem/planets/jupiter/callisto/callisto.asset b/data/assets/scene/solarsystem/planets/jupiter/callisto/callisto.asset index 1a31062cd1..d0b2496e52 100644 --- a/data/assets/scene/solarsystem/planets/jupiter/callisto/callisto.asset +++ b/data/assets/scene/solarsystem/planets/jupiter/callisto/callisto.asset @@ -3,7 +3,7 @@ local assetHelper = asset.require('util/asset_helper') asset.require("spice/base") asset.request('./trail') local kernel = asset.require('../kernels').jup310 -local labelsPath = asset.require('../jupiter_labels').LabelsPath +local labelsPath = asset.require('../jupiter_globelabels').LabelsPath diff --git a/data/assets/scene/solarsystem/planets/jupiter/europa/europa.asset b/data/assets/scene/solarsystem/planets/jupiter/europa/europa.asset index 9ee299ebf6..d5e455bb9f 100644 --- a/data/assets/scene/solarsystem/planets/jupiter/europa/europa.asset +++ b/data/assets/scene/solarsystem/planets/jupiter/europa/europa.asset @@ -3,7 +3,7 @@ local assetHelper = asset.require('util/asset_helper') asset.require("spice/base") asset.request('./trail') local kernel = asset.require('../kernels').jup310 -local labelsPath = asset.require('../jupiter_labels').LabelsPath +local labelsPath = asset.require('../jupiter_globelabels').LabelsPath local map_service_configs = asset.localResource("map_service_configs") diff --git a/data/assets/scene/solarsystem/planets/jupiter/ganymede/ganymede.asset b/data/assets/scene/solarsystem/planets/jupiter/ganymede/ganymede.asset index 510484cebf..513136ef98 100644 --- a/data/assets/scene/solarsystem/planets/jupiter/ganymede/ganymede.asset +++ b/data/assets/scene/solarsystem/planets/jupiter/ganymede/ganymede.asset @@ -3,7 +3,7 @@ local assetHelper = asset.require('util/asset_helper') asset.require("spice/base") asset.request('./trail') local kernel = asset.require('../kernels').jup310 -local labelsPath = asset.require('../jupiter_labels').LabelsPath +local labelsPath = asset.require('../jupiter_globelabels').LabelsPath diff --git a/data/assets/scene/solarsystem/planets/jupiter/io/io.asset b/data/assets/scene/solarsystem/planets/jupiter/io/io.asset index ca10670c06..fb10f0b3a8 100644 --- a/data/assets/scene/solarsystem/planets/jupiter/io/io.asset +++ b/data/assets/scene/solarsystem/planets/jupiter/io/io.asset @@ -3,7 +3,7 @@ local assetHelper = asset.require('util/asset_helper') asset.require("spice/base") asset.request('./trail') local kernel = asset.require('../kernels').jup310 -local labelsPath = asset.require('../jupiter_labels').LabelsPath +local labelsPath = asset.require('../jupiter_globelabels').LabelsPath diff --git a/data/assets/scene/solarsystem/planets/jupiter/jupiter.asset b/data/assets/scene/solarsystem/planets/jupiter/jupiter.asset index 9333c339c1..071a9cad9f 100644 --- a/data/assets/scene/solarsystem/planets/jupiter/jupiter.asset +++ b/data/assets/scene/solarsystem/planets/jupiter/jupiter.asset @@ -42,6 +42,25 @@ local Jupiter = { } } +local JupiterLabel = { + Identifier = "JupiterLabel", + Parent = Jupiter.Identifier, + Renderable = { + Enabled = false, + Type = "RenderableLabels", + LabelText = "Jupiter", + FontSize = 100.0, + LabelSize = 8.6, + LabelMaxSize = 100.0, + LabelMinSize = 1.0, + LabelOrientationOption = "Camera View Direction", + BlendMode = "Additive" + }, + Tag = { "solarsystem_labels" }, + GUI = { + Name = "Jupiter Label", + Path = "/Solar System/Planets/Jupiter" + } +} - -assetHelper.registerSceneGraphNodesAndExport(asset, { Jupiter }) +assetHelper.registerSceneGraphNodesAndExport(asset, { Jupiter, JupiterLabel }) diff --git a/data/assets/scene/solarsystem/planets/jupiter/jupiter_labels.asset b/data/assets/scene/solarsystem/planets/jupiter/jupiter_globelabels.asset similarity index 100% rename from data/assets/scene/solarsystem/planets/jupiter/jupiter_labels.asset rename to data/assets/scene/solarsystem/planets/jupiter/jupiter_globelabels.asset diff --git a/data/assets/scene/solarsystem/planets/mars/mars.asset b/data/assets/scene/solarsystem/planets/mars/mars.asset index 57ee23d861..bd330c8c01 100644 --- a/data/assets/scene/solarsystem/planets/mars/mars.asset +++ b/data/assets/scene/solarsystem/planets/mars/mars.asset @@ -2,7 +2,7 @@ local transforms = asset.require('./transforms') local assetHelper = asset.require('util/asset_helper') asset.require("spice/base") asset.request('./trail') -local labelsPath = asset.require('./mars_labels').LabelsPath +local labelsPath = asset.require('./mars_globelabels').LabelsPath @@ -29,6 +29,10 @@ local color_layers = { Name = "Mars Texture", FilePath = textures .. "/mars.jpg", Enabled = true + }, + Settings = { + Gamma = 1.6, + Multiplier = 1.07 } }, { @@ -40,6 +44,10 @@ local color_layers = { Name = "Mars Texture", FilePath = textures .. "/mars.jpg", Enabled = true + }, + Settings = { + Gamma = 1.6, + Multiplier = 1.07 } }, { @@ -107,6 +115,16 @@ local color_layers = { Name = "CTX Mosaic [Sweden]", FilePath = mapServiceConfigs .. "/LiU/CTX.wms", BlendMode = "Color" + }, + { + Identifier = "CTX_belended_01", + Name = "CTX Belended beta01", + FilePath = mapServiceConfigs .. "/ESRI/CTX/CTXblended.vrt", + BlendMode = "Color", + Settings = { + Gamma = 2.14, + Multiplier = 1.54 + } } } @@ -187,4 +205,31 @@ local Mars = { } } -assetHelper.registerSceneGraphNodesAndExport(asset, { Mars }) +local MarsLabel = { + Identifier = "MarsLabel", + Parent = Mars.Identifier, + Renderable = { + Enabled = false, + Type = "RenderableLabels", + LabelText = "Mars", + FontSize = 100.0, + LabelSize = 8.5, + LabelMaxSize = 100.0, + LabelMinSize = 1.0, + LabelOrientationOption = "Camera View Direction", + BlendMode = "Additive", + TransformationMatrix = { + 1.0, 0.0, 0.0, -8.0E6, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 1.0E7, + 0.0, 0.0, 0.0, 1.0 + }, + }, + Tag = { "solarsystem_labels" }, + GUI = { + Name = "Mars Label", + Path = "/Solar System/Planets/Mars" + } +} + +assetHelper.registerSceneGraphNodesAndExport(asset, { Mars, MarsLabel }) diff --git a/data/assets/scene/solarsystem/planets/mars/mars_labels.asset b/data/assets/scene/solarsystem/planets/mars/mars_globelabels.asset similarity index 100% rename from data/assets/scene/solarsystem/planets/mars/mars_labels.asset rename to data/assets/scene/solarsystem/planets/mars/mars_globelabels.asset diff --git a/data/assets/scene/solarsystem/planets/mercury/mercury.asset b/data/assets/scene/solarsystem/planets/mercury/mercury.asset index d2bcf7c591..8eda6c5eb9 100644 --- a/data/assets/scene/solarsystem/planets/mercury/mercury.asset +++ b/data/assets/scene/solarsystem/planets/mercury/mercury.asset @@ -1,6 +1,6 @@ local assetHelper = asset.require('util/asset_helper') local transforms = asset.require('./transforms') -local labelsPath = asset.require('./mercury_labels').LabelsPath +local labelsPath = asset.require('./mercury_globelabels').LabelsPath asset.require("spice/base") @@ -223,5 +223,25 @@ local Mercury = { } } +local MercuryLabel = { + Identifier = "MercuryLabel", + Parent = Mercury.Identifier, + Renderable = { + Enabled = false, + Type = "RenderableLabels", + LabelText = "Mercury", + FontSize = 100.0, + LabelSize = 8.3, + LabelMaxSize = 100.0, + LabelMinSize = 1.0, + LabelOrientationOption = "Camera View Direction", + BlendMode = "Additive" + }, + Tag = { "solarsystem_labels" }, + GUI = { + Name = "Mercury Label", + Path = "/Solar System/Planets/Mercury" + } +} -assetHelper.registerSceneGraphNodesAndExport(asset, { Mercury }) +assetHelper.registerSceneGraphNodesAndExport(asset, { Mercury, MercuryLabel }) diff --git a/data/assets/scene/solarsystem/planets/mercury/mercury_labels.asset b/data/assets/scene/solarsystem/planets/mercury/mercury_globelabels.asset similarity index 100% rename from data/assets/scene/solarsystem/planets/mercury/mercury_labels.asset rename to data/assets/scene/solarsystem/planets/mercury/mercury_globelabels.asset diff --git a/data/assets/scene/solarsystem/planets/neptune/neptune.asset b/data/assets/scene/solarsystem/planets/neptune/neptune.asset index 677395e8e5..326b2ef6c0 100644 --- a/data/assets/scene/solarsystem/planets/neptune/neptune.asset +++ b/data/assets/scene/solarsystem/planets/neptune/neptune.asset @@ -40,4 +40,25 @@ local Neptune = { } } -assetHelper.registerSceneGraphNodesAndExport(asset, { Neptune }) +local NeptuneLabel = { + Identifier = "NeptuneLabel", + Parent = Neptune.Identifier, + Renderable = { + Enabled = false, + Type = "RenderableLabels", + LabelText = "Neptune", + FontSize = 100.0, + LabelSize = 8.8, + LabelMaxSize = 100.0, + LabelMinSize = 1.0, + LabelOrientationOption = "Camera View Direction", + BlendMode = "Additive" + }, + Tag = { "solarsystem_labels" }, + GUI = { + Name = "Neptune Label", + Path = "/Solar System/Planets/Neptune" + } +} + +assetHelper.registerSceneGraphNodesAndExport(asset, { Neptune, NeptuneLabel }) diff --git a/data/assets/scene/solarsystem/planets/saturn/dione/dione.asset b/data/assets/scene/solarsystem/planets/saturn/dione/dione.asset index 7cdd49b5cd..ded4b6ae73 100644 --- a/data/assets/scene/solarsystem/planets/saturn/dione/dione.asset +++ b/data/assets/scene/solarsystem/planets/saturn/dione/dione.asset @@ -2,7 +2,7 @@ local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') local kernel = asset.require('../kernels').sat375 asset.request('./trail') -local labelsPath = asset.require('../saturn_labels').LabelsPath +local labelsPath = asset.require('../saturn_globelabels').LabelsPath diff --git a/data/assets/scene/solarsystem/planets/saturn/enceladus/enceladus.asset b/data/assets/scene/solarsystem/planets/saturn/enceladus/enceladus.asset index 5fa01501ba..8a66735198 100644 --- a/data/assets/scene/solarsystem/planets/saturn/enceladus/enceladus.asset +++ b/data/assets/scene/solarsystem/planets/saturn/enceladus/enceladus.asset @@ -2,7 +2,7 @@ local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') local kernel = asset.require('../kernels').sat375 asset.request('./trail') -local labelsPath = asset.require('../saturn_labels').LabelsPath +local labelsPath = asset.require('../saturn_globelabels').LabelsPath diff --git a/data/assets/scene/solarsystem/planets/saturn/iapetus/iapetus.asset b/data/assets/scene/solarsystem/planets/saturn/iapetus/iapetus.asset index bab9c45056..892cc2c13e 100644 --- a/data/assets/scene/solarsystem/planets/saturn/iapetus/iapetus.asset +++ b/data/assets/scene/solarsystem/planets/saturn/iapetus/iapetus.asset @@ -2,7 +2,7 @@ local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') local kernel = asset.require('../kernels').sat375 asset.request('./trail') -local labelsPath = asset.require('../saturn_labels').LabelsPath +local labelsPath = asset.require('../saturn_globelabels').LabelsPath diff --git a/data/assets/scene/solarsystem/planets/saturn/mimas/mimas.asset b/data/assets/scene/solarsystem/planets/saturn/mimas/mimas.asset index 4dbedaad48..53d9b7da21 100644 --- a/data/assets/scene/solarsystem/planets/saturn/mimas/mimas.asset +++ b/data/assets/scene/solarsystem/planets/saturn/mimas/mimas.asset @@ -2,7 +2,7 @@ local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') local kernel = asset.require('../kernels').sat375 asset.request('./trail') -local labelsPath = asset.require('../saturn_labels').LabelsPath +local labelsPath = asset.require('../saturn_globelabels').LabelsPath diff --git a/data/assets/scene/solarsystem/planets/saturn/rhea/rhea.asset b/data/assets/scene/solarsystem/planets/saturn/rhea/rhea.asset index 0ab5688544..008663ecf5 100644 --- a/data/assets/scene/solarsystem/planets/saturn/rhea/rhea.asset +++ b/data/assets/scene/solarsystem/planets/saturn/rhea/rhea.asset @@ -2,7 +2,7 @@ local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') local kernel = asset.require('../kernels').sat375 asset.request('./trail') -local labelsPath = asset.require('../saturn_labels').LabelsPath +local labelsPath = asset.require('../saturn_globelabels').LabelsPath diff --git a/data/assets/scene/solarsystem/planets/saturn/saturn.asset b/data/assets/scene/solarsystem/planets/saturn/saturn.asset index 77b45972f2..aeef8db352 100644 --- a/data/assets/scene/solarsystem/planets/saturn/saturn.asset +++ b/data/assets/scene/solarsystem/planets/saturn/saturn.asset @@ -34,7 +34,16 @@ local Saturn = { Enabled = true } } - } + }, + Rings = { + Texture = textures .. "/saturn_rings.png", + Size = 140445000, + Offset = { 74500 / 140445.100671159, 1.0 }, -- min / max extend + }, + Shadows = { + Enabled = true, + DistanceFraction = 40.0 + } }, Tag = { "planet_solarSystem", "planet_giants" }, GUI = { @@ -42,21 +51,25 @@ local Saturn = { } } -local SaturnRings = { - Identifier = "SaturnRings", +local SaturnLabel = { + Identifier = "SaturnLabel", Parent = Saturn.Identifier, Renderable = { - Type = "RenderableRings", - Texture = textures .. "/saturn_rings.png", - Size = 140445000, - Offset = { 74500 / 140445.100671159, 1.0 } -- min / max extend + Enabled = false, + Type = "RenderableLabels", + LabelText = "Saturn", + FontSize = 100.0, + LabelSize = 8.7, + LabelMaxSize = 100.0, + LabelMinSize = 1.0, + BlendMode = "Additive", + LabelOrientationOption = "Camera View Direction" }, + Tag = { "solarsystem_labels" }, GUI = { - Name = "Saturn Rings", + Name = "Saturn Label", Path = "/Solar System/Planets/Saturn" } } - - -assetHelper.registerSceneGraphNodesAndExport(asset, { Saturn, SaturnRings }) +assetHelper.registerSceneGraphNodesAndExport(asset, { Saturn, SaturnLabel }) diff --git a/data/assets/scene/solarsystem/planets/saturn/saturn_labels.asset b/data/assets/scene/solarsystem/planets/saturn/saturn_globelabels.asset similarity index 100% rename from data/assets/scene/solarsystem/planets/saturn/saturn_labels.asset rename to data/assets/scene/solarsystem/planets/saturn/saturn_globelabels.asset diff --git a/data/assets/scene/solarsystem/planets/saturn/tethys/tethys.asset b/data/assets/scene/solarsystem/planets/saturn/tethys/tethys.asset index 1979cf4d66..fea8618180 100644 --- a/data/assets/scene/solarsystem/planets/saturn/tethys/tethys.asset +++ b/data/assets/scene/solarsystem/planets/saturn/tethys/tethys.asset @@ -2,7 +2,7 @@ local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') local kernel = asset.require('../kernels').sat375 asset.request('./trail') -local labelsPath = asset.require('../saturn_labels').LabelsPath +local labelsPath = asset.require('../saturn_globelabels').LabelsPath diff --git a/data/assets/scene/solarsystem/planets/saturn/titan/titan.asset b/data/assets/scene/solarsystem/planets/saturn/titan/titan.asset index 0145308ed4..a086c9eecb 100644 --- a/data/assets/scene/solarsystem/planets/saturn/titan/titan.asset +++ b/data/assets/scene/solarsystem/planets/saturn/titan/titan.asset @@ -2,7 +2,7 @@ local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') local kernel = asset.require('../kernels').sat375 asset.request('./trail') -local labelsPath = asset.require('../saturn_labels').LabelsPath +local labelsPath = asset.require('../saturn_globelabels').LabelsPath local map_service_configs = asset.localResource("map_service_configs") diff --git a/data/assets/scene/solarsystem/planets/uranus/uranus.asset b/data/assets/scene/solarsystem/planets/uranus/uranus.asset index 1bb29fa184..db3fb11848 100644 --- a/data/assets/scene/solarsystem/planets/uranus/uranus.asset +++ b/data/assets/scene/solarsystem/planets/uranus/uranus.asset @@ -42,6 +42,25 @@ local Uranus = { } } +local UranusLabel = { + Identifier = "UranusLabel", + Parent = Uranus.Identifier, + Renderable = { + Enabled = false, + Type = "RenderableLabels", + LabelText = "Uranus", + FontSize = 100.0, + LabelSize = 8.7, + LabelMaxSize = 100.0, + LabelMinSize = 1.0, + LabelOrientationOption = "Camera View Direction", + BlendMode = "Additive" + }, + Tag = { "solarsystem_labels" }, + GUI = { + Name = "Neptune Label", + Path = "/Solar System/Planets/Uranus" + } +} - -assetHelper.registerSceneGraphNodesAndExport(asset, { Uranus }) +assetHelper.registerSceneGraphNodesAndExport(asset, { Uranus, UranusLabel }) diff --git a/data/assets/scene/solarsystem/planets/venus/atmosphere.asset b/data/assets/scene/solarsystem/planets/venus/atmosphere.asset new file mode 100644 index 0000000000..a89828ffbc --- /dev/null +++ b/data/assets/scene/solarsystem/planets/venus/atmosphere.asset @@ -0,0 +1,66 @@ +local transforms = asset.require('./venus') +local assetHelper = asset.require('util/asset_helper') + + + +local Atmosphere = { + Identifier = "VenusAtmosphere", + Parent = transforms.Venus.Identifier, + Renderable = { + Type = "RenderableAtmosphere", + Atmosphere = { + -- Atmosphere radius in Km + AtmosphereRadius = 6121.9, + PlanetRadius = 6051.9, + PlanetAverageGroundReflectance = 0.018, + GroundRadianceEmittion = 0.8, + SunIntensity = 11.47, + --MieScatteringExtinctionPropCoefficient = 0.23862, + Rayleigh = { + Coefficients = { + -- Wavelengths are given in 10^-9m + Wavelengths = { 680, 550, 440 }, + -- Reflection coefficients are given in km^-1 + Scattering = { 19.518E-3, 13.83E-3, 3.65E-3 } + -- In Rayleigh scattering, the coefficients of + -- absorption and scattering are the same. + }, + -- Thichkness of atmosphere if its density were uniform, in Km + H_R = 3.53 + }, + -- Default + Mie = { + Coefficients = { + -- Reflection coefficients are given in km^-1 + Scattering = { 53.61771e-3, 53.61771e-3, 53.61771e-3 }, + -- Extinction coefficients are a fraction of the Scattering coefficients + Extinction = { 53.61771e-3/0.98979, 53.61771e-3/0.98979, 53.61771e-3/0.98979 } + }, + -- Mie Height scale (atmosphere thickness for constant density) in Km + H_M = 5.42, + -- Mie Phase Function Value (G e [-1.0, 1.0]. + -- If G = 1.0, Mie phase function = Rayleigh Phase Function) + G = 0.85 + }, + Image = { + ToneMapping = jToneMapping, + Exposure = 0.4, + Background = 1.8, + Gamma = 1.85 + }, + Debug = { + -- PreCalculatedTextureScale is a float from 1.0 to N, with N > 0.0 and N in Naturals (i.e., 1, 2, 3, 4, 5....) + PreCalculatedTextureScale = 1.0, + SaveCalculatedTextures = false + } + } + }, + GUI = { + Name = "Venus Atmosphere", + Path = "/Solar System/Planets/Venus" + } +} + + + +assetHelper.registerSceneGraphNodesAndExport(asset, { Atmosphere }) diff --git a/data/assets/scene/solarsystem/planets/venus/map_service_configs/Utah/MagellanDEM.wms b/data/assets/scene/solarsystem/planets/venus/map_service_configs/Utah/MagellanDEM.wms new file mode 100644 index 0000000000..c8072a6e30 --- /dev/null +++ b/data/assets/scene/solarsystem/planets/venus/map_service_configs/Utah/MagellanDEM.wms @@ -0,0 +1,21 @@ + + + http://openspace.sci.utah.edu/Venus/MagellanDEM/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 8192 + 4096 + 4 + top + + GEOGCS["GCS_Venus",DATUM["D_Venus",SPHEROID["Venus",6051000,0]],PRIMEM["Reference_Meridian",0],UNIT["Degree",0.0174532925199433]] + 256 + 256 + 1 + 10 + 5 + diff --git a/data/assets/scene/solarsystem/planets/venus/map_service_configs/Utah/MagellanMosaic.vrt b/data/assets/scene/solarsystem/planets/venus/map_service_configs/Utah/MagellanMosaic.vrt new file mode 100644 index 0000000000..7eb41cc198 --- /dev/null +++ b/data/assets/scene/solarsystem/planets/venus/map_service_configs/Utah/MagellanMosaic.vrt @@ -0,0 +1,28 @@ + + GEOGCS["GCS_Venus",DATUM["D_Venus",SPHEROID["Venus_localRadius",6051000,0]],PRIMEM["Reference_Meridian",0],UNIT["Degree",0.0174532925199433]] + -1.8000000000000000e+02, 7.1016002272512077e-04, 0.0000000000000000e+00, 9.0000000000000000e+01, 0.0000000000000000e+00, -7.1011656303583486e-04 + + Gray + + MagellanMosaic.wms + 1 + + + + + + + Alpha + 0 + + MagellanMosaic.wms + 1 + + + + 255 + 0 + 0 + + + diff --git a/data/assets/scene/solarsystem/planets/venus/map_service_configs/Utah/MagellanMosaic.wms b/data/assets/scene/solarsystem/planets/venus/map_service_configs/Utah/MagellanMosaic.wms new file mode 100644 index 0000000000..084e231ea4 --- /dev/null +++ b/data/assets/scene/solarsystem/planets/venus/map_service_configs/Utah/MagellanMosaic.wms @@ -0,0 +1,21 @@ + + + http://openspace.sci.utah.edu/Venus/MagellanMosaic/tile/${z}/${y}/${x} + + + -180.0 + 84.0 + 180.0 + -80.0 + 506928 + 230948 + 9 + top + + GEOGCS["GCS_Venus",DATUM["D_Venus",SPHEROID["Venus_localRadius",6051000,0]],PRIMEM["Reference_Meridian",0],UNIT["Degree",0.0174532925199433]] + 512 + 512 + 1 + 10 + 5 + diff --git a/data/assets/scene/solarsystem/planets/venus/venus.asset b/data/assets/scene/solarsystem/planets/venus/venus.asset index 0b7617dad2..486f2d2cab 100644 --- a/data/assets/scene/solarsystem/planets/venus/venus.asset +++ b/data/assets/scene/solarsystem/planets/venus/venus.asset @@ -2,9 +2,9 @@ local assetHelper = asset.require('util/asset_helper') local transforms = asset.require('./transforms') asset.require("spice/base") asset.request('./trail') -local labelsPath = asset.require('./venus_labels').LabelsPath - +local labelsPath = asset.require('./venus_globelabels').LabelsPath +local mapServiceConfigs = asset.localResource("map_service_configs") local textures = asset.syncedResource({ Name = "Venus Textures", @@ -13,6 +13,42 @@ local textures = asset.syncedResource({ Version = 1 }) +local color_layers = { + { + Identifier = "Texture", + FilePath = textures .. "/venus.jpg", + Enabled = true, + Settings = { + Opacity = 0.48, + Gamma = 0.48 + } + }, + { + Identifier = "Magellan_Mosaic_Utah", + Name = "Magellan Mosaic [Utah]", + FilePath = mapServiceConfigs .. "/Utah/MagellanMosaic.vrt", + BlendMode = "Color", + Settings = { + Gamma = 2.0 + }, + Enabled = true + }, +} + +local height_layers = { + { + Identifier = "Magellan", + Name = "Magellan Elevation [Utah]", + FilePath = mapServiceConfigs .. "/Utah/MagellanDEM.wms", + TilePixelSize = 64, + Settings = { + Gamma = 1.72, + Multiplier = 1.1 + }, + Enabled = true + } +} + local Venus = { Identifier = "Venus", Parent = transforms.VenusBarycenter.Identifier, @@ -30,16 +66,12 @@ local Venus = { }, Renderable = { Type = "RenderableGlobe", - Radii = { 6051900.0, 6051900.0, 6051800.0 }, + --Radii = { 6051900.0, 6051900.0, 6051800.0 }, + Radii = { 6051900.0, 6051900.0, 6051900.0 }, SegmentsPerPatch = 64, Layers = { - ColorLayers = { - { - Identifier = "Texture", - FilePath = textures .. "/venus.jpg", - Enabled = true - } - } + ColorLayers = color_layers, + HeightLayers = height_layers }, Labels = { Enable = false, @@ -64,6 +96,26 @@ local Venus = { } } +local VenusLabel = { + Identifier = "VenusLabel", + Parent = Venus.Identifier, + Renderable = { + Enabled = false, + Type = "RenderableLabels", + LabelText = "Venus", + FontSize = 100.0, + LabelSize = 8.4, + LabelMaxSize = 100.0, + LabelMinSize = 1.0, + LabelOrientationOption = "Camera View Direction", + BlendMode = "Additive" + }, + Tag = { "solarsystem_labels" }, + GUI = { + Name = "Venus Label", + Path = "/Solar System/Planets/Venus" + } +} -assetHelper.registerSceneGraphNodesAndExport(asset, { Venus }) +assetHelper.registerSceneGraphNodesAndExport(asset, { Venus, VenusLabel }) diff --git a/data/assets/scene/solarsystem/planets/venus/venus_labels.asset b/data/assets/scene/solarsystem/planets/venus/venus_globelabels.asset similarity index 100% rename from data/assets/scene/solarsystem/planets/venus/venus_labels.asset rename to data/assets/scene/solarsystem/planets/venus/venus_globelabels.asset diff --git a/data/assets/scene/solarsystem/sssb/pha.asset b/data/assets/scene/solarsystem/sssb/pha.asset new file mode 100644 index 0000000000..5ba2b2e4eb --- /dev/null +++ b/data/assets/scene/solarsystem/sssb/pha.asset @@ -0,0 +1,8 @@ +local assetHelper = asset.require('util/asset_helper') +local sharedSssb = asset.require('./sssb_shared') + +local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'pha', 'sssb_data_pha') +local object = sharedSssb.createSssbGroupObject("sssb_data_pha.csv", filepath, { 0.75, 0.2, 0.2 }) +object.Renderable.Enabled = false + +assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/sssb_shared.asset b/data/assets/scene/solarsystem/sssb/sssb_shared.asset new file mode 100644 index 0000000000..d67679baff --- /dev/null +++ b/data/assets/scene/solarsystem/sssb/sssb_shared.asset @@ -0,0 +1,39 @@ +local transforms = asset.require('scene/solarsystem/sun/transforms') + +function downloadSssbDatabaseFile(sceneAsset, name, identifier) + assert(sceneAsset, "'asset' needs to be provided") + assert(name, "'name' needs to be provided") + assert(identifier, "'identifier'needs to be provided") + + return sceneAsset.syncedResource({ + Name = "Small SolarSystem Body Data (" .. name .. ")", + Type = "HttpSynchronization", + Identifier = identifier, + Version = 1 + }) +end + +local createSssbGroupObject = function(filename, sssbFolder, trailColor) + assert(filename, "'filename' needs to be provided") + assert(sssbFolder, "'sssbFolder' needs to be provided") + trailColor = trailColor or { 0.75, 0.1, 0.1 } + + local filenameSansExt = filename:gsub(filename:match("(%.%w+)$"), "") + return { + Identifier = 'sssb_'..filenameSansExt, + Parent = transforms.SunECLIPJ2000.Identifier, + Renderable = { + Type = "RenderableSmallBody", + Path = sssbFolder.."/"..filename, + Segments = 200, + Color = trailColor, + Fade = 0.5, + }, + GUI = { + Path = "/Solar System/Small Solar System Body" + } + } +end + +asset.export("downloadSssbDatabaseFile", downloadSssbDatabaseFile) +asset.export("createSssbGroupObject", createSssbGroupObject) diff --git a/data/assets/scene/solarsystem/sun/sun.asset b/data/assets/scene/solarsystem/sun/sun.asset index f3e9495232..a4d5abb9d1 100644 --- a/data/assets/scene/solarsystem/sun/sun.asset +++ b/data/assets/scene/solarsystem/sun/sun.asset @@ -27,5 +27,32 @@ local Sun = { } } -assetHelper.registerSceneGraphNodesAndExport(asset, { Sun }) +local SunLabel = { + Identifier = "SunLabel", + Parent = Sun.Identifier, + Renderable = { + Enabled = false, + Type = "RenderableLabels", + LabelText = "Sun", + FontSize = 100.0, + LabelSize = 13.127, + LabelMaxSize = 100.0, + LabelMinSize = 1.0, + LabelOrientationOption = "Camera View Direction", + BlendMode = "Additive", + EnableFading = true, + FadeStartUnit = "Pm", + FadeStartDistance = 2.841, + FadeStartSpeed = 1.375, + FadeEndUnit = "pc", + FadeEndDistance = 1.326, + FadeEndSpeed = 1.0 + }, + Tag = { "solarsystem_labels" }, + GUI = { + Name = "Sun Label", + Path = "/Solar System/Sun" + } +} +assetHelper.registerSceneGraphNodesAndExport(asset, { Sun, SunLabel }) diff --git a/data/assets/scene/solarsystem/sun/transforms.asset b/data/assets/scene/solarsystem/sun/transforms.asset index b80dc222b9..ea76c08add 100644 --- a/data/assets/scene/solarsystem/sun/transforms.asset +++ b/data/assets/scene/solarsystem/sun/transforms.asset @@ -42,6 +42,26 @@ local SunIAU = { } } +local SunECLIPJ2000 = { + Identifier = "SunECLIPJ2000", + Parent = SolarSystemBarycenter.Identifier, + Transform = { + Translation = { + Type = "SpiceTranslation", + Target = "SUN", + Observer = "SSB" + }, + Rotation = { + Type = "SpiceRotation", + SourceFrame = "ECLIPJ2000", + DestinationFrame = "GALACTIC" + } + }, + GUI = { + Name = "SUN J2000", + Path = "/Solar System/Sun", + Hidden = true + } +} - -assetHelper.registerSceneGraphNodesAndExport(asset, { SolarSystemBarycenter, SunIAU }) +assetHelper.registerSceneGraphNodesAndExport(asset, { SolarSystemBarycenter, SunIAU, SunECLIPJ2000 }) diff --git a/data/assets/touch.profile b/data/assets/touch.profile new file mode 100644 index 0000000000..237a1c79b5 --- /dev/null +++ b/data/assets/touch.profile @@ -0,0 +1,25 @@ +#Version +1.0 + +#Module +Touch local webGui = asset.require('util/webgui'); webGui.setCefRoute("ontouch") openspace.printFatal('Could not load scene due to missing module "touch"') + +#Asset +scene/solarsystem/planets/earth/earth required +util/webgui required + +#Property +setPropertyValueSingle Scene.Pluto.Renderable.Enabled false +setPropertyValueSingle Scene.Charon.Renderable.Enabled false +setPropertyValueSingle Scene.PlutoBarycenterTrail.Renderable.Enabled false + +#Time +relative -1d + +#Camera +setNavigationState "Earth" 58.5877,16.1924,20000000 + +#MarkNodes +Earth +Mars +Moon diff --git a/data/assets/util/default_keybindings.asset b/data/assets/util/default_keybindings.asset index 1022144d37..cd8559d306 100644 --- a/data/assets/util/default_keybindings.asset +++ b/data/assets/util/default_keybindings.asset @@ -20,16 +20,16 @@ local Keybindings = { { Key = "PRINT_SCREEN", Name = "Take Screenshot", - Command = "openspace.setPropertyValueSingle('RenderEngine.TakeScreenshot', nil)", - Documentation = "Saves the contents of the screen to a file in the working directory.", + Command = "openspace.takeScreenshot()", + Documentation = "Saves the contents of the screen to a file in the ${SCREENSHOTS} directory.", GuiPath = "/Rendering", Local = true }, { Key = "F12", Name = "Take Screenshot", - Command = "openspace.setPropertyValueSingle('RenderEngine.TakeScreenshot', nil)", - Documentation = "Saves the contents of the screen to a file in the working directory.", + Command = "openspace.takeScreenshot()", + Documentation = "Saves the contents of the screen to a file in the ${SCREENSHOTS} directory.", GuiPath = "/Rendering", Local = true }, diff --git a/data/assets/util/generate_bookmarks.asset b/data/assets/util/generate_bookmarks.asset new file mode 100644 index 0000000000..c312b0cfee --- /dev/null +++ b/data/assets/util/generate_bookmarks.asset @@ -0,0 +1,80 @@ +local assetHelper = asset.require('util/asset_helper') + +local getBookmarks = function (guiPath, bookmarkfile) + local genBookmarks = {}; + local notFirstLine = false; + local PARSEC_CONSTANT = 3.0856776E16; + for line in io.lines(openspace.absPath(bookmarkfile)) do + if (notFirstLine) then + local matchstring = '(.-),(.-),(.-),(.-),(.-),(.-),(.-),(.-),(.-),(.-),(.-)$' + local group, name, globe, lat, lon, altitude, x, y, z, scale, linewidth = line:match(matchstring) + + scale = (scale == '' and 75000 or scale) + linewidth = (linewidth == '' and 2.0 or tonumber(linewidth)) + group = (group == '' and globe or group) + + local parent = (globe == '' and 'Root' or globe) + + local sgn = { + Identifier = guiPath .. '-' .. name, + Parent = parent, + Transform = { + Scale = { + Type = 'StaticScale', + Scale = tonumber(scale); + } + }, + Renderable = { + Type = 'RenderableSphericalGrid', + Enabled = false, + GridColor = { 0.3, 0.84, 1.0, 0.3}, + LineWidth = linewidth, + GridMatrix = { -0.05487554, 0.4941095, -0.8676661 , 0.0, + -0.9938214 , -0.1109906, -0.0003515167, 0.0, + -0.09647644, 0.8622859, 0.4971472 , 0.0, + 0.0 , 0.0 , 0.0 , 1.0 } + }, + GUI = { + Name = name, + Path = '/' .. guiPath + } + } + + if (group ~= '') then + sgn.GUI.Path = sgn.GUI.Path .. '/' .. group + end + + if (globe == '') then + sgn.Transform.Translation = { + Type = 'StaticTranslation', + Position = { + tonumber(x) * PARSEC_CONSTANT, + tonumber(y) * PARSEC_CONSTANT, + tonumber(z) * PARSEC_CONSTANT + } + } + else + sgn.Transform.Translation = { + Type = 'GlobeTranslation', + Globe = globe, + Latitude = tonumber(lat), + Longitude = tonumber(lon) + } + if (altitude == nil) then + sgn.Transform.Translation.UseHeightMap = true; + else + sgn.Transform.Translation.UseHeightMap = false; + sgn.Transform.Translation.Altitude = tonumber(altitude); + end + end + + table.insert(genBookmarks, sgn); + else + notFirstLine = true + end + end + return genBookmarks +end + +asset.export('getBookmarks', getBookmarks) + diff --git a/data/assets/util/screenshots_endpoint.asset b/data/assets/util/screenshots_endpoint.asset new file mode 100644 index 0000000000..712b0a5a8b --- /dev/null +++ b/data/assets/util/screenshots_endpoint.asset @@ -0,0 +1,21 @@ +asset.onInitialize(function () + -- Disable the server, add production gui endpoint, and restart server. + -- The temporary disabling avoids restarting the server on each property change. + -- TODO: Add a trigger property to the module to restart the server "manually" + -- and remove automatic restart on each property change, + -- since frequent restarting seems to be unstable on mac. + + local enabled = openspace.getPropertyValue("Modules.WebGui.ServerProcessEnabled") + openspace.setPropertyValueSingle("Modules.WebGui.ServerProcessEnabled", false) + + local directories = openspace.getPropertyValue("Modules.WebGui.Directories") + directories[#directories + 1] = "screenshots" + directories[#directories + 1] = "${SCREENSHOTS}" + openspace.setPropertyValueSingle("Modules.WebGui.Directories", directories) + openspace.setPropertyValueSingle("Modules.WebGui.ServerProcessEnabled", enabled) +end) + +asset.onDeinitialize(function () + -- TODO: Remove endpoints. As of 2019-10-29, OpenSpace sometimes + -- crashes when endpoints are removed while the application is closing. +end) \ No newline at end of file diff --git a/data/assets/util/testing_keybindings.asset b/data/assets/util/testing_keybindings.asset index 8565b3c1cf..e902f34c37 100644 --- a/data/assets/util/testing_keybindings.asset +++ b/data/assets/util/testing_keybindings.asset @@ -7,8 +7,8 @@ local Keybindings = { { Key = "F7", Name = "Take Screenshot", - Command = "openspace.setPropertyValueSingle('RenderEngine.TakeScreenshot', nil)", - Documentation = "Saves the contents of the screen to a file in the working directory.", + Command = "openspace.takeScreenshot()", + Documentation = "Saves the contents of the screen to a file in the ${SCREENSHOTS} directory.", GuiPath = "/Rendering", Local = true } diff --git a/data/assets/util/tle_helper.asset b/data/assets/util/tle_helper.asset new file mode 100644 index 0000000000..92293479c3 --- /dev/null +++ b/data/assets/util/tle_helper.asset @@ -0,0 +1,110 @@ +local transforms = asset.require('scene/solarsystem/planets/earth/transforms') +local assetHelper = asset.require('util/asset_helper') + +function downloadTLEFile(sceneAsset, url, name, filename) + local identifier = name + identifier = identifier:gsub(" ", "") + identifier = identifier:gsub("&", "") + identifier = identifier:gsub("-", "") + + local urlSyncTable = { + Name = "Satellite TLE Data (" .. name .. ")", + Type = "UrlSynchronization", + Identifier = "satellite_tle_data_" .. identifier, + Url = url + } + + if (filename ~= '') then + urlSyncTable.Filename = filename + end + + return sceneAsset.syncedResource(urlSyncTable) +end + +-- Check format of a set of 3 TLE file lines and return nonzero if there is a format error +function isValidTLEFileFormat(lineArr) + function isEmpty(s) return s == nil or s == '' end + + if isEmpty(lineArr[1]) or isEmpty(lineArr[2]) or isEmpty(lineArr[3]) then + return false + end + if string.sub(lineArr[2], 1, 2) ~= "1 " then + return false + end + if string.sub(lineArr[3], 1, 2) ~= "2 " then + return false + end + return true +end + +local makeSingleLineElement = function(tle, filename) + local path = tle .. "/" .. filename + local file = io.open(path, "r") + assert(file, "File not found: " .. path) + + local line = { + file:read('*l'), --title line + file:read('*l'), + file:read('*l') + } + + assert(isValidTLEFileFormat(line), "TLE file syntax error on line " .. 1 .. ": " .. path) + + -- Trim string + line[1] = line[1]:gsub("^%s*(.-)%s*$", "%1") + line[1] = line[1]:gsub("%s+", "_") + line[1] = line[1]:gsub("[%-()]", "") + --local title = line[1] + + return line +end + +function numLinesInFile(filename) + local ctr = 0 + for _ in io.lines(filename) do ctr = ctr + 1 end + return ctr +end + +local getPeriodFromElement = function(element) + -- Get period from correct location of the string + local per = tonumber(string.sub(element[3], 53, 63)) + -- Trail for 2x a single revolution + per = 1.0 / per + + return per +end + +function satellites(title, file, color, group) + return { + Identifier = title, + Parent = transforms.EarthInertial.Identifier, + Renderable = { + Type = "RenderableSatellites", + Path = file, + Segments = 120, + Color = color, + Fade = 1.5 + }, + Tag = { "earth_satellites" }, + GUI = { + Path = "/Solar System/Planets/Earth/Satellites" + } + } +end + +local registerSatelliteGroupObjects = function(containingAsset, group, tleFolder, shouldAddDuplicates) + local filename = group.Url:match("([^/]+)$") + local filenameSansExt = filename:gsub(filename:match("(%.%w+)$"), "") + + local path = tleFolder .. "/" .. filename + + local SatelliteBatch = satellites(filenameSansExt, path, group.TrailColor, group) + assetHelper.registerSceneGraphNodesAndExport(containingAsset, { SatelliteBatch }) +end + +asset.export("downloadTLEFile", downloadTLEFile) +asset.export("isValidTLEFileFormat", isValidTLEFileFormat) +asset.export("numLinesInFile", numLinesInFile) +asset.export("makeSingleLineElement", makeSingleLineElement) +asset.export("getPeriodFromElement", getPeriodFromElement) +asset.export("registerSatelliteGroupObjects", registerSatelliteGroupObjects) diff --git a/data/assets/util/webgui.asset b/data/assets/util/webgui.asset index 5a052ed12b..13baac61cb 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 = "785d6fe3416b2e30bed0a04313ef61b0e2729645" +local frontendHash = "c2d8ff7419b82a614b6cdc02fbe391e0862279de" local dataProvider = "data.openspaceproject.com/files/webgui" local frontend = asset.syncedResource({ diff --git a/data/assets/voyager.profile b/data/assets/voyager.profile new file mode 100644 index 0000000000..150344f1e1 --- /dev/null +++ b/data/assets/voyager.profile @@ -0,0 +1,54 @@ +#Version +1.0 + +#Asset +scene/solarsystem/planets/jupiter/minor_moons required +scene/solarsystem/planets/saturn/minor_moons required +scene/solarsystem/planets/uranus/minor_moons required +scene/solarsystem/planets/neptune/inner_moons required +scene/solarsystem/planets/neptune/irregular_prograde_moons required +scene/solarsystem/planets/neptune/irregular_retrograde_moons required +scene/solarsystem/missions/voyager/voyager1 required +scene/solarsystem/missions/voyager/voyager2 required + +#Keybinding +1 Setting the simulation speed to 1 seconds per realtime second Set sim speed 1 /Simulation Speed false "openspace.time.interpolateDeltaTime(1)" +2 Setting the simulation speed to 5 seconds per realtime second Set sim speed 5 /Simulation Speed false "openspace.time.interpolateDeltaTime(5)" +3 Setting the simulation speed to 10 seconds per realtime second Set sim speed 10 /Simulation Speed false "openspace.time.interpolateDeltaTime(10)" +4 Setting the simulation speed to 20 seconds per realtime second Set sim speed 20 /Simulation Speed false "openspace.time.interpolateDeltaTime(20)" +5 Setting the simulation speed to 40 seconds per realtime second Set sim speed 40 /Simulation Speed false "openspace.time.interpolateDeltaTime(40)" +6 Setting the simulation speed to 90 seconds per realtime second Set sim speed 90 /Simulation Speed false "openspace.time.interpolateDeltaTime(90)" +7 Setting the simulation speed to 360 seconds per realtime second Set sim speed 360 /Simulation Speed false "openspace.time.interpolateDeltaTime(360)" +8 Setting the simulation speed to 720 seconds per realtime second Set sim speed 720 /Simulation Speed false "openspace.time.interpolateDeltaTime(720)" +9 Setting the simulation speed to 2880 seconds per realtime second Set sim speed 2880 /Simulation Speed false "openspace.time.interpolateDeltaTime(2880)" +0 Setting the simulation speed to 14400 seconds per realtime second Set sim speed 14400 /Simulation Speed false "openspace.time.interpolateDeltaTime(14400)" +Shift+1 Setting the simulation speed to 28800 seconds per realtime second Set sim speed 28800 /Simulation Speed false "openspace.time.interpolateDeltaTime(28800)" +Shift+2 Setting the simulation speed to 57600 seconds per realtime second Set sim speed 57600 /Simulation Speed false "openspace.time.interpolateDeltaTime(57600)" +Shift+3 Setting the simulation speed to 115200 seconds per realtime second Set sim speed 115200 /Simulation Speed false "openspace.time.interpolateDeltaTime(115200)" +Shift+4 Setting the simulation speed to 230400 seconds per realtime second Set sim speed 230400 /Simulation Speed false "openspace.time.interpolateDeltaTime(230400)" +Shift+5 Setting the simulation speed to 460800 seconds per realtime second Set sim speed 460800 /Simulation Speed false "openspace.time.interpolateDeltaTime(460800)" +Shift+6 Setting the simulation speed to 921600 seconds per realtime second Set sim speed 921600 /Simulation Speed false "openspace.time.interpolateDeltaTime(921600)" +Shift+7 Setting the simulation speed to 1843200 seconds per realtime second Set sim speed 1843200 /Simulation Speed false "openspace.time.interpolateDeltaTime(1843200)" +Shift+8 Setting the simulation speed to 3686400 seconds per realtime second Set sim speed 3686400 /Simulation Speed false "openspace.time.interpolateDeltaTime(3686400)" +Shift+9 Setting the simulation speed to 7372800 seconds per realtime second Set sim speed 7372800 /Simulation Speed false "openspace.time.interpolateDeltaTime(7372800)" +Shift+0 Setting the simulation speed to 14745600 seconds per realtime second Set sim speed 14745600 /Simulation Speed false "openspace.time.interpolateDeltaTime(14745600)" + +#Property +setPropertyValueSingle Scene.Pluto.Renderable.Enabled false +setPropertyValueSingle Scene.Charon.Renderable.Enabled false +setPropertyValueSingle Scene.PlutoBarycenterTrail.Renderable.Enabled false + +#Time +absolute 1977 SEP 10 12:00:00 + +#Camera +setNavigationState "Voyager_1" "Root" 526781518487.171326, 257168309890.072144, -1381125204152.817383 + +#MarkNodes +Earth +Voyager 1 +Voyager 2 +Jupiter +Saturn +Uranus +Neptune diff --git a/ext/ghoul b/ext/ghoul index 38272a9b7d..0461bf1f44 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 38272a9b7d30bc07656336d35cbaae3a24ffd4bb +Subproject commit 0461bf1f44b58e04fb21d929b0f385e1120da7b4 diff --git a/include/openspace/documentation/core_registration.h b/include/openspace/documentation/core_registration.h index a433bfd517..90176260a9 100644 --- a/include/openspace/documentation/core_registration.h +++ b/include/openspace/documentation/core_registration.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/documentation/documentation.h b/include/openspace/documentation/documentation.h index 6dc9432799..f6dac77b15 100644 --- a/include/openspace/documentation/documentation.h +++ b/include/openspace/documentation/documentation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/documentation/documentationengine.h b/include/openspace/documentation/documentationengine.h index 26dd0e14f9..4fc4065f8d 100644 --- a/include/openspace/documentation/documentationengine.h +++ b/include/openspace/documentation/documentationengine.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/documentation/documentationgenerator.h b/include/openspace/documentation/documentationgenerator.h index 43733989c3..41c3f21508 100644 --- a/include/openspace/documentation/documentationgenerator.h +++ b/include/openspace/documentation/documentationgenerator.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/documentation/verifier.h b/include/openspace/documentation/verifier.h index 07b6194d77..a94792e2b0 100644 --- a/include/openspace/documentation/verifier.h +++ b/include/openspace/documentation/verifier.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/documentation/verifier.inl b/include/openspace/documentation/verifier.inl index c0863127b5..6b707ece6f 100644 --- a/include/openspace/documentation/verifier.inl +++ b/include/openspace/documentation/verifier.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/engine/configuration.h b/include/openspace/engine/configuration.h index 0c8139f8c9..907ccd0e3f 100644 --- a/include/openspace/engine/configuration.h +++ b/include/openspace/engine/configuration.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -44,6 +44,7 @@ struct Configuration { std::string windowConfiguration = "${CONFIG}/single.xml"; std::string asset; + std::string profile; std::vector globalCustomizationScripts; std::map pathTokens = { { "CACHE" , "CACHE = \"${BASE}/cache\"" } @@ -86,9 +87,9 @@ struct Configuration { bool usePerSceneCache = false; bool isRenderingOnMasterDisabled = false; - glm::dvec3 globalRotation; - glm::dvec3 screenSpaceRotation; - glm::dvec3 masterRotation; + glm::dvec3 globalRotation = glm::dvec3(0.0); + glm::dvec3 screenSpaceRotation = glm::dvec3(0.0); + glm::dvec3 masterRotation = glm::dvec3(0.0); bool isConsoleDisabled = false; std::map moduleConfigurations; diff --git a/include/openspace/engine/downloadmanager.h b/include/openspace/engine/downloadmanager.h index 8e5e02483e..9769089855 100644 --- a/include/openspace/engine/downloadmanager.h +++ b/include/openspace/engine/downloadmanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/engine/globals.h b/include/openspace/engine/globals.h index 994ba901fa..c7133339bf 100644 --- a/include/openspace/engine/globals.h +++ b/include/openspace/engine/globals.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -53,6 +53,7 @@ namespace configuration { struct Configuration; } namespace interaction { struct JoystickInputStates; struct WebsocketInputStates; + class InteractionMonitor; class KeybindingManager; class NavigationHandler; class SessionRecording; @@ -87,6 +88,7 @@ VersionChecker& gVersionChecker(); VirtualPropertyManager& gVirtualPropertyManager(); WindowDelegate& gWindowDelegate(); configuration::Configuration& gConfiguration(); +interaction::InteractionMonitor& gInteractionMonitor(); interaction::JoystickInputStates& gJoystickInputStates(); interaction::WebsocketInputStates& gWebsocketInputStates(); interaction::KeybindingManager& gKeybindingManager(); @@ -120,6 +122,7 @@ static VersionChecker& versionChecker = detail::gVersionChecker(); static VirtualPropertyManager& virtualPropertyManager = detail::gVirtualPropertyManager(); static WindowDelegate& windowDelegate = detail::gWindowDelegate(); static configuration::Configuration& configuration = detail::gConfiguration(); +static interaction::InteractionMonitor& interactionMonitor = detail::gInteractionMonitor(); static interaction::JoystickInputStates& joystickInputStates = detail::gJoystickInputStates(); static interaction::WebsocketInputStates& websocketInputStates = diff --git a/include/openspace/engine/globalscallbacks.h b/include/openspace/engine/globalscallbacks.h index 856cc79f4f..9131294139 100644 --- a/include/openspace/engine/globalscallbacks.h +++ b/include/openspace/engine/globalscallbacks.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -53,6 +54,10 @@ std::vector>& gMouseB std::vector>& gMousePosition(); std::vector>& gMouseScrollWheel(); +std::vector>& gTouchDetected(); +std::vector>& gTouchUpdated(); +std::vector>& gTouchExit(); + } // namespace detail namespace callback { @@ -76,7 +81,12 @@ static std::vector>& mousePosition = detail::gMousePosition(); static std::vector>& mouseScrollWheel = detail::gMouseScrollWheel(); - +static std::vector>& touchDetected = + detail::gTouchDetected(); +static std::vector>& touchUpdated = + detail::gTouchUpdated(); +static std::vector>& touchExit = + detail::gTouchExit(); /** * If the framerate becomes slow, Chromium Embedded Framework (used in Web Browser Module) diff --git a/include/openspace/engine/logfactory.h b/include/openspace/engine/logfactory.h index d596e1d88a..4d023ec9e9 100644 --- a/include/openspace/engine/logfactory.h +++ b/include/openspace/engine/logfactory.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/engine/moduleengine.h b/include/openspace/engine/moduleengine.h index 06ebd45c07..d12cf5189f 100644 --- a/include/openspace/engine/moduleengine.h +++ b/include/openspace/engine/moduleengine.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/engine/moduleengine.inl b/include/openspace/engine/moduleengine.inl index 45b10014d6..7853a64eb1 100644 --- a/include/openspace/engine/moduleengine.inl +++ b/include/openspace/engine/moduleengine.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h index fb0ad85061..539530cad0 100644 --- a/include/openspace/engine/openspaceengine.h +++ b/include/openspace/engine/openspaceengine.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -80,7 +81,9 @@ public: void mouseButtonCallback(MouseButton button, MouseAction action, KeyModifier mods); void mousePositionCallback(double x, double y); void mouseScrollWheelCallback(double posX, double posY); - void externalControlCallback(const char* receivedChars, int size, int clientId); + void touchDetectionCallback(TouchInput input); + void touchUpdateCallback(TouchInput input); + void touchExitCallback(TouchInput input); std::vector encode(); void decode(std::vector data); @@ -106,6 +109,7 @@ private: void runGlobalCustomizationScripts(); void configureLogging(); + std::string generateFilePath(std::string openspaceRelativePath); std::unique_ptr _scene; std::unique_ptr _assetManager; diff --git a/include/openspace/engine/syncengine.h b/include/openspace/engine/syncengine.h index 49934315fc..5b5b4f2d89 100644 --- a/include/openspace/engine/syncengine.h +++ b/include/openspace/engine/syncengine.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/engine/virtualpropertymanager.h b/include/openspace/engine/virtualpropertymanager.h index d7479a6ffb..5d0701797f 100644 --- a/include/openspace/engine/virtualpropertymanager.h +++ b/include/openspace/engine/virtualpropertymanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/engine/windowdelegate.h b/include/openspace/engine/windowdelegate.h index b3c44e181d..1bef12d181 100644 --- a/include/openspace/engine/windowdelegate.h +++ b/include/openspace/engine/windowdelegate.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -74,8 +74,6 @@ struct WindowDelegate { int (*currentNumberOfAaSamples)() = []() { return 1; }; - bool (*isRegularRendering)() = []() { return true; }; - bool (*hasGuiWindow)() = []() { return false; }; bool (*isGuiWindow)() = []() { return false; }; @@ -98,16 +96,12 @@ struct WindowDelegate { glm::ivec4 (*viewportPixelCoordinates)() = []() { return glm::ivec4(0, 0, 0, 0); }; - bool (*isExternalControlConnected)() = []() { return false; }; - void (*sendMessageToExternalControl)(const std::vector& message) = [](const std::vector&) {}; - bool (*isSimpleRendering)() = []() { return true; }; - bool (*isFisheyeRendering)() = []() { return false; }; - void (*takeScreenshot)(bool applyWarping) = [](bool) { }; + unsigned int(*takeScreenshot)(bool applyWarping) = [](bool) { return 0u; }; void (*swapBuffer)() = []() {}; @@ -118,6 +112,10 @@ struct WindowDelegate { double (*getHorizFieldOfView)() = []() { return 0.0; }; void (*setHorizFieldOfView)(float hFovDeg) = [](float) { }; + + void* (*getNativeWindowHandle)(size_t windowIndex) = [](size_t) -> void* { + return nullptr; + }; using GLProcAddress = void(*)(void); diff --git a/include/openspace/interaction/camerainteractionstates.h b/include/openspace/interaction/camerainteractionstates.h index e4e21e0ae7..0e6f0f56a4 100644 --- a/include/openspace/interaction/camerainteractionstates.h +++ b/include/openspace/interaction/camerainteractionstates.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -64,12 +64,12 @@ protected: void setFriction(double friction); void setVelocityScaleFactor(double scaleFactor); - glm::dvec2 previousPosition; + glm::dvec2 previousPosition = glm::dvec2(0.0); DelayedVariable velocity; }; - double _sensitivity; + double _sensitivity = 0.0; InteractionState _globalRotationState; InteractionState _localRotationState; diff --git a/include/openspace/interaction/delayedvariable.h b/include/openspace/interaction/delayedvariable.h index 88dbb6938c..fd2a653820 100644 --- a/include/openspace/interaction/delayedvariable.h +++ b/include/openspace/interaction/delayedvariable.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -46,8 +46,8 @@ public: private: ScaleType _scaleFactor; ScaleType _friction; - T _targetValue; - T _currentValue; + T _targetValue = T(0); + T _currentValue = T(0); }; } // namespace openspace::interaction diff --git a/include/openspace/interaction/delayedvariable.inl b/include/openspace/interaction/delayedvariable.inl index cbd32d63da..2d36d5fbfa 100644 --- a/include/openspace/interaction/delayedvariable.inl +++ b/include/openspace/interaction/delayedvariable.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/interaction/externinteraction.h b/include/openspace/interaction/externinteraction.h index 6d9c10af36..a0478c86e1 100644 --- a/include/openspace/interaction/externinteraction.h +++ b/include/openspace/interaction/externinteraction.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/interaction/inputstate.h b/include/openspace/interaction/inputstate.h index 1ff5b39b8b..443899df35 100644 --- a/include/openspace/interaction/inputstate.h +++ b/include/openspace/interaction/inputstate.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -70,7 +70,7 @@ private: // Input from mouse std::vector _mouseButtonsDown; - glm::dvec2 _mousePosition; + glm::dvec2 _mousePosition = glm::dvec2(0.0); double _mouseScrollDelta; }; diff --git a/apps/TimelineView/mainwindow.h b/include/openspace/interaction/interactionmonitor.h similarity index 59% rename from apps/TimelineView/mainwindow.h rename to include/openspace/interaction/interactionmonitor.h index 550c075bee..b8c7a8b2b9 100644 --- a/apps/TimelineView/mainwindow.h +++ b/include/openspace/interaction/interactionmonitor.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -22,53 +22,49 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_APP_TIMELINEVIEW___MAINWINDOW___H__ -#define __OPENSPACE_APP_TIMELINEVIEW___MAINWINDOW___H__ +#ifndef __OPENSPACE_CORE___INTERACTIONMONITOR___H__ +#define __OPENSPACE_CORE___INTERACTIONMONITOR___H__ -#include -#include +#include -#include "common.h" +#include +#include -class ConfigurationWidget; -class ControlWidget; -class InformationWidget; -class TimelineWidget; +namespace openspace::interaction { -class MainWindow : public QWidget { -Q_OBJECT +/** + * The class InteractionMonitor keeps track of user interactions during an OpenSpace + * session. It keeps track of when the latest interaction was made and of when the state + * changes to idle. + */ +class InteractionMonitor : public properties::PropertyOwner { public: - MainWindow(); - ~MainWindow(); + InteractionMonitor(); - std::string nextTarget() const; + void setActivityState(bool isActive); + void setIdleTime(float time); -public slots: - void sendScript(QString script); + /* + * Called every frame from OpenSpaceEngine and calculates the activity state depending + * on the last registered interaction. + */ + void updateActivityState(); -private slots: - void onConnect(QString host, QString port); - void onDisconnect(); - - void onSocketConnected(); - void onSocketDisconnected(); - - void readTcpData(); - void handleStatusMessage(QByteArray data); - QByteArray handlePlaybook(QByteArray data); - void printMapping(QByteArray data); - - void fullyConnected(); + /* + * Called from all places we want to mark activity from. Updates the last registered + * interaction time + */ + void markInteraction(); private: - ConfigurationWidget* _configurationWidget; - ControlWidget* _timeControlWidget; - InformationWidget* _informationWidget; - TimelineWidget* _timelineWidget; + double _lastInteractionTime = 0; + properties::BoolProperty _isInActiveState; + properties::FloatProperty _idleTime; // in seconds - QTcpSocket* _socket; - - bool _isConnected = false; + // @TODO (lovisa) make a list of interactions to listen for + // and only allow registering updates from those interactions }; -#endif // __OPENSPACE_APP_TIMELINEVIEW___MAINWINDOW___H__ +} // namespace openspace::interaction + +#endif // __OPENSPACE_CORE___INTERACTIONMONITOR___H__ diff --git a/include/openspace/interaction/interpolator.h b/include/openspace/interaction/interpolator.h index 54750bc1eb..d872e1706d 100644 --- a/include/openspace/interaction/interpolator.h +++ b/include/openspace/interaction/interpolator.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/interaction/interpolator.inl b/include/openspace/interaction/interpolator.inl index d17741ea96..d28f07f573 100644 --- a/include/openspace/interaction/interpolator.inl +++ b/include/openspace/interaction/interpolator.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/interaction/joystickcamerastates.h b/include/openspace/interaction/joystickcamerastates.h index 965d0e16e6..ade9b9d2c7 100644 --- a/include/openspace/interaction/joystickcamerastates.h +++ b/include/openspace/interaction/joystickcamerastates.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/interaction/joystickinputstate.h b/include/openspace/interaction/joystickinputstate.h index 1a1b2a07ad..990cb2cf14 100644 --- a/include/openspace/interaction/joystickinputstate.h +++ b/include/openspace/interaction/joystickinputstate.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/interaction/keybindingmanager.h b/include/openspace/interaction/keybindingmanager.h index 08363bcd0d..aca56d84e6 100644 --- a/include/openspace/interaction/keybindingmanager.h +++ b/include/openspace/interaction/keybindingmanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -75,7 +75,6 @@ public: const std::multimap& keyBindings() const; private: - std::multimap _keyLua; }; diff --git a/include/openspace/interaction/keyframenavigator.h b/include/openspace/interaction/keyframenavigator.h index a241815c2c..c78db27cd7 100644 --- a/include/openspace/interaction/keyframenavigator.h +++ b/include/openspace/interaction/keyframenavigator.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -49,8 +49,8 @@ public: BooleanType(Inclusive); struct CameraPose { - glm::dvec3 position; - glm::quat rotation; + glm::dvec3 position = glm::dvec3(0.0); + glm::quat rotation = glm::quat(1.f, 0.f, 0.f, 0.f); std::string focusNode; float scale; bool followFocusNodeRotation; diff --git a/include/openspace/interaction/mousecamerastates.h b/include/openspace/interaction/mousecamerastates.h index bd2917dec5..f592dc0ed1 100644 --- a/include/openspace/interaction/mousecamerastates.h +++ b/include/openspace/interaction/mousecamerastates.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/interaction/navigationhandler.h b/include/openspace/interaction/navigationhandler.h index 89fc965785..66b1e3942b 100644 --- a/include/openspace/interaction/navigationhandler.h +++ b/include/openspace/interaction/navigationhandler.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -67,7 +67,7 @@ public: std::string anchor; std::string aim; std::string referenceFrame; - glm::dvec3 position; + glm::dvec3 position = glm::dvec3(0.0); std::optional up; double yaw = 0.0; double pitch = 0.0; @@ -136,6 +136,7 @@ public: WebsocketCameraStates::AxisNormalize shouldNormalize = WebsocketCameraStates::AxisNormalize::No); + NavigationState navigationState() const; NavigationState navigationState(const SceneGraphNode& referenceFrame) const; void saveNavigationState(const std::string& filepath, @@ -165,6 +166,7 @@ private: std::optional _pendingNavigationState; + properties::BoolProperty _disableInputs; properties::BoolProperty _useKeyFrameInteraction; }; diff --git a/include/openspace/interaction/orbitalnavigator.h b/include/openspace/interaction/orbitalnavigator.h index 155bfdd1af..c6671c8d6f 100644 --- a/include/openspace/interaction/orbitalnavigator.h +++ b/include/openspace/interaction/orbitalnavigator.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -99,13 +99,13 @@ public: private: struct CameraRotationDecomposition { - glm::dquat localRotation; - glm::dquat globalRotation; + glm::dquat localRotation = glm::dquat(1.0, 0.0, 0.0, 0.0); + glm::dquat globalRotation = glm::dquat(1.0, 0.0, 0.0, 0.0); }; struct CameraPose { - glm::dvec3 position; - glm::dquat rotation; + glm::dvec3 position = glm::dvec3(0.0); + glm::dquat rotation = glm::dquat(1.0, 0.0, 0.0, 0.0); }; using Displacement = std::pair; diff --git a/include/openspace/interaction/scriptcamerastates.h b/include/openspace/interaction/scriptcamerastates.h index 2153dee497..c70814bac4 100644 --- a/include/openspace/interaction/scriptcamerastates.h +++ b/include/openspace/interaction/scriptcamerastates.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -42,11 +42,11 @@ public: void addGlobalRoll(const glm::dvec2& delta); private: - glm::dvec2 _localRotation; - glm::dvec2 _globalRotation; - glm::dvec2 _truckMovement; - glm::dvec2 _localRoll; - glm::dvec2 _globalRoll; + glm::dvec2 _localRotation = glm::dvec2(0.0); + glm::dvec2 _globalRotation = glm::dvec2(0.0); + glm::dvec2 _truckMovement = glm::dvec2(0.0); + glm::dvec2 _localRoll = glm::dvec2(0.0); + glm::dvec2 _globalRoll = glm::dvec2(0.0); }; } // namespace openspace::interaction diff --git a/include/openspace/interaction/sessionrecording.h b/include/openspace/interaction/sessionrecording.h index 26c5f5a094..b3856c5981 100644 --- a/include/openspace/interaction/sessionrecording.h +++ b/include/openspace/interaction/sessionrecording.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/interaction/sessionrecording.inl b/include/openspace/interaction/sessionrecording.inl index 0839562306..386357c9c5 100644 --- a/include/openspace/interaction/sessionrecording.inl +++ b/include/openspace/interaction/sessionrecording.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -33,9 +33,11 @@ T nextKeyframeObj(unsigned int index, const std::vector& keyframeContainer, finishedCallback(); } return keyframeContainer.back(); - } else if (index < keyframeContainer.size()) { + } + else if (index < keyframeContainer.size()) { return keyframeContainer[index]; - } else { + } + else { return keyframeContainer.back(); } } @@ -44,9 +46,11 @@ template T prevKeyframeObj(unsigned int index, const std::vector& keyframeContainer) { if (index >= keyframeContainer.size()) { return keyframeContainer.back(); - } else if (index > 0) { + } + else if (index > 0) { return keyframeContainer[index - 1]; - } else { + } + else { return keyframeContainer.front(); } } diff --git a/include/openspace/interaction/shortcutmanager.h b/include/openspace/interaction/shortcutmanager.h index e08f4c708f..4f901f9f42 100644 --- a/include/openspace/interaction/shortcutmanager.h +++ b/include/openspace/interaction/shortcutmanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/interaction/touchbar.h b/include/openspace/interaction/touchbar.h index beae46641d..3b769a03f9 100644 --- a/include/openspace/interaction/touchbar.h +++ b/include/openspace/interaction/touchbar.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/interaction/websocketcamerastates.h b/include/openspace/interaction/websocketcamerastates.h index ab38160203..0b0bc5c4a9 100644 --- a/include/openspace/interaction/websocketcamerastates.h +++ b/include/openspace/interaction/websocketcamerastates.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/interaction/websocketinputstate.h b/include/openspace/interaction/websocketinputstate.h index a5a722491e..576e0c4c24 100644 --- a/include/openspace/interaction/websocketinputstate.h +++ b/include/openspace/interaction/websocketinputstate.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/json.h b/include/openspace/json.h index 5acf454641..11faafa5cf 100644 --- a/include/openspace/json.h +++ b/include/openspace/json.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/mission/mission.h b/include/openspace/mission/mission.h index 0cd8b73974..3cb5c8caf1 100644 --- a/include/openspace/mission/mission.h +++ b/include/openspace/mission/mission.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/mission/missionmanager.h b/include/openspace/mission/missionmanager.h index 4be9762d74..97522d490d 100644 --- a/include/openspace/mission/missionmanager.h +++ b/include/openspace/mission/missionmanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/network/messagestructures.h b/include/openspace/network/messagestructures.h index d1e60f7bb3..06fe7841ee 100644 --- a/include/openspace/network/messagestructures.h +++ b/include/openspace/network/messagestructures.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -45,8 +45,8 @@ struct CameraKeyframe { deserialize(buffer); } - glm::dvec3 _position; - glm::dquat _rotation; + glm::dvec3 _position = glm::dvec3(0.0); + glm::dquat _rotation = glm::dquat(1.0, 0.0, 0.0, 0.0); bool _followNodeRotation; std::string _focusNode; float _scale; diff --git a/include/openspace/network/parallelconnection.h b/include/openspace/network/parallelconnection.h index bffa3c9626..f70e87ed16 100644 --- a/include/openspace/network/parallelconnection.h +++ b/include/openspace/network/parallelconnection.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/network/parallelpeer.h b/include/openspace/network/parallelpeer.h index b34d4bcea2..293f433794 100644 --- a/include/openspace/network/parallelpeer.h +++ b/include/openspace/network/parallelpeer.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/network/parallelserver.h b/include/openspace/network/parallelserver.h index 6cf0b1b1f5..18ce60e573 100644 --- a/include/openspace/network/parallelserver.h +++ b/include/openspace/network/parallelserver.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/performance/performancelayout.h b/include/openspace/performance/performancelayout.h index 7eb6b69f1c..85d325cf45 100644 --- a/include/openspace/performance/performancelayout.h +++ b/include/openspace/performance/performancelayout.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/performance/performancemanager.h b/include/openspace/performance/performancemanager.h index 86ffc9dd92..4c37fd5b81 100644 --- a/include/openspace/performance/performancemanager.h +++ b/include/openspace/performance/performancemanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/performance/performancemeasurement.h b/include/openspace/performance/performancemeasurement.h index 0c762449d1..3222a72479 100644 --- a/include/openspace/performance/performancemeasurement.h +++ b/include/openspace/performance/performancemeasurement.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/matrix/dmat2property.h b/include/openspace/properties/matrix/dmat2property.h index 2b11e012dc..030e9b710c 100644 --- a/include/openspace/properties/matrix/dmat2property.h +++ b/include/openspace/properties/matrix/dmat2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/matrix/dmat2x3property.h b/include/openspace/properties/matrix/dmat2x3property.h index 9fdeee4f7d..4885a392c0 100644 --- a/include/openspace/properties/matrix/dmat2x3property.h +++ b/include/openspace/properties/matrix/dmat2x3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/matrix/dmat2x4property.h b/include/openspace/properties/matrix/dmat2x4property.h index 310234a21d..20eb77fcda 100644 --- a/include/openspace/properties/matrix/dmat2x4property.h +++ b/include/openspace/properties/matrix/dmat2x4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/matrix/dmat3property.h b/include/openspace/properties/matrix/dmat3property.h index 1f355bc91f..9c2543d7d2 100644 --- a/include/openspace/properties/matrix/dmat3property.h +++ b/include/openspace/properties/matrix/dmat3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/matrix/dmat3x2property.h b/include/openspace/properties/matrix/dmat3x2property.h index 406114d809..5824b869ee 100644 --- a/include/openspace/properties/matrix/dmat3x2property.h +++ b/include/openspace/properties/matrix/dmat3x2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/matrix/dmat3x4property.h b/include/openspace/properties/matrix/dmat3x4property.h index 450c075702..39c83f408d 100644 --- a/include/openspace/properties/matrix/dmat3x4property.h +++ b/include/openspace/properties/matrix/dmat3x4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/matrix/dmat4property.h b/include/openspace/properties/matrix/dmat4property.h index 9c93bda9e9..cd7b9b3eb1 100644 --- a/include/openspace/properties/matrix/dmat4property.h +++ b/include/openspace/properties/matrix/dmat4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/matrix/dmat4x2property.h b/include/openspace/properties/matrix/dmat4x2property.h index ac4a421f5c..a1bea90a79 100644 --- a/include/openspace/properties/matrix/dmat4x2property.h +++ b/include/openspace/properties/matrix/dmat4x2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/matrix/dmat4x3property.h b/include/openspace/properties/matrix/dmat4x3property.h index 66cd49f667..8ed951cffb 100644 --- a/include/openspace/properties/matrix/dmat4x3property.h +++ b/include/openspace/properties/matrix/dmat4x3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/matrix/mat2property.h b/include/openspace/properties/matrix/mat2property.h index cc8bb9254d..f500659e08 100644 --- a/include/openspace/properties/matrix/mat2property.h +++ b/include/openspace/properties/matrix/mat2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/matrix/mat2x3property.h b/include/openspace/properties/matrix/mat2x3property.h index dc51ae3b95..2ba18f51e1 100644 --- a/include/openspace/properties/matrix/mat2x3property.h +++ b/include/openspace/properties/matrix/mat2x3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/matrix/mat2x4property.h b/include/openspace/properties/matrix/mat2x4property.h index 79a0ebca3b..98820e069a 100644 --- a/include/openspace/properties/matrix/mat2x4property.h +++ b/include/openspace/properties/matrix/mat2x4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/matrix/mat3property.h b/include/openspace/properties/matrix/mat3property.h index 1dfccfcad9..dd2104482e 100644 --- a/include/openspace/properties/matrix/mat3property.h +++ b/include/openspace/properties/matrix/mat3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/matrix/mat3x2property.h b/include/openspace/properties/matrix/mat3x2property.h index 63d8f35e97..88c157d3bf 100644 --- a/include/openspace/properties/matrix/mat3x2property.h +++ b/include/openspace/properties/matrix/mat3x2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/matrix/mat3x4property.h b/include/openspace/properties/matrix/mat3x4property.h index 0e86c22fcb..294e77b82f 100644 --- a/include/openspace/properties/matrix/mat3x4property.h +++ b/include/openspace/properties/matrix/mat3x4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/matrix/mat4property.h b/include/openspace/properties/matrix/mat4property.h index 28467cae7c..abf0e01e61 100644 --- a/include/openspace/properties/matrix/mat4property.h +++ b/include/openspace/properties/matrix/mat4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/matrix/mat4x2property.h b/include/openspace/properties/matrix/mat4x2property.h index dda6c83965..a688965a86 100644 --- a/include/openspace/properties/matrix/mat4x2property.h +++ b/include/openspace/properties/matrix/mat4x2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/matrix/mat4x3property.h b/include/openspace/properties/matrix/mat4x3property.h index c624b67c50..231d253c0d 100644 --- a/include/openspace/properties/matrix/mat4x3property.h +++ b/include/openspace/properties/matrix/mat4x3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/numericalproperty.h b/include/openspace/properties/numericalproperty.h index 046658143e..d66ec0e99c 100644 --- a/include/openspace/properties/numericalproperty.h +++ b/include/openspace/properties/numericalproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -67,7 +67,7 @@ public: using TemplateProperty::operator=; - void setInterpolationTarget(ghoul::any value) override; + void setInterpolationTarget(std::any value) override; void setLuaInterpolationTarget(lua_State* state) override; void setStringInterpolationTarget(std::string value) override; @@ -90,13 +90,13 @@ protected: */ std::string luaToJson(std::string luaValue) const; - T _minimumValue; - T _maximumValue; - T _stepping; - float _exponent; + T _minimumValue = T(0); + T _maximumValue = T(0); + T _stepping = T(0); + float _exponent = 0.f; - T _interpolationStart; - T _interpolationEnd; + T _interpolationStart = T(0); + T _interpolationEnd = T(0); }; } // namespace openspace::properties diff --git a/include/openspace/properties/numericalproperty.inl b/include/openspace/properties/numericalproperty.inl index 186b493126..eb4504ae84 100644 --- a/include/openspace/properties/numericalproperty.inl +++ b/include/openspace/properties/numericalproperty.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -23,6 +23,7 @@ ****************************************************************************************/ #include +#include namespace openspace::properties { @@ -342,7 +343,7 @@ bool NumericalProperty::setStringValue(std::string value) { value, success ); if (success) { - TemplateProperty::set(ghoul::any(std::move(thisValue))); + TemplateProperty::set(std::any(std::move(thisValue))); } return success; } @@ -421,8 +422,8 @@ std::string NumericalProperty::jsonValue() const { } template -void NumericalProperty::setInterpolationTarget(ghoul::any value) { - T v = ghoul::any_cast(std::move(value)); +void NumericalProperty::setInterpolationTarget(std::any value) { + T v = std::any_cast(std::move(value)); _interpolationStart = TemplateProperty::_value; _interpolationEnd = std::move(v); diff --git a/include/openspace/properties/optionproperty.h b/include/openspace/properties/optionproperty.h index 25c13c77ff..1165337d56 100644 --- a/include/openspace/properties/optionproperty.h +++ b/include/openspace/properties/optionproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/property.h b/include/openspace/properties/property.h index 6d7bbc3d3f..1e5dd5c8b3 100644 --- a/include/openspace/properties/property.h +++ b/include/openspace/properties/property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -153,7 +153,7 @@ public: * \return The value that is encapsulated by this Property, or an empty ghoul::any * object if the method was not overritten. */ - virtual ghoul::any get() const; + virtual std::any get() const; /** * Sets the value encapsulated by this Property to the \p value passed to this @@ -164,7 +164,7 @@ public: * * \param value The new value that should be stored in this Property */ - virtual void set(ghoul::any value); + virtual void set(std::any value); /** * This method returns the type that is requested by this Property for the set method. @@ -395,9 +395,7 @@ public: /** * Default view options that can be used in the Property::setViewOption method. The * values are: Property::ViewOptions::Color = \c color, - * Property::ViewOptions::LightPosition = \c lightPosition, - * Property::ViewOptions::PowerScaledScalar = \c powerScaledScalar, and - * Property::ViewOptions::PowerScaledCoordinate = \c powerScaledCoordinate. + * Property::ViewOptions::LightPosition = \c lightPosition */ struct ViewOptions { static const char* Color; @@ -455,7 +453,7 @@ public: virtual std::string jsonValue() const; /// Interpolation methods - virtual void setInterpolationTarget(ghoul::any value); + virtual void setInterpolationTarget(std::any value); virtual void setLuaInterpolationTarget(lua_State* state); virtual void setStringInterpolationTarget(std::string value); diff --git a/include/openspace/properties/propertydelegate.h b/include/openspace/properties/propertydelegate.h index 4af67d8723..cd2c0e7979 100644 --- a/include/openspace/properties/propertydelegate.h +++ b/include/openspace/properties/propertydelegate.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/propertydelegate.inl b/include/openspace/properties/propertydelegate.inl index 11ddd9d8d1..d09a4f615e 100644 --- a/include/openspace/properties/propertydelegate.inl +++ b/include/openspace/properties/propertydelegate.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/propertyowner.h b/include/openspace/properties/propertyowner.h index d7134b9c54..5b4b9bd038 100644 --- a/include/openspace/properties/propertyowner.h +++ b/include/openspace/properties/propertyowner.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/scalar/boolproperty.h b/include/openspace/properties/scalar/boolproperty.h index 16428bf95d..e478e3318a 100644 --- a/include/openspace/properties/scalar/boolproperty.h +++ b/include/openspace/properties/scalar/boolproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/scalar/charproperty.h b/include/openspace/properties/scalar/charproperty.h index 4bf7e3b6e2..07ab7ad040 100644 --- a/include/openspace/properties/scalar/charproperty.h +++ b/include/openspace/properties/scalar/charproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/scalar/doubleproperty.h b/include/openspace/properties/scalar/doubleproperty.h index bbb38258c1..2f11f14277 100644 --- a/include/openspace/properties/scalar/doubleproperty.h +++ b/include/openspace/properties/scalar/doubleproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/scalar/floatproperty.h b/include/openspace/properties/scalar/floatproperty.h index 3b06e60d9e..a19df16279 100644 --- a/include/openspace/properties/scalar/floatproperty.h +++ b/include/openspace/properties/scalar/floatproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/scalar/intproperty.h b/include/openspace/properties/scalar/intproperty.h index 48e16324fb..ec5c528ac2 100644 --- a/include/openspace/properties/scalar/intproperty.h +++ b/include/openspace/properties/scalar/intproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/scalar/longdoubleproperty.h b/include/openspace/properties/scalar/longdoubleproperty.h index c842da0da9..768bba53f1 100644 --- a/include/openspace/properties/scalar/longdoubleproperty.h +++ b/include/openspace/properties/scalar/longdoubleproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/scalar/longlongproperty.h b/include/openspace/properties/scalar/longlongproperty.h index 5853792f30..eedcff1a82 100644 --- a/include/openspace/properties/scalar/longlongproperty.h +++ b/include/openspace/properties/scalar/longlongproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/scalar/longproperty.h b/include/openspace/properties/scalar/longproperty.h index f328f8a6eb..ed23a04a6f 100644 --- a/include/openspace/properties/scalar/longproperty.h +++ b/include/openspace/properties/scalar/longproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/scalar/shortproperty.h b/include/openspace/properties/scalar/shortproperty.h index 1d332900d2..a8cf97126e 100644 --- a/include/openspace/properties/scalar/shortproperty.h +++ b/include/openspace/properties/scalar/shortproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/scalar/signedcharproperty.h b/include/openspace/properties/scalar/signedcharproperty.h index 667ba9bf62..9419e9a7e2 100644 --- a/include/openspace/properties/scalar/signedcharproperty.h +++ b/include/openspace/properties/scalar/signedcharproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/scalar/ucharproperty.h b/include/openspace/properties/scalar/ucharproperty.h index 5cdcd1f2d5..4439157256 100644 --- a/include/openspace/properties/scalar/ucharproperty.h +++ b/include/openspace/properties/scalar/ucharproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/scalar/uintproperty.h b/include/openspace/properties/scalar/uintproperty.h index bc6865ab4f..12b40502fa 100644 --- a/include/openspace/properties/scalar/uintproperty.h +++ b/include/openspace/properties/scalar/uintproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/scalar/ulonglongproperty.h b/include/openspace/properties/scalar/ulonglongproperty.h index dcb638550a..c852b42554 100644 --- a/include/openspace/properties/scalar/ulonglongproperty.h +++ b/include/openspace/properties/scalar/ulonglongproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/scalar/ulongproperty.h b/include/openspace/properties/scalar/ulongproperty.h index e9667ce0f7..fdb283b2aa 100644 --- a/include/openspace/properties/scalar/ulongproperty.h +++ b/include/openspace/properties/scalar/ulongproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/scalar/ushortproperty.h b/include/openspace/properties/scalar/ushortproperty.h index 861e855dc2..d58c9e12f7 100644 --- a/include/openspace/properties/scalar/ushortproperty.h +++ b/include/openspace/properties/scalar/ushortproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/scalar/wcharproperty.h b/include/openspace/properties/scalar/wcharproperty.h index 07bc68ef76..9ede24d24c 100644 --- a/include/openspace/properties/scalar/wcharproperty.h +++ b/include/openspace/properties/scalar/wcharproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/selectionproperty.h b/include/openspace/properties/selectionproperty.h index f0ea9f0eaf..871faf1c7e 100644 --- a/include/openspace/properties/selectionproperty.h +++ b/include/openspace/properties/selectionproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/stringlistproperty.h b/include/openspace/properties/stringlistproperty.h index 98a38e0617..7078bdaecb 100644 --- a/include/openspace/properties/stringlistproperty.h +++ b/include/openspace/properties/stringlistproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/stringproperty.h b/include/openspace/properties/stringproperty.h index d3e12051b5..2ad56eb387 100644 --- a/include/openspace/properties/stringproperty.h +++ b/include/openspace/properties/stringproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/templateproperty.h b/include/openspace/properties/templateproperty.h index f04af496d3..eb55526ee1 100644 --- a/include/openspace/properties/templateproperty.h +++ b/include/openspace/properties/templateproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -86,7 +86,7 @@ public: * * \return The stored value packed into a ghoul::any object */ - virtual ghoul::any get() const override; + virtual std::any get() const override; /** * Sets the value from the provided ghoul::any object. If the types between @@ -95,7 +95,7 @@ public: * * \param value The value that is used to set this Property */ - virtual void set(ghoul::any value) override; + virtual void set(std::any value) override; /** * Returns the std::type_info describing the template parameter diff --git a/include/openspace/properties/templateproperty.inl b/include/openspace/properties/templateproperty.inl index 72d92843b2..56fdca6a1a 100644 --- a/include/openspace/properties/templateproperty.inl +++ b/include/openspace/properties/templateproperty.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -186,13 +186,13 @@ std::ostream& operator<<(std::ostream& os, const TemplateProperty& obj) { } template -ghoul::any TemplateProperty::get() const { - return ghoul::any(_value); +std::any TemplateProperty::get() const { + return std::any(_value); } template -void TemplateProperty::set(ghoul::any value) { - T v = ghoul::any_cast(std::move(value)); +void TemplateProperty::set(std::any value) { + T v = std::any_cast(std::move(value)); if (v != _value) { _value = std::move(v); notifyChangeListeners(); @@ -221,7 +221,7 @@ bool TemplateProperty::setLuaValue(lua_State* state) { success ); if (success) { - set(ghoul::any(thisValue)); + set(std::any(thisValue)); } return success; } @@ -248,7 +248,7 @@ bool TemplateProperty::setStringValue(std::string value) { success ); if (success) { - set(ghoul::any(thisValue)); + set(std::any(thisValue)); } return success; } diff --git a/include/openspace/properties/triggerproperty.h b/include/openspace/properties/triggerproperty.h index 485564e9aa..cd741a1101 100644 --- a/include/openspace/properties/triggerproperty.h +++ b/include/openspace/properties/triggerproperty.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -64,7 +64,7 @@ public: * listeners regardless of the value * \param value The ignored value */ - void set(ghoul::any value) override; + void set(std::any value) override; std::string toJson() const override; diff --git a/include/openspace/properties/vector/bvec2property.h b/include/openspace/properties/vector/bvec2property.h index bdc158a4fc..76e81000fc 100644 --- a/include/openspace/properties/vector/bvec2property.h +++ b/include/openspace/properties/vector/bvec2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/vector/bvec3property.h b/include/openspace/properties/vector/bvec3property.h index 724bf1cce4..65aeb2ffc7 100644 --- a/include/openspace/properties/vector/bvec3property.h +++ b/include/openspace/properties/vector/bvec3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/vector/bvec4property.h b/include/openspace/properties/vector/bvec4property.h index 4958f4889e..b551d624ef 100644 --- a/include/openspace/properties/vector/bvec4property.h +++ b/include/openspace/properties/vector/bvec4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/vector/dvec2property.h b/include/openspace/properties/vector/dvec2property.h index 20385dda18..66985a611f 100644 --- a/include/openspace/properties/vector/dvec2property.h +++ b/include/openspace/properties/vector/dvec2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/vector/dvec3property.h b/include/openspace/properties/vector/dvec3property.h index 7adff33d3e..974d4133e8 100644 --- a/include/openspace/properties/vector/dvec3property.h +++ b/include/openspace/properties/vector/dvec3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/vector/dvec4property.h b/include/openspace/properties/vector/dvec4property.h index 2784a3899f..13b6ffa47d 100644 --- a/include/openspace/properties/vector/dvec4property.h +++ b/include/openspace/properties/vector/dvec4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/vector/ivec2property.h b/include/openspace/properties/vector/ivec2property.h index 2a02500f04..59b4bc89f4 100644 --- a/include/openspace/properties/vector/ivec2property.h +++ b/include/openspace/properties/vector/ivec2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/vector/ivec3property.h b/include/openspace/properties/vector/ivec3property.h index b652fe8f68..d24f44e85d 100644 --- a/include/openspace/properties/vector/ivec3property.h +++ b/include/openspace/properties/vector/ivec3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/vector/ivec4property.h b/include/openspace/properties/vector/ivec4property.h index cca0031147..597516ba0e 100644 --- a/include/openspace/properties/vector/ivec4property.h +++ b/include/openspace/properties/vector/ivec4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/vector/uvec2property.h b/include/openspace/properties/vector/uvec2property.h index 3acaeb9df7..ff647091c8 100644 --- a/include/openspace/properties/vector/uvec2property.h +++ b/include/openspace/properties/vector/uvec2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/vector/uvec3property.h b/include/openspace/properties/vector/uvec3property.h index 724b1f2723..cff5d16233 100644 --- a/include/openspace/properties/vector/uvec3property.h +++ b/include/openspace/properties/vector/uvec3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/vector/uvec4property.h b/include/openspace/properties/vector/uvec4property.h index 4b7ff01146..ccd4a97fbc 100644 --- a/include/openspace/properties/vector/uvec4property.h +++ b/include/openspace/properties/vector/uvec4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/vector/vec2property.h b/include/openspace/properties/vector/vec2property.h index c58f47d36c..1a9709a728 100644 --- a/include/openspace/properties/vector/vec2property.h +++ b/include/openspace/properties/vector/vec2property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/vector/vec3property.h b/include/openspace/properties/vector/vec3property.h index b36779c70a..1795c705a0 100644 --- a/include/openspace/properties/vector/vec3property.h +++ b/include/openspace/properties/vector/vec3property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/properties/vector/vec4property.h b/include/openspace/properties/vector/vec4property.h index 09e429483c..bc66aafab8 100644 --- a/include/openspace/properties/vector/vec4property.h +++ b/include/openspace/properties/vector/vec4property.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/query/query.h b/include/openspace/query/query.h index a9584485af..18253a75d0 100644 --- a/include/openspace/query/query.h +++ b/include/openspace/query/query.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/rendering/abufferrenderer.h b/include/openspace/rendering/abufferrenderer.h index aa99d10ad1..275d41c897 100644 --- a/include/openspace/rendering/abufferrenderer.h +++ b/include/openspace/rendering/abufferrenderer.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -112,7 +112,7 @@ private: void saveTextureToMemory(GLenum color_buffer_attachment, int width, int height, std::vector & memory) const; - glm::ivec2 _resolution = glm::ivec2(0, 0); + glm::ivec2 _resolution = glm::ivec2(0); bool _dirtyResolution = true; bool _dirtyRendererData = true; diff --git a/include/openspace/rendering/dashboard.h b/include/openspace/rendering/dashboard.h index 12f10b5a98..019b086773 100644 --- a/include/openspace/rendering/dashboard.h +++ b/include/openspace/rendering/dashboard.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/rendering/dashboarditem.h b/include/openspace/rendering/dashboarditem.h index 8814ae712b..e33467a555 100644 --- a/include/openspace/rendering/dashboarditem.h +++ b/include/openspace/rendering/dashboarditem.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/rendering/deferredcaster.h b/include/openspace/rendering/deferredcaster.h index 7a1dfc5c18..32e8592f4e 100644 --- a/include/openspace/rendering/deferredcaster.h +++ b/include/openspace/rendering/deferredcaster.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/rendering/deferredcasterlistener.h b/include/openspace/rendering/deferredcasterlistener.h index 37cfb3e9ca..067ec2afb6 100644 --- a/include/openspace/rendering/deferredcasterlistener.h +++ b/include/openspace/rendering/deferredcasterlistener.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/rendering/deferredcastermanager.h b/include/openspace/rendering/deferredcastermanager.h index 4348f04456..0d6623e066 100644 --- a/include/openspace/rendering/deferredcastermanager.h +++ b/include/openspace/rendering/deferredcastermanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/rendering/framebufferrenderer.h b/include/openspace/rendering/framebufferrenderer.h index a49568fe17..70330f2243 100644 --- a/include/openspace/rendering/framebufferrenderer.h +++ b/include/openspace/rendering/framebufferrenderer.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -70,6 +70,7 @@ public: void updateDeferredcastData(); void updateHDRAndFiltering(); void updateFXAA(); + void updateDownscaledVolume(); void setResolution(glm::ivec2 res) override; void setHDRExposure(float hdrExposure) override; @@ -110,6 +111,9 @@ private: void resolveMSAA(float blackoutFactor); void applyTMO(float blackoutFactor); void applyFXAA(); + void updateDownscaleTextures(); + void updateExitVolumeTextures(); + void writeDownscaledVolume(); std::map _raycastData; RaycasterProgObjMap _exitPrograms; @@ -122,10 +126,13 @@ private: std::unique_ptr _hdrFilteringProgram; std::unique_ptr _tmoProgram; std::unique_ptr _fxaaProgram; + std::unique_ptr _downscaledVolumeProgram; UniformCache(hdrFeedingTexture, blackoutFactor, hdrExposure, gamma, Hue, Saturation, Value) _hdrUniformCache; UniformCache(renderedTexture, inverseScreenSize) _fxaaUniformCache; + UniformCache(downscaledRenderedVolume, downscaledRenderedVolumeDepth) + _writeDownscaledVolumeUniformCache; GLint _defaultFBO; GLuint _screenQuad; @@ -157,6 +164,13 @@ private: GLuint fxaaTexture; } _fxaaBuffers; + struct { + GLuint framebuffer; + GLuint colorTexture; + GLuint depthbuffer; + float currentDownscaleFactor = 1.f; + } _downscaleVolumeRendering; + unsigned int _pingPongIndex = 0u; bool _dirtyDeferredcastData; diff --git a/include/openspace/rendering/helper.h b/include/openspace/rendering/helper.h index 834f26ff05..dbe6bfef42 100644 --- a/include/openspace/rendering/helper.h +++ b/include/openspace/rendering/helper.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/rendering/loadingscreen.h b/include/openspace/rendering/loadingscreen.h index 0c4a300776..5e3900e8eb 100644 --- a/include/openspace/rendering/loadingscreen.h +++ b/include/openspace/rendering/loadingscreen.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -120,8 +120,8 @@ private: ProgressInfo progress; bool hasLocation; - glm::vec2 ll; - glm::vec2 ur; + glm::vec2 ll = glm::vec2(0.f); + glm::vec2 ur = glm::vec2(0.f); std::chrono::system_clock::time_point finishedTime; }; diff --git a/include/openspace/rendering/luaconsole.h b/include/openspace/rendering/luaconsole.h index e4c02ee9c3..2c4e0e21a9 100644 --- a/include/openspace/rendering/luaconsole.h +++ b/include/openspace/rendering/luaconsole.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/rendering/raycasterlistener.h b/include/openspace/rendering/raycasterlistener.h index 382e9553ed..5a0af12e7d 100644 --- a/include/openspace/rendering/raycasterlistener.h +++ b/include/openspace/rendering/raycasterlistener.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/rendering/raycastermanager.h b/include/openspace/rendering/raycastermanager.h index 683dbe236b..8aa36ab6d1 100644 --- a/include/openspace/rendering/raycastermanager.h +++ b/include/openspace/rendering/raycastermanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/rendering/renderable.h b/include/openspace/rendering/renderable.h index d72a6e1b8c..d43b8f9bb7 100644 --- a/include/openspace/rendering/renderable.h +++ b/include/openspace/rendering/renderable.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index 8093c16c4d..5216060d6d 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -142,9 +142,14 @@ public: void setResolveData(ghoul::Dictionary resolveData); /** - * Mark that one screenshot should be taken + * Take a screenshot and store in the ${SCREENSHOTS} directory */ - void takeScreenShot(); + void takeScreenshot(); + + /** + * Get the filename of the latest screenshot + */ + unsigned int latestScreenshotNumber() const; /** * Returns the Lua library that contains all Lua functions available to affect the @@ -187,8 +192,6 @@ private: properties::BoolProperty _showVersionInfo; properties::BoolProperty _showCameraInfo; - properties::TriggerProperty _takeScreenshot; - bool _shouldTakeScreenshot = false; properties::BoolProperty _applyWarping; properties::BoolProperty _showFrameInformation; #ifdef OPENSPACE_WITH_INSTRUMENTATION @@ -226,6 +229,7 @@ private: properties::Vec3Property _masterRotation; uint64_t _frameNumber = 0; + unsigned int _latestScreenshotNumber = 0; std::vector _programs; @@ -235,9 +239,9 @@ private: std::shared_ptr _fontLog; struct { - glm::ivec4 rotation; - glm::ivec4 zoom; - glm::ivec4 roll; + glm::ivec4 rotation = glm::ivec4(0); + glm::ivec4 zoom = glm::ivec4(0); + glm::ivec4 roll = glm::ivec4(0); } _cameraButtonLocations; }; diff --git a/include/openspace/rendering/renderer.h b/include/openspace/rendering/renderer.h index d8b38f0450..b587e640f6 100644 --- a/include/openspace/rendering/renderer.h +++ b/include/openspace/rendering/renderer.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/rendering/screenspacerenderable.h b/include/openspace/rendering/screenspacerenderable.h index d5dfabef94..24d887e1a7 100644 --- a/include/openspace/rendering/screenspacerenderable.h +++ b/include/openspace/rendering/screenspacerenderable.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -75,6 +75,8 @@ public: protected: void createShaders(); + std::string makeUniqueIdentifier(std::string name); + glm::mat4 scaleMatrix(); glm::mat4 globalRotationMatrix(); glm::mat4 translationMatrix(); @@ -105,7 +107,7 @@ protected: properties::FloatProperty _alpha; properties::TriggerProperty _delete; - glm::ivec2 _objectSize; + glm::ivec2 _objectSize = glm::ivec2(0); UniformCache(alpha, modelTransform, viewProj, texture) _uniformCache; std::unique_ptr _shader; }; diff --git a/include/openspace/rendering/transferfunction.h b/include/openspace/rendering/transferfunction.h index b0f02acf21..43edecbd53 100644 --- a/include/openspace/rendering/transferfunction.h +++ b/include/openspace/rendering/transferfunction.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -70,11 +70,11 @@ private: struct MappingKey { MappingKey(float p, const glm::vec4& c): position(p), color(c) {}; - MappingKey(float p): position(p), color(glm::vec4(0.0f)) {}; + MappingKey(float p): position(p), color(glm::vec4(0.f)) {}; bool operator<(const MappingKey& rhs) {return position < rhs.position;}; float position = 0.f; - glm::vec4 color = glm::vec4(0.f, 0.f, 0.f, 0.f); + glm::vec4 color = glm::vec4(0.f); }; } // namespace openspace diff --git a/include/openspace/rendering/volume.h b/include/openspace/rendering/volume.h index 4be0a807c1..c3d40bcaf7 100644 --- a/include/openspace/rendering/volume.h +++ b/include/openspace/rendering/volume.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/rendering/volumeraycaster.h b/include/openspace/rendering/volumeraycaster.h index f8ed000553..29c159f442 100644 --- a/include/openspace/rendering/volumeraycaster.h +++ b/include/openspace/rendering/volumeraycaster.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -128,6 +128,25 @@ public: * helper file) which should be a prefix to all symbols defined by the helper */ virtual std::string helperPath() const = 0; + + void setMaxSteps(int nsteps); + + int maxSteps() const; + + void setDownscaleRender(float value); + + float downscaleRender() const; + +private: + /** + * Maximum number of integration steps to be executed by the volume integrator. + */ + int _rayCastMaxSteps = 1000; + + /** + * Enable and set the downscale rendering of the volume. Used to improve performance. + */ + float _downscaleRenderConst = 1.0f; }; } // namespace openspace diff --git a/include/openspace/scene/asset.h b/include/openspace/scene/asset.h index edc6eda3fc..13b7fe650f 100644 --- a/include/openspace/scene/asset.h +++ b/include/openspace/scene/asset.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -61,8 +61,6 @@ public: */ Asset(AssetLoader* loader, SynchronizationWatcher* watcher, std::string assetPath); - ~Asset() = default; - std::string id() const; const std::string& assetFilePath() const; bool hasAssetFile() const; diff --git a/include/openspace/scene/assetlistener.h b/include/openspace/scene/assetlistener.h index d864717b44..60061fd263 100644 --- a/include/openspace/scene/assetlistener.h +++ b/include/openspace/scene/assetlistener.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/scene/assetloader.h b/include/openspace/scene/assetloader.h index 49fda6ac13..ea32931835 100644 --- a/include/openspace/scene/assetloader.h +++ b/include/openspace/scene/assetloader.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -61,7 +61,7 @@ class AssetListener; class AssetLoader { public: - AssetLoader(ghoul::lua::LuaState& luaState, SynchronizationWatcher* syncWatcher, + AssetLoader(ghoul::lua::LuaState* luaState, SynchronizationWatcher* syncWatcher, std::string assetRootDirectory); ~AssetLoader(); diff --git a/include/openspace/scene/assetmanager.h b/include/openspace/scene/assetmanager.h index c29b4a9ec1..d279219463 100644 --- a/include/openspace/scene/assetmanager.h +++ b/include/openspace/scene/assetmanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/scene/lightsource.h b/include/openspace/scene/lightsource.h index dc06f5552f..ff754e6efb 100644 --- a/include/openspace/scene/lightsource.h +++ b/include/openspace/scene/lightsource.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/scene/rotation.h b/include/openspace/scene/rotation.h index 78843a80ee..995543935f 100644 --- a/include/openspace/scene/rotation.h +++ b/include/openspace/scene/rotation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -61,7 +61,7 @@ protected: private: bool _needsUpdate = true; double _cachedTime = -std::numeric_limits::max(); - glm::dmat3 _cachedMatrix; + glm::dmat3 _cachedMatrix = glm::dmat3(1.0); }; } // namespace openspace diff --git a/include/openspace/scene/scale.h b/include/openspace/scene/scale.h index b1481b2aec..ee4a113b20 100644 --- a/include/openspace/scene/scale.h +++ b/include/openspace/scene/scale.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/scene/scene.h b/include/openspace/scene/scene.h index cfaae6e160..f9bfbf4e4e 100644 --- a/include/openspace/scene/scene.h +++ b/include/openspace/scene/scene.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/scene/scenegraphnode.h b/include/openspace/scene/scenegraphnode.h index eab4fd6ee6..86bffe0658 100644 --- a/include/openspace/scene/scenegraphnode.h +++ b/include/openspace/scene/scenegraphnode.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -183,14 +183,14 @@ private: std::unique_ptr _timeFrame; // Cached transform data - glm::dvec3 _worldPositionCached; - glm::dmat3 _worldRotationCached; + glm::dvec3 _worldPositionCached = glm::dvec3(0.0); + glm::dmat3 _worldRotationCached = glm::dmat3(1.0); double _worldScaleCached = 1.0; float _fixedBoundingSphere = 0.f; - glm::dmat4 _modelTransformCached; - glm::dmat4 _inverseModelTransformCached; + glm::dmat4 _modelTransformCached = glm::dmat4(1.0); + glm::dmat4 _inverseModelTransformCached = glm::dmat4(1.0); properties::BoolProperty _computeScreenSpaceValues; properties::IVec2Property _screenSpacePosition; diff --git a/include/openspace/scene/sceneinitializer.h b/include/openspace/scene/sceneinitializer.h index 2dd30fc6a3..eb1a4e4c6b 100644 --- a/include/openspace/scene/sceneinitializer.h +++ b/include/openspace/scene/sceneinitializer.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/scene/scenelicense.h b/include/openspace/scene/scenelicense.h index d2a6e9a822..297ee415a8 100644 --- a/include/openspace/scene/scenelicense.h +++ b/include/openspace/scene/scenelicense.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/scene/scenelicensewriter.h b/include/openspace/scene/scenelicensewriter.h index 59270476ab..00a056f85a 100644 --- a/include/openspace/scene/scenelicensewriter.h +++ b/include/openspace/scene/scenelicensewriter.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/scene/timeframe.h b/include/openspace/scene/timeframe.h index 41044f63b8..95d5aff38c 100644 --- a/include/openspace/scene/timeframe.h +++ b/include/openspace/scene/timeframe.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/scene/translation.h b/include/openspace/scene/translation.h index da506d0f56..9a027f1e07 100644 --- a/include/openspace/scene/translation.h +++ b/include/openspace/scene/translation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/scripting/lualibrary.h b/include/openspace/scripting/lualibrary.h index 4c2ff7c663..275d485adc 100644 --- a/include/openspace/scripting/lualibrary.h +++ b/include/openspace/scripting/lualibrary.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/scripting/scriptengine.h b/include/openspace/scripting/scriptengine.h index 0ca40db7f0..8914527778 100644 --- a/include/openspace/scripting/scriptengine.h +++ b/include/openspace/scripting/scriptengine.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -50,7 +50,7 @@ namespace openspace::scripting { */ class ScriptEngine : public Syncable, public DocumentationGenerator { public: - using ScriptCallback = std::optional>; + using ScriptCallback = std::function; BooleanType(RemoteScripting); struct QueueItem { diff --git a/include/openspace/scripting/scriptscheduler.h b/include/openspace/scripting/scriptscheduler.h index 9a93cc986c..98327cf41e 100644 --- a/include/openspace/scripting/scriptscheduler.h +++ b/include/openspace/scripting/scriptscheduler.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/scripting/systemcapabilitiesbinding.h b/include/openspace/scripting/systemcapabilitiesbinding.h index a81c7281f9..af4e524fe9 100644 --- a/include/openspace/scripting/systemcapabilitiesbinding.h +++ b/include/openspace/scripting/systemcapabilitiesbinding.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/blockplaneintersectiongeometry.h b/include/openspace/util/blockplaneintersectiongeometry.h index 9f3d787d05..e4f4703f8b 100644 --- a/include/openspace/util/blockplaneintersectiongeometry.h +++ b/include/openspace/util/blockplaneintersectiongeometry.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -47,12 +47,11 @@ public: private: void updateVertices(); std::vector _vertices; - // bool _isInitialized; GLuint _vaoId = 0; GLuint _vBufferId = 0; - glm::vec3 _size; - glm::vec3 _normal; - float _planeDistance; + glm::vec3 _size = glm::vec3(0.f); + glm::vec3 _normal = glm::vec3(0.f); + float _planeDistance = 0.f; }; } // namespace openspace diff --git a/include/openspace/util/boxgeometry.h b/include/openspace/util/boxgeometry.h index 6f694cae2b..9d42e83d1f 100644 --- a/include/openspace/util/boxgeometry.h +++ b/include/openspace/util/boxgeometry.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -41,7 +41,7 @@ public: GLuint _vaoId = 0; GLuint _vBufferId = 0; - glm::vec3 _size; + glm::vec3 _size = glm::vec3(0.f); }; } // namespace openspace diff --git a/include/openspace/util/camera.h b/include/openspace/util/camera.h index 8131d04191..0ea6ca7285 100644 --- a/include/openspace/util/camera.h +++ b/include/openspace/util/camera.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -25,7 +25,6 @@ #ifndef __OPENSPACE_CORE___CAMERA___H__ #define __OPENSPACE_CORE___CAMERA___H__ -#include #include #include #include @@ -36,7 +35,6 @@ class SceneGraphNode; /** * This class still needs some more love. Suggested improvements: - * - Remove psc from the camera class interface. * - Accessors should return constant references to double precision class members. * - Remove the scaling variable (What is it used for?) * - Remove the maxFov and sinMaxfov variables. Redundant since the fov is embedded @@ -60,9 +58,8 @@ public: */ template struct Cached { - Cached() { isDirty = true; } - T datum; - bool isDirty; + T datum = T(0); + bool isDirty = true; }; Camera() = default; @@ -101,7 +98,6 @@ public: // Right now this function returns the actual combined matrix which makes some // of the old calls to the function wrong.. const glm::dmat4& combinedViewMatrix() const; - const glm::dmat4& combinedViewMatrixNoScale() const; void invalidateCache(); @@ -128,9 +124,9 @@ public: SgctInternal() = default; SgctInternal(const SgctInternal& o); - glm::mat4 _sceneMatrix; - glm::mat4 _viewMatrix; - glm::mat4 _projectionMatrix; + glm::mat4 _sceneMatrix = glm::mat4(1.f); + glm::mat4 _viewMatrix = glm::mat4(1.f); + glm::mat4 _projectionMatrix = glm::mat4(1.f); mutable Cached _cachedViewProjectionMatrix; mutable std::mutex _mutex; @@ -158,7 +154,7 @@ private: SceneGraphNode* _parent = nullptr; // _focusPosition to be removed - glm::dvec3 _focusPosition; + glm::dvec3 _focusPosition = glm::dvec3(0.0); float _maxFov = 0.f; // Cached data diff --git a/include/openspace/util/concurrentjobmanager.h b/include/openspace/util/concurrentjobmanager.h index effd5497a2..ddb4331294 100644 --- a/include/openspace/util/concurrentjobmanager.h +++ b/include/openspace/util/concurrentjobmanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/concurrentjobmanager.inl b/include/openspace/util/concurrentjobmanager.inl index 14588f215c..f53897d514 100644 --- a/include/openspace/util/concurrentjobmanager.inl +++ b/include/openspace/util/concurrentjobmanager.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/concurrentqueue.h b/include/openspace/util/concurrentqueue.h index dedaad7c5c..83d7a1aa62 100644 --- a/include/openspace/util/concurrentqueue.h +++ b/include/openspace/util/concurrentqueue.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/concurrentqueue.inl b/include/openspace/util/concurrentqueue.inl index 3392bd7cac..4f150dda2c 100644 --- a/include/openspace/util/concurrentqueue.inl +++ b/include/openspace/util/concurrentqueue.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/distanceconstants.h b/include/openspace/util/distanceconstants.h index 104f14c97e..8bb599cc04 100644 --- a/include/openspace/util/distanceconstants.h +++ b/include/openspace/util/distanceconstants.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/distanceconversion.h b/include/openspace/util/distanceconversion.h index 7a2e2e7ceb..fb37657915 100644 --- a/include/openspace/util/distanceconversion.h +++ b/include/openspace/util/distanceconversion.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/factorymanager.h b/include/openspace/util/factorymanager.h index d68299190f..3edc713b5f 100644 --- a/include/openspace/util/factorymanager.h +++ b/include/openspace/util/factorymanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/factorymanager.inl b/include/openspace/util/factorymanager.inl index bdb85d82c3..0718c3be15 100644 --- a/include/openspace/util/factorymanager.inl +++ b/include/openspace/util/factorymanager.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/histogram.h b/include/openspace/util/histogram.h index 268ad86f4a..92e21898a0 100644 --- a/include/openspace/util/histogram.h +++ b/include/openspace/util/histogram.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/httprequest.h b/include/openspace/util/httprequest.h index 785b4335f5..11744e8e4e 100644 --- a/include/openspace/util/httprequest.h +++ b/include/openspace/util/httprequest.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/job.h b/include/openspace/util/job.h index f7946eaf4a..bce9134c69 100644 --- a/include/openspace/util/job.h +++ b/include/openspace/util/job.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/keys.h b/include/openspace/util/keys.h index 8b6057c6f6..4bcb0b8e23 100644 --- a/include/openspace/util/keys.h +++ b/include/openspace/util/keys.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/mouse.h b/include/openspace/util/mouse.h index 8e9803afc5..a215afa244 100644 --- a/include/openspace/util/mouse.h +++ b/include/openspace/util/mouse.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/openspacemodule.h b/include/openspace/util/openspacemodule.h index 8de0407c82..c1f5a2603e 100644 --- a/include/openspace/util/openspacemodule.h +++ b/include/openspace/util/openspacemodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/powerscaledcoordinate.h b/include/openspace/util/powerscaledcoordinate.h deleted file mode 100644 index 64f258940c..0000000000 --- a/include/openspace/util/powerscaledcoordinate.h +++ /dev/null @@ -1,114 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2019 * - * * - * 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_CORE___POWERSCALEDCOORDINATE___H__ -#define __OPENSPACE_CORE___POWERSCALEDCOORDINATE___H__ - -#include - -namespace openspace { - -class PowerScaledScalar; - -class PowerScaledCoordinate { -public: - // constructors - PowerScaledCoordinate() = default; - - PowerScaledCoordinate(PowerScaledCoordinate&& rhs); - PowerScaledCoordinate(const PowerScaledCoordinate& rhs); - - // Sets the power scaled coordinates directly - PowerScaledCoordinate(glm::vec4 v); - PowerScaledCoordinate(float f1, float f2, float f3, float f4); - // Sets the power scaled coordinates with w = 0 - PowerScaledCoordinate(glm::vec3 v); - - static PowerScaledCoordinate CreatePowerScaledCoordinate(double d1, double d2, - double d3); - - // get functions - // return the full, unmodified PSC - const glm::vec4& vec4() const; - - // returns the rescaled, "normal" coordinates - glm::vec3 vec3() const; - - // return the full psc as dvec4() - glm::dvec4 dvec4() const; - - // rescaled return as dvec3 - glm::dvec3 dvec3() const; - - // length of the vector as a pss - float length() const; - glm::vec3 direction() const; - - // operator overloading - PowerScaledCoordinate& operator=(const PowerScaledCoordinate& rhs); - PowerScaledCoordinate& operator=(PowerScaledCoordinate&& rhs); - PowerScaledCoordinate& operator+=(const PowerScaledCoordinate& rhs); - PowerScaledCoordinate operator+(const PowerScaledCoordinate& rhs) const; - PowerScaledCoordinate& operator-=(const PowerScaledCoordinate& rhs); - PowerScaledCoordinate operator-(const PowerScaledCoordinate& rhs) const; - float& operator[](unsigned int idx); - float operator[](unsigned int idx) const; - double dot(const PowerScaledCoordinate& rhs) const; - double angle(const PowerScaledCoordinate& rhs) const; - - // scalar operators - PowerScaledCoordinate operator*(const double& rhs) const; - PowerScaledCoordinate operator*(const float& rhs) const; - PowerScaledCoordinate operator*(const glm::mat4& matrix) const; - - - // comparison - bool operator==(const PowerScaledCoordinate& other) const; - bool operator!=(const PowerScaledCoordinate& other) const; - bool operator<(const PowerScaledCoordinate& other) const; - bool operator>(const PowerScaledCoordinate& other) const; - bool operator<=(const PowerScaledCoordinate& other) const; - bool operator>=(const PowerScaledCoordinate& other) const; - - // glm integration - PowerScaledCoordinate& operator=(const glm::dvec4& rhs); - PowerScaledCoordinate& operator=(const glm::vec4& rhs); - PowerScaledCoordinate& operator=(const glm::dvec3& rhs); - PowerScaledCoordinate& operator=(const glm::vec3& rhs); - - friend std::ostream& operator<<(std::ostream& os, const PowerScaledCoordinate& rhs); - - // allow the power scaled scalars to access private members - friend class PowerScaledScalar; - -private: - // internal glm vector - glm::vec4 _vec = glm::vec4(0.f); -}; - -typedef PowerScaledCoordinate psc; - -} // namespace openspace - -#endif // __OPENSPACE_CORE___POWERSCALEDCOORDINATE___H__ diff --git a/include/openspace/util/progressbar.h b/include/openspace/util/progressbar.h index 293401e83c..8667500c9e 100644 --- a/include/openspace/util/progressbar.h +++ b/include/openspace/util/progressbar.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/resourcesynchronization.h b/include/openspace/util/resourcesynchronization.h index a7e4bcf367..605f049dc1 100644 --- a/include/openspace/util/resourcesynchronization.h +++ b/include/openspace/util/resourcesynchronization.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/screenlog.h b/include/openspace/util/screenlog.h index 29d4890872..c6ded67ff1 100644 --- a/include/openspace/util/screenlog.h +++ b/include/openspace/util/screenlog.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/powerscaledsphere.h b/include/openspace/util/sphere.h similarity index 84% rename from include/openspace/util/powerscaledsphere.h rename to include/openspace/util/sphere.h index 8be00b6f0b..a0e1557b63 100644 --- a/include/openspace/util/powerscaledsphere.h +++ b/include/openspace/util/sphere.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -22,22 +22,20 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_CORE___POWERSCALEDSPHERE___H__ -#define __OPENSPACE_CORE___POWERSCALEDSPHERE___H__ +#ifndef __OPENSPACE_CORE___SPHERE___H__ +#define __OPENSPACE_CORE___SPHERE___H__ #include #include namespace openspace { -class PowerScaledSphere; - -class PowerScaledSphere { +class Sphere { public: - PowerScaledSphere(float radius, int segments = 8); - PowerScaledSphere(glm::vec3 radius, int segments); - PowerScaledSphere(const PowerScaledSphere& cpy); - ~PowerScaledSphere(); + Sphere(float radius, int segments = 8); + Sphere(glm::vec3 radius, int segments); + Sphere(const Sphere& cpy); + ~Sphere(); bool initialize(); @@ -62,4 +60,4 @@ public: } // namespace openspace -#endif // __OPENSPACE_CORE___POWERSCALEDSPHERE___H__ +#endif // __OPENSPACE_CORE___SPHERE___H__ diff --git a/include/openspace/util/spicemanager.h b/include/openspace/util/spicemanager.h index 8aab7b6094..e7afb7aaab 100644 --- a/include/openspace/util/spicemanager.h +++ b/include/openspace/util/spicemanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -566,23 +566,23 @@ public: * The closest surface intercept point on the target body in Cartesian Coordinates * relative to the reference frame. */ - glm::dvec3 surfaceIntercept; + glm::dvec3 surfaceIntercept = glm::dvec3(0.0); /** * If the aberration correction is not AberrationCorrection::Type::None, this * value contains the time for which the intercept was computed. Otherwise it is * the same as the ephemerisTime. */ - double interceptEpoch; + double interceptEpoch = 0.0; /** * The vector from the observer's position to the \p surfaceIntercept position in * the provided reference frame. */ - glm::dvec3 surfaceVector; + glm::dvec3 surfaceVector = glm::dvec3(0.0); /// true if the ray intersects the body, false otherwise - bool interceptFound; + bool interceptFound = false; }; /** @@ -652,47 +652,17 @@ public: FieldOfViewMethod method, AberrationCorrection aberrationCorrection, double& ephemerisTime) const; - /** - * Determine whether a specific \p target is in the field-of-view of a specified - * \p instrument or an \p observer at a given time. The reference frame used is - * derived from the \p target by converting it into an \c IAU inertial reference - * frame. - * - * \param target The name or NAIF ID code string of the target - * \param observer The name or NAIF ID code string of the observer - * \param instrument The name or NAIF ID code string of the instrument - * \param method The type of shape model used for the target - * \param aberrationCorrection The aberration correction method - * \param ephemerisTime Time of the observation (seconds past J2000) - * \return \c true if the target is visible, \c false otherwise - * - * \throw SpiceException If the \p target or \p observer do not name valid - * NAIF objects, the \p target or \p observer name the same NAIF object, the - * \p instrument does not name a valid NAIF object, or insufficient kernel - * information has been loaded. - * \pre \p target must not be empty. - * \pre \p observer must not be empty. - * \pre \p target and \p observer must not be different strings - * \pre \p referenceFrame must not be empty. - * \pre \p instrument must not be empty. - * - * \sa http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/fovtrg_c.html - */ - bool isTargetInFieldOfView(const std::string& target, const std::string& observer, - const std::string& instrument, FieldOfViewMethod method, - AberrationCorrection aberrationCorrection, double& ephemerisTime) const; - /// Struct that is used as the return value from the #targetState method struct TargetStateResult { /// The target position - glm::dvec3 position; + glm::dvec3 position = glm::dvec3(0.0); /// The target velocity - glm::dvec3 velocity; + glm::dvec3 velocity = glm::dvec3(0.0); /// One-way light time between target and observer if /// the aberration correction is enabled - double lightTime; + double lightTime = 0.0; }; /** @@ -810,7 +780,7 @@ public: std::string frameName; /// The direction towards the center of the field of view - glm::dvec3 boresightVector; + glm::dvec3 boresightVector = glm::dvec3(0.0); /// The corners of the field of view's bounding box, not necessarily unit vectors std::vector bounds; @@ -852,14 +822,14 @@ public: struct TerminatorEllipseResult { /// The vector from the target body at #targetEphemerisTime to the observer at /// the original time - glm::dvec3 observerPosition; + glm::dvec3 observerPosition = glm::dvec3(0.0); /// The full list of terminator points specified in the original reference frame std::vector terminatorPoints; /// The local ephemeris time at the target, determined by the original /// aberrationCorrection factor - double targetEphemerisTime; + double targetEphemerisTime = 0.0; }; /** @@ -902,26 +872,6 @@ public: AberrationCorrection aberrationCorrection, double ephemerisTime, int numberOfTerminatorPoints); - /** - * This function adds a frame to a body. - * - * \param body - the name of the body - * \param frame - the name of the frame - * \return false if the arguments are empty - * - * \todo I think this function should die ---abock - */ - bool addFrame(std::string body, std::string frame); - - /** - * This function returns the frame of a body if defined, otherwise it returns - * IAU_ + body (most frames are known by the International Astronomical Union) - * \param body - the name of the body - * \return the frame of the body - * \todo I think this function should die ---abock - */ - std::string frameFromBody(const std::string& body) const; - /** * Sets the SpiceManager's exception handling. If UseException::No is passed to this * function, all subsequent calls will not throw an error, but fail silently instead. @@ -1048,8 +998,6 @@ private: std::map>> _spkIntervals; std::map> _ckCoverageTimes; std::map> _spkCoverageTimes; - // Vector of pairs: Body, Frame - std::vector> _frameByBody; /// Stores whether the SpiceManager throws exceptions (Yes) or fails silently (No) UseException _useExceptions = UseException::Yes; diff --git a/include/openspace/util/syncable.h b/include/openspace/util/syncable.h index 762546fdcb..f3c19e7afd 100644 --- a/include/openspace/util/syncable.h +++ b/include/openspace/util/syncable.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/syncbuffer.h b/include/openspace/util/syncbuffer.h index 8d8f5bb7e7..4f2a7ed370 100644 --- a/include/openspace/util/syncbuffer.h +++ b/include/openspace/util/syncbuffer.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/syncbuffer.inl b/include/openspace/util/syncbuffer.inl index 99860e7bdc..fcac31e1e5 100644 --- a/include/openspace/util/syncbuffer.inl +++ b/include/openspace/util/syncbuffer.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/syncdata.h b/include/openspace/util/syncdata.h index 1e2022d2fb..7f3552c5a5 100644 --- a/include/openspace/util/syncdata.h +++ b/include/openspace/util/syncdata.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/syncdata.inl b/include/openspace/util/syncdata.inl index 9352b56334..b0a39e4ae0 100644 --- a/include/openspace/util/syncdata.inl +++ b/include/openspace/util/syncdata.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/synchronizationwatcher.h b/include/openspace/util/synchronizationwatcher.h index 46cc9c2b23..fe8bac8e40 100644 --- a/include/openspace/util/synchronizationwatcher.h +++ b/include/openspace/util/synchronizationwatcher.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/task.h b/include/openspace/util/task.h index 97cbd32b7d..ef7e280dcd 100644 --- a/include/openspace/util/task.h +++ b/include/openspace/util/task.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/taskloader.h b/include/openspace/util/taskloader.h index e484aa65d1..6a598df9e5 100644 --- a/include/openspace/util/taskloader.h +++ b/include/openspace/util/taskloader.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/threadpool.h b/include/openspace/util/threadpool.h index de91dd9863..ba596fc732 100644 --- a/include/openspace/util/threadpool.h +++ b/include/openspace/util/threadpool.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/time.h b/include/openspace/util/time.h index d784ac2426..d98cd896cb 100644 --- a/include/openspace/util/time.h +++ b/include/openspace/util/time.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/timeconversion.h b/include/openspace/util/timeconversion.h index 19f5f1e984..0ec2feca49 100644 --- a/include/openspace/util/timeconversion.h +++ b/include/openspace/util/timeconversion.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/timeline.h b/include/openspace/util/timeline.h index 81f2a9687b..ea2b31f135 100644 --- a/include/openspace/util/timeline.h +++ b/include/openspace/util/timeline.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/timeline.inl b/include/openspace/util/timeline.inl index d2811a6aee..5ceae3d875 100644 --- a/include/openspace/util/timeline.inl +++ b/include/openspace/util/timeline.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/timemanager.h b/include/openspace/util/timemanager.h index 523ec5da5b..6a29f82faa 100644 --- a/include/openspace/util/timemanager.h +++ b/include/openspace/util/timemanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/timerange.h b/include/openspace/util/timerange.h index 47e40ccbb9..8b56bfb996 100644 --- a/include/openspace/util/timerange.h +++ b/include/openspace/util/timerange.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/tests/test_iswamanager.inl b/include/openspace/util/touch.h similarity index 54% rename from tests/test_iswamanager.inl rename to include/openspace/util/touch.h index 8275b485d3..cb9a6e71da 100644 --- a/tests/test_iswamanager.inl +++ b/include/openspace/util/touch.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -22,66 +22,67 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifdef OPENSPACE_MODULE_ISWA_ENABLED +#ifndef __OPENSPACE_CORE___TOUCH___H__ +#define __OPENSPACE_CORE___TOUCH___H__ -#define private public -#include -#define private private +#include -#include -#include - - -/* - * For each test the following is run: - * Constructor() -> setUp() -> test -> tearDown() -> Deconstructor() - */ +#include +#include namespace openspace { -class IswaManagerTest : public testing::Test { -protected: +struct TouchInput { + TouchInput(size_t touchDeviceId, size_t fingerId, float x, float y, double timestamp); + glm::vec2 screenCoordinates(glm::vec2 resolution) const; + glm::vec2 currentWindowCoordinates() const; + bool isMoving() const; + float distanceToPos(float otherX, float otherY) const; + float angleToPos(float otherX, float otherY) const; - IswaManagerTest() - : _downloadManager("", 0) - { - IswaManager::initialize(); - } - - ~IswaManagerTest() { - IswaManager::deinitialize(); - } - - void reset() {} - - DownloadManager _downloadManager; + size_t touchDeviceId; + size_t fingerId; + float x; + float y; + float dx = 0.f; // movement in x direction since last touch input + float dy = 0.f; // movement in y direction since last touch input + double timestamp; // timestamp in seconds from global touch initialization }; -TEST_F(IswaManagerTest, initialize){ - IswaManager::deinitialize(); +class TouchInputHolder { +public: + TouchInputHolder(TouchInput input); - ASSERT_FALSE(IswaManager::isInitialized()) << "IswaManager is initialized before initialize call"; + // tryAddInput: + // Succeeds upon a different input than last. + // Fails upon a too similar input as last. + bool tryAddInput(TouchInput input); + void clearInputs(); - IswaManager::initialize(); + bool holdsInput(const TouchInput &input) const; - ASSERT_TRUE(IswaManager::isInitialized()) << "IswaManager is not initialized after initialize call"; + size_t touchDeviceId() const; + size_t fingerId() const; - ASSERT_NE(&IswaManager::ref(), nullptr) << "IswaManager ref() is not a nullptr"; + float speedX() const; + float speedY() const; - EXPECT_EQ(&IswaManager::ref(), &IswaManager::ref()) << "IswaManager ref() returns the same object twice"; -} + bool isMoving() const; + float gestureDistance() const; + double gestureTime() const; -TEST_F(IswaManagerTest, iswaUrl){ + size_t numInputs() const; + const TouchInput& latestInput() const; + const std::deque& peekInputs() const; - //OsEng.loadSpiceKernels(); - //Time::ref().setTime(double(100000.0)); - //Time::ref().preSynchronization(); - //Time::ref().postSynchronizationPreDraw(); - //std::string url = ISWAManager::ref().iSWAurl(7); - //std::string expectedUrl = "http://iswa2.ccmc.gsfc.nasa.gov/IswaSystemWebApp/iSWACygnetStreamer?timestamp=2000-01-02%2015:45:35&window=-1&cygnetId=7"; +private: + //A deque of recorded inputs. Adding newer points to the front of the queue + std::deque _inputs; - //EXPECT_EQ(expectedUrl, url); -} + size_t _touchDeviceId; + size_t _fingerId; +}; -}//namespace openspace -#endif +} // namespace openspace + +#endif // __OPENSPACE_CORE___TOUCH___H__ diff --git a/include/openspace/util/transformationmanager.h b/include/openspace/util/transformationmanager.h index 50066f601e..abd1361351 100644 --- a/include/openspace/util/transformationmanager.h +++ b/include/openspace/util/transformationmanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/include/openspace/util/updatestructures.h b/include/openspace/util/updatestructures.h index f6ecef64a4..0e5281554f 100644 --- a/include/openspace/util/updatestructures.h +++ b/include/openspace/util/updatestructures.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -26,7 +26,6 @@ #define __OPENSPACE_CORE___UPDATESTRUCTURES___H__ #include -#include #include namespace openspace { @@ -37,9 +36,9 @@ class VolumeRaycaster; struct InitializeData {}; struct TransformData { - glm::dvec3 translation; - glm::dmat3 rotation; - double scale; + glm::dvec3 translation = glm::dvec3(0.0); + glm::dmat3 rotation = glm::dmat3(1.0); + double scale = 0.0; }; struct UpdateData { @@ -52,8 +51,8 @@ struct UpdateData { struct RenderData { const Camera& camera; const Time time; - bool doPerformanceMeasurement; - int renderBinMask; + bool doPerformanceMeasurement = false; + int renderBinMask = -1; TransformData modelTransform; }; @@ -73,12 +72,12 @@ struct RendererTasks { }; struct RaycastData { - int id; + int id = -1; std::string namespaceName; }; struct DeferredcastData { - int id; + int id = -1; std::string namespaceName; }; @@ -88,13 +87,13 @@ struct DeferredcastData { */ struct SurfacePositionHandle { /// Vector from the center of the object to the reference surface of the object - glm::dvec3 centerToReferenceSurface; + glm::dvec3 centerToReferenceSurface = glm::dvec3(0.0); /// Direction out from the reference. Can conincide with the surface normal but does /// not have to. - glm::dvec3 referenceSurfaceOutDirection; + glm::dvec3 referenceSurfaceOutDirection = glm::dvec3(0.0); /// Height from the reference surface out to the actual surface in the direction of /// the surface normal. Can be positive or negative. - double heightToSurface; + double heightToSurface = 0.0; }; } // namespace openspace diff --git a/include/openspace/util/versionchecker.h b/include/openspace/util/versionchecker.h index 4d3776dd46..fb4c513e45 100644 --- a/include/openspace/util/versionchecker.h +++ b/include/openspace/util/versionchecker.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/CMakeLists.txt b/modules/atmosphere/CMakeLists.txt index 4cb7e5ebbe..68f88ebda5 100644 --- a/modules/atmosphere/CMakeLists.txt +++ b/modules/atmosphere/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2018 # +# Copyright (c) 2014-2020 # # # # 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 # diff --git a/modules/atmosphere/atmospheremodule.cpp b/modules/atmosphere/atmospheremodule.cpp index 2d56790860..94fb594ef0 100644 --- a/modules/atmosphere/atmospheremodule.cpp +++ b/modules/atmosphere/atmospheremodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/atmospheremodule.h b/modules/atmosphere/atmospheremodule.h index f7100dd181..6b89bc761f 100644 --- a/modules/atmosphere/atmospheremodule.h +++ b/modules/atmosphere/atmospheremodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp index 3e5dec47ad..81a6d0bfaf 100644 --- a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp +++ b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -60,7 +60,6 @@ #include #include -#include #include #include #include @@ -116,58 +115,6 @@ namespace { namespace openspace { -AtmosphereDeferredcaster::AtmosphereDeferredcaster() - : _transmittanceProgramObject(nullptr) - , _irradianceProgramObject(nullptr) - , _irradianceSupTermsProgramObject(nullptr) - , _irradianceFinalProgramObject(nullptr) - , _inScatteringProgramObject(nullptr) - , _inScatteringSupTermsProgramObject(nullptr) - , _deltaEProgramObject(nullptr) - , _deltaSProgramObject(nullptr) - , _deltaSSupTermsProgramObject(nullptr) - , _deltaJProgramObject(nullptr) - , _atmosphereProgramObject(nullptr) - , _transmittanceTableTexture(0) - , _irradianceTableTexture(0) - , _inScatteringTableTexture(0) - , _deltaETableTexture(0) - , _deltaSRayleighTableTexture(0) - , _deltaSMieTableTexture(0) - , _deltaJTableTexture(0) - , _atmosphereTexture(0) - , _atmosphereCalculated(false) - , _ozoneEnabled(false) - , _sunFollowingCameraEnabled(false) - , _atmosphereRadius(0.f) - , _atmospherePlanetRadius(0.f) - , _planetAverageGroundReflectance(0.f) - , _planetGroundRadianceEmittion(0.f) - , _rayleighHeightScale(0.f) - , _ozoneHeightScale(0.f) - , _mieHeightScale(0.f) - , _miePhaseConstant(0.f) - , _sunRadianceIntensity(5.f) - , _rayleighScatteringCoeff(glm::vec3(0.f)) - , _ozoneExtinctionCoeff(glm::vec3(0.f)) - , _mieScatteringCoeff(glm::vec3(0.f)) - , _mieExtinctionCoeff(glm::vec3(0.f)) - , _ellipsoidRadii(glm::dvec3(0.0)) - , _transmittance_table_width(256) - , _transmittance_table_height(64) - , _irradiance_table_width(64) - , _irradiance_table_height(16) - , _delta_e_table_width(64) - , _delta_e_table_height(16) - , _r_samples(32) - , _mu_samples(128) - , _mu_s_samples(32) - , _nu_samples(8) - , _hardShadowsEnabled(false) - , _calculationTextureScale(1.0) - , _saveCalculationTextures(false) -{} - void AtmosphereDeferredcaster::initialize() { if (!_atmosphereCalculated) { preCalculateAtmosphereParam(); diff --git a/modules/atmosphere/rendering/atmospheredeferredcaster.h b/modules/atmosphere/rendering/atmospheredeferredcaster.h index 6c0af90d37..80da5a2a6c 100644 --- a/modules/atmosphere/rendering/atmospheredeferredcaster.h +++ b/modules/atmosphere/rendering/atmospheredeferredcaster.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -47,7 +47,6 @@ struct ShadowConfiguration; class AtmosphereDeferredcaster : public Deferredcaster { public: - AtmosphereDeferredcaster(); virtual ~AtmosphereDeferredcaster() = default; void initialize(); @@ -140,61 +139,61 @@ private: hardShadows, transmittanceTexture, irradianceTexture, inscatterTexture) _uniformCache2; - GLuint _transmittanceTableTexture; - GLuint _irradianceTableTexture; - GLuint _inScatteringTableTexture; - GLuint _deltaETableTexture; - GLuint _deltaSRayleighTableTexture; - GLuint _deltaSMieTableTexture; - GLuint _deltaJTableTexture; - GLuint _atmosphereTexture; + GLuint _transmittanceTableTexture = 0; + GLuint _irradianceTableTexture = 0; + GLuint _inScatteringTableTexture = 0; + GLuint _deltaETableTexture = 0; + GLuint _deltaSRayleighTableTexture = 0; + GLuint _deltaSMieTableTexture = 0; + GLuint _deltaJTableTexture = 0; + GLuint _atmosphereTexture = 0; ghoul::opengl::TextureUnit _transmittanceTableTextureUnit; ghoul::opengl::TextureUnit _irradianceTableTextureUnit; ghoul::opengl::TextureUnit _inScatteringTableTextureUnit; // Atmosphere Data - bool _atmosphereCalculated; - bool _ozoneEnabled; - bool _sunFollowingCameraEnabled; - float _atmosphereRadius; - float _atmospherePlanetRadius; - float _planetAverageGroundReflectance; - float _planetGroundRadianceEmittion; - float _rayleighHeightScale; - float _ozoneHeightScale; - float _mieHeightScale; - float _miePhaseConstant; - float _sunRadianceIntensity; + bool _atmosphereCalculated = false; + bool _ozoneEnabled = false; + bool _sunFollowingCameraEnabled = false; + float _atmosphereRadius = 0.f; + float _atmospherePlanetRadius = 0.f; + float _planetAverageGroundReflectance = 0.f; + float _planetGroundRadianceEmittion = 0.f; + float _rayleighHeightScale = 0.f; + float _ozoneHeightScale = 0.f; + float _mieHeightScale = 0.f; + float _miePhaseConstant = 0.f; + float _sunRadianceIntensity = 5.f; - glm::vec3 _rayleighScatteringCoeff; - glm::vec3 _ozoneExtinctionCoeff; - glm::vec3 _mieScatteringCoeff; - glm::vec3 _mieExtinctionCoeff; - glm::dvec3 _ellipsoidRadii; + glm::vec3 _rayleighScatteringCoeff = glm::vec3(0.f); + glm::vec3 _ozoneExtinctionCoeff = glm::vec3(0.f); + glm::vec3 _mieScatteringCoeff = glm::vec3(0.f); + glm::vec3 _mieExtinctionCoeff = glm::vec3(0.f); + glm::dvec3 _ellipsoidRadii = glm::vec3(0.f); // Atmosphere Textures Dimmensions - int _transmittance_table_width; - int _transmittance_table_height; - int _irradiance_table_width; - int _irradiance_table_height; - int _delta_e_table_width; - int _delta_e_table_height; - int _r_samples; - int _mu_samples; - int _mu_s_samples; - int _nu_samples; + int _transmittance_table_width = 256; + int _transmittance_table_height = 64; + int _irradiance_table_width = 64; + int _irradiance_table_height = 16; + int _delta_e_table_width = 64; + int _delta_e_table_height = 16; + int _r_samples = 32; + int _mu_samples = 128; + int _mu_s_samples = 32; + int _nu_samples = 8; glm::dmat4 _modelTransform; double _time = 0.0; // Eclipse Shadows std::vector _shadowConfArray; - bool _hardShadowsEnabled; + bool _hardShadowsEnabled = false; // Atmosphere Debugging - float _calculationTextureScale; - bool _saveCalculationTextures; + float _calculationTextureScale = 1.f; + bool _saveCalculationTextures = false; }; } // openspace diff --git a/modules/atmosphere/rendering/renderableatmosphere.cpp b/modules/atmosphere/rendering/renderableatmosphere.cpp index fd931c251f..671cc2c3c9 100644 --- a/modules/atmosphere/rendering/renderableatmosphere.cpp +++ b/modules/atmosphere/rendering/renderableatmosphere.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -254,27 +254,6 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary) , _sunIntensityP(SunIntensityInfo, 50.0f, 0.1f, 1000.0f) , _sunFollowingCameraEnabledP(EnableSunOnCameraPositionInfo, false) , _hardShadowsEnabledP(EclipseHardShadowsInfo, false) - , _atmosphereEnabled(false) - , _ozoneLayerEnabled(false) - , _sunFollowingCameraEnabled(false) - , _atmosphereRadius(0.f) - , _atmospherePlanetRadius(0.f) - , _planetAverageGroundReflectance(0.f) - , _planetGroundRadianceEmittion(0.f) - , _rayleighHeightScale(0.f) - , _ozoneHeightScale(0.f) - , _mieHeightScale(0.f) - , _miePhaseConstant(0.f) - , _sunRadianceIntensity(5.f) - , _mieScattExtPropCoefProp(1.f) - , _mieExtinctionCoeff(glm::vec3(0.f)) - , _rayleighScatteringCoeff(glm::vec3(0.f)) - , _ozoneExtinctionCoeff(glm::vec3(0.f)) - , _mieScatteringCoeff(glm::vec3(0.f)) - , _saveCalculationsToTexture(false) - , _preCalculatedTexturesScale(1.0) - , _shadowEnabled(false) - , _hardShadows(false) { ghoul_precondition( dictionary.hasKeyAndValue(SceneGraphNode::KeyIdentifier), @@ -433,7 +412,7 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary) if (success) { // Not using right now. - glm::vec3 rayleighWavelengths; + glm::vec3 rayleighWavelengths = glm::vec3(0.f); rayleighDictionary.getValue( "Coefficients.Wavelengths", rayleighWavelengths @@ -452,8 +431,9 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary) } if (!rayleighDictionary.getValue( - keyRayleighHeightScale, - _rayleighHeightScale)) + keyRayleighHeightScale, + _rayleighHeightScale) + ) { errorReadingAtmosphereData = true; LWARNINGC( diff --git a/modules/atmosphere/rendering/renderableatmosphere.h b/modules/atmosphere/rendering/renderableatmosphere.h index 202933b593..a2cfa7f158 100644 --- a/modules/atmosphere/rendering/renderableatmosphere.h +++ b/modules/atmosphere/rendering/renderableatmosphere.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -59,13 +59,13 @@ struct ShadowConfiguration { }; struct ShadowRenderingStruct { - double xu; - double xp; - double rs; - double rc; - glm::dvec3 sourceCasterVec; - glm::dvec3 casterPositionVec; - bool isShadowing; + double xu = 0.0; + double xp = 0.0; + double rs = 0.0; + double rc = 0.0; + glm::dvec3 sourceCasterVec = glm::dvec3(0.0); + glm::dvec3 casterPositionVec = glm::dvec3(0.0); + bool isShadowing = false; }; namespace documentation { struct Documentation; } @@ -110,35 +110,35 @@ private: properties::BoolProperty _sunFollowingCameraEnabledP; properties::BoolProperty _hardShadowsEnabledP; - bool _atmosphereEnabled; - bool _ozoneLayerEnabled; - bool _sunFollowingCameraEnabled; - float _atmosphereRadius; - float _atmospherePlanetRadius; - float _planetAverageGroundReflectance; - float _planetGroundRadianceEmittion; - float _rayleighHeightScale; - float _ozoneHeightScale; - float _mieHeightScale; - float _miePhaseConstant; - float _sunRadianceIntensity; - float _mieScattExtPropCoefProp; + bool _atmosphereEnabled = false; + bool _ozoneLayerEnabled = false; + bool _sunFollowingCameraEnabled = false; + float _atmosphereRadius = 0.f; + float _atmospherePlanetRadius = 0.f; + float _planetAverageGroundReflectance = 0.f; + float _planetGroundRadianceEmittion = 0.f; + float _rayleighHeightScale = 0.f; + float _ozoneHeightScale = 0.f; + float _mieHeightScale = 0.f; + float _miePhaseConstant = 0.f; + float _sunRadianceIntensity = 5.f; + float _mieScattExtPropCoefProp = 1.f; - glm::vec3 _mieExtinctionCoeff; - glm::vec3 _rayleighScatteringCoeff; - glm::vec3 _ozoneExtinctionCoeff; - glm::vec3 _mieScatteringCoeff; + glm::vec3 _mieExtinctionCoeff = glm::vec3(0.f); + glm::vec3 _rayleighScatteringCoeff = glm::vec3(0.f); + glm::vec3 _ozoneExtinctionCoeff = glm::vec3(0.f); + glm::vec3 _mieScatteringCoeff = glm::dvec3(0.f); // Atmosphere Debug - bool _saveCalculationsToTexture; - float _preCalculatedTexturesScale; + bool _saveCalculationsToTexture = false; + float _preCalculatedTexturesScale = 1.f; std::unique_ptr _deferredcaster; - bool _shadowEnabled; - bool _hardShadows; + bool _shadowEnabled = false; + bool _hardShadows = false; - glm::dmat3 _stateMatrix; + glm::dmat3 _stateMatrix = glm::dmat3(1.0); std::vector _shadowConfArray; }; diff --git a/modules/atmosphere/shaders/atmosphere_common.glsl b/modules/atmosphere/shaders/atmosphere_common.glsl index 8be26b6e53..c806dfab8e 100644 --- a/modules/atmosphere/shaders/atmosphere_common.glsl +++ b/modules/atmosphere/shaders/atmosphere_common.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -125,7 +125,8 @@ vec3 analyticTransmittance(const float r, const float mu, const float d) { return exp(-betaRayleigh * opticalDepth(HR, r, mu, d) - betaOzoneExtinction * (0.0000006) * opticalDepth(HO, r, mu, d) - betaMieExtinction * opticalDepth(HM, r, mu, d)); - } else { + } + else { return exp(-betaRayleigh * opticalDepth(HR, r, mu, d) - betaMieExtinction * opticalDepth(HM, r, mu, d)); } @@ -315,7 +316,8 @@ vec3 transmittance(const float r, const float mu, const float d) { if (mu > 0.0f) { return min(transmittanceLUT(r, mu) / transmittanceLUT(ri, mui), 1.0f); - } else { + } + else { return min(transmittanceLUT(ri, -mui) / transmittanceLUT(r, -mu), 1.0f); } diff --git a/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl b/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl index d7a788322a..e9c3fdb17a 100644 --- a/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl +++ b/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -128,14 +128,16 @@ vec4 calcShadow(const ShadowRenderingStruct shadowInfoArray[numberOfShadows], co if (ground) { if (hardShadows) { return vec4(0.2, 0.2, 0.2, 1.0); - } else { + } + else { return butterworthFunc(length_d, r_u_pi, 4.0); } } else { if (hardShadows) { return vec4(0.5, 0.5, 0.5, 1.0); - } else { + } + else { return vec4(vec3(length_d/r_p_pi), 1.0); } } @@ -143,7 +145,8 @@ vec4 calcShadow(const ShadowRenderingStruct shadowInfoArray[numberOfShadows], co else if ( length_d < r_p_pi ) {// penumbra if (hardShadows) { return vec4(0.5, 0.5, 0.5, 1.0); - } else { + } + else { return vec4(vec3(length_d/r_p_pi), 1.0); } } @@ -212,7 +215,8 @@ bool dAtmosphereIntersection(const dvec3 planetPosition, const dRay ray, const d inside = false; offset = s - q; maxLength = s + q; - } else { + } + else { inside = true; offset = 0.0; maxLength = s + q; @@ -332,7 +336,8 @@ vec3 inscatterRadiance(inout vec3 x, inout float t, inout float irradianceFactor // We set the irradianceFactor to 1.0 so the reflected irradiance will be considered // when calculating the reflected light on the ground. irradianceFactor = 1.0; - } else { + } + else { attenuation = analyticTransmittance(r, mu, t); //attenuation = transmittance(r, mu, t); groundHit = false; @@ -412,13 +417,13 @@ vec3 inscatterRadiance(inout vec3 x, inout float t, inout float irradianceFactor if (groundHit) { return finalScatteringRadiance; - } else { + } + else { //return ((r-Rg) * invRtMinusRg)*spaceColor.rgb + finalScatteringRadiance; - return attenuation * spaceColor.rgb + finalScatteringRadiance; + return spaceColor.rgb + finalScatteringRadiance; // return attenuation * spaceColor.rgb + // (vec3(1.0) - attenuation) * finalScatteringRadiance; - } - + } } /* @@ -477,7 +482,8 @@ vec3 groundColor(const vec3 x, const float t, const vec3 v, const vec3 s, const vec3 RLStar = (muSun * transmittanceL0 + irradianceReflected) * sunIntensity / M_PI; if (dotNS < 0.05f) { groundRadiance = groundReflectance.rgb * mix(30.0f, 1.0f, smoothstep(-1.0f, 0.05f, dotNS)) * RLStar; - } else { + } + else { groundRadiance = groundReflectance.rgb * RLStar; } @@ -619,7 +625,8 @@ void main() { if (pixelDepth < offset) { // ATM Occluded - Something in fron of ATM. atmosphereFinalColor += color; - } else { + } + else { // Following paper nomenclature double t = offset; vec3 attenuation; @@ -659,7 +666,8 @@ void main() { groundColorV = groundColor(x, tF, v, s, r, mu, attenuation, color, normal.xyz, irradianceFactor, normal.a, sunIntensityGround); - } else { + } + else { // In order to get better performance, we are not tracing // multiple rays per pixel when the ray doesn't intersect // the ground. diff --git a/modules/atmosphere/shaders/atmosphere_deferred_vs.glsl b/modules/atmosphere/shaders/atmosphere_deferred_vs.glsl index 33f0eb1651..f211ee9b42 100644 --- a/modules/atmosphere/shaders/atmosphere_deferred_vs.glsl +++ b/modules/atmosphere/shaders/atmosphere_deferred_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaE_calc_fs.glsl b/modules/atmosphere/shaders/deltaE_calc_fs.glsl index b845c2ae67..6ce7053b56 100644 --- a/modules/atmosphere/shaders/deltaE_calc_fs.glsl +++ b/modules/atmosphere/shaders/deltaE_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaE_calc_vs.glsl b/modules/atmosphere/shaders/deltaE_calc_vs.glsl index a85594b7d2..fad2402e2a 100644 --- a/modules/atmosphere/shaders/deltaE_calc_vs.glsl +++ b/modules/atmosphere/shaders/deltaE_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaJ_calc_fs.glsl b/modules/atmosphere/shaders/deltaJ_calc_fs.glsl index 56114090c8..d39e6e2e15 100644 --- a/modules/atmosphere/shaders/deltaJ_calc_fs.glsl +++ b/modules/atmosphere/shaders/deltaJ_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -173,7 +173,8 @@ void inscatter(float r, float mu, float muSun, float nu, inout vec3 radianceJ) { // Initial InScattering including the phase functions radianceJ1 += singleRay * phaseRaySW + singleMie * phaseMieSW; - } else { + } + else { // On line 9 of the algorithm, the texture table deltaSR is updated, so when we are not in the first // iteraction, we are getting the updated result of deltaSR (not the single inscattered light but the // accumulated (higher order) inscattered light. diff --git a/modules/atmosphere/shaders/deltaJ_calc_gs.glsl b/modules/atmosphere/shaders/deltaJ_calc_gs.glsl index bc9987eab3..2756507b85 100644 --- a/modules/atmosphere/shaders/deltaJ_calc_gs.glsl +++ b/modules/atmosphere/shaders/deltaJ_calc_gs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaJ_calc_vs.glsl b/modules/atmosphere/shaders/deltaJ_calc_vs.glsl index a85594b7d2..fad2402e2a 100644 --- a/modules/atmosphere/shaders/deltaJ_calc_vs.glsl +++ b/modules/atmosphere/shaders/deltaJ_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaS_calc_fs.glsl b/modules/atmosphere/shaders/deltaS_calc_fs.glsl index ea2151793b..055888f2d5 100644 --- a/modules/atmosphere/shaders/deltaS_calc_fs.glsl +++ b/modules/atmosphere/shaders/deltaS_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaS_calc_gs.glsl b/modules/atmosphere/shaders/deltaS_calc_gs.glsl index bc9987eab3..2756507b85 100644 --- a/modules/atmosphere/shaders/deltaS_calc_gs.glsl +++ b/modules/atmosphere/shaders/deltaS_calc_gs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaS_calc_vs.glsl b/modules/atmosphere/shaders/deltaS_calc_vs.glsl index a85594b7d2..fad2402e2a 100644 --- a/modules/atmosphere/shaders/deltaS_calc_vs.glsl +++ b/modules/atmosphere/shaders/deltaS_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaS_sup_calc_fs.glsl b/modules/atmosphere/shaders/deltaS_sup_calc_fs.glsl index 9625840f45..bc32a189e5 100644 --- a/modules/atmosphere/shaders/deltaS_sup_calc_fs.glsl +++ b/modules/atmosphere/shaders/deltaS_sup_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaS_sup_calc_gs.glsl b/modules/atmosphere/shaders/deltaS_sup_calc_gs.glsl index c9ca35e88c..61f1cd1805 100644 --- a/modules/atmosphere/shaders/deltaS_sup_calc_gs.glsl +++ b/modules/atmosphere/shaders/deltaS_sup_calc_gs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaS_sup_calc_vs.glsl b/modules/atmosphere/shaders/deltaS_sup_calc_vs.glsl index 3988002d04..74c77c3837 100644 --- a/modules/atmosphere/shaders/deltaS_sup_calc_vs.glsl +++ b/modules/atmosphere/shaders/deltaS_sup_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/shaders/inScattering_calc_fs.glsl b/modules/atmosphere/shaders/inScattering_calc_fs.glsl index 87fe562553..6201fc1acb 100644 --- a/modules/atmosphere/shaders/inScattering_calc_fs.glsl +++ b/modules/atmosphere/shaders/inScattering_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -68,7 +68,8 @@ void integrand(const float r, const float mu, const float muSun, const float nu, if (ozoneLayerEnabled) { S_R = (exp(-(ri - Rg) / HO) + exp( -(ri - Rg) / HR )) * transmittanceY; S_M = exp( -(ri - Rg) / HM ) * transmittanceY; - } else { + } + else { S_R = exp( -(ri - Rg) / HR ) * transmittanceY; S_M = exp( -(ri - Rg) / HM ) * transmittanceY; } diff --git a/modules/atmosphere/shaders/inScattering_calc_gs.glsl b/modules/atmosphere/shaders/inScattering_calc_gs.glsl index c3bcf0c6fe..5bdbacc9d9 100644 --- a/modules/atmosphere/shaders/inScattering_calc_gs.glsl +++ b/modules/atmosphere/shaders/inScattering_calc_gs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/shaders/inScattering_calc_vs.glsl b/modules/atmosphere/shaders/inScattering_calc_vs.glsl index a85594b7d2..fad2402e2a 100644 --- a/modules/atmosphere/shaders/inScattering_calc_vs.glsl +++ b/modules/atmosphere/shaders/inScattering_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/shaders/inScattering_sup_calc_fs.glsl b/modules/atmosphere/shaders/inScattering_sup_calc_fs.glsl index 0cb4290902..8bb50ef4bf 100644 --- a/modules/atmosphere/shaders/inScattering_sup_calc_fs.glsl +++ b/modules/atmosphere/shaders/inScattering_sup_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/shaders/inScattering_sup_calc_gs.glsl b/modules/atmosphere/shaders/inScattering_sup_calc_gs.glsl index c9ca35e88c..61f1cd1805 100644 --- a/modules/atmosphere/shaders/inScattering_sup_calc_gs.glsl +++ b/modules/atmosphere/shaders/inScattering_sup_calc_gs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/shaders/inScattering_sup_calc_vs.glsl b/modules/atmosphere/shaders/inScattering_sup_calc_vs.glsl index 3988002d04..74c77c3837 100644 --- a/modules/atmosphere/shaders/inScattering_sup_calc_vs.glsl +++ b/modules/atmosphere/shaders/inScattering_sup_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/shaders/irradiance_calc_fs.glsl b/modules/atmosphere/shaders/irradiance_calc_fs.glsl index fe14612948..4891fce05b 100644 --- a/modules/atmosphere/shaders/irradiance_calc_fs.glsl +++ b/modules/atmosphere/shaders/irradiance_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/shaders/irradiance_calc_vs.glsl b/modules/atmosphere/shaders/irradiance_calc_vs.glsl index a85594b7d2..fad2402e2a 100644 --- a/modules/atmosphere/shaders/irradiance_calc_vs.glsl +++ b/modules/atmosphere/shaders/irradiance_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/shaders/irradiance_final_fs.glsl b/modules/atmosphere/shaders/irradiance_final_fs.glsl index 33b17b126f..64b0a547e5 100644 --- a/modules/atmosphere/shaders/irradiance_final_fs.glsl +++ b/modules/atmosphere/shaders/irradiance_final_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/shaders/irradiance_final_vs.glsl b/modules/atmosphere/shaders/irradiance_final_vs.glsl index 84a3c2750e..fd0c83d4cb 100644 --- a/modules/atmosphere/shaders/irradiance_final_vs.glsl +++ b/modules/atmosphere/shaders/irradiance_final_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/shaders/irradiance_sup_calc_fs.glsl b/modules/atmosphere/shaders/irradiance_sup_calc_fs.glsl index e381d2e6f2..07ba931806 100644 --- a/modules/atmosphere/shaders/irradiance_sup_calc_fs.glsl +++ b/modules/atmosphere/shaders/irradiance_sup_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -78,7 +78,8 @@ void main(void) { vec3 singleMie = texture4D(deltaSMTexture, r, w.z, muSun, nu).rgb; // w.z is the cosine(theta) = mu for vec(w) and also vec(w) dot vec(n(xo)) irradianceE += (singleRay * phaseRay + singleMie * phaseMie) * w.z * dw; - } else { + } + else { // On line 10 of the algorithm, the texture table deltaE is updated, so when we are not in the first // iteraction, we are getting the updated result of deltaE (not the single irradiance light but the // accumulated (higher order) irradiance light. diff --git a/modules/atmosphere/shaders/irradiance_sup_calc_vs.glsl b/modules/atmosphere/shaders/irradiance_sup_calc_vs.glsl index a85594b7d2..fad2402e2a 100644 --- a/modules/atmosphere/shaders/irradiance_sup_calc_vs.glsl +++ b/modules/atmosphere/shaders/irradiance_sup_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/atmosphere/shaders/transmittance_calc_fs.glsl b/modules/atmosphere/shaders/transmittance_calc_fs.glsl index 2eebbfa582..3413b91e41 100644 --- a/modules/atmosphere/shaders/transmittance_calc_fs.glsl +++ b/modules/atmosphere/shaders/transmittance_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -82,7 +82,8 @@ void main(void) { opDepth = betaOzoneExtinction * (0.0000006) * opticalDepth(r, muSun, HO) + betaMieExtinction * opticalDepth(r, muSun, HM) + betaRayleigh * opticalDepth(r, muSun, HR); - } else { + } + else { opDepth = betaMieExtinction * opticalDepth(r, muSun, HM) + betaRayleigh * opticalDepth(r, muSun, HR); } diff --git a/modules/atmosphere/shaders/transmittance_calc_vs.glsl b/modules/atmosphere/shaders/transmittance_calc_vs.glsl index 9927f4b026..0f972cb4e3 100644 --- a/modules/atmosphere/shaders/transmittance_calc_vs.glsl +++ b/modules/atmosphere/shaders/transmittance_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/CMakeLists.txt b/modules/base/CMakeLists.txt index b570090c70..905f374169 100644 --- a/modules/base/CMakeLists.txt +++ b/modules/base/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2018 # +# Copyright (c) 2014-2020 # # # # 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 # @@ -41,7 +41,9 @@ set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rendering/multimodelgeometry.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableboxgrid.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablecartesianaxes.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablelabels.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablemodel.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablenodeline.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplane.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplaneimagelocal.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplaneimageonline.h @@ -89,7 +91,9 @@ set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rendering/multimodelgeometry.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableboxgrid.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablecartesianaxes.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablelabels.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablemodel.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablenodeline.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplane.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplaneimagelocal.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplaneimageonline.cpp @@ -126,6 +130,8 @@ set(SHADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/shaders/grid_fs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/imageplane_fs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/imageplane_vs.glsl + ${CMAKE_CURRENT_SOURCE_DIR}/shaders/line_fs.glsl + ${CMAKE_CURRENT_SOURCE_DIR}/shaders/line_vs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/model_fs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/model_vs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/plane_fs.glsl diff --git a/modules/base/basemodule.cpp b/modules/base/basemodule.cpp index f1288c776a..cba8c4973e 100644 --- a/modules/base/basemodule.cpp +++ b/modules/base/basemodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -38,7 +38,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -123,7 +125,9 @@ void BaseModule::internalInitialize(const ghoul::Dictionary&) { fRenderable->registerClass("RenderableBoxGrid"); fRenderable->registerClass("RenderableCartesianAxes"); + fRenderable->registerClass("RenderableLabels"); fRenderable->registerClass("RenderableModel"); + fRenderable->registerClass("RenderableNodeLine"); fRenderable->registerClass("RenderablePlaneImageLocal"); fRenderable->registerClass("RenderablePlaneImageOnline"); fRenderable->registerClass("RenderableSphere"); @@ -191,7 +195,9 @@ std::vector BaseModule::documentations() const { DashboardItemVelocity::Documentation(), RenderableBoxGrid::Documentation(), + RenderableLabels::Documentation(), RenderableModel::Documentation(), + RenderableNodeLine::Documentation(), RenderablePlane::Documentation(), RenderableSphere::Documentation(), RenderableTimeVaryingSphere::Documentation(), diff --git a/modules/base/basemodule.h b/modules/base/basemodule.h index ceeca7da28..be3e54889c 100644 --- a/modules/base/basemodule.h +++ b/modules/base/basemodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/dashboard/dashboarditemangle.cpp b/modules/base/dashboard/dashboarditemangle.cpp index 3c2bd88682..aaeb8cb6e1 100644 --- a/modules/base/dashboard/dashboarditemangle.cpp +++ b/modules/base/dashboard/dashboarditemangle.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/dashboard/dashboarditemangle.h b/modules/base/dashboard/dashboarditemangle.h index 40f39a0fcb..21791cc63b 100644 --- a/modules/base/dashboard/dashboarditemangle.h +++ b/modules/base/dashboard/dashboarditemangle.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/dashboard/dashboarditemdate.cpp b/modules/base/dashboard/dashboarditemdate.cpp index 0f6815e7be..f0e5f21d0e 100644 --- a/modules/base/dashboard/dashboarditemdate.cpp +++ b/modules/base/dashboard/dashboarditemdate.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/dashboard/dashboarditemdate.h b/modules/base/dashboard/dashboarditemdate.h index 560b59f730..139b03477a 100644 --- a/modules/base/dashboard/dashboarditemdate.h +++ b/modules/base/dashboard/dashboarditemdate.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/dashboard/dashboarditemdistance.cpp b/modules/base/dashboard/dashboarditemdistance.cpp index 7cb68aac93..1f986c4595 100644 --- a/modules/base/dashboard/dashboarditemdistance.cpp +++ b/modules/base/dashboard/dashboarditemdistance.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -385,7 +385,7 @@ std::pair DashboardItemDistance::positionAndLabel( return { mainComp.node->worldPosition(), mainComp.node->guiName() }; case Type::NodeSurface: { - glm::dvec3 otherPos; + glm::dvec3 otherPos = glm::dvec3(0.0); if (otherComp.type == Type::NodeSurface) { // We are only interested in the direction, and we want to prevent // infinite recursion diff --git a/modules/base/dashboard/dashboarditemdistance.h b/modules/base/dashboard/dashboarditemdistance.h index 480f500f6d..aab5098bfb 100644 --- a/modules/base/dashboard/dashboarditemdistance.h +++ b/modules/base/dashboard/dashboarditemdistance.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/dashboard/dashboarditemframerate.cpp b/modules/base/dashboard/dashboarditemframerate.cpp index bdc10a49a0..7e7c31f59b 100644 --- a/modules/base/dashboard/dashboarditemframerate.cpp +++ b/modules/base/dashboard/dashboarditemframerate.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/dashboard/dashboarditemframerate.h b/modules/base/dashboard/dashboarditemframerate.h index 1a3b22bb00..2b1b8c2de9 100644 --- a/modules/base/dashboard/dashboarditemframerate.h +++ b/modules/base/dashboard/dashboarditemframerate.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/dashboard/dashboarditemmission.cpp b/modules/base/dashboard/dashboarditemmission.cpp index 19b3c6c7cb..8fc99bb908 100644 --- a/modules/base/dashboard/dashboarditemmission.cpp +++ b/modules/base/dashboard/dashboarditemmission.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/dashboard/dashboarditemmission.h b/modules/base/dashboard/dashboarditemmission.h index 91e27bb107..bce6364865 100644 --- a/modules/base/dashboard/dashboarditemmission.h +++ b/modules/base/dashboard/dashboarditemmission.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/dashboard/dashboarditemparallelconnection.cpp b/modules/base/dashboard/dashboarditemparallelconnection.cpp index d012d18c97..c894446637 100644 --- a/modules/base/dashboard/dashboarditemparallelconnection.cpp +++ b/modules/base/dashboard/dashboarditemparallelconnection.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/dashboard/dashboarditemparallelconnection.h b/modules/base/dashboard/dashboarditemparallelconnection.h index 2e1976066e..5c0bb7f1f5 100644 --- a/modules/base/dashboard/dashboarditemparallelconnection.h +++ b/modules/base/dashboard/dashboarditemparallelconnection.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/dashboard/dashboarditempropertyvalue.cpp b/modules/base/dashboard/dashboarditempropertyvalue.cpp index 4a60c7415a..77f9c5fa7c 100644 --- a/modules/base/dashboard/dashboarditempropertyvalue.cpp +++ b/modules/base/dashboard/dashboarditempropertyvalue.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/dashboard/dashboarditempropertyvalue.h b/modules/base/dashboard/dashboarditempropertyvalue.h index 8266769cad..0f5a475e02 100644 --- a/modules/base/dashboard/dashboarditempropertyvalue.h +++ b/modules/base/dashboard/dashboarditempropertyvalue.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/dashboard/dashboarditemsimulationincrement.cpp b/modules/base/dashboard/dashboarditemsimulationincrement.cpp index 7dec612f45..e0aa1da825 100644 --- a/modules/base/dashboard/dashboarditemsimulationincrement.cpp +++ b/modules/base/dashboard/dashboarditemsimulationincrement.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/dashboard/dashboarditemsimulationincrement.h b/modules/base/dashboard/dashboarditemsimulationincrement.h index 35134dc4db..389778f0c2 100644 --- a/modules/base/dashboard/dashboarditemsimulationincrement.h +++ b/modules/base/dashboard/dashboarditemsimulationincrement.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/dashboard/dashboarditemspacing.cpp b/modules/base/dashboard/dashboarditemspacing.cpp index 3124cea06a..7b9f98977f 100644 --- a/modules/base/dashboard/dashboarditemspacing.cpp +++ b/modules/base/dashboard/dashboarditemspacing.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/dashboard/dashboarditemspacing.h b/modules/base/dashboard/dashboarditemspacing.h index 5eb23c9751..d3b48199a8 100644 --- a/modules/base/dashboard/dashboarditemspacing.h +++ b/modules/base/dashboard/dashboarditemspacing.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/dashboard/dashboarditemvelocity.cpp b/modules/base/dashboard/dashboarditemvelocity.cpp index a6cf5f03f4..aa0d42f394 100644 --- a/modules/base/dashboard/dashboarditemvelocity.cpp +++ b/modules/base/dashboard/dashboarditemvelocity.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/dashboard/dashboarditemvelocity.h b/modules/base/dashboard/dashboarditemvelocity.h index 6a7d5ae5a1..2fcfa4ef16 100644 --- a/modules/base/dashboard/dashboarditemvelocity.h +++ b/modules/base/dashboard/dashboarditemvelocity.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -58,7 +58,7 @@ private: properties::BoolProperty _doSimplification; properties::OptionProperty _requestedUnit; - glm::dvec3 _prevPosition; + glm::dvec3 _prevPosition = glm::dvec3(0.0); std::shared_ptr _font; }; diff --git a/modules/base/lightsource/cameralightsource.cpp b/modules/base/lightsource/cameralightsource.cpp index be7d6974a8..ade1fce643 100644 --- a/modules/base/lightsource/cameralightsource.cpp +++ b/modules/base/lightsource/cameralightsource.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/lightsource/cameralightsource.h b/modules/base/lightsource/cameralightsource.h index 312d23b201..fea98d94a3 100644 --- a/modules/base/lightsource/cameralightsource.h +++ b/modules/base/lightsource/cameralightsource.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/lightsource/scenegraphlightsource.cpp b/modules/base/lightsource/scenegraphlightsource.cpp index 905524ca17..628b8586bd 100644 --- a/modules/base/lightsource/scenegraphlightsource.cpp +++ b/modules/base/lightsource/scenegraphlightsource.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/lightsource/scenegraphlightsource.h b/modules/base/lightsource/scenegraphlightsource.h index e4d6b7a602..f1d4ed7b52 100644 --- a/modules/base/lightsource/scenegraphlightsource.h +++ b/modules/base/lightsource/scenegraphlightsource.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/modelgeometry.cpp b/modules/base/rendering/modelgeometry.cpp index bbd4a1873b..1fee2ed0cd 100644 --- a/modules/base/rendering/modelgeometry.cpp +++ b/modules/base/rendering/modelgeometry.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/modelgeometry.h b/modules/base/rendering/modelgeometry.h index 0535052703..8251fd4be3 100644 --- a/modules/base/rendering/modelgeometry.h +++ b/modules/base/rendering/modelgeometry.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/multimodelgeometry.cpp b/modules/base/rendering/multimodelgeometry.cpp index c59a815ea5..96bed213a3 100644 --- a/modules/base/rendering/multimodelgeometry.cpp +++ b/modules/base/rendering/multimodelgeometry.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/multimodelgeometry.h b/modules/base/rendering/multimodelgeometry.h index 2b26169ccd..c8d2c116a9 100644 --- a/modules/base/rendering/multimodelgeometry.h +++ b/modules/base/rendering/multimodelgeometry.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/renderableboxgrid.cpp b/modules/base/rendering/renderableboxgrid.cpp index 0ea998333f..c224cec84b 100644 --- a/modules/base/rendering/renderableboxgrid.cpp +++ b/modules/base/rendering/renderableboxgrid.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -265,14 +265,14 @@ void RenderableBoxGrid::update(const UpdateData&) { // 0 -> 1 -> 2 -> 3 -> 0 -> 4 -> 5 -> 6 -> 7 -> 4 -> 5(d) -> 1 -> 2(d) -> 6 // -> 7(d) -> 3 - const glm::vec3 v0 = { llf.x, llf.y, llf.z }; - const glm::vec3 v1 = { urb.x, llf.y, llf.z }; - const glm::vec3 v2 = { urb.x, urb.y, llf.z }; - const glm::vec3 v3 = { llf.x, urb.y, llf.z }; - const glm::vec3 v4 = { llf.x, llf.y, urb.z }; - const glm::vec3 v5 = { urb.x, llf.y, urb.z }; - const glm::vec3 v6 = { urb.x, urb.y, urb.z }; - const glm::vec3 v7 = { llf.x, urb.y, urb.z }; + const glm::vec3 v0 = glm::vec3(llf.x, llf.y, llf.z); + const glm::vec3 v1 = glm::vec3(urb.x, llf.y, llf.z); + const glm::vec3 v2 = glm::vec3(urb.x, urb.y, llf.z); + const glm::vec3 v3 = glm::vec3(llf.x, urb.y, llf.z); + const glm::vec3 v4 = glm::vec3(llf.x, llf.y, urb.z); + const glm::vec3 v5 = glm::vec3(urb.x, llf.y, urb.z); + const glm::vec3 v6 = glm::vec3(urb.x, urb.y, urb.z); + const glm::vec3 v7 = glm::vec3(llf.x, urb.y, urb.z); // First add the bounds _varray.push_back({ v0.x, v0.y, v0.z }); diff --git a/modules/base/rendering/renderableboxgrid.h b/modules/base/rendering/renderableboxgrid.h index e74f82e1fd..937d22dc82 100644 --- a/modules/base/rendering/renderableboxgrid.h +++ b/modules/base/rendering/renderableboxgrid.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/renderablecartesianaxes.cpp b/modules/base/rendering/renderablecartesianaxes.cpp index 841923c5ba..ced04ad50e 100644 --- a/modules/base/rendering/renderablecartesianaxes.cpp +++ b/modules/base/rendering/renderablecartesianaxes.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/renderablecartesianaxes.h b/modules/base/rendering/renderablecartesianaxes.h index bd090c1055..600770100b 100644 --- a/modules/base/rendering/renderablecartesianaxes.h +++ b/modules/base/rendering/renderablecartesianaxes.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/renderablelabels.cpp b/modules/base/rendering/renderablelabels.cpp new file mode 100644 index 0000000000..e661982bc0 --- /dev/null +++ b/modules/base/rendering/renderablelabels.cpp @@ -0,0 +1,787 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2020 * + * * + * 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 +#include +#include +#include +#include +#include +#include + +namespace { + constexpr const char* _loggerCat = "base::RenderableLabels"; + + constexpr const char* MeterUnit = "m"; + constexpr const char* KilometerUnit = "Km"; + constexpr const char* MegameterUnit = "Mm"; + constexpr const char* GigameterUnit = "Gm"; + constexpr const char* AstronomicalUnit = "au"; + constexpr const char* TerameterUnit = "Tm"; + constexpr const char* PetameterUnit = "Pm"; + constexpr const char* ParsecUnit = "pc"; + constexpr const char* KiloparsecUnit = "Kpc"; + constexpr const char* MegaparsecUnit = "Mpc"; + constexpr const char* GigaparsecUnit = "Gpc"; + constexpr const char* GigalightyearUnit = "Gly"; + + enum BlendMode { + BlendModeNormal = 0, + BlendModeAdditive + }; + + constexpr const int ViewDirection = 0; + constexpr const int NormalDirection = 1; + + constexpr double PARSEC = 0.308567756E17; + + constexpr openspace::properties::Property::PropertyInfo BlendModeInfo = { + "BlendMode", + "Blending Mode", + "This determines the blending mode that is applied to this plane." + }; + + constexpr openspace::properties::Property::PropertyInfo LabelColorInfo = { + "LabelColor", + "Label Color", + "The label color for the astronomical object." + }; + + constexpr openspace::properties::Property::PropertyInfo FontSizeInfo = { + "FontSize", + "Font Size", + "The font size for the astronomical object labels." + }; + + constexpr openspace::properties::Property::PropertyInfo LabelSizeInfo = { + "LabelSize", + "Label Size", + "The label size for the astronomical object labels." + }; + + constexpr openspace::properties::Property::PropertyInfo LabelTextInfo = { + "LabelText", + "Label Text", + "The text that will be displayed on screen." + }; + + constexpr openspace::properties::Property::PropertyInfo LabelMinSizeInfo = { + "LabelMinSize", + "Label Min Size", + "The minimal size (in pixels) of the labels for the astronomical " + "objects being rendered." + }; + + constexpr openspace::properties::Property::PropertyInfo LabelMaxSizeInfo = { + "LabelMaxSize", + "Label Max Size", + "The maximum size (in pixels) of the labels for the astronomical " + "objects being rendered." + }; + + constexpr openspace::properties::Property::PropertyInfo TransformationMatrixInfo = { + "TransformationMatrix", + "Transformation Matrix", + "Transformation matrix to be applied to each astronomical object." + }; + + constexpr openspace::properties::Property::PropertyInfo LabelOrientationOptionInfo = { + "LabelOrientationOption", + "Label Orientation Option", + "Label orientation rendering mode." + }; + + constexpr openspace::properties::Property::PropertyInfo EnableFadingEffectInfo = { + "EnableFading", + "Enable/Disable Fade-in effect", + "Enable/Disable the Fade-in effect." + }; + + constexpr openspace::properties::Property::PropertyInfo PixelSizeControlInfo = { + "EnablePixelSizeControl", + "Enable pixel size control.", + "Enable pixel size control for rectangular projections." + }; + + constexpr openspace::properties::Property::PropertyInfo FadeStartUnitOptionInfo = { + "FadeStartUnit", + "Fade-In/-Out Start Unit.", + "Unit for fade-in/-out starting position calculation." + }; + + constexpr openspace::properties::Property::PropertyInfo FadeEndUnitOptionInfo = { + "FadeEndUnit", + "Fade-In/-Out End Unit.", + "Unit for fade-in/-out ending position calculation." + }; + + constexpr openspace::properties::Property::PropertyInfo FadeStartDistInfo = { + "FadeStartDistance", + "Fade-In/-Out starting distance.", + "Fade-In/-Out starting distance." + }; + + constexpr openspace::properties::Property::PropertyInfo FadeEndDistInfo = { + "FadeEndDistance", + "Fade-In/-Out ending distance.", + "Fade-In/-Out ending distance." + }; + + constexpr openspace::properties::Property::PropertyInfo FadeStartSpeedInfo = { + "FadeStartSpeed", + "Fade-In/-Out starting speed.", + "Fade-In/-Out starting speed." + }; + + constexpr openspace::properties::Property::PropertyInfo FadeEndSpeedInfo = { + "FadeEndSpeed", + "Fade-In/-Out ending speed.", + "Fade-In/-Out ending speed." + }; +} // namespace + +namespace openspace { + +documentation::Documentation RenderableLabels::Documentation() { + using namespace documentation; + return { + "Renderable Labels", + "base_renderable_labels", + { + { + BlendModeInfo.identifier, + new StringInListVerifier({ "Normal", "Additive" }), + Optional::Yes, + BlendModeInfo.description, // + " The default value is 'Normal'.", + }, + { + LabelOrientationOptionInfo.identifier, + new StringInListVerifier( + { "Camera View Direction", "Camera Position Normal" } + ), + Optional::Yes, + LabelOrientationOptionInfo.description, + }, + { + LabelColorInfo.identifier, + new DoubleVector4Verifier, + Optional::Yes, + LabelColorInfo.description, + }, + { + LabelColorInfo.identifier, + new DoubleVector4Verifier, + Optional::Yes, + LabelColorInfo.description, + }, + { + LabelTextInfo.identifier, + new StringVerifier, + Optional::No, + LabelTextInfo.description + }, + { + FontSizeInfo.identifier, + new DoubleVerifier, + Optional::Yes, + FontSizeInfo.description + }, + { + LabelSizeInfo.identifier, + new DoubleVerifier, + Optional::Yes, + LabelSizeInfo.description + }, + { + LabelMinSizeInfo.identifier, + new DoubleVerifier, + Optional::Yes, + LabelMinSizeInfo.description + }, + { + LabelMaxSizeInfo.identifier, + new DoubleVerifier, + Optional::Yes, + LabelMaxSizeInfo.description + }, + { + EnableFadingEffectInfo.identifier, + new BoolVerifier, + Optional::Yes, + EnableFadingEffectInfo.description + }, + { + PixelSizeControlInfo.identifier, + new BoolVerifier, + Optional::Yes, + PixelSizeControlInfo.description + }, + { + FadeStartUnitOptionInfo.identifier, + new StringInListVerifier( + { "m", "Km", "Mm", "Gm", "au", "Tm", "Pm", "pc", "Kpc", "Mpc", + "Gpc", "Gly"} + ), + Optional::Yes, + FadeStartUnitOptionInfo.description, + }, + { + FadeEndUnitOptionInfo.identifier, + new StringInListVerifier( + {"m", "Km", "Mm", "Gm", "au", "Tm", "Pm", "pc", "Kpc", "Mpc", + "Gpc", "Gly"} + ), + Optional::Yes, + FadeEndUnitOptionInfo.description, + }, + { + FadeStartDistInfo.identifier, + new DoubleVerifier, + Optional::Yes, + FadeStartDistInfo.description + }, + { + FadeEndDistInfo.identifier, + new DoubleVerifier, + Optional::Yes, + FadeEndDistInfo.description + }, + { + FadeStartSpeedInfo.identifier, + new DoubleVerifier, + Optional::Yes, + FadeStartSpeedInfo.description + }, + { + FadeEndSpeedInfo.identifier, + new DoubleVerifier, + Optional::Yes, + FadeEndSpeedInfo.description + }, + } + }; +} + +RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary) + : Renderable(dictionary) + , _blendMode(BlendModeInfo, properties::OptionProperty::DisplayType::Dropdown) + , _labelColor( + LabelColorInfo, + glm::vec4(1.f, 1.f, 1.f, 1.f), + glm::vec4(0.f), + glm::vec4(1.f) + ) + , _labelSize(LabelSizeInfo, 8.f, 0.5f, 30.f) + , _fontSize(FontSizeInfo, 50.f, 1.f, 100.f) + , _labelMinSize(LabelMinSizeInfo, 8.f, 0.5f, 24.f) + , _labelMaxSize(LabelMaxSizeInfo, 20.f, 0.5f, 100.f) + , _pixelSizeControl(PixelSizeControlInfo, false) + , _enableFadingEffect(EnableFadingEffectInfo, false) + , _labelText(LabelTextInfo) + , _fadeStartDistance(FadeStartDistInfo, 1.f, 0.f, 100.f) + , _fadeEndDistance(FadeEndDistInfo, 1.f, 0.f, 100.f) + , _fadeStartSpeed(FadeStartSpeedInfo, 1.f, 1.f, 100.f) + , _fadeEndSpeed(FadeEndSpeedInfo, 1.f, 1.f, 100.f) + , _labelOrientationOption( + LabelOrientationOptionInfo, + properties::OptionProperty::DisplayType::Dropdown + ) + , _fadeStartUnitOption( + FadeStartUnitOptionInfo, + properties::OptionProperty::DisplayType::Dropdown + ) + , _fadeEndUnitOption( + FadeEndUnitOptionInfo, + properties::OptionProperty::DisplayType::Dropdown + ) +{ + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "RenderableLabels" + ); + + registerUpdateRenderBinFromOpacity(); + + _blendMode.addOptions({ + { BlendModeNormal, "Normal" }, + { BlendModeAdditive, "Additive"} + }); + _blendMode.onChange([&]() { + switch (_blendMode) { + case BlendModeNormal: + setRenderBinFromOpacity(); + break; + case BlendModeAdditive: + setRenderBin(Renderable::RenderBin::Transparent); + break; + default: + throw ghoul::MissingCaseException(); + } + }); + + if (dictionary.hasKey(BlendModeInfo.identifier)) { + const std::string v = dictionary.value(BlendModeInfo.identifier); + if (v == "Normal") { + _blendMode = BlendModeNormal; + } + else if (v == "Additive") { + _blendMode = BlendModeAdditive; + } + } + + addProperty(_blendMode); + + _labelOrientationOption.addOption(ViewDirection, "Camera View Direction"); + _labelOrientationOption.addOption(NormalDirection, "Camera Position Normal"); + + _labelOrientationOption = NormalDirection; + if (dictionary.hasKeyAndValue(LabelOrientationOptionInfo.identifier)) { + const std::string o = dictionary.value( + LabelOrientationOptionInfo.identifier + ); + + if (o == "Camera View Direction") { + _labelOrientationOption = ViewDirection; + } + else if (o == "Camera Position Normal") { + _labelOrientationOption = NormalDirection; + } + } + + if (dictionary.hasKey(LabelTextInfo.identifier)) { + _labelText = dictionary.value(LabelTextInfo.identifier); + } + addProperty(_labelText); + + addProperty(_labelOrientationOption); + + _labelColor.setViewOption(properties::Property::ViewOptions::Color); + if (dictionary.hasKey(LabelColorInfo.identifier)) { + _labelColor = dictionary.value(LabelColorInfo.identifier); + } + addProperty(_labelColor); + + if (dictionary.hasKey(FontSizeInfo.identifier)) { + _fontSize = dictionary.value(FontSizeInfo.identifier); + } + _fontSize.onChange([&]() { + _font = global::fontManager.font( + "Mono", + _fontSize, + ghoul::fontrendering::FontManager::Outline::Yes, + ghoul::fontrendering::FontManager::LoadGlyphs::No + ); + }); + addProperty(_fontSize); + + if (dictionary.hasKey(LabelSizeInfo.identifier)) { + _labelSize = dictionary.value(LabelSizeInfo.identifier); + } + addProperty(_labelSize); + + if (dictionary.hasKey(LabelMinSizeInfo.identifier)) { + _labelMinSize = dictionary.value(LabelMinSizeInfo.identifier); + } + addProperty(_labelMinSize); + + if (dictionary.hasKey(LabelMaxSizeInfo.identifier)) { + _labelMaxSize = dictionary.value(LabelMaxSizeInfo.identifier); + } + addProperty(_labelMaxSize); + + if (dictionary.hasKey(TransformationMatrixInfo.identifier)) { + _transformationMatrix = dictionary.value( + TransformationMatrixInfo.identifier + ); + } + + if (dictionary.hasKey(PixelSizeControlInfo.identifier)) { + _pixelSizeControl = dictionary.value(PixelSizeControlInfo.identifier); + addProperty(_pixelSizeControl); + } + + if (dictionary.hasKey(EnableFadingEffectInfo.identifier)) { + _enableFadingEffect = dictionary.value(EnableFadingEffectInfo.identifier); + } + addProperty(_enableFadingEffect); + + if (dictionary.hasKey(FadeStartDistInfo.identifier)) { + _fadeStartDistance = dictionary.value(FadeStartDistInfo.identifier); + } + + addProperty(_fadeStartDistance); + + _fadeStartUnitOption.addOption(Meter, MeterUnit); + _fadeStartUnitOption.addOption(Kilometer, KilometerUnit); + _fadeStartUnitOption.addOption(Megameter, MegameterUnit); + _fadeStartUnitOption.addOption(Gigameter, GigameterUnit); + _fadeStartUnitOption.addOption(AU, AstronomicalUnit); + _fadeStartUnitOption.addOption(Terameter, TerameterUnit); + _fadeStartUnitOption.addOption(Petameter, PetameterUnit); + _fadeStartUnitOption.addOption(Parsec, ParsecUnit); + _fadeStartUnitOption.addOption(Kiloparsec, KiloparsecUnit); + _fadeStartUnitOption.addOption(Megaparsec, MegaparsecUnit); + _fadeStartUnitOption.addOption(Gigaparsec, GigaparsecUnit); + _fadeStartUnitOption.addOption(GigalightYears, GigalightyearUnit); + + _fadeStartUnitOption = AU; + + if (dictionary.hasKey(FadeStartUnitOptionInfo.identifier)) { + std::string unit = dictionary.value( + FadeStartUnitOptionInfo.identifier + ); + if (unit == MeterUnit) { + _fadeStartUnitOption = Meter; + } + else if (unit == KilometerUnit) { + _fadeStartUnitOption = Kilometer; + } + else if (unit == MegameterUnit) { + _fadeStartUnitOption = Megameter; + } + else if (unit == GigameterUnit) { + _fadeStartUnitOption = Gigameter; + } + else if (unit == AstronomicalUnit) { + _fadeStartUnitOption = AU; + } + else if (unit == TerameterUnit) { + _fadeStartUnitOption = Terameter; + } + else if (unit == PetameterUnit) { + _fadeStartUnitOption = Petameter; + } + else if (unit == ParsecUnit) { + _fadeStartUnitOption = Parsec; + } + else if (unit == KiloparsecUnit) { + _fadeStartUnitOption = Kiloparsec; + } + else if (unit == MegaparsecUnit) { + _fadeStartUnitOption = Megaparsec; + } + else if (unit == GigaparsecUnit) { + _fadeStartUnitOption = Gigaparsec; + } + else if (unit == GigalightyearUnit) { + _fadeStartUnitOption = GigalightYears; + } + else { + LWARNING( + "No unit given for RenderableLabels. Using kilometer as units." + ); + _fadeStartUnitOption = Kilometer; + } + } + + addProperty(_fadeStartUnitOption); + + if (dictionary.hasKey(FadeStartSpeedInfo.identifier)) { + _fadeStartSpeed = dictionary.value(FadeStartSpeedInfo.identifier); + } + + addProperty(_fadeStartSpeed); + + if (dictionary.hasKey(FadeEndDistInfo.identifier)) { + _fadeEndDistance = dictionary.value(FadeEndDistInfo.identifier); + } + + addProperty(_fadeEndDistance); + + _fadeEndUnitOption.addOption(Meter, MeterUnit); + _fadeEndUnitOption.addOption(Kilometer, KilometerUnit); + _fadeEndUnitOption.addOption(Megameter, MegameterUnit); + _fadeEndUnitOption.addOption(Gigameter, GigameterUnit); + _fadeEndUnitOption.addOption(AU, AstronomicalUnit); + _fadeEndUnitOption.addOption(Terameter, TerameterUnit); + _fadeEndUnitOption.addOption(Petameter, PetameterUnit); + _fadeEndUnitOption.addOption(Parsec, ParsecUnit); + _fadeEndUnitOption.addOption(Kiloparsec, KiloparsecUnit); + _fadeEndUnitOption.addOption(Megaparsec, MegaparsecUnit); + _fadeEndUnitOption.addOption(Gigaparsec, GigaparsecUnit); + _fadeEndUnitOption.addOption(GigalightYears, GigalightyearUnit); + + _fadeEndUnitOption = AU; + + if (dictionary.hasKey(FadeEndUnitOptionInfo.identifier)) { + std::string unit = dictionary.value( + FadeEndUnitOptionInfo.identifier + ); + if (unit == MeterUnit) { + _fadeEndUnitOption = Meter; + } + else if (unit == KilometerUnit) { + _fadeEndUnitOption = Kilometer; + } + else if (unit == MegameterUnit) { + _fadeEndUnitOption = Megameter; + } + else if (unit == GigameterUnit) { + _fadeEndUnitOption = Gigameter; + } + else if (unit == AstronomicalUnit) { + _fadeEndUnitOption = AU; + } + else if (unit == TerameterUnit) { + _fadeEndUnitOption = Terameter; + } + else if (unit == PetameterUnit) { + _fadeEndUnitOption = Petameter; + } + else if (unit == ParsecUnit) { + _fadeEndUnitOption = Parsec; + } + else if (unit == KiloparsecUnit) { + _fadeEndUnitOption = Kiloparsec; + } + else if (unit == MegaparsecUnit) { + _fadeEndUnitOption = Megaparsec; + } + else if (unit == GigaparsecUnit) { + _fadeEndUnitOption = Gigaparsec; + } + else if (unit == GigalightyearUnit) { + _fadeEndUnitOption = GigalightYears; + } + else { + LWARNING( + "No unit given for RenderableLabels. Using kilometer as units." + ); + _fadeEndUnitOption = Kilometer; + } + } + + addProperty(_fadeEndUnitOption); + + if (dictionary.hasKey(FadeEndSpeedInfo.identifier)) { + _fadeEndSpeed = dictionary.value(FadeEndSpeedInfo.identifier); + } + + addProperty(_fadeEndSpeed); +} + +bool RenderableLabels::isReady() const { + return true; +} + +void RenderableLabels::initialize() { + bool success = true;// loadData(); + if (!success) { + throw ghoul::RuntimeError("Error loading objects labels data."); + } + + setRenderBin(Renderable::RenderBin::Transparent); +} + +void RenderableLabels::initializeGL() { + if (_font == nullptr) { + //size_t _fontSize = 50; + _font = global::fontManager.font( + "Mono", + _fontSize, + ghoul::fontrendering::FontManager::Outline::Yes, + ghoul::fontrendering::FontManager::LoadGlyphs::No + ); + } +} + +void RenderableLabels::deinitializeGL() {} + +void RenderableLabels::render(const RenderData& data, RendererTasks&) { + + //bool additiveBlending = (_blendMode == BlendModeAdditive); + //if (additiveBlending) { + glDepthMask(false); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + //} + + float fadeInVariable = 1.f; + + if (_enableFadingEffect) { + float distanceNodeToCamera = glm::distance( + data.camera.positionVec3(), + data.modelTransform.translation + ); + float sUnit = unit(_fadeStartUnitOption); + float eUnit = unit(_fadeEndUnitOption); + float startX = _fadeStartDistance * sUnit; + float endX = _fadeEndDistance * eUnit; + //fadeInVariable = changedPerlinSmoothStepFunc(distanceNodeToCamera, startX, endX); + fadeInVariable = linearSmoothStepFunc( + distanceNodeToCamera, + startX, + endX, + sUnit, + eUnit + ); + } + + glm::dmat4 modelMatrix(1.0); + glm::dmat4 modelViewMatrix = data.camera.combinedViewMatrix() * modelMatrix; + glm::dmat4 projectionMatrix = glm::dmat4(data.camera.projectionMatrix()); + + glm::dmat4 modelViewProjectionMatrix = projectionMatrix * modelViewMatrix; + + glm::dvec3 cameraViewDirectionWorld = -data.camera.viewDirectionWorldSpace(); + glm::dvec3 cameraUpDirectionWorld = data.camera.lookUpVectorWorldSpace(); + glm::dvec3 orthoRight = glm::normalize( + glm::cross(cameraUpDirectionWorld, cameraViewDirectionWorld) + ); + if (orthoRight == glm::dvec3(0.0)) { + glm::dvec3 otherVector( + cameraUpDirectionWorld.y, + cameraUpDirectionWorld.x, + cameraUpDirectionWorld.z + ); + orthoRight = glm::normalize(glm::cross(otherVector, cameraViewDirectionWorld)); + } + glm::dvec3 orthoUp = glm::normalize(glm::cross(cameraViewDirectionWorld, orthoRight)); + + renderLabels(data, modelViewProjectionMatrix, orthoRight, orthoUp, fadeInVariable); + + //if (additiveBlending) { + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDepthMask(true); + //} +} + + +void RenderableLabels::setLabelText(const std::string & newText) { + _labelText = newText; +} + +void RenderableLabels::renderLabels(const RenderData& data, + const glm::dmat4& modelViewProjectionMatrix, + const glm::dvec3& orthoRight, + const glm::dvec3& orthoUp, float fadeInVariable) +{ + glm::vec4 textColor = _labelColor; + + textColor.a *= fadeInVariable; + textColor.a *= _opacity; + + ghoul::fontrendering::FontRenderer::ProjectedLabelsInformation labelInfo; + + labelInfo.orthoRight = orthoRight; + labelInfo.orthoUp = orthoUp; + labelInfo.minSize = static_cast(_labelMinSize); + labelInfo.maxSize = static_cast(_labelMaxSize); + labelInfo.cameraPos = data.camera.positionVec3(); + labelInfo.cameraLookUp = data.camera.lookUpVectorWorldSpace(); + labelInfo.renderType = _labelOrientationOption; + labelInfo.mvpMatrix = modelViewProjectionMatrix; + labelInfo.scale = powf(10.f, _labelSize); + labelInfo.enableDepth = true; + labelInfo.enableFalseDepth = false; + + // We don't use spice rotation and scale + glm::vec3 transformedPos( + _transformationMatrix * glm::dvec4(data.modelTransform.translation, 1.0) + ); + + ghoul::fontrendering::FontRenderer::defaultProjectionRenderer().render( + *_font, + transformedPos, + _labelText, + textColor, + labelInfo + ); +} + +float RenderableLabels::changedPerlinSmoothStepFunc(float x, float startX, + float endX) const +{ + float f1 = 6.f * powf((x - startX), 5.f) - 15.f * powf((x - startX), 4.f) + + 10.f * powf((x - startX), 3.f); + float f2 = -6.f * powf((x - endX), 5.f) + 15.f * powf((x - endX), 4.f) - + 10.f * powf((x - endX), 3.f) + 1.f; + float f3 = 1.f; + + if (x <= startX) { + return std::clamp(f1, 0.f, 1.f); + } + else if (x > startX && x < endX) { + return f3; + } + else if (x >= endX) { + return std::clamp(f2, 0.f, 1.f); + } +} + +float RenderableLabels::linearSmoothStepFunc(float x, float startX, float endX, + float sUnit, float eUnit) const +{ + float sdiv = 1.f / (sUnit * _fadeStartSpeed); + float ediv = -1.f / (eUnit * _fadeEndSpeed); + float f1 = sdiv * (x - startX) + 1.f; + float f2 = ediv * (x - endX) + 1.f; + float f3 = 1.f; + + if (x <= startX) { + return std::clamp(f1, 0.f, 1.f); + } + else if (x > startX && x < endX) { + return f3; + } + else if (x >= endX) { + return std::clamp(f2, 0.f, 1.f); + } +} + +float RenderableLabels::unit(int unit) const { + switch (static_cast(unit)) { + case Meter: return 1.f; + case Kilometer: return 1e3; + case Megameter: return 1e6; + case Gigameter: return 1e9; + case AU: return 149597870700.f; + case Terameter: return 1e12; + case Petameter: return 1e15; + case Parsec: return static_cast(PARSEC); + case Kiloparsec: return static_cast(1e3 * PARSEC); + case Megaparsec: return static_cast(1e6 * PARSEC); + case Gigaparsec: return static_cast(1e9 * PARSEC); + case GigalightYears: return static_cast(306391534.73091 * PARSEC); + default: throw std::logic_error("Missing case label"); + } +} + +} // namespace openspace diff --git a/modules/base/rendering/renderablelabels.h b/modules/base/rendering/renderablelabels.h new file mode 100644 index 0000000000..7be35abaef --- /dev/null +++ b/modules/base/rendering/renderablelabels.h @@ -0,0 +1,133 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2020 * + * * + * 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_BASE___RENDERABLELABELS___H__ +#define __OPENSPACE_MODULE_BASE___RENDERABLELABELS___H__ + +#include + +#include +#include +#include +#include +#include +#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 { + +struct RenderData; +struct UpdateData; + +namespace documentation { struct Documentation; } + +struct LinePoint; + +class RenderableLabels : public Renderable { +public: + RenderableLabels(const ghoul::Dictionary& dictionary); + + void initialize() override; + void initializeGL() override; + void deinitializeGL() override; + + bool isReady() const override; + + void render(const RenderData& data, RendererTasks& rendererTask) override; + + static documentation::Documentation Documentation(); + + void setLabelText(const std::string & newText); + +protected: + properties::OptionProperty _blendMode; + + float unit(int unit) const; + + // Data may require some type of transformation prior the spice transformation being + // applied. + glm::dmat4 _transformationMatrix = glm::dmat4(1.0); + + enum Unit { + Meter = 0, + Kilometer, + Megameter, + Gigameter, + AU, + Terameter, + Petameter, + Parsec, + Kiloparsec, + Megaparsec, + Gigaparsec, + GigalightYears + }; + +private: + void renderLabels(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix, + const glm::dvec3& orthoRight, const glm::dvec3& orthoUp, float fadeInVariable); + + float changedPerlinSmoothStepFunc(float x, float startX, float endX) const; + + float linearSmoothStepFunc(float x, float startX, float endX, float sUnit, + float eUnit) const; + + properties::Vec4Property _labelColor; + properties::FloatProperty _labelSize; + properties::FloatProperty _fontSize; + properties::FloatProperty _labelMinSize; + properties::FloatProperty _labelMaxSize; + properties::BoolProperty _pixelSizeControl; + properties::BoolProperty _enableFadingEffect; + properties::StringProperty _labelText; + properties::FloatProperty _fadeStartDistance; + properties::FloatProperty _fadeEndDistance; + properties::FloatProperty _fadeStartSpeed; + properties::FloatProperty _fadeEndSpeed; + + properties::OptionProperty _labelOrientationOption; + properties::OptionProperty _fadeStartUnitOption; + properties::OptionProperty _fadeEndUnitOption; + + std::shared_ptr _font; + + std::string _speckFile; + std::string _colorMapFile; + std::string _labelFile; + std::string _colorOptionString; + std::string _datavarSizeOptionString; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_BASE___RENDERABLELABELS___H__ diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index 05ce3e39ce..cec22961fc 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/renderablemodel.h b/modules/base/rendering/renderablemodel.h index 6feb61bf71..317b62d7d2 100644 --- a/modules/base/rendering/renderablemodel.h +++ b/modules/base/rendering/renderablemodel.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/renderablenodeline.cpp b/modules/base/rendering/renderablenodeline.cpp new file mode 100644 index 0000000000..4dc4291a55 --- /dev/null +++ b/modules/base/rendering/renderablenodeline.cpp @@ -0,0 +1,349 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2020 * + * * + * 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 + +namespace { + constexpr const char* _loggerCat = "RenderableNodeLine"; + constexpr const char* ProgramName = "NodeLineProgram"; + constexpr const char* Root = "Root"; + + constexpr openspace::properties::Property::PropertyInfo StartNodeInfo = { + "StartNode", + "Start Node", + "The identifier of the node the line starts from. " + "Defaults to 'Root' if not specified. " + }; + + constexpr openspace::properties::Property::PropertyInfo EndNodeInfo = { + "EndNode", + "End Node", + "The identifier of the node the line ends at. " + "Defaults to 'Root' if not specified. " + }; + + constexpr openspace::properties::Property::PropertyInfo LineColorInfo = { + "Color", + "Color", + "This value determines the RGB color for the line." + }; + + constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = { + "LineWidth", + "Line Width", + "This value specifies the line width." + }; + + // Returns a position that is relative to the current anchor node. This is a method to + // handle precision problems that occur when approaching a line end point + glm::dvec3 coordinatePosFromAnchorNode(const glm::dvec3& worldPos) { + using namespace openspace; + glm::dvec3 anchorNodePos(0.0); + + const interaction::OrbitalNavigator& nav = + global::navigationHandler.orbitalNavigator(); + + if (nav.anchorNode()) { + anchorNodePos = nav.anchorNode()->worldPosition(); + } + glm::dvec3 diffPos = worldPos - anchorNodePos; + return diffPos; + } +} // namespace + +namespace openspace { + +documentation::Documentation RenderableNodeLine::Documentation() { + using namespace documentation; + return { + "Renderable Node Line", + "base_renderable_renderablenodeline", + { + { + StartNodeInfo.identifier, + new StringVerifier, + Optional::Yes, + StartNodeInfo.description + }, + { + EndNodeInfo.identifier, + new StringVerifier, + Optional::Yes, + EndNodeInfo.description + }, + { + LineColorInfo.identifier, + new DoubleVector3Verifier, + Optional::Yes, + LineColorInfo.description + }, + { + LineWidthInfo.identifier, + new DoubleVerifier, + Optional::Yes, + LineWidthInfo.description + } + } + }; +} + +RenderableNodeLine::RenderableNodeLine(const ghoul::Dictionary& dictionary) + : Renderable(dictionary) + , _lineColor(LineColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) + , _lineWidth(LineWidthInfo, 2.f, 1.f, 20.f) + , _start(StartNodeInfo, Root) + , _end(EndNodeInfo, Root) +{ + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "RenderableNodeLine" + ); + + if (dictionary.hasKey(StartNodeInfo.identifier)) { + _start = dictionary.value(StartNodeInfo.identifier); + } + + if (dictionary.hasKey(EndNodeInfo.identifier)) { + _end = dictionary.value(EndNodeInfo.identifier); + } + + if (dictionary.hasKey(LineColorInfo.identifier)) { + _lineColor = dictionary.value(LineColorInfo.identifier); + } + if (dictionary.hasKey(LineWidthInfo.identifier)) { + _lineWidth = static_cast(dictionary.value(LineWidthInfo.identifier)); + } + + _start.onChange([&]() { validateNodes(); }); + _end.onChange([&]() { validateNodes(); }); + + addProperty(_start); + addProperty(_end); + addProperty(_lineColor); + addProperty(_lineWidth); + addProperty(_opacity); +} + +double RenderableNodeLine::distance() const { + return glm::distance(_startPos, _endPos); +} + +std::string RenderableNodeLine::start() const { + return _start; +} + +std::string RenderableNodeLine::end() const { + return _end; +} + +void RenderableNodeLine::initializeGL() { + _program = BaseModule::ProgramObjectManager.request( + ProgramName, + []() -> std::unique_ptr { + return global::renderEngine.buildRenderProgram( + ProgramName, + absPath("${MODULE_BASE}/shaders/line_vs.glsl"), + absPath("${MODULE_BASE}/shaders/line_fs.glsl") + ); + } + ); + + // Generate + glGenVertexArrays(1, &_vaoId); + glGenBuffers(1, &_vBufferId); + + bindGL(); + + glVertexAttribPointer(_locVertex, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), nullptr); + glEnableVertexAttribArray(_locVertex); + + unbindGL(); +} + +void RenderableNodeLine::deinitializeGL() { + glDeleteVertexArrays(1, &_vaoId); + _vaoId = 0; + + glDeleteBuffers(1, &_vBufferId); + _vBufferId = 0; + + BaseModule::ProgramObjectManager.release( + ProgramName, + [](ghoul::opengl::ProgramObject* p) { + global::renderEngine.removeRenderProgram(p); + } + ); + _program = nullptr; +} + +bool RenderableNodeLine::isReady() const { + bool ready = true; + ready &= (_program != nullptr); + return ready; +} + +void RenderableNodeLine::unbindGL() { + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindVertexArray(0); +} + +void RenderableNodeLine::bindGL() { + glBindVertexArray(_vaoId); + glBindBuffer(GL_ARRAY_BUFFER, _vBufferId); +} + +void RenderableNodeLine::updateVertexData() { + _vertexArray.clear(); + + // Update the positions of the nodes + _startPos = coordinatePosFromAnchorNode( + global::renderEngine.scene()->sceneGraphNode(_start)->worldPosition() + ); + _endPos = coordinatePosFromAnchorNode( + global::renderEngine.scene()->sceneGraphNode(_end)->worldPosition() + ); + + _vertexArray.push_back(_startPos.x); + _vertexArray.push_back(_startPos.y); + _vertexArray.push_back(_startPos.z); + + _vertexArray.push_back(_endPos.x); + _vertexArray.push_back(_endPos.y); + _vertexArray.push_back(_endPos.z); + + _vertexArray; + + bindGL(); + glBufferData( + GL_ARRAY_BUFFER, + _vertexArray.size() * sizeof(float), + _vertexArray.data(), + GL_DYNAMIC_DRAW + ); + + // update vertex attributes + glVertexAttribPointer(_locVertex, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), nullptr); + + unbindGL(); +} + +void RenderableNodeLine::render(const RenderData& data, RendererTasks&) { + updateVertexData(); + + _program->activate(); + + glm::dmat4 anchorTranslation(1.0); + // Update anchor node information, used to counter precision problems + if (global::navigationHandler.orbitalNavigator().anchorNode()) { + anchorTranslation = glm::translate( + glm::dmat4(1.0), + global::navigationHandler.orbitalNavigator().anchorNode()->worldPosition() + ); + } + + const glm::dmat4 modelTransform = + glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * + glm::dmat4(data.modelTransform.rotation) * + glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)); + + const glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * + modelTransform * anchorTranslation; + + _program->setUniform("modelViewTransform", glm::mat4(modelViewTransform)); + _program->setUniform("projectionTransform", data.camera.projectionMatrix()); + _program->setUniform("color", glm::vec4(_lineColor.value(), _opacity)); + + // Save current state: + GLboolean isBlendEnabled = glIsEnabledi(GL_BLEND, 0); + GLboolean isLineSmoothEnabled = glIsEnabled(GL_LINE_SMOOTH); + GLfloat currentLineWidth; + glGetFloatv(GL_LINE_WIDTH, ¤tLineWidth); + + GLenum blendEquationRGB; + GLenum blendEquationAlpha; + GLenum blendDestAlpha; + GLenum blendDestRGB; + GLenum blendSrcAlpha; + GLenum blendSrcRGB; + glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB); + glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); + glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); + glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB); + glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); + glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB); + + // Change GL state: + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnablei(GL_BLEND, 0); + glEnable(GL_LINE_SMOOTH); + glLineWidth(_lineWidth); + + // Bind and draw + bindGL(); + glDrawArrays(GL_LINES, 0, 2); + + // Restore GL State + unbindGL(); + _program->deactivate(); + glLineWidth(currentLineWidth); + glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha); + glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha); + if (!isBlendEnabled) { + glDisablei(GL_BLEND, 0); + } + if (!isLineSmoothEnabled) { + glDisable(GL_LINE_SMOOTH); + } +} + +void RenderableNodeLine::validateNodes() { + if (!global::renderEngine.scene()->sceneGraphNode(_start)) { + LERROR(fmt::format( + "There is no scenegraph node with id {}, defaults to 'Root'", _start + )); + _start = Root; + } + if (!global::renderEngine.scene()->sceneGraphNode(_end)) { + LERROR(fmt::format( + "There is no scenegraph node with id {}, defaults to 'Root'", _end + )); + _end = Root; + } +} + +} // namespace openspace diff --git a/modules/base/rendering/renderablenodeline.h b/modules/base/rendering/renderablenodeline.h new file mode 100644 index 0000000000..075f59eea0 --- /dev/null +++ b/modules/base/rendering/renderablenodeline.h @@ -0,0 +1,90 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2020 * + * * + * 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_BASE___RENDERABLENODELINE___H__ +#define __OPENSPACE_MODULE_BASE___RENDERABLENODELINE___H__ + +#include + +#include +#include +#include +#include +#include + +namespace ghoul::opengl { class ProgramObject; } +namespace openspace::documentation { struct Documentation; } + +namespace openspace { + +class Translation; + +/** + * This is a class for a line that is drawn between two nodes in OpenSpace. + */ +class RenderableNodeLine : public Renderable { +public: + RenderableNodeLine(const ghoul::Dictionary& dictionary); + ~RenderableNodeLine() = default; + + static documentation::Documentation Documentation(); + + // Get the distance between the start and end node + double distance() const; + + std::string start() const; + std::string end() const; + +private: + void initializeGL() override; + void deinitializeGL() override; + + bool isReady() const override; + void updateVertexData(); + void render(const RenderData& data, RendererTasks& rendererTask) override; + void validateNodes(); + + void unbindGL(); + void bindGL(); + + ghoul::opengl::ProgramObject* _program; + /// The vertex attribute location for position + /// must correlate to layout location in vertex shader + const GLuint _locVertex = 0; + GLuint _vaoId = 0; + GLuint _vBufferId = 0; + std::vector _vertexArray; + + glm::dvec3 _startPos = glm::dvec3(0.0); + glm::dvec3 _endPos = glm::dvec3(0.0); + + properties::StringProperty _start; + properties::StringProperty _end; + properties::Vec3Property _lineColor; + properties::FloatProperty _lineWidth; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_BASE___RENDERABLENODELINE___H__ diff --git a/modules/base/rendering/renderableplane.cpp b/modules/base/rendering/renderableplane.cpp index 922e040a7f..cebce3931c 100644 --- a/modules/base/rendering/renderableplane.cpp +++ b/modules/base/rendering/renderableplane.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -215,7 +215,7 @@ void RenderablePlane::render(const RenderData& data, RendererTasks&) { ); glm::dvec3 newUp = glm::cross(normal, newRight); - glm::dmat4 cameraOrientedRotation; + glm::dmat4 cameraOrientedRotation = glm::dmat4(1.0); cameraOrientedRotation[0] = glm::dvec4(newRight, 0.0); cameraOrientedRotation[1] = glm::dvec4(newUp, 0.0); cameraOrientedRotation[2] = glm::dvec4(normal, 0.0); diff --git a/modules/base/rendering/renderableplane.h b/modules/base/rendering/renderableplane.h index a8be7ebe90..4f29066be1 100644 --- a/modules/base/rendering/renderableplane.h +++ b/modules/base/rendering/renderableplane.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/renderableplaneimagelocal.cpp b/modules/base/rendering/renderableplaneimagelocal.cpp index 9b6713ae5c..0de7e7f14c 100644 --- a/modules/base/rendering/renderableplaneimagelocal.cpp +++ b/modules/base/rendering/renderableplaneimagelocal.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/renderableplaneimagelocal.h b/modules/base/rendering/renderableplaneimagelocal.h index f207bdba7c..4b2f795e6d 100644 --- a/modules/base/rendering/renderableplaneimagelocal.h +++ b/modules/base/rendering/renderableplaneimagelocal.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/renderableplaneimageonline.cpp b/modules/base/rendering/renderableplaneimageonline.cpp index 6b33c315d1..9e89e49525 100644 --- a/modules/base/rendering/renderableplaneimageonline.cpp +++ b/modules/base/rendering/renderableplaneimageonline.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/renderableplaneimageonline.h b/modules/base/rendering/renderableplaneimageonline.h index 616fb526c3..10060d8cfb 100644 --- a/modules/base/rendering/renderableplaneimageonline.h +++ b/modules/base/rendering/renderableplaneimageonline.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/renderablesphere.cpp b/modules/base/rendering/renderablesphere.cpp index 4afb273429..b940702a5d 100644 --- a/modules/base/rendering/renderablesphere.cpp +++ b/modules/base/rendering/renderablesphere.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -305,7 +305,7 @@ bool RenderableSphere::isReady() const { } void RenderableSphere::initializeGL() { - _sphere = std::make_unique(_size, _segments); + _sphere = std::make_unique(_size, _segments); _sphere->initialize(); _shader = BaseModule::ProgramObjectManager.request( @@ -425,7 +425,8 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) { if (orientation == Orientation::Inside) { glCullFace(GL_FRONT); - } else if (orientation == Orientation::Both) { + } + else if (orientation == Orientation::Both) { glDisable(GL_CULL_FACE); } @@ -456,7 +457,8 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) { if (orientation == Orientation::Inside) { glCullFace(GL_BACK); - } else if (orientation == Orientation::Both) { + } + else if (orientation == Orientation::Both) { glEnable(GL_CULL_FACE); } } @@ -468,7 +470,7 @@ void RenderableSphere::update(const UpdateData&) { } if (_sphereIsDirty) { - _sphere = std::make_unique(_size, _segments); + _sphere = std::make_unique(_size, _segments); _sphere->initialize(); _sphereIsDirty = false; } diff --git a/modules/base/rendering/renderablesphere.h b/modules/base/rendering/renderablesphere.h index a37545acbf..98b2f3ac47 100644 --- a/modules/base/rendering/renderablesphere.h +++ b/modules/base/rendering/renderablesphere.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -40,7 +40,7 @@ namespace ghoul::opengl { namespace openspace { -class PowerScaledSphere; +class Sphere; struct RenderData; struct UpdateData; @@ -83,7 +83,7 @@ private: ghoul::opengl::ProgramObject* _shader = nullptr; std::unique_ptr _texture; - std::unique_ptr _sphere; + std::unique_ptr _sphere; UniformCache(opacity, modelViewProjection, modelViewRotation, colorTexture, _mirrorTexture) _uniformCache; diff --git a/modules/base/rendering/renderablesphericalgrid.cpp b/modules/base/rendering/renderablesphericalgrid.cpp index 054c83fa6c..f551902794 100644 --- a/modules/base/rendering/renderablesphericalgrid.cpp +++ b/modules/base/rendering/renderablesphericalgrid.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/renderablesphericalgrid.h b/modules/base/rendering/renderablesphericalgrid.h index 47b6b1f203..84400e2547 100644 --- a/modules/base/rendering/renderablesphericalgrid.h +++ b/modules/base/rendering/renderablesphericalgrid.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/renderabletrail.cpp b/modules/base/rendering/renderabletrail.cpp index 836ee76954..b6fa66ff23 100644 --- a/modules/base/rendering/renderabletrail.cpp +++ b/modules/base/rendering/renderabletrail.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -38,10 +38,10 @@ namespace { constexpr const char* ProgramName = "EphemerisProgram"; constexpr const char* KeyTranslation = "Translation"; - constexpr const std::array UniformNames = { + constexpr const std::array UniformNames = { "opacity", "modelViewTransform", "projectionTransform", "color", "useLineFade", "lineFade", "vertexSortingMethod", "idOffset", "nVertices", "stride", "pointSize", - "renderPhase" + "renderPhase", "resolution", "lineWidth" }; // The possible values for the _renderingModes property @@ -175,10 +175,10 @@ documentation::Documentation RenderableTrail::Documentation() { RenderableTrail::Appearance::Appearance() : properties::PropertyOwner(AppearanceInfo) - , lineColor(LineColorInfo, glm::vec3(1.0f, 1.0f, 0.f), glm::vec3(0.f), glm::vec3(1.f)) + , lineColor(LineColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) , useLineFade(EnableFadeInfo, true) , lineFade(FadeInfo, 1.f, 0.f, 30.f) - , lineWidth(LineWidthInfo, 2.f, 1.f, 20.f) + , lineWidth(LineWidthInfo, 10.f, 1.f, 20.f) , pointSize(PointSizeInfo, 1, 1, 64) , renderingModes( RenderingModeInfo, @@ -249,6 +249,18 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary) } void RenderableTrail::initializeGL() { +#ifdef __APPLE__ + _programObject = BaseModule::ProgramObjectManager.request( + ProgramName, + []() -> std::unique_ptr { + return global::renderEngine.buildRenderProgram( + ProgramName, + absPath("${MODULE_BASE}/shaders/renderabletrail_apple_vs.glsl"), + absPath("${MODULE_BASE}/shaders/renderabletrail_apple_fs.glsl") + ); + } + ); +#else _programObject = BaseModule::ProgramObjectManager.request( ProgramName, []() -> std::unique_ptr { @@ -259,6 +271,7 @@ void RenderableTrail::initializeGL() { ); } ); +#endif ghoul::opengl::updateUniformLocations(*_programObject, _uniformCache, UniformNames); } @@ -294,6 +307,9 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) { _programObject->setUniform(_uniformCache.lineFade, _appearance.lineFade); } + /*glm::ivec2 resolution = global::renderEngine.renderingResolution(); + _programObject->setUniform(_uniformCache.resolution, resolution);*/ + static std::map SortingMapping = { // Fragile! Keep in sync with shader { RenderInformation::VertexSorting::NewestFirst, 0 }, @@ -317,15 +333,19 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) { (_appearance.renderingModes == RenderingModeLinesPoints); if (renderLines) { - glLineWidth(_appearance.lineWidth); +#ifdef __APPLE__ + glLineWidth(1.f); +#else + glLineWidth(ceil((2.f * 1.f + _appearance.lineWidth) * std::sqrt(2.f))); +#endif } if (renderPoints) { glEnable(GL_PROGRAM_POINT_SIZE); } auto render = [renderLines, renderPoints, p = _programObject, &data, - &modelTransform, pointSize = _appearance.pointSize.value(), - c = _uniformCache] + &modelTransform, pointSize = _appearance.pointSize.value(), + c = _uniformCache, lw = _appearance.lineWidth] (RenderInformation& info, int nVertices, int offset) { // We pass in the model view transformation matrix as double in order to maintain @@ -346,6 +366,14 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) { p->setUniform(c.nVertices, nVertices); + + #ifndef __APPLE__ + glm::ivec2 resolution = global::renderEngine.renderingResolution(); + p->setUniform(c.resolution, resolution); + + p->setUniform(c.lineWidth, ceil((2.f * 1.f + lw) * std::sqrt(2.f))); + #endif + if (renderPoints) { // The stride parameter determines the distance between larger points and // smaller ones @@ -361,8 +389,6 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) { glBindVertexArray(info._vaoID); if (renderLines) { - glEnable(GL_LINE_SMOOTH); - glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); p->setUniform(c.renderPhase, RenderPhaseLines); // Subclasses of this renderer might be using the index array or might now be // so we check if there is data available and if there isn't, we use the @@ -382,7 +408,6 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) { reinterpret_cast(info.first * sizeof(unsigned int)) ); } - glDisable(GL_LINE_SMOOTH); } if (renderPoints) { // Subclasses of this renderer might be using the index array or might now be @@ -413,6 +438,24 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) { 0 : _primaryRenderInformation.first; + // Culling + const double scaledRadius = glm::length( + glm::dmat3(modelTransform) * glm::dvec3(_boundingSphere, 0.0, 0.0) + ); + + glm::dvec3 trailPosWorld = glm::dvec3( + modelTransform * _primaryRenderInformation._localTransform * + glm::dvec4(0.0, 0.0, 0.0, 1.0) + ); + const double distance = glm::distance( + trailPosWorld, + data.camera.eyePositionVec3() + ); + + if (distance > scaledRadius * DISTANCE_CULLING_RADII) { + return; + } + // Render the primary batch of vertices render(_primaryRenderInformation, totalNumber, primaryOffset); diff --git a/modules/base/rendering/renderabletrail.h b/modules/base/rendering/renderabletrail.h index 68adcf8e8b..e2a0eb088d 100644 --- a/modules/base/rendering/renderabletrail.h +++ b/modules/base/rendering/renderabletrail.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -72,6 +72,8 @@ class Translation; class RenderableTrail : public Renderable { public: +const double DISTANCE_CULLING_RADII = 800.0; + struct Appearance : properties::PropertyOwner { Appearance(); /// Specifies the base color of the line before fading @@ -182,7 +184,8 @@ private: ghoul::opengl::ProgramObject* _programObject = nullptr; UniformCache(opacity, modelView, projection, color, useLineFade, lineFade, - vertexSorting, idOffset, nVertices, stride, pointSize, renderPhase) _uniformCache; + vertexSorting, idOffset, nVertices, stride, pointSize, renderPhase, + resolution, lineWidth) _uniformCache; }; } // namespace openspace diff --git a/modules/base/rendering/renderabletrailorbit.cpp b/modules/base/rendering/renderabletrailorbit.cpp index f92385d35f..db57d56381 100644 --- a/modules/base/rendering/renderabletrailorbit.cpp +++ b/modules/base/rendering/renderabletrailorbit.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -356,6 +356,24 @@ void RenderableTrailOrbit::update(const UpdateData& data) { glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, nullptr); glBindVertexArray(0); + + // Updating bounding sphere + glm::vec3 maxVertex(-std::numeric_limits::max()); + glm::vec3 minVertex(std::numeric_limits::max()); + + auto setMax = [&maxVertex, &minVertex](const TrailVBOLayout& vertexData) { + maxVertex.x = std::max(maxVertex.x, vertexData.x); + maxVertex.y = std::max(maxVertex.y, vertexData.y); + maxVertex.z = std::max(maxVertex.z, vertexData.z); + + minVertex.x = std::min(minVertex.x, vertexData.x); + minVertex.y = std::min(minVertex.y, vertexData.y); + minVertex.z = std::min(minVertex.z, vertexData.z); + }; + + std::for_each(_vertexArray.begin(), _vertexArray.end(), setMax); + + setBoundingSphere(glm::distance(maxVertex, minVertex) / 2.0); } RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails( diff --git a/modules/base/rendering/renderabletrailorbit.h b/modules/base/rendering/renderabletrailorbit.h index 62228454d7..49c2257e5f 100644 --- a/modules/base/rendering/renderabletrailorbit.h +++ b/modules/base/rendering/renderabletrailorbit.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/renderabletrailtrajectory.cpp b/modules/base/rendering/renderabletrailtrajectory.cpp index ee019b8827..e8dae4adc8 100644 --- a/modules/base/rendering/renderabletrailtrajectory.cpp +++ b/modules/base/rendering/renderabletrailtrajectory.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -333,6 +333,25 @@ void RenderableTrailTrajectory::update(const UpdateData& data) { } glBindVertexArray(0); + + // Updating bounding sphere + glm::vec3 maxVertex(-std::numeric_limits::max()); + glm::vec3 minVertex(std::numeric_limits::max()); + + auto setMax = [&maxVertex, &minVertex](const TrailVBOLayout& vertexData) { + maxVertex.x = std::max(maxVertex.x, vertexData.x); + maxVertex.y = std::max(maxVertex.y, vertexData.y); + maxVertex.z = std::max(maxVertex.z, vertexData.z); + + minVertex.x = std::min(minVertex.x, vertexData.x); + minVertex.y = std::min(minVertex.y, vertexData.y); + minVertex.z = std::min(minVertex.z, vertexData.z); + }; + + std::for_each(_vertexArray.begin(), _vertexArray.end(), setMax); + + setBoundingSphere(glm::distance(maxVertex, minVertex) / 2.0); + } } // namespace openspace diff --git a/modules/base/rendering/renderabletrailtrajectory.h b/modules/base/rendering/renderabletrailtrajectory.h index 3f2311bc35..82a97bb968 100644 --- a/modules/base/rendering/renderabletrailtrajectory.h +++ b/modules/base/rendering/renderabletrailtrajectory.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/screenspacedashboard.cpp b/modules/base/rendering/screenspacedashboard.cpp index d86376d06f..a6dfd3a214 100644 --- a/modules/base/rendering/screenspacedashboard.cpp +++ b/modules/base/rendering/screenspacedashboard.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -151,24 +151,15 @@ ScreenSpaceDashboard::ScreenSpaceDashboard(const ghoul::Dictionary& dictionary) "ScreenSpaceDashboard" ); - int iIdentifier = 0; - if (_identifier.empty()) { - static int id = 0; - iIdentifier = id; - - if (iIdentifier == 0) { - setIdentifier("ScreenSpaceDashboard"); - } - else { - setIdentifier("ScreenSpaceDashboard" + std::to_string(iIdentifier)); - } - ++id; + std::string identifier; + if (dictionary.hasKeyAndValue(KeyIdentifier)) { + identifier = dictionary.value(KeyIdentifier); } - - if (_guiName.empty()) { - // Adding an extra space to the user-facing name as it looks nicer - setGuiName("ScreenSpaceDashboard " + std::to_string(iIdentifier)); + else { + identifier = "ScreenSpaceDashboard"; } + identifier = makeUniqueIdentifier(identifier); + setIdentifier(std::move(identifier)); if (dictionary.hasKey(UseMainInfo.identifier)) { _useMainDashboard = dictionary.value(UseMainInfo.identifier); @@ -210,7 +201,7 @@ bool ScreenSpaceDashboard::isReady() const { void ScreenSpaceDashboard::update() { if (global::windowDelegate.windowHasResized()) { - const glm::ivec2 size = global::windowDelegate.currentWindowResolution(); + const glm::ivec2 size = global::windowDelegate.currentDrawBufferResolution(); _size = { 0.f, 0.f, size.x, size.y }; createFramebuffer(); } diff --git a/modules/base/rendering/screenspacedashboard.h b/modules/base/rendering/screenspacedashboard.h index ad7763cd27..49b2a8fbed 100644 --- a/modules/base/rendering/screenspacedashboard.h +++ b/modules/base/rendering/screenspacedashboard.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/screenspaceframebuffer.cpp b/modules/base/rendering/screenspaceframebuffer.cpp index 5a94669b99..dab0c44e2b 100644 --- a/modules/base/rendering/screenspaceframebuffer.cpp +++ b/modules/base/rendering/screenspaceframebuffer.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -77,7 +77,7 @@ ScreenSpaceFramebuffer::ScreenSpaceFramebuffer(const ghoul::Dictionary& dictiona setGuiName("ScreenSpaceFramebuffer " + std::to_string(iIdentifier)); } - glm::vec2 resolution = global::windowDelegate.currentWindowResolution(); + glm::vec2 resolution = global::windowDelegate.currentDrawBufferResolution(); addProperty(_size); _size.set(glm::vec4(0, 0, resolution.x,resolution.y)); } @@ -103,13 +103,15 @@ bool ScreenSpaceFramebuffer::deinitializeGL() { } void ScreenSpaceFramebuffer::render() { - const glm::vec2& resolution = global::windowDelegate.currentWindowResolution(); + const glm::vec2& resolution = global::windowDelegate.currentDrawBufferResolution(); const glm::vec4& size = _size.value(); const float xratio = resolution.x / (size.z - size.x); const float yratio = resolution.y / (size.w - size.y);; if (!_renderFunctions.empty()) { + GLint viewport[4]; + glGetIntegerv(GL_VIEWPORT, viewport); glViewport( static_cast(-size.x * xratio), static_cast(-size.y * yratio), @@ -127,12 +129,7 @@ void ScreenSpaceFramebuffer::render() { _framebuffer->deactivate(); glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); - glViewport( - 0, - 0, - static_cast(resolution.x), - static_cast(resolution.y) - ); + glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); const glm::mat4 globalRotation = globalRotationMatrix(); const glm::mat4 translation = translationMatrix(); @@ -170,7 +167,7 @@ void ScreenSpaceFramebuffer::removeAllRenderFunctions() { } void ScreenSpaceFramebuffer::createFramebuffer() { - glm::vec2 resolution = global::windowDelegate.currentWindowResolution(); + glm::vec2 resolution = global::windowDelegate.currentDrawBufferResolution(); _framebuffer = std::make_unique(); _framebuffer->activate(); diff --git a/modules/base/rendering/screenspaceframebuffer.h b/modules/base/rendering/screenspaceframebuffer.h index e1919e0f5f..e824179bb6 100644 --- a/modules/base/rendering/screenspaceframebuffer.h +++ b/modules/base/rendering/screenspaceframebuffer.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/screenspaceimagelocal.cpp b/modules/base/rendering/screenspaceimagelocal.cpp index 392a8952d0..7901089979 100644 --- a/modules/base/rendering/screenspaceimagelocal.cpp +++ b/modules/base/rendering/screenspaceimagelocal.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -78,24 +78,15 @@ ScreenSpaceImageLocal::ScreenSpaceImageLocal(const ghoul::Dictionary& dictionary "ScreenSpaceImageLocal" ); - int iIdentifier = 0; - if (_identifier.empty()) { - static int id = 0; - iIdentifier = id; - - if (iIdentifier == 0) { - setIdentifier("ScreenSpaceImageLocal"); - } - else { - setIdentifier("ScreenSpaceImageLocal" + std::to_string(iIdentifier)); - } - ++id; + std::string identifier; + if (dictionary.hasKeyAndValue(KeyIdentifier)) { + identifier = dictionary.value(KeyIdentifier); } - - if (_guiName.empty()) { - // Adding an extra space to the user-facing name as it looks nicer - setGuiName("ScreenSpaceImageLocal " + std::to_string(iIdentifier)); + else { + identifier = "ScreenSpaceImageLocal"; } + identifier = makeUniqueIdentifier(identifier); + setIdentifier(identifier); _texturePath.onChange([this]() { if (!FileSys.fileExists(FileSys.absolutePath(_texturePath))) { diff --git a/modules/base/rendering/screenspaceimagelocal.h b/modules/base/rendering/screenspaceimagelocal.h index e5a1ce8ec9..0c1fbc711e 100644 --- a/modules/base/rendering/screenspaceimagelocal.h +++ b/modules/base/rendering/screenspaceimagelocal.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rendering/screenspaceimageonline.cpp b/modules/base/rendering/screenspaceimageonline.cpp index 83026445cc..e9f41f952f 100644 --- a/modules/base/rendering/screenspaceimageonline.cpp +++ b/modules/base/rendering/screenspaceimageonline.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -80,24 +80,15 @@ ScreenSpaceImageOnline::ScreenSpaceImageOnline(const ghoul::Dictionary& dictiona "ScreenSpaceImageOnline" ); - int iIdentifier = 0; - if (_identifier.empty()) { - static int id = 0; - iIdentifier = id; - - if (iIdentifier == 0) { - setIdentifier("ScreenSpaceImageOnline"); - } - else { - setIdentifier("ScreenSpaceImageOnline" + std::to_string(iIdentifier)); - } - ++id; + std::string identifier; + if (dictionary.hasKeyAndValue(KeyIdentifier)) { + identifier = dictionary.value(KeyIdentifier); } - - if (_guiName.empty()) { - // Adding an extra space to the user-facing name as it looks nicer - setGuiName("ScreenSpaceImageOnline " + std::to_string(iIdentifier)); + else { + identifier = "ScreenSpaceImageOnline"; } + identifier = makeUniqueIdentifier(identifier); + setIdentifier(std::move(identifier)); _texturePath.onChange([this]() { _textureIsDirty = true; }); addProperty(_texturePath); diff --git a/modules/base/rendering/screenspaceimageonline.h b/modules/base/rendering/screenspaceimageonline.h index 1b23306692..428bee0c3d 100644 --- a/modules/base/rendering/screenspaceimageonline.h +++ b/modules/base/rendering/screenspaceimageonline.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rotation/constantrotation.cpp b/modules/base/rotation/constantrotation.cpp index d79577c5d9..3696f09910 100644 --- a/modules/base/rotation/constantrotation.cpp +++ b/modules/base/rotation/constantrotation.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rotation/constantrotation.h b/modules/base/rotation/constantrotation.h index bf887fea4c..91faf7c80f 100644 --- a/modules/base/rotation/constantrotation.h +++ b/modules/base/rotation/constantrotation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rotation/fixedrotation.cpp b/modules/base/rotation/fixedrotation.cpp index 7015ae14f4..5a9a07e5fd 100644 --- a/modules/base/rotation/fixedrotation.cpp +++ b/modules/base/rotation/fixedrotation.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rotation/fixedrotation.h b/modules/base/rotation/fixedrotation.h index 0c93d1434b..6c59047c90 100644 --- a/modules/base/rotation/fixedrotation.h +++ b/modules/base/rotation/fixedrotation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rotation/luarotation.cpp b/modules/base/rotation/luarotation.cpp index 77035c21fb..7fa81592d1 100644 --- a/modules/base/rotation/luarotation.cpp +++ b/modules/base/rotation/luarotation.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rotation/luarotation.h b/modules/base/rotation/luarotation.h index 032ee20c33..74248480ac 100644 --- a/modules/base/rotation/luarotation.h +++ b/modules/base/rotation/luarotation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rotation/staticrotation.cpp b/modules/base/rotation/staticrotation.cpp index 6b4dca540a..c5ca228c74 100644 --- a/modules/base/rotation/staticrotation.cpp +++ b/modules/base/rotation/staticrotation.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -35,25 +35,25 @@ namespace { "graph node that this transformation is attached to relative to its parent." }; - // Conversion from rotation matrix to euler angles, - // given that the rotation is a pure rotation matrix. - // Inspired by: - // https://www.learnopencv.com/rotation-matrix-to-euler-angles/ + // Conversion from rotation matrix to euler angles, given that the rotation is a pure + // rotation matrix. + // Inspired by: https://www.learnopencv.com/rotation-matrix-to-euler-angles/ glm::dvec3 rotationMatrixToEulerAngles(glm::dmat4 mat) { - double sy = glm::sqrt(mat[0][0] * mat[0][0] + mat[0][1] * mat[0][1]); + const double sy = glm::sqrt(mat[0][0] * mat[0][0] + mat[0][1] * mat[0][1]); bool singular = sy < 1e-6; - double x, y, z; + glm::dvec3 res; if (singular) { - x = glm::atan(-mat[2][1], mat[1][1]); - y = glm::atan(-mat[0][2], sy); - z = 0; - } else { - x = glm::atan(mat[1][2], mat[2][2]); - y = glm::atan(-mat[0][2], sy); - z = glm::atan(mat[0][1], mat[0][0]); + res.x = glm::atan(-mat[2][1], mat[1][1]); + res.y = glm::atan(-mat[0][2], sy); + res.z = 0; } - return glm::dvec3(x, y, z); + else { + res.x = glm::atan(mat[1][2], mat[2][2]); + res.y = glm::atan(-mat[0][2], sy); + res.z = glm::atan(mat[0][1], mat[0][0]); + } + return res; } } // namespace @@ -109,13 +109,15 @@ StaticRotation::StaticRotation(const ghoul::Dictionary& dictionary) : StaticRota dictionary.value(RotationInfo.identifier) ); _matrixIsDirty = true; - } else if (dictionary.hasKeyAndValue(RotationInfo.identifier)) { + } + else if (dictionary.hasKeyAndValue(RotationInfo.identifier)) { glm::dvec4 data = dictionary.value(RotationInfo.identifier); _eulerRotation = rotationMatrixToEulerAngles( glm::mat3_cast(glm::dquat(data.w, data.x, data.y, data.z)) ); _matrixIsDirty = true; - } else if (dictionary.hasKeyAndValue(RotationInfo.identifier)) { + } + else if (dictionary.hasKeyAndValue(RotationInfo.identifier)) { _eulerRotation = rotationMatrixToEulerAngles( dictionary.value(RotationInfo.identifier) ); diff --git a/modules/base/rotation/staticrotation.h b/modules/base/rotation/staticrotation.h index a4e43ecee9..c9a647bdec 100644 --- a/modules/base/rotation/staticrotation.h +++ b/modules/base/rotation/staticrotation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -44,7 +44,7 @@ public: private: properties::Vec3Property _eulerRotation; - mutable glm::dmat3 _cachedMatrix; + mutable glm::dmat3 _cachedMatrix = glm::dmat3(1.0); mutable bool _matrixIsDirty = true; }; diff --git a/modules/base/rotation/timelinerotation.cpp b/modules/base/rotation/timelinerotation.cpp index b55389aa6d..533fd21e47 100644 --- a/modules/base/rotation/timelinerotation.cpp +++ b/modules/base/rotation/timelinerotation.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/rotation/timelinerotation.h b/modules/base/rotation/timelinerotation.h index a969341a89..a5f6a3b41a 100644 --- a/modules/base/rotation/timelinerotation.h +++ b/modules/base/rotation/timelinerotation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/scale/luascale.cpp b/modules/base/scale/luascale.cpp index 8ed69aac29..cfd19f9aca 100644 --- a/modules/base/scale/luascale.cpp +++ b/modules/base/scale/luascale.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/scale/luascale.h b/modules/base/scale/luascale.h index e24f6d0a14..ce8a1fa061 100644 --- a/modules/base/scale/luascale.h +++ b/modules/base/scale/luascale.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/scale/staticscale.cpp b/modules/base/scale/staticscale.cpp index 91f2602f1c..bb282dfb9e 100644 --- a/modules/base/scale/staticscale.cpp +++ b/modules/base/scale/staticscale.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -58,7 +58,7 @@ double StaticScale::scaleValue(const UpdateData&) const { return _scaleValue; } -StaticScale::StaticScale() : _scaleValue(ScaleInfo, 1.0, 0.1, 100) { +StaticScale::StaticScale() : _scaleValue(ScaleInfo, 1.f, 0.1f, 100.f) { addProperty(_scaleValue); _scaleValue.onChange([this]() { diff --git a/modules/base/scale/staticscale.h b/modules/base/scale/staticscale.h index 5557bbaca2..21e5bb6cde 100644 --- a/modules/base/scale/staticscale.h +++ b/modules/base/scale/staticscale.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/scale/timedependentscale.cpp b/modules/base/scale/timedependentscale.cpp index 4c0ed6812a..0fba563a0c 100644 --- a/modules/base/scale/timedependentscale.cpp +++ b/modules/base/scale/timedependentscale.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/scale/timedependentscale.h b/modules/base/scale/timedependentscale.h index ef0d782a51..e2d219bf6e 100644 --- a/modules/base/scale/timedependentscale.h +++ b/modules/base/scale/timedependentscale.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/shaders/axes_fs.glsl b/modules/base/shaders/axes_fs.glsl index 7435730021..0b1513ac46 100644 --- a/modules/base/shaders/axes_fs.glsl +++ b/modules/base/shaders/axes_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/shaders/axes_vs.glsl b/modules/base/shaders/axes_vs.glsl index 60a723f819..6ae73a55eb 100644 --- a/modules/base/shaders/axes_vs.glsl +++ b/modules/base/shaders/axes_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/shaders/grid_fs.glsl b/modules/base/shaders/grid_fs.glsl index ee5466bc80..3f1e1e13f1 100644 --- a/modules/base/shaders/grid_fs.glsl +++ b/modules/base/shaders/grid_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/shaders/grid_vs.glsl b/modules/base/shaders/grid_vs.glsl index 5153c1f2c4..d5b710ad4e 100644 --- a/modules/base/shaders/grid_vs.glsl +++ b/modules/base/shaders/grid_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/shaders/imageplane_fs.glsl b/modules/base/shaders/imageplane_fs.glsl index a8e81ab9a8..2ebb17f323 100644 --- a/modules/base/shaders/imageplane_fs.glsl +++ b/modules/base/shaders/imageplane_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/shaders/imageplane_vs.glsl b/modules/base/shaders/imageplane_vs.glsl index 0962157b38..585154a73f 100644 --- a/modules/base/shaders/imageplane_vs.glsl +++ b/modules/base/shaders/imageplane_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -22,6 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ +// @TODO (abock, 2019-12-27) Move this file to the spacecraftinstruments module + #version __CONTEXT__ #include "PowerScaling/powerScaling_vs.hglsl" @@ -36,7 +38,7 @@ uniform mat4 modelViewProjectionTransform; void main() { - vec4 position = vec4(in_position.xyz * pow(10, in_position.w), 1); + vec4 position = vec4(in_position.xyz, 1); vec4 positionClipSpace = modelViewProjectionTransform * position; vec4 positionScreenSpace = z_normalization(positionClipSpace); diff --git a/apps/TimelineView/informationwidget.h b/modules/base/shaders/line_fs.glsl similarity index 80% rename from apps/TimelineView/informationwidget.h rename to modules/base/shaders/line_fs.glsl index a19ee41fb8..0b8309c319 100644 --- a/apps/TimelineView/informationwidget.h +++ b/modules/base/shaders/line_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -22,20 +22,21 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_APP_TIMELINEVIEW___INFORMATIONWIDGET___H__ -#define __OPENSPACE_APP_TIMELINEVIEW___INFORMATIONWIDGET___H__ +#include "fragment.glsl" +#include "floatoperations.glsl" -#include +in float vs_depth; +in vec4 vs_positionViewSpace; -class InformationWidget : public QTextEdit { -Q_OBJECT -public: - InformationWidget(QWidget* parent); - void socketConnected(); - void socketDisconnected(); +uniform vec4 color; -public slots: - void logInformation(QString text); -}; +Fragment getFragment() { + Fragment frag; -#endif // __OPENSPACE_APP_TIMELINEVIEW___INFORMATIONWIDGET___H__ + frag.color = color; + + frag.depth = vs_depth; + frag.gPosition = vs_positionViewSpace; + frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0); + return frag; +} diff --git a/modules/base/shaders/line_vs.glsl b/modules/base/shaders/line_vs.glsl new file mode 100644 index 0000000000..af629e75a2 --- /dev/null +++ b/modules/base/shaders/line_vs.glsl @@ -0,0 +1,43 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2020 * + * * + * 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__ + +layout(location = 0) in vec3 in_position; + +out float vs_depth; +out vec4 vs_positionViewSpace; + +uniform mat4 modelViewTransform; +uniform mat4 projectionTransform; + +void main() { + vs_positionViewSpace = vec4(modelViewTransform * dvec4(in_position, 1)); + vec4 positionScreenSpace = projectionTransform * vs_positionViewSpace; + vs_depth = positionScreenSpace.w; + gl_Position = positionScreenSpace; + + // Set z to 0 to disable near and far plane, unique handling for perspective in space + gl_Position.z = 0.f; +} diff --git a/modules/base/shaders/model_fs.glsl b/modules/base/shaders/model_fs.glsl index b4bd1fd9ec..628c87b2d4 100644 --- a/modules/base/shaders/model_fs.glsl +++ b/modules/base/shaders/model_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/shaders/model_vs.glsl b/modules/base/shaders/model_vs.glsl index 86c93858fa..1d951f8ef5 100644 --- a/modules/base/shaders/model_vs.glsl +++ b/modules/base/shaders/model_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/shaders/plane_fs.glsl b/modules/base/shaders/plane_fs.glsl index 62554968fe..e5be9c9e62 100644 --- a/modules/base/shaders/plane_fs.glsl +++ b/modules/base/shaders/plane_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/shaders/plane_vs.glsl b/modules/base/shaders/plane_vs.glsl index a341672fa4..a702df7eee 100644 --- a/modules/base/shaders/plane_vs.glsl +++ b/modules/base/shaders/plane_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/tests/test_gdalwms.inl b/modules/base/shaders/renderabletrail_apple_fs.glsl similarity index 60% rename from tests/test_gdalwms.inl rename to modules/base/shaders/renderabletrail_apple_fs.glsl index 50b7dec7ec..d89b3cc720 100644 --- a/tests/test_gdalwms.inl +++ b/modules/base/shaders/renderabletrail_apple_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -22,37 +22,47 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include "gdal.h" -#include "gdal_priv.h" +#include "fragment.glsl" -#include +in float vs_positionDepth; +in vec4 vs_gPosition; +in float fade; + +uniform vec3 color; +uniform int renderPhase; +uniform float opacity = 1.0; + +// Fragile! Keep in sync with RenderableTrail::render::RenderPhase +#define RenderPhaseLines 0 +#define RenderPhasePoints 1 + +#define Delta 0.25 -#include "cpl_conv.h" -#include "cpl_string.h" +Fragment getFragment() { + Fragment frag; + frag.color = vec4(color * fade, fade * opacity); + frag.depth = vs_positionDepth; + frag.blend = BLEND_MODE_ADDITIVE; -// Error: cannot open source file "wms/wmsdriver.h" -//#include "wms/wmsdriver.h" + if (renderPhase == RenderPhasePoints) { + // Use the length of the vector (dot(circCoord, circCoord)) as factor in the + // smoothstep to gradually decrease the alpha on the edges of the point + vec2 circCoord = 2.0 * gl_PointCoord - 1.0; + //float circleClipping = 1.0 - smoothstep(1.0 - Delta, 1.0, dot(circCoord, circCoord)); + float circleClipping = smoothstep(1.0, 1.0 - Delta, dot(circCoord, circCoord)); + float transparencyCorrection = frag.color.a * circleClipping; + if (transparencyCorrection < 0.9) { + discard; + } -// Error: cannot open source file "wms/wmsmetadataset.h" -//#include "wms/wmsmetadataset.h" + frag.color.a = transparencyCorrection; + } + frag.gPosition = vs_gPosition; -class GdalWmsTest : public testing::Test {}; + // There is no normal here + frag.gNormal = vec4(0.0, 0.0, -1.0, 1.0); -TEST_F(GdalWmsTest, Simple) { - //GDALDatasetH poDataset; - //GDALAllRegister(); - - // - //std::string res = GDALVersionInfo("format"); - // - //std::cout << res << std::endl; - - //std::string testFile = absPath("${TESTDIR}/gdal/TERRA_CR_B143_2016-04-12.wms"); - - //poDataset = GDALOpen(testFile.c_str(), GA_ReadOnly); - - // This assertion fails - //ASSERT_NE(poDataset, nullptr) << "Failed to load testFile"; + return frag; } diff --git a/modules/base/shaders/renderabletrail_apple_vs.glsl b/modules/base/shaders/renderabletrail_apple_vs.glsl new file mode 100644 index 0000000000..aa6224c3af --- /dev/null +++ b/modules/base/shaders/renderabletrail_apple_vs.glsl @@ -0,0 +1,83 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2020 * + * * + * 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" + +layout(location = 0) in vec3 in_point_position; + +out float vs_positionDepth; +out vec4 vs_gPosition; +out float fade; + +uniform dmat4 modelViewTransform; +uniform mat4 projectionTransform; +uniform int idOffset; +uniform int nVertices; +uniform bool useLineFade; +uniform float lineFade; +uniform int vertexSortingMethod; +uniform int pointSize; +uniform int stride; + +uniform ivec2 resolution; + +// Fragile! Keep in sync with RenderableTrail::render +#define VERTEX_SORTING_NEWESTFIRST 0 +#define VERTEX_SORTING_OLDESTFIRST 1 +#define VERTEX_SORTING_NOSORTING 2 + + +void main() { + int modId = gl_VertexID; + + if ((vertexSortingMethod != VERTEX_SORTING_NOSORTING) && useLineFade) { + // Account for a potential rolling buffer + modId = gl_VertexID - idOffset; + if (modId < 0) { + modId += nVertices; + } + + // Convert the index to a [0,1] ranger + float id = float(modId) / float(nVertices); + + if (vertexSortingMethod == VERTEX_SORTING_NEWESTFIRST) { + id = 1.0 - id; + } + + fade = clamp(id * lineFade, 0.0, 1.0); + } + else { + fade = 1.0; + } + + vs_gPosition = vec4(modelViewTransform * dvec4(in_point_position, 1)); + vec4 vs_positionClipSpace = projectionTransform * vs_gPosition; + vs_positionDepth = vs_positionClipSpace.w; + + gl_PointSize = (stride == 1 || int(modId) % stride == 0) ? + float(pointSize) : float(pointSize) / 2; + gl_Position = z_normalization(vs_positionClipSpace); +} diff --git a/modules/base/shaders/renderabletrail_fs.glsl b/modules/base/shaders/renderabletrail_fs.glsl index 4482761a7e..86aae007f2 100644 --- a/modules/base/shaders/renderabletrail_fs.glsl +++ b/modules/base/shaders/renderabletrail_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -24,14 +24,15 @@ #include "fragment.glsl" -in vec4 vs_positionScreenSpace; +in float vs_positionDepth; in vec4 vs_gPosition; in float fade; -in float v_pointSize; +noperspective in vec2 mathLine; uniform vec3 color; uniform int renderPhase; uniform float opacity = 1.0; +uniform float lineWidth; // Fragile! Keep in sync with RenderableTrail::render::RenderPhase #define RenderPhaseLines 0 @@ -43,7 +44,7 @@ uniform float opacity = 1.0; Fragment getFragment() { Fragment frag; frag.color = vec4(color * fade, fade * opacity); - frag.depth = vs_positionScreenSpace.w; + frag.depth = vs_positionDepth; frag.blend = BLEND_MODE_ADDITIVE; if (renderPhase == RenderPhasePoints) { @@ -60,6 +61,17 @@ Fragment getFragment() { frag.color.a = transparencyCorrection; } + double distanceCenter = length(mathLine - vec2(gl_FragCoord.xy)); + double dLW = double(lineWidth); + float blendFactor = 20; + + if (distanceCenter > dLW) { + frag.color.a = 0.0; + } + else { + frag.color.a *= pow(float((dLW - distanceCenter) / dLW), blendFactor); + } + frag.gPosition = vs_gPosition; // There is no normal here diff --git a/modules/base/shaders/renderabletrail_vs.glsl b/modules/base/shaders/renderabletrail_vs.glsl index 49af45b2ce..f7f0804fd8 100644 --- a/modules/base/shaders/renderabletrail_vs.glsl +++ b/modules/base/shaders/renderabletrail_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -28,10 +28,10 @@ layout(location = 0) in vec3 in_point_position; -out vec4 vs_positionScreenSpace; +out float vs_positionDepth; out vec4 vs_gPosition; out float fade; -out float v_pointSize; +noperspective out vec2 mathLine; uniform dmat4 modelViewTransform; uniform mat4 projectionTransform; @@ -43,6 +43,8 @@ uniform int vertexSortingMethod; uniform int pointSize; uniform int stride; +uniform ivec2 resolution; + // Fragile! Keep in sync with RenderableTrail::render #define VERTEX_SORTING_NEWESTFIRST 0 #define VERTEX_SORTING_OLDESTFIRST 1 @@ -73,9 +75,13 @@ void main() { } vs_gPosition = vec4(modelViewTransform * dvec4(in_point_position, 1)); - vs_positionScreenSpace = z_normalization(projectionTransform * vs_gPosition); + vec4 vs_positionClipSpace = projectionTransform * vs_gPosition; + vec4 vs_positionNDC = vs_positionClipSpace / vs_positionClipSpace.w; + vs_positionDepth = vs_positionClipSpace.w; + + gl_PointSize = (stride == 1 || int(modId) % stride == 0) ? + float(pointSize) : float(pointSize) / 2; + gl_Position = z_normalization(vs_positionClipSpace); - gl_PointSize = (stride == 1 || int(modId) % stride == 0) ? float(pointSize) : float(pointSize) / 2; - v_pointSize = gl_PointSize; - gl_Position = vs_positionScreenSpace; + mathLine = 0.5 * (vs_positionNDC.xy + vec2(1.0)) * vec2(resolution); } diff --git a/modules/base/shaders/screenspace_fs.glsl b/modules/base/shaders/screenspace_fs.glsl index 9dc5fd70ad..dc7d73b601 100644 --- a/modules/base/shaders/screenspace_fs.glsl +++ b/modules/base/shaders/screenspace_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/shaders/screenspace_vs.glsl b/modules/base/shaders/screenspace_vs.glsl index 075110baf2..f5c345f7e2 100644 --- a/modules/base/shaders/screenspace_vs.glsl +++ b/modules/base/shaders/screenspace_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/shaders/sphere_fs.glsl b/modules/base/shaders/sphere_fs.glsl index 5a82d91e6e..3aecbe4355 100644 --- a/modules/base/shaders/sphere_fs.glsl +++ b/modules/base/shaders/sphere_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/shaders/sphere_vs.glsl b/modules/base/shaders/sphere_vs.glsl index 38b19f23f0..cf747e4a51 100644 --- a/modules/base/shaders/sphere_vs.glsl +++ b/modules/base/shaders/sphere_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/timeframe/timeframeinterval.cpp b/modules/base/timeframe/timeframeinterval.cpp index f24268f3fd..53d8ebc1b9 100644 --- a/modules/base/timeframe/timeframeinterval.cpp +++ b/modules/base/timeframe/timeframeinterval.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -133,7 +133,8 @@ TimeFrameInterval::TimeFrameInterval(const ghoul::Dictionary& dictionary) dictionary.value(StartInfo.identifier) ); _hasStart = true; - } else if (dictionary.hasValue(StartInfo.identifier)) { + } + else if (dictionary.hasValue(StartInfo.identifier)) { _start = dictionary.value(StartInfo.identifier); _hasStart = true; } diff --git a/modules/base/timeframe/timeframeinterval.h b/modules/base/timeframe/timeframeinterval.h index e386063141..04b5f54cfc 100644 --- a/modules/base/timeframe/timeframeinterval.h +++ b/modules/base/timeframe/timeframeinterval.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/timeframe/timeframeunion.cpp b/modules/base/timeframe/timeframeunion.cpp index 4a01054c5b..2a2af962fe 100644 --- a/modules/base/timeframe/timeframeunion.cpp +++ b/modules/base/timeframe/timeframeunion.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/timeframe/timeframeunion.h b/modules/base/timeframe/timeframeunion.h index 679835c7f4..0b3c761859 100644 --- a/modules/base/timeframe/timeframeunion.h +++ b/modules/base/timeframe/timeframeunion.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/translation/luatranslation.cpp b/modules/base/translation/luatranslation.cpp index e16f486b70..1c3d1610b2 100644 --- a/modules/base/translation/luatranslation.cpp +++ b/modules/base/translation/luatranslation.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/translation/luatranslation.h b/modules/base/translation/luatranslation.h index 14f1836afa..2951c7e45d 100644 --- a/modules/base/translation/luatranslation.h +++ b/modules/base/translation/luatranslation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/translation/statictranslation.cpp b/modules/base/translation/statictranslation.cpp index a52abb34a7..00efb611b4 100644 --- a/modules/base/translation/statictranslation.cpp +++ b/modules/base/translation/statictranslation.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/translation/statictranslation.h b/modules/base/translation/statictranslation.h index 4b832d618c..a786bddfd6 100644 --- a/modules/base/translation/statictranslation.h +++ b/modules/base/translation/statictranslation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/translation/timelinetranslation.cpp b/modules/base/translation/timelinetranslation.cpp index 0dafe620b6..396e39e27f 100644 --- a/modules/base/translation/timelinetranslation.cpp +++ b/modules/base/translation/timelinetranslation.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/base/translation/timelinetranslation.h b/modules/base/translation/timelinetranslation.h index 0d528d36a6..86ef39af60 100644 --- a/modules/base/translation/timelinetranslation.h +++ b/modules/base/translation/timelinetranslation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/cefwebgui/CMakeLists.txt b/modules/cefwebgui/CMakeLists.txt index cd728ae7b2..0fcab73536 100644 --- a/modules/cefwebgui/CMakeLists.txt +++ b/modules/cefwebgui/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2018 # +# Copyright (c) 2014-2020 # # # # 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 # diff --git a/modules/cefwebgui/cefwebguimodule.cpp b/modules/cefwebgui/cefwebguimodule.cpp index 44c3ffa24b..2d5b7c520d 100644 --- a/modules/cefwebgui/cefwebguimodule.cpp +++ b/modules/cefwebgui/cefwebguimodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -35,6 +35,7 @@ #include #include #include +#include namespace { constexpr openspace::properties::Property::PropertyInfo EnabledInfo = { @@ -86,6 +87,8 @@ CefWebGuiModule::CefWebGuiModule() } void CefWebGuiModule::startOrStopGui() { + ZoneScoped + WebBrowserModule* webBrowserModule = global::moduleEngine.module(); const bool isGuiWindow = @@ -103,7 +106,13 @@ void CefWebGuiModule::startOrStopGui() { new GUIKeyboardHandler ); _instance->initialize(); - _instance->loadUrl(_url); + _instance->reshape(static_cast( + static_cast(global::windowDelegate.currentSubwindowSize()) * + global::windowDelegate.dpiScaling() + )); + if (!_url.value().empty()) { + _instance->loadUrl(_url); + } } if (_visible) { webBrowserModule->attachEventHandler(_instance.get()); @@ -112,7 +121,8 @@ void CefWebGuiModule::startOrStopGui() { _instance->setZoom(_guiScale); webBrowserModule->addBrowser(_instance.get()); - } else if (_instance) { + } + else if (_instance) { _instance->close(true); webBrowserModule->removeBrowser(_instance.get()); webBrowserModule->detachEventHandler(); @@ -121,6 +131,8 @@ void CefWebGuiModule::startOrStopGui() { } void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration) { + ZoneScoped + WebBrowserModule* webBrowserModule = global::moduleEngine.module(); @@ -131,31 +143,42 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration) } _enabled.onChange([this]() { + ZoneScopedN("CefWebGuiModule::enabled") + startOrStopGui(); }); _url.onChange([this]() { + ZoneScopedN("CefWebGuiModule::url") + if (_instance) { _instance->loadUrl(_url); } }); _reload.onChange([this]() { + ZoneScopedN("CefWebGuiModule::reload") + if (_instance) { _instance->reloadBrowser(); } }); _guiScale.onChange([this]() { + ZoneScopedN("CefWebGuiModule::guiScale") + if (_instance) { _instance->setZoom(_guiScale); } }); _visible.onChange([this, webBrowserModule]() { + ZoneScopedN("CefWebGuiModule::visible") + if (_visible && _instance) { webBrowserModule->attachEventHandler(_instance.get()); - } else { + } + else { webBrowserModule->detachEventHandler(); } }); @@ -170,6 +193,7 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration) _endpointCallback = webGuiModule->addEndpointChangeCallback( [this](const std::string& endpoint, bool exists) { + ZoneScopedN("CefWebGuiModule::endpointCallback") if (exists && endpoint == "frontend" && _instance) { _instance->reloadBrowser(); } @@ -191,6 +215,8 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration) }); global::callback::draw2D.emplace_back([this](){ + ZoneScopedN("CefWebGuiModule") + const bool isGuiWindow = global::windowDelegate.hasGuiWindow() ? global::windowDelegate.isGuiWindow() : @@ -198,11 +224,12 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration) const bool isMaster = global::windowDelegate.isMaster(); if (isGuiWindow && isMaster && _instance) { - if (global::windowDelegate.windowHasResized()) { + if (global::windowDelegate.windowHasResized() || _instance->_shouldReshape) { _instance->reshape(static_cast( - static_cast(global::windowDelegate.currentWindowSize()) * + static_cast(global::windowDelegate.currentSubwindowSize()) * global::windowDelegate.dpiScaling() )); + _instance->_shouldReshape = false; } if (_visible) { _instance->draw(); @@ -211,6 +238,8 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration) }); global::callback::deinitializeGL.emplace_back([this]() { + ZoneScopedN("CefWebGuiModule") + if (_endpointCallback != -1) { WebGuiModule* webGuiModule = global::moduleEngine.module(); webGuiModule->removeEndpointChangeCallback(_endpointCallback); diff --git a/modules/cefwebgui/cefwebguimodule.h b/modules/cefwebgui/cefwebguimodule.h index d822b838a5..2d42ed3c66 100644 --- a/modules/cefwebgui/cefwebguimodule.h +++ b/modules/cefwebgui/cefwebguimodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/cefwebgui/include/guikeyboardhandler.h b/modules/cefwebgui/include/guikeyboardhandler.h index ecd2f05d19..2a74407adc 100644 --- a/modules/cefwebgui/include/guikeyboardhandler.h +++ b/modules/cefwebgui/include/guikeyboardhandler.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/cefwebgui/include/guirenderhandler.h b/modules/cefwebgui/include/guirenderhandler.h index b28a1875f5..e03c5cfe1c 100644 --- a/modules/cefwebgui/include/guirenderhandler.h +++ b/modules/cefwebgui/include/guirenderhandler.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/cefwebgui/shaders/gui_fs.glsl b/modules/cefwebgui/shaders/gui_fs.glsl index 9dda0651ab..3b31cb9184 100644 --- a/modules/cefwebgui/shaders/gui_fs.glsl +++ b/modules/cefwebgui/shaders/gui_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/cefwebgui/shaders/gui_vs.glsl b/modules/cefwebgui/shaders/gui_vs.glsl index 2323d505d3..f8ee811e0a 100644 --- a/modules/cefwebgui/shaders/gui_vs.glsl +++ b/modules/cefwebgui/shaders/gui_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/cefwebgui/src/guikeyboardhandler.cpp b/modules/cefwebgui/src/guikeyboardhandler.cpp index 4c562bfec7..ef534d0095 100644 --- a/modules/cefwebgui/src/guikeyboardhandler.cpp +++ b/modules/cefwebgui/src/guikeyboardhandler.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/cefwebgui/src/guirenderhandler.cpp b/modules/cefwebgui/src/guirenderhandler.cpp index bf2099d697..325210abb8 100644 --- a/modules/cefwebgui/src/guirenderhandler.cpp +++ b/modules/cefwebgui/src/guirenderhandler.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/debugging/CMakeLists.txt b/modules/debugging/CMakeLists.txt index 382ea0b1dc..41dfdd2605 100644 --- a/modules/debugging/CMakeLists.txt +++ b/modules/debugging/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2018 # +# Copyright (c) 2014-2020 # # # # 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 # diff --git a/modules/debugging/debuggingmodule.cpp b/modules/debugging/debuggingmodule.cpp index 99e76a18f1..6e00c47158 100644 --- a/modules/debugging/debuggingmodule.cpp +++ b/modules/debugging/debuggingmodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/debugging/debuggingmodule.h b/modules/debugging/debuggingmodule.h index 27b26d8d18..2d30ebcdc9 100644 --- a/modules/debugging/debuggingmodule.h +++ b/modules/debugging/debuggingmodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/debugging/rendering/debugrenderer.cpp b/modules/debugging/rendering/debugrenderer.cpp index 6ffad6fd57..362bfe6580 100644 --- a/modules/debugging/rendering/debugrenderer.cpp +++ b/modules/debugging/rendering/debugrenderer.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/debugging/rendering/debugrenderer.h b/modules/debugging/rendering/debugrenderer.h index cfdd1ea48b..37729510e7 100644 --- a/modules/debugging/rendering/debugrenderer.h +++ b/modules/debugging/rendering/debugrenderer.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/debugging/rendering/debugshader_fs.glsl b/modules/debugging/rendering/debugshader_fs.glsl index 17a6ba023c..0baca40150 100644 --- a/modules/debugging/rendering/debugshader_fs.glsl +++ b/modules/debugging/rendering/debugshader_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/debugging/rendering/debugshader_vs.glsl b/modules/debugging/rendering/debugshader_vs.glsl index 6302b41b06..359cb7cbc6 100644 --- a/modules/debugging/rendering/debugshader_vs.glsl +++ b/modules/debugging/rendering/debugshader_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/debugging/rendering/renderabledebugplane.cpp b/modules/debugging/rendering/renderabledebugplane.cpp index 1ba47a690c..770211d15a 100644 --- a/modules/debugging/rendering/renderabledebugplane.cpp +++ b/modules/debugging/rendering/renderabledebugplane.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -208,7 +208,7 @@ void RenderableDebugPlane::deinitializeGL() { } void RenderableDebugPlane::render(const RenderData& data, RendererTasks&) { - glm::mat4 transform = glm::mat4(1.0); + glm::mat4 transform = glm::mat4(1.f); if (_billboard) { transform = glm::inverse(glm::mat4(data.camera.viewRotationMatrix())); } diff --git a/modules/debugging/rendering/renderabledebugplane.h b/modules/debugging/rendering/renderabledebugplane.h index 971df23bcd..95d003d435 100644 --- a/modules/debugging/rendering/renderabledebugplane.h +++ b/modules/debugging/rendering/renderabledebugplane.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/digitaluniverse/CMakeLists.txt b/modules/digitaluniverse/CMakeLists.txt index d5f5d119b0..e2f68ab6fa 100644 --- a/modules/digitaluniverse/CMakeLists.txt +++ b/modules/digitaluniverse/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2018 # +# Copyright (c) 2014-2020 # # # # 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 # diff --git a/modules/digitaluniverse/digitaluniversemodule.cpp b/modules/digitaluniverse/digitaluniversemodule.cpp index 7cebee2399..a49031dbd4 100644 --- a/modules/digitaluniverse/digitaluniversemodule.cpp +++ b/modules/digitaluniverse/digitaluniversemodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/digitaluniverse/digitaluniversemodule.h b/modules/digitaluniverse/digitaluniversemodule.h index dffa1914b9..9f1b46c7f8 100644 --- a/modules/digitaluniverse/digitaluniversemodule.h +++ b/modules/digitaluniverse/digitaluniversemodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp index da42b36210..688d518611 100644 --- a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp +++ b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include @@ -466,7 +465,8 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di if (o == "Camera View Direction") { _renderOption = RenderOptionViewDirection; - } else if (o == "Camera Position Normal") { + } + else if (o == "Camera Position Normal") { _renderOption = RenderOptionPositionNormal; } } @@ -814,21 +814,23 @@ void RenderableBillboardsCloud::renderBillboards(const RenderData& data, _program->setUniform(_uniformCache.cameraPos, data.camera.positionVec3()); _program->setUniform( _uniformCache.cameraLookup, - data.camera.lookUpVectorWorldSpace() + glm::vec3(data.camera.lookUpVectorWorldSpace()) ); _program->setUniform(_uniformCache.renderOption, _renderOption.value()); _program->setUniform(_uniformCache.modelMatrix, modelMatrix); _program->setUniform( _uniformCache.cameraViewProjectionMatrix, - glm::dmat4(data.camera.projectionMatrix()) * data.camera.combinedViewMatrix() + glm::mat4( + glm::dmat4(data.camera.projectionMatrix()) * data.camera.combinedViewMatrix() + ) ); _program->setUniform(_uniformCache.minBillboardSize, _billboardMinSize); // in pixels _program->setUniform(_uniformCache.maxBillboardSize, _billboardMaxSize); // in pixels _program->setUniform(_uniformCache.color, _pointColor); _program->setUniform(_uniformCache.alphaValue, _opacity); _program->setUniform(_uniformCache.scaleFactor, _scaleFactor); - _program->setUniform(_uniformCache.up, orthoUp); - _program->setUniform(_uniformCache.right, orthoRight); + _program->setUniform(_uniformCache.up, glm::vec3(orthoUp)); + _program->setUniform(_uniformCache.right, glm::vec3(orthoRight)); _program->setUniform(_uniformCache.fadeInValue, fadeInVariable); _program->setUniform( @@ -1473,8 +1475,8 @@ bool RenderableBillboardsCloud::readLabelFile() { std::stringstream str(line); - glm::vec3 position; - for (auto j = 0; j < 3; ++j) { + glm::vec3 position = glm::vec3(0.f); + for (int j = 0; j < 3; ++j) { str >> position[j]; } @@ -1692,7 +1694,7 @@ void RenderableBillboardsCloud::createDataSlice() { addPosition(position); } } - _fadeInDistance.setMaxValue(glm::vec2(10.0f * biggestCoord)); + _fadeInDistance.setMaxValue(glm::vec2(10.f * biggestCoord)); } void RenderableBillboardsCloud::createPolygonTexture() { @@ -1730,7 +1732,7 @@ void RenderableBillboardsCloud::renderToTexture(GLuint textureToRenderTo, glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureToRenderTo, 0); - glViewport(0, 0, textureWidth, textureHeight); + glViewport(viewport[0], viewport[1], textureWidth, textureHeight); loadPolygonGeometryForRendering(); renderPolygonGeometry(_polygonVao); diff --git a/modules/digitaluniverse/rendering/renderablebillboardscloud.h b/modules/digitaluniverse/rendering/renderablebillboardscloud.h index aea5818783..15d4d241e6 100644 --- a/modules/digitaluniverse/rendering/renderablebillboardscloud.h +++ b/modules/digitaluniverse/rendering/renderablebillboardscloud.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.cpp b/modules/digitaluniverse/rendering/renderabledumeshes.cpp index f0e96c1bba..bdc7b80436 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.cpp +++ b/modules/digitaluniverse/rendering/renderabledumeshes.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -236,12 +236,7 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _alphaValue(TransparencyInfo, 1.f, 0.f, 1.f) //, _scaleFactor(ScaleFactorInfo, 1.f, 0.f, 64.f) - , _textColor( - TextColorInfo, - glm::vec4(1.0f, 1.0, 1.0f, 1.f), - glm::vec4(0.f), - glm::vec4(1.f) - ) + , _textColor(TextColorInfo, glm::vec4(1.f), glm::vec4(0.f), glm::vec4(1.f)) , _textSize(TextSizeInfo, 8.f, 0.5f, 24.f) , _drawElements(DrawElementsInfo, true) , _drawLabels(DrawLabelInfo, false) @@ -718,7 +713,8 @@ bool RenderableDUMeshes::readSpeckFile() { //file.seekg(position); //break; continue; - } else { + } + else { //if (line.substr(0, 4) == "mesh") { // mesh lines are structured as follows: @@ -866,7 +862,7 @@ bool RenderableDUMeshes::readLabelFile() { std::stringstream str(line); - glm::vec3 position; + glm::vec3 position = glm::vec3(0.f); for (int j = 0; j < 3; ++j) { str >> position[j]; } diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.h b/modules/digitaluniverse/rendering/renderabledumeshes.h index 570d0c29b0..418f45eafe 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.h +++ b/modules/digitaluniverse/rendering/renderabledumeshes.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -146,7 +146,7 @@ private: std::vector> _labelData; int _nValuesPerAstronomicalObject = 0; - glm::dmat4 _transformationMatrix; + glm::dmat4 _transformationMatrix = glm::dmat4(1.0); std::unordered_map _meshColorMap; std::unordered_map _renderingMeshesMap; diff --git a/modules/digitaluniverse/rendering/renderableplanescloud.cpp b/modules/digitaluniverse/rendering/renderableplanescloud.cpp index a86eac1e72..e25c8c9eb9 100644 --- a/modules/digitaluniverse/rendering/renderableplanescloud.cpp +++ b/modules/digitaluniverse/rendering/renderableplanescloud.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -1118,7 +1118,7 @@ bool RenderablePlanesCloud::readLabelFile() { std::stringstream str(line); - glm::vec3 position; + glm::vec3 position = glm::vec3(0.f); for (int j = 0; j < 3; ++j) { str >> position[j]; } diff --git a/modules/digitaluniverse/rendering/renderableplanescloud.h b/modules/digitaluniverse/rendering/renderableplanescloud.h index ddde9e6023..bf7cced594 100644 --- a/modules/digitaluniverse/rendering/renderableplanescloud.h +++ b/modules/digitaluniverse/rendering/renderableplanescloud.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/digitaluniverse/rendering/renderablepoints.cpp b/modules/digitaluniverse/rendering/renderablepoints.cpp index befe656857..22054c2734 100644 --- a/modules/digitaluniverse/rendering/renderablepoints.cpp +++ b/modules/digitaluniverse/rendering/renderablepoints.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/digitaluniverse/rendering/renderablepoints.h b/modules/digitaluniverse/rendering/renderablepoints.h index f4d2711c97..58731d3c56 100644 --- a/modules/digitaluniverse/rendering/renderablepoints.h +++ b/modules/digitaluniverse/rendering/renderablepoints.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/digitaluniverse/shaders/billboard_fs.glsl b/modules/digitaluniverse/shaders/billboard_fs.glsl index 3ca590e5a5..d0fd92a9d2 100644 --- a/modules/digitaluniverse/shaders/billboard_fs.glsl +++ b/modules/digitaluniverse/shaders/billboard_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -25,7 +25,7 @@ #include "fragment.glsl" flat in vec4 gs_colorMap; -in float vs_screenSpaceDepth; +flat in float vs_screenSpaceDepth; in vec2 texCoord; in float ta; @@ -35,18 +35,23 @@ uniform sampler2D spriteTexture; uniform bool hasColorMap; uniform float fadeInValue; -Fragment getFragment() { - +Fragment getFragment() { vec4 textureColor = texture(spriteTexture, texCoord); + if (textureColor.a == 0.f || gs_colorMap.a == 0.f || ta == 0.f || fadeInValue == 0.f) + { + discard; + } + vec4 fullColor = vec4(1.0); if (hasColorMap) { fullColor = vec4( - gs_colorMap.rgb * textureColor.rgb, + gs_colorMap.rgb * textureColor.rgb, gs_colorMap.a * textureColor.a * alphaValue - ); - } else { + ); + } + else { fullColor = vec4(color.rgb * textureColor.rgb, textureColor.a * alphaValue); } @@ -58,14 +63,13 @@ Fragment getFragment() { } Fragment frag; - frag.color = fullColor; - frag.depth = vs_screenSpaceDepth; + frag.color = fullColor; + frag.depth = vs_screenSpaceDepth; // Setting the position of the billboards to not interact // with the ATM. - frag.gPosition = vec4(-1e32, -1e32, -1e32, 1.0); - frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0); + frag.gPosition = vec4(-1e32, -1e32, -1e32, 1.0); + frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0); //frag.disableLDR2HDR = true; - return frag; -} \ No newline at end of file +} diff --git a/modules/digitaluniverse/shaders/billboard_gs.glsl b/modules/digitaluniverse/shaders/billboard_gs.glsl index cb955fbc33..2ee4ea61cd 100644 --- a/modules/digitaluniverse/shaders/billboard_gs.glsl +++ b/modules/digitaluniverse/shaders/billboard_gs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -30,16 +30,16 @@ layout(points) in; layout(triangle_strip, max_vertices = 4) out; uniform float scaleFactor; -uniform dvec3 up; -uniform dvec3 right; +uniform vec3 up; +uniform vec3 right; uniform dvec3 cameraPosition; // in world space (no SGCT View was considered) -uniform dvec3 cameraLookUp; // in world space (no SGCT View was considered) +uniform vec3 cameraLookUp; // in world space (no SGCT View was considered) uniform int renderOption; uniform vec2 screenSize; uniform float maxBillboardSize; uniform float minBillboardSize; -uniform dmat4 cameraViewProjectionMatrix; +uniform mat4 cameraViewProjectionMatrix; uniform dmat4 modelMatrix; uniform float correctionSizeFactor; @@ -55,7 +55,7 @@ flat in float dvarScaling[]; flat out vec4 gs_colorMap; out vec2 texCoord; -out float vs_screenSpaceDepth; +flat out float vs_screenSpaceDepth; out float ta; const double PARSEC = 0.308567756e17LF; @@ -78,15 +78,20 @@ void main() { // Must be the same as the enum in RenderableBillboardsCloud.h if (pos.w == 1.f) { unit = 1E3; - } else if (pos.w == 2.f) { + } + else if (pos.w == 2.f) { unit = PARSEC; - } else if (pos.w == 3.f) { + } + else if (pos.w == 3.f) { unit = 1E3 * PARSEC; - } else if (pos.w == 4.f) { + } + else if (pos.w == 4.f) { unit = 1E6 * PARSEC; - } else if (pos.w == 5.f) { + } + else if (pos.w == 5.f) { unit = 1E9 * PARSEC; - } else if (pos.w == 6.f) { + } + else if (pos.w == 6.f) { // Convertion factor from Parsecs to GigalightYears unit = 306391534.73091 * PARSEC; } @@ -94,27 +99,28 @@ void main() { dvec4 dpos = dvec4(dvec3(pos.xyz) * unit, 1.0); dpos = modelMatrix * dpos; - double scaleMultiply = exp(scaleFactor * 0.10); + float scaleMultiply = exp(scaleFactor * 0.10f); scaleMultiply = hasDvarScaling ? dvarScaling[0] * scaleMultiply : scaleMultiply; - dvec3 scaledRight = dvec3(0.0); - dvec3 scaledUp = dvec3(0.0); + vec3 scaledRight = vec3(0.f); + vec3 scaledUp = vec3(0.f); vec4 initialPosition, secondPosition, thirdPosition, crossCorner; if (renderOption == 0) { scaledRight = scaleMultiply * right * 0.5f; scaledUp = scaleMultiply * up * 0.5f; - } else if (renderOption == 1) { - dvec3 normal = normalize(cameraPosition - dpos.xyz); - dvec3 newRight = normalize(cross(cameraLookUp, normal)); - dvec3 newUp = cross(normal, newRight); + } + else if (renderOption == 1) { + vec3 normal = vec3(normalize(cameraPosition - dpos.xyz)); + vec3 newRight = normalize(cross(cameraLookUp, normal)); + vec3 newUp = cross(normal, newRight); if (!enabledRectSizeControl) { double distCamera = length(cameraPosition - dpos.xyz); float expVar = float(-distCamera) / pow(10.f, correctionSizeEndDistance); - double factorVar = double(pow(10, correctionSizeFactor)); - scaleMultiply *= 1.0 / (1.0 + factorVar * double(exp(expVar))); + float factorVar = pow(10.f, correctionSizeFactor); + scaleMultiply *= 1.f / (1.f + factorVar * exp(expVar)); } scaledRight = scaleMultiply * newRight * 0.5f; @@ -122,11 +128,13 @@ void main() { } if (enabledRectSizeControl) { - initialPosition = z_normalization(vec4(cameraViewProjectionMatrix * - dvec4(dpos.xyz - scaledRight - scaledUp, dpos.w))); + initialPosition = z_normalization(cameraViewProjectionMatrix * + vec4(vec3(dpos.xyz) - scaledRight - scaledUp, dpos.w)); + vs_screenSpaceDepth = initialPosition.w; - crossCorner = z_normalization(vec4(cameraViewProjectionMatrix * - dvec4(dpos.xyz + scaledUp + scaledRight, dpos.w))); + + crossCorner = z_normalization(cameraViewProjectionMatrix * + vec4(vec3(dpos.xyz) + scaledUp + scaledRight, dpos.w)); // Testing size for rectangular viewport: vec2 halfViewSize = vec2(screenSize.x, screenSize.y) * 0.5f; @@ -146,7 +154,8 @@ void main() { scaledRight *= correctionScale; scaledUp *= correctionScale; - } else { + } + else { // linear alpha decay if (sizes.x < 2.0f * minBillboardSize) { float maxVar = 2.0f * minBillboardSize; @@ -158,30 +167,35 @@ void main() { } } } - - initialPosition = z_normalization(vec4(cameraViewProjectionMatrix * - dvec4(dpos.xyz - scaledRight - scaledUp, dpos.w))); - vs_screenSpaceDepth = initialPosition.w; - secondPosition = z_normalization(vec4(cameraViewProjectionMatrix * - dvec4(dpos.xyz + scaledRight - scaledUp, dpos.w))); - crossCorner = z_normalization(vec4(cameraViewProjectionMatrix * - dvec4(dpos.xyz + scaledUp + scaledRight, dpos.w))); - thirdPosition = z_normalization(vec4(cameraViewProjectionMatrix * - dvec4(dpos.xyz + scaledUp - scaledRight, dpos.w))); + // Saving one matrix multiplication: + vec4 dposClip = cameraViewProjectionMatrix * vec4(dpos); + vec4 scaledRightClip = cameraViewProjectionMatrix * vec4(scaledRight, 0.0); + vec4 scaledUpClip = cameraViewProjectionMatrix * vec4(scaledUp, 0.0); + + initialPosition = z_normalization(dposClip - scaledRightClip - scaledUpClip); + vs_screenSpaceDepth = initialPosition.w; + secondPosition = z_normalization(dposClip + scaledRightClip - scaledUpClip); + crossCorner = z_normalization(dposClip + scaledUpClip + scaledRightClip); + thirdPosition = z_normalization(dposClip + scaledUpClip - scaledRightClip); // Build primitive - texCoord = corners[3]; - gl_Position = thirdPosition; - EmitVertex(); + texCoord = corners[0]; gl_Position = initialPosition; EmitVertex(); - texCoord = corners[2]; - gl_Position = crossCorner; - EmitVertex(); + texCoord = corners[1]; gl_Position = secondPosition; EmitVertex(); + + texCoord = corners[3]; + gl_Position = thirdPosition; + EmitVertex(); + + texCoord = corners[2]; + gl_Position = crossCorner; + EmitVertex(); + EndPrimitive(); } \ No newline at end of file diff --git a/modules/digitaluniverse/shaders/billboard_vs.glsl b/modules/digitaluniverse/shaders/billboard_vs.glsl index 66e03e2a3c..2a8a25f8ba 100644 --- a/modules/digitaluniverse/shaders/billboard_vs.glsl +++ b/modules/digitaluniverse/shaders/billboard_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/digitaluniverse/shaders/billboardpolygon_fs.glsl b/modules/digitaluniverse/shaders/billboardpolygon_fs.glsl index 7c76866961..44b6b55b04 100644 --- a/modules/digitaluniverse/shaders/billboardpolygon_fs.glsl +++ b/modules/digitaluniverse/shaders/billboardpolygon_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/digitaluniverse/shaders/billboardpolygon_gs.glsl b/modules/digitaluniverse/shaders/billboardpolygon_gs.glsl index 9d7243239e..7592e9d685 100644 --- a/modules/digitaluniverse/shaders/billboardpolygon_gs.glsl +++ b/modules/digitaluniverse/shaders/billboardpolygon_gs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/digitaluniverse/shaders/billboardpolygon_vs.glsl b/modules/digitaluniverse/shaders/billboardpolygon_vs.glsl index 9927f4b026..0f972cb4e3 100644 --- a/modules/digitaluniverse/shaders/billboardpolygon_vs.glsl +++ b/modules/digitaluniverse/shaders/billboardpolygon_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/digitaluniverse/shaders/dumesh_fs.glsl b/modules/digitaluniverse/shaders/dumesh_fs.glsl index f6192f68ff..6997b13fc1 100644 --- a/modules/digitaluniverse/shaders/dumesh_fs.glsl +++ b/modules/digitaluniverse/shaders/dumesh_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/digitaluniverse/shaders/dumesh_vs.glsl b/modules/digitaluniverse/shaders/dumesh_vs.glsl index 3e2bed3fcf..ebbdf31643 100644 --- a/modules/digitaluniverse/shaders/dumesh_vs.glsl +++ b/modules/digitaluniverse/shaders/dumesh_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/digitaluniverse/shaders/plane_fs.glsl b/modules/digitaluniverse/shaders/plane_fs.glsl index 41bf693217..51b0a869fe 100644 --- a/modules/digitaluniverse/shaders/plane_fs.glsl +++ b/modules/digitaluniverse/shaders/plane_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/digitaluniverse/shaders/plane_vs.glsl b/modules/digitaluniverse/shaders/plane_vs.glsl index 7a25575a0b..e4e2dd04f6 100644 --- a/modules/digitaluniverse/shaders/plane_vs.glsl +++ b/modules/digitaluniverse/shaders/plane_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/digitaluniverse/shaders/points_fs.glsl b/modules/digitaluniverse/shaders/points_fs.glsl index 97dbfe371d..ff55cd58d8 100644 --- a/modules/digitaluniverse/shaders/points_fs.glsl +++ b/modules/digitaluniverse/shaders/points_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -41,7 +41,8 @@ Fragment getFragment() { if (hasColorMap) { frag.color = vec4(colorMap.xyz, alphaValue); - } else { + } + else { frag.color = vec4(color, alphaValue); } diff --git a/modules/digitaluniverse/shaders/points_gs.glsl b/modules/digitaluniverse/shaders/points_gs.glsl index 612161fd76..e2b63ded8d 100644 --- a/modules/digitaluniverse/shaders/points_gs.glsl +++ b/modules/digitaluniverse/shaders/points_gs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/digitaluniverse/shaders/points_sprite_fs.glsl b/modules/digitaluniverse/shaders/points_sprite_fs.glsl index c2f6c9952d..f47d8beba2 100644 --- a/modules/digitaluniverse/shaders/points_sprite_fs.glsl +++ b/modules/digitaluniverse/shaders/points_sprite_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/digitaluniverse/shaders/points_vs.glsl b/modules/digitaluniverse/shaders/points_vs.glsl index e765942f17..63d4aa0992 100644 --- a/modules/digitaluniverse/shaders/points_vs.glsl +++ b/modules/digitaluniverse/shaders/points_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/digitaluniverse/shaders/pointssprite_fs.glsl b/modules/digitaluniverse/shaders/pointssprite_fs.glsl index ff54c1253e..6dbf377174 100644 --- a/modules/digitaluniverse/shaders/pointssprite_fs.glsl +++ b/modules/digitaluniverse/shaders/pointssprite_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/digitaluniverse/shaders/pointssprite_vs.glsl b/modules/digitaluniverse/shaders/pointssprite_vs.glsl index 7d6318a258..a6627b5ad1 100644 --- a/modules/digitaluniverse/shaders/pointssprite_vs.glsl +++ b/modules/digitaluniverse/shaders/pointssprite_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/fieldlines/CMakeLists.txt b/modules/fieldlines/CMakeLists.txt index 7bfcaf2c08..9a887da930 100644 --- a/modules/fieldlines/CMakeLists.txt +++ b/modules/fieldlines/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2018 # +# Copyright (c) 2014-2020 # # # # 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 # diff --git a/modules/fieldlines/fieldlinesmodule.cpp b/modules/fieldlines/fieldlinesmodule.cpp index 5ddcbed1bf..52aeab21f3 100644 --- a/modules/fieldlines/fieldlinesmodule.cpp +++ b/modules/fieldlines/fieldlinesmodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/fieldlines/fieldlinesmodule.h b/modules/fieldlines/fieldlinesmodule.h index b9ffe0e845..e9652bd508 100644 --- a/modules/fieldlines/fieldlinesmodule.h +++ b/modules/fieldlines/fieldlinesmodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/fieldlines/rendering/renderablefieldlines.cpp b/modules/fieldlines/rendering/renderablefieldlines.cpp index 8caf8d0408..b8970efb3b 100644 --- a/modules/fieldlines/rendering/renderablefieldlines.cpp +++ b/modules/fieldlines/rendering/renderablefieldlines.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -371,8 +371,8 @@ void RenderableFieldlines::loadSeedPointsFromTable() { LINFO("Loading provided list of seed points"); ghoul::Dictionary seedpointsDictionary; _seedPointsInfo.getValue(KeySeedPointsTable, seedpointsDictionary); - glm::vec3 seedPos; for (const std::string& index : seedpointsDictionary.keys()) { + glm::vec3 seedPos = glm::vec3(0.f); _fieldlineInfo.getValue(std::string(KeySeedPointsTable) + "." + index, seedPos); _seedPoints.push_back(seedPos); } diff --git a/modules/fieldlines/rendering/renderablefieldlines.h b/modules/fieldlines/rendering/renderablefieldlines.h index 690e50343e..cc73bd60cf 100644 --- a/modules/fieldlines/rendering/renderablefieldlines.h +++ b/modules/fieldlines/rendering/renderablefieldlines.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/fieldlines/shaders/fieldline_fs.glsl b/modules/fieldlines/shaders/fieldline_fs.glsl index c76f07490c..71b7525467 100644 --- a/modules/fieldlines/shaders/fieldline_fs.glsl +++ b/modules/fieldlines/shaders/fieldline_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/fieldlines/shaders/fieldline_gs.glsl b/modules/fieldlines/shaders/fieldline_gs.glsl index cb55a36d0f..16310196d6 100644 --- a/modules/fieldlines/shaders/fieldline_gs.glsl +++ b/modules/fieldlines/shaders/fieldline_gs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/fieldlines/shaders/fieldline_vs.glsl b/modules/fieldlines/shaders/fieldline_vs.glsl index 8c566324ec..ceba91ab1f 100644 --- a/modules/fieldlines/shaders/fieldline_vs.glsl +++ b/modules/fieldlines/shaders/fieldline_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/fieldlinessequence/CMakeLists.txt b/modules/fieldlinessequence/CMakeLists.txt index cf9a0d7f70..009d976908 100644 --- a/modules/fieldlinessequence/CMakeLists.txt +++ b/modules/fieldlinessequence/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2018 # +# Copyright (c) 2014-2020 # # # # 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 # diff --git a/modules/fieldlinessequence/fieldlinessequencemodule.cpp b/modules/fieldlinessequence/fieldlinessequencemodule.cpp index fc9e763ee0..6fd64755c1 100644 --- a/modules/fieldlinessequence/fieldlinessequencemodule.cpp +++ b/modules/fieldlinessequence/fieldlinessequencemodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/fieldlinessequence/fieldlinessequencemodule.h b/modules/fieldlinessequence/fieldlinessequencemodule.h index 6143273a86..c88ba9f5d5 100644 --- a/modules/fieldlinessequence/fieldlinessequencemodule.h +++ b/modules/fieldlinessequence/fieldlinessequencemodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp index fe8b64c13c..8000c0d481 100644 --- a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp +++ b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -254,7 +254,7 @@ RenderableFieldlinesSequence::RenderableFieldlinesSequence( , _pColorTablePath(ColorTablePathInfo) , _pColorUniform( ColorUniformInfo, - glm::vec4(0.75f, 0.5f, 0.0f, 0.5f), + glm::vec4(0.75f, 0.5f, 0.f, 0.5f), glm::vec4(0.f), glm::vec4(1.f) ) @@ -267,7 +267,7 @@ RenderableFieldlinesSequence::RenderableFieldlinesSequence( , _pDomainR(DomainRInfo) , _pFlowColor( FlowColorInfo, - glm::vec4(0.8f, 0.7f, 0.0f, 0.6f), + glm::vec4(0.8f, 0.7f, 0.f, 0.6f), glm::vec4(0.f), glm::vec4(1.f) ) @@ -1241,8 +1241,8 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) { _needsUpdate = true; _activeStateIndex = _activeTriggerTimeIndex; } - } - // else {we're still in same state as previous frame (no changes needed)} + + } // else {we're still in same state as previous frame (no changes needed)} } else { // Not in interval => set everything to false diff --git a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.h b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.h index d7a1f61988..b637727a88 100644 --- a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.h +++ b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/fieldlinessequence/shaders/fieldlinessequence_fs.glsl b/modules/fieldlinessequence/shaders/fieldlinessequence_fs.glsl index 4ffe5a3679..fc3d4c47c3 100644 --- a/modules/fieldlinessequence/shaders/fieldlinessequence_fs.glsl +++ b/modules/fieldlinessequence/shaders/fieldlinessequence_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/fieldlinessequence/shaders/fieldlinessequence_vs.glsl b/modules/fieldlinessequence/shaders/fieldlinessequence_vs.glsl index 29ad0734d9..df6a265a9e 100644 --- a/modules/fieldlinessequence/shaders/fieldlinessequence_vs.glsl +++ b/modules/fieldlinessequence/shaders/fieldlinessequence_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -108,7 +108,8 @@ void main() { if (isParticle) { vs_color = flowColor; - } else { + } + else { vs_color = lineColor; } @@ -116,7 +117,8 @@ void main() { vec4 quantityColor = getTransferFunctionColor(); vs_color = vec4(quantityColor.xyz, vs_color.a * quantityColor.a); } - } else { + } + else { vs_color = vec4(0); } diff --git a/modules/fieldlinessequence/util/commons.cpp b/modules/fieldlinessequence/util/commons.cpp index 16482bc86f..b6e202f8c4 100644 --- a/modules/fieldlinessequence/util/commons.cpp +++ b/modules/fieldlinessequence/util/commons.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -29,9 +29,11 @@ namespace openspace::fls { Model stringToModel(const std::string& s) { if (s == "batsrus") { return Model::Batsrus; - } else if (s == "enlil") { + } + else if (s == "enlil") { return Model::Enlil; - } else if (s == "pfss") { + } + else if (s == "pfss") { return Model::Pfss; } else if (s == "wsa") { return Model::Wsa; diff --git a/modules/fieldlinessequence/util/commons.h b/modules/fieldlinessequence/util/commons.h index ac6de6cb8b..65bf75d43b 100644 --- a/modules/fieldlinessequence/util/commons.h +++ b/modules/fieldlinessequence/util/commons.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/fieldlinessequence/util/fieldlinesstate.cpp b/modules/fieldlinessequence/util/fieldlinesstate.cpp index dc185e43d6..396a05b731 100644 --- a/modules/fieldlinessequence/util/fieldlinesstate.cpp +++ b/modules/fieldlinessequence/util/fieldlinesstate.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/fieldlinessequence/util/fieldlinesstate.h b/modules/fieldlinessequence/util/fieldlinesstate.h index 7011c0547e..656403b33b 100644 --- a/modules/fieldlinessequence/util/fieldlinesstate.h +++ b/modules/fieldlinessequence/util/fieldlinesstate.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/fieldlinessequence/util/kameleonfieldlinehelper.cpp b/modules/fieldlinessequence/util/kameleonfieldlinehelper.cpp index 7bacdebb00..76daab2b7a 100644 --- a/modules/fieldlinessequence/util/kameleonfieldlinehelper.cpp +++ b/modules/fieldlinessequence/util/kameleonfieldlinehelper.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -236,7 +236,8 @@ void addExtraQuantities(ccmc::Kameleon* kameleon, val = interpolator->interpolate("p", p.x, p.y, p.z); val *= ToKelvin; val /= interpolator->interpolate("rho", p.x, p.y, p.z); - } else { + } + else { val = interpolator->interpolate(extraScalarVars[i], p.x, p.y, p.z); // When measuring density in ENLIL CCMC multiply by the radius^2 @@ -265,7 +266,8 @@ void addExtraQuantities(ccmc::Kameleon* kameleon, // the magnetic field vector! val = glm::dot(glm::vec3(x,y,z), normMagnetic); - } else { + } + else { val = std::sqrt(x*x + y*y + z*z); } state.appendToExtra(i + nXtraScalars, val); @@ -315,7 +317,8 @@ void prepareStateAndKameleonForExtras(ccmc::Kameleon* kameleon, )); extraScalarVars.erase(extraScalarVars.begin() + i); --i; - } else { + } + else { extraQuantityNames.push_back(str); } } @@ -359,11 +362,13 @@ void prepareStateAndKameleonForExtras(ccmc::Kameleon* kameleon, extraMagVars.begin() + i + 3 ); i -= 3; - } else { + } + else { extraQuantityNames.push_back(std::move(name)); } } - } else { + } + else { // WRONG NUMBER OF MAGNITUDE VARIABLES.. REMOVE ALL! extraMagVars.clear(); LWARNING(fmt::format( diff --git a/modules/fieldlinessequence/util/kameleonfieldlinehelper.h b/modules/fieldlinessequence/util/kameleonfieldlinehelper.h index 2c53f524b9..39fa5d7212 100644 --- a/modules/fieldlinessequence/util/kameleonfieldlinehelper.h +++ b/modules/fieldlinessequence/util/kameleonfieldlinehelper.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/fitsfilereader/CMakeLists.txt b/modules/fitsfilereader/CMakeLists.txt index 46e0c43125..4e07757fa7 100644 --- a/modules/fitsfilereader/CMakeLists.txt +++ b/modules/fitsfilereader/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2018 # +# Copyright (c) 2014-2020 # # # # 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 # @@ -57,5 +57,10 @@ set_folder_location(cfitsio "External") add_subdirectory(${CCFITS_ROOT_DIR}) set_folder_location(CCfits "External") +if (GHOUL_DISABLE_EXTERNAL_WARNINGS) + disable_external_warnings(cfitsio) + disable_external_warnings(CCfits) +endif () + target_include_directories(${MODULE_NAME} SYSTEM PUBLIC ${INCLUDES_FOR_TARGET}) target_link_libraries(${MODULE_NAME} PRIVATE CCfits) diff --git a/modules/fitsfilereader/fitsfilereadermodule.cpp b/modules/fitsfilereader/fitsfilereadermodule.cpp index 3aeb83f509..e0c66c7882 100644 --- a/modules/fitsfilereader/fitsfilereadermodule.cpp +++ b/modules/fitsfilereader/fitsfilereadermodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/fitsfilereader/fitsfilereadermodule.h b/modules/fitsfilereader/fitsfilereadermodule.h index 7eb7467ceb..a16cfaba75 100644 --- a/modules/fitsfilereader/fitsfilereadermodule.h +++ b/modules/fitsfilereader/fitsfilereadermodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/fitsfilereader/include/fitsfilereader.h b/modules/fitsfilereader/include/fitsfilereader.h index 4a7c464f4f..e3db1daae7 100644 --- a/modules/fitsfilereader/include/fitsfilereader.h +++ b/modules/fitsfilereader/include/fitsfilereader.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/fitsfilereader/src/fitsfilereader.cpp b/modules/fitsfilereader/src/fitsfilereader.cpp index 39240d6b2f..d259c335b5 100644 --- a/modules/fitsfilereader/src/fitsfilereader.cpp +++ b/modules/fitsfilereader/src/fitsfilereader.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/gaia/CMakeLists.txt b/modules/gaia/CMakeLists.txt index fdef0ffbf5..782b9ced23 100644 --- a/modules/gaia/CMakeLists.txt +++ b/modules/gaia/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2018 # +# Copyright (c) 2014-2020 # # # # 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 # diff --git a/modules/gaia/gaiamodule.cpp b/modules/gaia/gaiamodule.cpp index 0c2f233199..7174ca6705 100644 --- a/modules/gaia/gaiamodule.cpp +++ b/modules/gaia/gaiamodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/gaia/gaiamodule.h b/modules/gaia/gaiamodule.h index 1a5befc41c..657ac52f04 100644 --- a/modules/gaia/gaiamodule.h +++ b/modules/gaia/gaiamodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/gaia/rendering/gaiaoptions.h b/modules/gaia/rendering/gaiaoptions.h index 219d8b2104..b1740b7cb5 100644 --- a/modules/gaia/rendering/gaiaoptions.h +++ b/modules/gaia/rendering/gaiaoptions.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/gaia/rendering/octreeculler.cpp b/modules/gaia/rendering/octreeculler.cpp index 8a1bb32f05..0ffef8d717 100644 --- a/modules/gaia/rendering/octreeculler.cpp +++ b/modules/gaia/rendering/octreeculler.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/gaia/rendering/octreeculler.h b/modules/gaia/rendering/octreeculler.h index 46025a0aab..c8a2e2362f 100644 --- a/modules/gaia/rendering/octreeculler.h +++ b/modules/gaia/rendering/octreeculler.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/gaia/rendering/octreemanager.cpp b/modules/gaia/rendering/octreemanager.cpp index 63efa73a43..5b56c62816 100644 --- a/modules/gaia/rendering/octreemanager.cpp +++ b/modules/gaia/rendering/octreemanager.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -51,7 +51,7 @@ void OctreeManager::initOctree(long long cpuRamBudget, int maxDist, int maxStars // Initialize the culler. The NDC.z of the comparing corners are always -1 or 1. globebrowsing::AABB3 box; box.min = glm::vec3(-1.f, -1.f, 0.f); - box.max = glm::vec3(1.f, 1.f, 1e2); + box.max = glm::vec3(1.f, 1.f, 100.f); _culler = std::make_unique(box); _removedKeysInPrevCall = std::set(); _leastRecentlyFetchedNodes = std::queue(); diff --git a/modules/gaia/rendering/octreemanager.h b/modules/gaia/rendering/octreemanager.h index aa584f424f..031e9e3630 100644 --- a/modules/gaia/rendering/octreemanager.h +++ b/modules/gaia/rendering/octreemanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/gaia/rendering/renderablegaiastars.cpp b/modules/gaia/rendering/renderablegaiastars.cpp index cb7522f99d..a67a1d17c2 100644 --- a/modules/gaia/rendering/renderablegaiastars.cpp +++ b/modules/gaia/rendering/renderablegaiastars.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -2325,7 +2325,7 @@ void RenderableGaiaStars::update(const UpdateData&) { // Update FBO texture resolution if we haven't already. glm::vec2 screenSize = glm::vec2(global::renderEngine.renderingResolution()); const bool hasChanged = glm::any( - glm::notEqual(_fboTexture->dimensions(), glm::uvec3(screenSize, 1.0)) + glm::notEqual(_fboTexture->dimensions(), glm::uvec3(screenSize, 1)) ); if (hasChanged) { diff --git a/modules/gaia/rendering/renderablegaiastars.h b/modules/gaia/rendering/renderablegaiastars.h index 2583b80a52..dfde5abc04 100644 --- a/modules/gaia/rendering/renderablegaiastars.h +++ b/modules/gaia/rendering/renderablegaiastars.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -191,7 +191,7 @@ private: size_t _nRenderValuesPerStar = 0; int _nStarsToRender = 0; bool _firstDrawCalls = true; - glm::dquat _previousCameraRotation; + glm::dquat _previousCameraRotation = glm::dquat(1.0, 0.0, 0.0, 0.0); bool _useVBO = false; long long _cpuRamBudgetInBytes = 0; long long _totalDatasetSizeInBytes = 0; diff --git a/modules/gaia/shaders/gaia_billboard_fs.glsl b/modules/gaia/shaders/gaia_billboard_fs.glsl index cf19477232..d9b9ebbbd5 100644 --- a/modules/gaia/shaders/gaia_billboard_fs.glsl +++ b/modules/gaia/shaders/gaia_billboard_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/gaia/shaders/gaia_billboard_ge.glsl b/modules/gaia/shaders/gaia_billboard_ge.glsl index 498df41df8..3296ae1fa2 100644 --- a/modules/gaia/shaders/gaia_billboard_ge.glsl +++ b/modules/gaia/shaders/gaia_billboard_ge.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -100,15 +100,15 @@ void main() { // Discard geometry if star has no position (but wasn't a nullArray). // Or if observed distance is above threshold set by cutOffThreshold. // By discarding in gs instead of fs we save computations for when nothing is visible. - if( length(position) < EPS || distThreshold <= 0){ + if (length(position) < EPS || distThreshold <= 0) { return; } vec4 centerWorldPos = vs_gPosition[0]; - dvec3 cameraNormal = normalize(cameraPos - dvec3(centerWorldPos.xyz)); + dvec3 cameraNormal = normalize(cameraPos - dvec3(centerWorldPos.xyz)); dvec3 newRight = normalize(cross(cameraLookUp, cameraNormal)); - dvec3 newUp = cross(cameraNormal, newRight); + dvec3 newUp = cross(cameraNormal, newRight); vec4 wCameraRight = vec4(newRight, 0.0); vec4 wCameraUp = vec4(newUp, 0.0); diff --git a/modules/gaia/shaders/gaia_billboard_nofbo_fs.glsl b/modules/gaia/shaders/gaia_billboard_nofbo_fs.glsl index 477a24a3ea..2e67386300 100644 --- a/modules/gaia/shaders/gaia_billboard_nofbo_fs.glsl +++ b/modules/gaia/shaders/gaia_billboard_nofbo_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/gaia/shaders/gaia_point_fs.glsl b/modules/gaia/shaders/gaia_point_fs.glsl index 35e77c28fc..22fa3fafb9 100644 --- a/modules/gaia/shaders/gaia_point_fs.glsl +++ b/modules/gaia/shaders/gaia_point_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/gaia/shaders/gaia_point_ge.glsl b/modules/gaia/shaders/gaia_point_ge.glsl index da23cf0cff..b36e18f5bb 100644 --- a/modules/gaia/shaders/gaia_point_ge.glsl +++ b/modules/gaia/shaders/gaia_point_ge.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -61,14 +61,14 @@ void main() { // Discard geometry if star has no position (but wasn't a nullArray). // Or if observed distance is above threshold set by cutOffThreshold. // By discarding in gs instead of fs we save computations for when nothing is visible. - if( length(position) < EPS || distThreshold <= 0){ + if (length(position) < EPS || distThreshold <= 0) { return; } //gl_PointSize = 1.0; gl_Position = position; gl_Position.z = 0.0; - ge_gPosition = viewPosition; + ge_gPosition = viewPosition; EmitVertex(); diff --git a/modules/gaia/shaders/gaia_ssbo_vs.glsl b/modules/gaia/shaders/gaia_ssbo_vs.glsl index 95fa3d99dd..ecd6f1b064 100644 --- a/modules/gaia/shaders/gaia_ssbo_vs.glsl +++ b/modules/gaia/shaders/gaia_ssbo_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -179,7 +179,8 @@ void main() { if ( length(in_position) > EPS ){ vs_gPosition = vec4(model * objectPosition); gl_Position = vec4(projection * viewPosition); - } else { + } + else { vs_gPosition = vec4(0.0); gl_Position = vec4(0.0); } diff --git a/modules/gaia/shaders/gaia_tonemapping_billboard_fs.glsl b/modules/gaia/shaders/gaia_tonemapping_billboard_fs.glsl index 1643a261ea..3cf794162f 100644 --- a/modules/gaia/shaders/gaia_tonemapping_billboard_fs.glsl +++ b/modules/gaia/shaders/gaia_tonemapping_billboard_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/gaia/shaders/gaia_tonemapping_point_fs.glsl b/modules/gaia/shaders/gaia_tonemapping_point_fs.glsl index 965f735b49..f2da517b0b 100644 --- a/modules/gaia/shaders/gaia_tonemapping_point_fs.glsl +++ b/modules/gaia/shaders/gaia_tonemapping_point_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -82,7 +82,8 @@ Fragment getFragment() { //vec2 screenOrigo = vec2(-left, -bottom) / vec2(right - left, top - bottom); //if (abs(screenOrigo.x - uv.x) > 0.0005 && abs(screenOrigo.y - uv.y) > 0.0005) { // origoFrag.color = vec4(0.0); - //} else { + //} + //else { // origoFrag.color = vec4(1.0); //} //return origoFrag; diff --git a/modules/gaia/shaders/gaia_tonemapping_vs.glsl b/modules/gaia/shaders/gaia_tonemapping_vs.glsl index 89f1175b56..2f9122836d 100644 --- a/modules/gaia/shaders/gaia_tonemapping_vs.glsl +++ b/modules/gaia/shaders/gaia_tonemapping_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/gaia/shaders/gaia_vbo_vs.glsl b/modules/gaia/shaders/gaia_vbo_vs.glsl index 25bc51f9c0..f5a635c3d2 100644 --- a/modules/gaia/shaders/gaia_vbo_vs.glsl +++ b/modules/gaia/shaders/gaia_vbo_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -112,7 +112,8 @@ void main() { if ( length(in_position) > EPS ){ vs_gPosition = vec4(model * objectPosition); gl_Position = vec4(projection * viewPosition); - } else { + } + else { vs_gPosition = vec4(0.0); gl_Position = vec4(0.0); } diff --git a/modules/gaia/tasks/constructoctreetask.cpp b/modules/gaia/tasks/constructoctreetask.cpp index 7af1fc746e..725d86963c 100644 --- a/modules/gaia/tasks/constructoctreetask.cpp +++ b/modules/gaia/tasks/constructoctreetask.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/gaia/tasks/constructoctreetask.h b/modules/gaia/tasks/constructoctreetask.h index 2954aea07c..824521e340 100644 --- a/modules/gaia/tasks/constructoctreetask.h +++ b/modules/gaia/tasks/constructoctreetask.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/gaia/tasks/readfilejob.cpp b/modules/gaia/tasks/readfilejob.cpp index c3357ad362..ac15d85d87 100644 --- a/modules/gaia/tasks/readfilejob.cpp +++ b/modules/gaia/tasks/readfilejob.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/gaia/tasks/readfilejob.h b/modules/gaia/tasks/readfilejob.h index f615e80ff2..13f3cfc38b 100644 --- a/modules/gaia/tasks/readfilejob.h +++ b/modules/gaia/tasks/readfilejob.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/gaia/tasks/readfitstask.cpp b/modules/gaia/tasks/readfitstask.cpp index 8572f64078..5cbe1cf384 100644 --- a/modules/gaia/tasks/readfitstask.cpp +++ b/modules/gaia/tasks/readfitstask.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/gaia/tasks/readfitstask.h b/modules/gaia/tasks/readfitstask.h index bd97e3d0be..ba3981fa0b 100644 --- a/modules/gaia/tasks/readfitstask.h +++ b/modules/gaia/tasks/readfitstask.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/gaia/tasks/readspecktask.cpp b/modules/gaia/tasks/readspecktask.cpp index 1665ef0963..d30d39d058 100644 --- a/modules/gaia/tasks/readspecktask.cpp +++ b/modules/gaia/tasks/readspecktask.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/gaia/tasks/readspecktask.h b/modules/gaia/tasks/readspecktask.h index 3a5cd097ff..e9c6517dfb 100644 --- a/modules/gaia/tasks/readspecktask.h +++ b/modules/gaia/tasks/readspecktask.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/galaxy/CMakeLists.txt b/modules/galaxy/CMakeLists.txt index 48b3d68d12..065f3971bc 100644 --- a/modules/galaxy/CMakeLists.txt +++ b/modules/galaxy/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2018 # +# Copyright (c) 2014-2020 # # # # 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 # diff --git a/modules/galaxy/galaxymodule.cpp b/modules/galaxy/galaxymodule.cpp index 63695821bd..504c807102 100644 --- a/modules/galaxy/galaxymodule.cpp +++ b/modules/galaxy/galaxymodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/galaxy/galaxymodule.h b/modules/galaxy/galaxymodule.h index 1a7e6a3e1a..bc72bcf948 100644 --- a/modules/galaxy/galaxymodule.h +++ b/modules/galaxy/galaxymodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/galaxy/rendering/galaxyraycaster.cpp b/modules/galaxy/rendering/galaxyraycaster.cpp index 7a38a44733..076662d73c 100644 --- a/modules/galaxy/rendering/galaxyraycaster.cpp +++ b/modules/galaxy/rendering/galaxyraycaster.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/galaxy/rendering/galaxyraycaster.h b/modules/galaxy/rendering/galaxyraycaster.h index 4bf4e98f19..cb8cf6de12 100644 --- a/modules/galaxy/rendering/galaxyraycaster.h +++ b/modules/galaxy/rendering/galaxyraycaster.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -78,13 +78,13 @@ private: glm::dmat4 modelViewTransform(const RenderData& data); BoxGeometry _boundingBox; - float _stepSize; - glm::mat4 _modelTransform; - glm::vec3 _aspect; - double _time; - float _opacityCoefficient; - float _absorptionMultiply; - float _emissionMultiply; + float _stepSize = 0.f; + glm::mat4 _modelTransform = glm::mat4(1.f); + glm::vec3 _aspect = glm::vec3(0.f); + double _time = 0.0; + float _opacityCoefficient = 0.f; + float _absorptionMultiply = 0.f; + float _emissionMultiply = 0.f; ghoul::opengl::Texture& _texture; std::unique_ptr _textureUnit; diff --git a/modules/galaxy/rendering/renderablegalaxy.cpp b/modules/galaxy/rendering/renderablegalaxy.cpp index 1d88c2da23..9023fe154d 100644 --- a/modules/galaxy/rendering/renderablegalaxy.cpp +++ b/modules/galaxy/rendering/renderablegalaxy.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -34,7 +34,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -46,18 +48,21 @@ #include namespace { + constexpr int8_t CurrentCacheVersion = 1; + constexpr const char* GlslRaycastPath = - "${MODULES}/galaxy/shaders/galaxyraycast.glsl"; + "${MODULE_GALAXY}/shaders/galaxyraycast.glsl"; constexpr const char* GlslBoundsVsPath = - "${MODULES}/galaxy/shaders/raycasterbounds_vs.glsl"; + "${MODULE_GALAXY}/shaders/raycasterbounds_vs.glsl"; constexpr const char* GlslBoundsFsPath = - "${MODULES}/galaxy/shaders/raycasterbounds_fs.glsl"; - constexpr const char* _loggerCat = "Renderable Galaxy"; + "${MODULE_GALAXY}/shaders/raycasterbounds_fs.glsl"; + constexpr const char* _loggerCat = "Renderable Galaxy"; constexpr const std::array UniformNamesPoints = { "modelMatrix", "cameraViewProjectionMatrix", "eyePosition", "opacityCoefficient" }; + constexpr const std::array UniformNamesBillboards = { "modelMatrix", "cameraViewProjectionMatrix", "cameraUp", "eyePosition", "psfTexture" @@ -117,11 +122,55 @@ namespace { "Enabled points", "" // @TODO Missing documentation }; + + constexpr openspace::properties::Property::PropertyInfo DownscaleVolumeRenderingInfo = + { + "Downscale", + "Downscale Factor Volume Rendering", + "This value set the downscaling factor" + " when rendering the current volume." + }; + + constexpr openspace::properties::Property::PropertyInfo NumberOfRayCastingStepsInfo = + { + "Steps", + "Number of RayCasting Steps", + "This value set the number of integration steps during the raycasting procedure." + }; + + void saveCachedFile(const std::string& file, const std::vector& positions, + const std::vector& colors, int64_t nPoints, + float pointsRatio) + { + std::ofstream fileStream(file, std::ofstream::binary); + + if (!fileStream.good()) { + LERROR(fmt::format("Error opening file '{}' for save cache file", file)); + return; + } + + fileStream.write(reinterpret_cast(&CurrentCacheVersion), sizeof(int8_t)); + fileStream.write(reinterpret_cast(&nPoints), sizeof(int64_t)); + fileStream.write(reinterpret_cast(&pointsRatio), sizeof(float)); + uint64_t nPositions = static_cast(positions.size()); + fileStream.write(reinterpret_cast(&nPositions), sizeof(uint64_t)); + fileStream.write( + reinterpret_cast(positions.data()), + positions.size() * sizeof(glm::vec3) + ); + uint64_t nColors = static_cast(colors.size()); + fileStream.write(reinterpret_cast(&nColors), sizeof(uint64_t)); + fileStream.write( + reinterpret_cast(colors.data()), + colors.size() * sizeof(glm::vec3) + ); + } + } // namespace namespace openspace { - RenderableGalaxy::RenderableGalaxy(const ghoul::Dictionary& dictionary) +RenderableGalaxy::RenderableGalaxy(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _volumeRenderingEnabled(VolumeRenderingEnabledInfo, true) , _starRenderingEnabled(StarRenderingEnabledInfo, true) @@ -134,7 +183,14 @@ namespace openspace { ) , _enabledPointsRatio(EnabledPointsRatioInfo, 0.5f, 0.01f, 1.0f) , _translation(TranslationInfo, glm::vec3(0.f), glm::vec3(0.f), glm::vec3(1.f)) - , _rotation(RotationInfo, glm::vec3(0.f), glm::vec3(0.f), glm::vec3(6.28f)) + , _rotation( + RotationInfo, + glm::vec3(0.f), + glm::vec3(0.f), + glm::vec3(glm::two_pi()) + ) + , _downScaleVolumeRendering(DownscaleVolumeRenderingInfo, 1.f, 0.1f, 1.f) + , _numberOfRayCastingSteps(NumberOfRayCastingStepsInfo, 1000.f, 1.f, 1000.f) { dictionary.getValue("VolumeRenderingEnabled", _volumeRenderingEnabled); dictionary.getValue("StarRenderingEnabled", _starRenderingEnabled); @@ -149,7 +205,7 @@ namespace openspace { if (dictionary.hasKeyAndValue(VolumeRenderingEnabledInfo.identifier)) { _volumeRenderingEnabled = dictionary.value( VolumeRenderingEnabledInfo.identifier - ); + ); } if (dictionary.hasKeyAndValue(StarRenderingEnabledInfo.identifier)) { @@ -209,14 +265,14 @@ namespace openspace { else { LERROR("No volume filename specified."); } - glm::vec3 volumeDimensions; + glm::vec3 volumeDimensions = glm::vec3(0.f); if (volumeDictionary.getValue("Dimensions", volumeDimensions)) { _volumeDimensions = static_cast(volumeDimensions); } else { LERROR("No volume dimensions specified."); } - glm::vec3 volumeSize; + glm::vec3 volumeSize = glm::vec3(0.f); if (volumeDictionary.getValue("Size", volumeSize)) { _volumeSize = volumeSize; } @@ -224,6 +280,21 @@ namespace openspace { LERROR("No volume dimensions specified."); } + if (volumeDictionary.hasKey(NumberOfRayCastingStepsInfo.identifier)) { + _numberOfRayCastingSteps = static_cast( + volumeDictionary.value(NumberOfRayCastingStepsInfo.identifier) + ); + } + else { + LINFO("Number of raycasting steps not specified. Using default value."); + } + + _downScaleVolumeRendering.setVisibility(properties::Property::Visibility::Developer); + if (volumeDictionary.hasKey(DownscaleVolumeRenderingInfo.identifier)) { + _downScaleVolumeRendering = + volumeDictionary.value(DownscaleVolumeRenderingInfo.identifier); + } + if (!dictionary.hasKeyAndValue("Points")) { LERROR("No points dictionary specified."); } @@ -240,7 +311,7 @@ namespace openspace { if (pointsDictionary.hasKeyAndValue(EnabledPointsRatioInfo.identifier)) { _enabledPointsRatio = static_cast( pointsDictionary.value(EnabledPointsRatioInfo.identifier) - ); + ); } std::string pointSpreadFunctionTexturePath; @@ -260,6 +331,7 @@ void RenderableGalaxy::initializeGL() { _aspect = static_cast(_volumeDimensions); _aspect /= std::max(std::max(_aspect.x, _aspect.y), _aspect.z); + // The volume volume::RawVolumeReader> reader( _volumeFilename, _volumeDimensions @@ -272,10 +344,11 @@ void RenderableGalaxy::initializeGL() { GL_RGBA, GL_UNSIGNED_BYTE, ghoul::opengl::Texture::FilterMode::Linear, - ghoul::opengl::Texture::WrappingMode::ClampToEdge); + ghoul::opengl::Texture::WrappingMode::ClampToEdge + ); - _texture->setPixelData(reinterpret_cast( - _volume->data()), + _texture->setPixelData( + reinterpret_cast(_volume->data()), ghoul::opengl::Texture::TakeOwnership::No ); @@ -307,133 +380,141 @@ void RenderableGalaxy::initializeGL() { addProperty(_enabledPointsRatio); addProperty(_translation); addProperty(_rotation); + addProperty(_downScaleVolumeRendering); + addProperty(_numberOfRayCastingSteps); // initialize points. - if (!_pointsFilename.empty()) { - _pointsProgram = global::renderEngine.buildRenderProgram( - "Galaxy points", - absPath("${MODULE_GALAXY}/shaders/points_vs.glsl"), - absPath("${MODULE_GALAXY}/shaders/points_fs.glsl") - ); - _billboardsProgram = global::renderEngine.buildRenderProgram( - "Galaxy billboard", - absPath("${MODULE_GALAXY}/shaders/billboard_vs.glsl"), - absPath("${MODULE_GALAXY}/shaders/billboard_fs.glsl"), - absPath("${MODULE_GALAXY}/shaders/billboard_ge.glsl") - ); - - if (!_pointSpreadFunctionTexturePath.empty()) { - _pointSpreadFunctionTexture = ghoul::io::TextureReader::ref().loadTexture( - absPath(_pointSpreadFunctionTexturePath) - ); - - if (_pointSpreadFunctionTexture) { - LDEBUG(fmt::format( - "Loaded texture from '{}'", - absPath(_pointSpreadFunctionTexturePath) - )); - _pointSpreadFunctionTexture->uploadTexture(); - } - _pointSpreadFunctionTexture->setFilter( - ghoul::opengl::Texture::FilterMode::AnisotropicMipMap - ); - - _pointSpreadFunctionFile = std::make_unique( - _pointSpreadFunctionTexturePath - ); - } - - ghoul::opengl::updateUniformLocations( - *_pointsProgram, - _uniformCachePoints, - UniformNamesPoints - ); - ghoul::opengl::updateUniformLocations( - *_billboardsProgram, - _uniformCacheBillboards, - UniformNamesBillboards - ); - - _pointsProgram->setIgnoreUniformLocationError( - ghoul::opengl::ProgramObject::IgnoreError::Yes - ); - - GLint positionAttrib = _pointsProgram->attributeLocation("in_position"); - GLint colorAttrib = _pointsProgram->attributeLocation("in_color"); - - std::ifstream pointFile(_pointsFilename, std::ios::in); - - std::vector pointPositions; - std::vector pointColors; - int64_t nPoints; - - // Read header for OFF (Object File Format) - std::string line; - std::getline(pointFile, line); - - // Read point count - std::getline(pointFile, line); - std::istringstream iss(line); - iss >> nPoints; - - // Prepare point reading - _nPoints = static_cast(nPoints); - float maxdist = 0; - - // Read points - float x, y, z, r, g, b, a; - for (size_t i = 0; - i < static_cast(_nPoints * _enabledPointsRatio.maxValue()) + 1; - ++i) - { - std::getline(pointFile, line); - std::istringstream issp(line); - issp >> x >> y >> z >> r >> g >> b >> a; - - //Convert klioparsec to meters - glm::vec3 position = glm::vec3(x, y, z); - position *= (openspace::distanceconstants::Parsec * 100); - - maxdist = std::max(maxdist, glm::length(position)); - - pointPositions.emplace_back(position); - pointColors.emplace_back(r, g, b); - } - - pointFile.close(); - - std::cout << maxdist << std::endl; - - glGenVertexArrays(1, &_pointsVao); - glGenBuffers(1, &_positionVbo); - glGenBuffers(1, &_colorVbo); - - glBindVertexArray(_pointsVao); - glBindBuffer(GL_ARRAY_BUFFER, _positionVbo); - glBufferData(GL_ARRAY_BUFFER, - pointPositions.size() * sizeof(glm::vec3), - pointPositions.data(), - GL_STATIC_DRAW - ); - - glBindBuffer(GL_ARRAY_BUFFER, _colorVbo); - glBufferData(GL_ARRAY_BUFFER, - pointColors.size() * sizeof(glm::vec3), - pointColors.data(), - GL_STATIC_DRAW - ); - - glBindBuffer(GL_ARRAY_BUFFER, _positionVbo); - glEnableVertexAttribArray(positionAttrib); - glVertexAttribPointer(positionAttrib, 3, GL_FLOAT, GL_FALSE, 0, nullptr); - - glBindBuffer(GL_ARRAY_BUFFER, _colorVbo); - glEnableVertexAttribArray(colorAttrib); - glVertexAttribPointer(colorAttrib, 3, GL_FLOAT, GL_FALSE, 0, nullptr); - - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindVertexArray(0); + if (_pointsFilename.empty()) { + return; } + + _pointsProgram = global::renderEngine.buildRenderProgram( + "Galaxy points", + absPath("${MODULE_GALAXY}/shaders/points_vs.glsl"), + absPath("${MODULE_GALAXY}/shaders/points_fs.glsl") + ); + _billboardsProgram = global::renderEngine.buildRenderProgram( + "Galaxy billboard", + absPath("${MODULE_GALAXY}/shaders/billboard_vs.glsl"), + absPath("${MODULE_GALAXY}/shaders/billboard_fs.glsl"), + absPath("${MODULE_GALAXY}/shaders/billboard_ge.glsl") + ); + + if (!_pointSpreadFunctionTexturePath.empty()) { + _pointSpreadFunctionTexture = ghoul::io::TextureReader::ref().loadTexture( + absPath(_pointSpreadFunctionTexturePath) + ); + + if (_pointSpreadFunctionTexture) { + LDEBUG(fmt::format( + "Loaded texture from '{}'", + absPath(_pointSpreadFunctionTexturePath) + )); + _pointSpreadFunctionTexture->uploadTexture(); + } + _pointSpreadFunctionTexture->setFilter( + ghoul::opengl::Texture::FilterMode::AnisotropicMipMap + ); + + _pointSpreadFunctionFile = std::make_unique( + _pointSpreadFunctionTexturePath + ); + } + + ghoul::opengl::updateUniformLocations( + *_pointsProgram, + _uniformCachePoints, + UniformNamesPoints + ); + ghoul::opengl::updateUniformLocations( + *_billboardsProgram, + _uniformCacheBillboards, + UniformNamesBillboards + ); + + _pointsProgram->setIgnoreUniformLocationError( + ghoul::opengl::ProgramObject::IgnoreError::Yes + ); + + GLint positionAttrib = _pointsProgram->attributeLocation("in_position"); + GLint colorAttrib = _pointsProgram->attributeLocation("in_color"); + + + std::vector pointPositions; + std::vector pointColors; + + std::string cachedPointsFile = FileSys.cacheManager()->cachedFilename( + _pointsFilename, + ghoul::filesystem::CacheManager::Persistent::Yes + ); + const bool hasCachedFile = FileSys.fileExists(cachedPointsFile); + if (hasCachedFile) { + LINFO(fmt::format("Cached file '{}' used for galaxy point file '{}'", + cachedPointsFile, _pointsFilename + )); + + Result res = loadCachedFile(cachedPointsFile); + if (res.success) { + pointPositions = std::move(res.positions); + pointColors = std::move(res.color); + } + else { + FileSys.cacheManager()->removeCacheFile(_pointsFilename); + Result res = loadPointFile(_pointsFilename); + pointPositions = std::move(res.positions); + pointColors = std::move(res.color); + saveCachedFile( + cachedPointsFile, + pointPositions, + pointColors, + _nPoints, + _enabledPointsRatio + ); + } + } + else { + Result res = loadPointFile(_pointsFilename); + ghoul_assert(res.success, "Point file loading failed"); + pointPositions = std::move(res.positions); + pointColors = std::move(res.color); + saveCachedFile( + cachedPointsFile, + pointPositions, + pointColors, + _nPoints, + _enabledPointsRatio + ); + } + + glGenVertexArrays(1, &_pointsVao); + glGenBuffers(1, &_positionVbo); + glGenBuffers(1, &_colorVbo); + + glBindVertexArray(_pointsVao); + glBindBuffer(GL_ARRAY_BUFFER, _positionVbo); + glBufferData(GL_ARRAY_BUFFER, + pointPositions.size() * sizeof(glm::vec3), + pointPositions.data(), + GL_STATIC_DRAW + ); + + glBindBuffer(GL_ARRAY_BUFFER, _colorVbo); + glBufferData(GL_ARRAY_BUFFER, + pointColors.size() * sizeof(glm::vec3), + pointColors.data(), + GL_STATIC_DRAW + ); + + glBindBuffer(GL_ARRAY_BUFFER, _positionVbo); + glEnableVertexAttribArray(positionAttrib); + glVertexAttribPointer(positionAttrib, 3, GL_FLOAT, GL_FALSE, 0, nullptr); + + glBindBuffer(GL_ARRAY_BUFFER, _colorVbo); + glEnableVertexAttribArray(colorAttrib); + glVertexAttribPointer(colorAttrib, 3, GL_FLOAT, GL_FALSE, 0, nullptr); + + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindVertexArray(0); } void RenderableGalaxy::deinitializeGL() { @@ -441,6 +522,10 @@ void RenderableGalaxy::deinitializeGL() { global::raycasterManager.detachRaycaster(*_raycaster); _raycaster = nullptr; } + + glDeleteVertexArrays(1, &_pointsVao); + glDeleteBuffers(1, &_positionVbo); + glDeleteBuffers(1, &_colorVbo); } bool RenderableGalaxy::isReady() const { @@ -448,41 +533,44 @@ bool RenderableGalaxy::isReady() const { } void RenderableGalaxy::update(const UpdateData& data) { - if (_raycaster) { - //glm::mat4 transform = glm::translate(, static_cast(_translation)); - const glm::vec3 eulerRotation = static_cast(_rotation); - glm::mat4 transform = glm::rotate( - glm::mat4(1.0), - eulerRotation.x, - glm::vec3(1, 0, 0) - ); - transform = glm::rotate(transform, eulerRotation.y, glm::vec3(0, 1, 0)); - transform = glm::rotate(transform, eulerRotation.z, glm::vec3(0, 0, 1)); - - glm::mat4 volumeTransform = glm::scale(transform, _volumeSize); - _pointTransform = transform; - //_pointTransform = glm::scale(transform, _pointScaling); - - const glm::vec4 translation = glm::vec4(_translation.value()*_volumeSize, 0.0); - - // Todo: handle floating point overflow, to actually support translation. - - volumeTransform[3] += translation; - _pointTransform[3] += translation; - - _raycaster->setStepSize(_stepSize); - _raycaster->setAspect(_aspect); - _raycaster->setModelTransform(volumeTransform); - _raycaster->setAbsorptionMultiplier(_absorptionMultiply); - _raycaster->setEmissionMultiplier(_emissionMultiply); - _raycaster->setTime(data.time.j2000Seconds()); + if (!_raycaster) { + return; } + //glm::mat4 transform = glm::translate(, static_cast(_translation)); + const glm::vec3 eulerRotation = static_cast(_rotation); + glm::mat4 transform = glm::rotate( + glm::mat4(1.f), + eulerRotation.x, + glm::vec3(1.f, 0.f, 0.f) + ); + transform = glm::rotate(transform, eulerRotation.y, glm::vec3(0.f, 1.f, 0.f)); + transform = glm::rotate(transform, eulerRotation.z, glm::vec3(0.f, 0.f, 1.f)); + + glm::mat4 volumeTransform = glm::scale(transform, _volumeSize); + _pointTransform = transform; + //_pointTransform = glm::scale(transform, _pointScaling); + + const glm::vec4 translation = glm::vec4(_translation.value()*_volumeSize, 0.f); + + // Todo: handle floating point overflow, to actually support translation. + + volumeTransform[3] += translation; + _pointTransform[3] += translation; + + _raycaster->setDownscaleRender(_downScaleVolumeRendering); + _raycaster->setMaxSteps(_numberOfRayCastingSteps); + _raycaster->setStepSize(_stepSize); + _raycaster->setAspect(_aspect); + _raycaster->setModelTransform(volumeTransform); + _raycaster->setAbsorptionMultiplier(_absorptionMultiply); + _raycaster->setEmissionMultiplier(_emissionMultiply); + _raycaster->setTime(data.time.j2000Seconds()); } void RenderableGalaxy::render(const RenderData& data, RendererTasks& tasks) { // Render the volume if (_raycaster && _volumeRenderingEnabled) { - RaycasterTask task{ _raycaster.get(), data }; + RaycasterTask task { _raycaster.get(), data }; const glm::vec3 position = data.camera.positionVec3(); const float length = safeLength(position); @@ -499,15 +587,19 @@ void RenderableGalaxy::render(const RenderData& data, RendererTasks& tasks) { float opacityCoefficient = 1.f; if (length < lowerRampStart) { opacityCoefficient = 0.f; // camera really close - } else if (length < lowerRampEnd) { + } + else if (length < lowerRampEnd) { opacityCoefficient = (length - lowerRampStart) / (lowerRampEnd - lowerRampStart); - } else if (length < upperRampStart) { + } + else if (length < upperRampStart) { opacityCoefficient = 1.f; // sweet spot (max) - } else if (length < upperRampEnd) { + } + else if (length < upperRampEnd) { opacityCoefficient = 1.f - (length - upperRampStart) / (upperRampEnd - upperRampStart); //fade out - } else { + } + else { opacityCoefficient = 0; } @@ -534,163 +626,166 @@ void RenderableGalaxy::render(const RenderData& data, RendererTasks& tasks) { } void RenderableGalaxy::renderPoints(const RenderData& data) { - if (_pointsProgram) { - // Saving current OpenGL state - GLenum blendEquationRGB; - GLenum blendEquationAlpha; - GLenum blendDestAlpha; - GLenum blendDestRGB; - GLenum blendSrcAlpha; - GLenum blendSrcRGB; - GLboolean depthMask; - - glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB); - glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); - glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); - glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB); - glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); - glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB); - - glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - glDepthMask(false); - glDisable(GL_DEPTH_TEST); - - _pointsProgram->activate(); - - glm::dmat4 rotMatrix = glm::rotate( - glm::dmat4(1.0), - glm::pi(), - glm::dvec3(1.0, 0.0, 0.0)) * - glm::rotate(glm::dmat4(1.0), 3.1248, glm::dvec3(0.0, 1.0, 0.0)) * - glm::rotate(glm::dmat4(1.0), 4.45741, glm::dvec3(0.0, 0.0, 1.0) - ); - - glm::dmat4 modelMatrix = - glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * - glm::dmat4(data.modelTransform.rotation) * rotMatrix * - glm::dmat4(glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale))); - - glm::dmat4 projectionMatrix = glm::dmat4(data.camera.projectionMatrix()); - - glm::dmat4 cameraViewProjectionMatrix = projectionMatrix * - data.camera.combinedViewMatrix(); - - _pointsProgram->setUniform(_uniformCachePoints.modelMatrix, modelMatrix); - _pointsProgram->setUniform( - _uniformCachePoints.cameraViewProjectionMatrix, - cameraViewProjectionMatrix - ); - - glm::dvec3 eyePosition = glm::dvec3( - glm::inverse(data.camera.combinedViewMatrix()) * - glm::dvec4(0.0, 0.0, 0.0, 1.0) - ); - _pointsProgram->setUniform(_uniformCachePoints.eyePosition, eyePosition); - _pointsProgram->setUniform( - _uniformCachePoints.opacityCoefficient, - _opacityCoefficient - ); - - glBindVertexArray(_pointsVao); - glDrawArrays(GL_POINTS, 0, static_cast(_nPoints * _enabledPointsRatio)); - - glBindVertexArray(0); - - _pointsProgram->deactivate(); - - glEnable(GL_DEPTH_TEST); - glDepthMask(true); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - // Restores OpenGL blending state - glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha); - glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha); - glDepthMask(depthMask); + if (!_pointsProgram) { + return; } + // Saving current OpenGL state + GLenum blendEquationRGB; + GLenum blendEquationAlpha; + GLenum blendDestAlpha; + GLenum blendDestRGB; + GLenum blendSrcAlpha; + GLenum blendSrcRGB; + GLboolean depthMask; + + glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB); + glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); + glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); + glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB); + glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); + glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB); + + glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glDepthMask(false); + glDisable(GL_DEPTH_TEST); + + _pointsProgram->activate(); + + glm::dmat4 rotMatrix = glm::rotate( + glm::dmat4(1.0), + glm::pi(), + glm::dvec3(1.0, 0.0, 0.0)) * + glm::rotate(glm::dmat4(1.0), 3.1248, glm::dvec3(0.0, 1.0, 0.0)) * + glm::rotate(glm::dmat4(1.0), 4.45741, glm::dvec3(0.0, 0.0, 1.0) + ); + + glm::dmat4 modelMatrix = + glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * + glm::dmat4(data.modelTransform.rotation) * rotMatrix * + glm::dmat4(glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale))); + + glm::dmat4 projectionMatrix = glm::dmat4(data.camera.projectionMatrix()); + + glm::dmat4 cameraViewProjectionMatrix = projectionMatrix * + data.camera.combinedViewMatrix(); + + _pointsProgram->setUniform(_uniformCachePoints.modelMatrix, modelMatrix); + _pointsProgram->setUniform( + _uniformCachePoints.cameraViewProjectionMatrix, + cameraViewProjectionMatrix + ); + + glm::dvec3 eyePosition = glm::dvec3( + glm::inverse(data.camera.combinedViewMatrix()) * + glm::dvec4(0.0, 0.0, 0.0, 1.0) + ); + _pointsProgram->setUniform(_uniformCachePoints.eyePosition, eyePosition); + _pointsProgram->setUniform( + _uniformCachePoints.opacityCoefficient, + _opacityCoefficient + ); + + glBindVertexArray(_pointsVao); + glDrawArrays(GL_POINTS, 0, static_cast(_nPoints * _enabledPointsRatio)); + + glBindVertexArray(0); + + _pointsProgram->deactivate(); + + glEnable(GL_DEPTH_TEST); + glDepthMask(true); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + // Restores OpenGL blending state + glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha); + glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha); + glDepthMask(depthMask); } void RenderableGalaxy::renderBillboards(const RenderData& data) { - if (_billboardsProgram) { - // Saving current OpenGL state - GLenum blendEquationRGB; - GLenum blendEquationAlpha; - GLenum blendDestAlpha; - GLenum blendDestRGB; - GLenum blendSrcAlpha; - GLenum blendSrcRGB; - GLboolean depthMask; - - glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB); - glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); - glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); - glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB); - glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); - glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB); - - glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - glDepthMask(false); - glDisable(GL_DEPTH_TEST); - - _billboardsProgram->activate(); - - glm::dmat4 rotMatrix = glm::rotate( - glm::dmat4(1.0), - glm::pi(), - glm::dvec3(1.0, 0.0, 0.0)) * - glm::rotate(glm::dmat4(1.0), 3.1248, glm::dvec3(0.0, 1.0, 0.0)) * - glm::rotate(glm::dmat4(1.0), 4.45741, glm::dvec3(0.0, 0.0, 1.0) - ); - - glm::dmat4 modelMatrix = - glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * - glm::dmat4(data.modelTransform.rotation) * rotMatrix * - glm::dmat4(glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale))); - - glm::dmat4 projectionMatrix = glm::dmat4(data.camera.projectionMatrix()); - - glm::dmat4 cameraViewProjectionMatrix = projectionMatrix * - data.camera.combinedViewMatrix(); - - _billboardsProgram->setUniform(_uniformCacheBillboards.modelMatrix, modelMatrix); - _billboardsProgram->setUniform( - _uniformCacheBillboards.cameraViewProjectionMatrix, - cameraViewProjectionMatrix - ); - - glm::dvec3 eyePosition = glm::dvec3( - glm::inverse(data.camera.combinedViewMatrix()) * - glm::dvec4(0.0, 0.0, 0.0, 1.0) - ); - _billboardsProgram->setUniform(_uniformCacheBillboards.eyePosition, eyePosition); - - glm::dvec3 cameraUp = data.camera.lookUpVectorWorldSpace(); - _billboardsProgram->setUniform(_uniformCacheBillboards.cameraUp, cameraUp); - - ghoul::opengl::TextureUnit psfUnit; - psfUnit.activate(); - _pointSpreadFunctionTexture->bind(); - _billboardsProgram->setUniform(_uniformCacheBillboards.psfTexture, psfUnit); - - glBindVertexArray(_pointsVao); - glDrawArrays(GL_POINTS, 0, static_cast(_nPoints * _enabledPointsRatio)); - - glBindVertexArray(0); - - _billboardsProgram->deactivate(); - - glEnable(GL_DEPTH_TEST); - glDepthMask(true); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - // Restores OpenGL blending state - glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha); - glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha); - glDepthMask(depthMask); + if (!_billboardsProgram) { + return; } + + // Saving current OpenGL state + GLenum blendEquationRGB; + GLenum blendEquationAlpha; + GLenum blendDestAlpha; + GLenum blendDestRGB; + GLenum blendSrcAlpha; + GLenum blendSrcRGB; + GLboolean depthMask; + + glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB); + glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); + glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); + glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB); + glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); + glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB); + + glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glDepthMask(false); + glDisable(GL_DEPTH_TEST); + + _billboardsProgram->activate(); + + glm::dmat4 rotMatrix = glm::rotate( + glm::dmat4(1.0), + glm::pi(), + glm::dvec3(1.0, 0.0, 0.0)) * + glm::rotate(glm::dmat4(1.0), 3.1248, glm::dvec3(0.0, 1.0, 0.0)) * + glm::rotate(glm::dmat4(1.0), 4.45741, glm::dvec3(0.0, 0.0, 1.0) + ); + + glm::dmat4 modelMatrix = + glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * + glm::dmat4(data.modelTransform.rotation) * rotMatrix * + glm::dmat4(glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale))); + + glm::dmat4 projectionMatrix = glm::dmat4(data.camera.projectionMatrix()); + + glm::dmat4 cameraViewProjectionMatrix = projectionMatrix * + data.camera.combinedViewMatrix(); + + _billboardsProgram->setUniform(_uniformCacheBillboards.modelMatrix, modelMatrix); + _billboardsProgram->setUniform( + _uniformCacheBillboards.cameraViewProjectionMatrix, + cameraViewProjectionMatrix + ); + + glm::dvec3 eyePosition = glm::dvec3( + glm::inverse(data.camera.combinedViewMatrix()) * + glm::dvec4(0.0, 0.0, 0.0, 1.0) + ); + _billboardsProgram->setUniform(_uniformCacheBillboards.eyePosition, eyePosition); + + glm::dvec3 cameraUp = data.camera.lookUpVectorWorldSpace(); + _billboardsProgram->setUniform(_uniformCacheBillboards.cameraUp, cameraUp); + + ghoul::opengl::TextureUnit psfUnit; + psfUnit.activate(); + _pointSpreadFunctionTexture->bind(); + _billboardsProgram->setUniform(_uniformCacheBillboards.psfTexture, psfUnit); + + glBindVertexArray(_pointsVao); + glDrawArrays(GL_POINTS, 0, static_cast(_nPoints * _enabledPointsRatio)); + + glBindVertexArray(0); + + _billboardsProgram->deactivate(); + + glEnable(GL_DEPTH_TEST); + glDepthMask(true); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + // Restores OpenGL blending state + glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha); + glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha); + glDepthMask(depthMask); } float RenderableGalaxy::safeLength(const glm::vec3& vector) const { @@ -700,4 +795,95 @@ float RenderableGalaxy::safeLength(const glm::vec3& vector) const { return glm::length(vector / maxComponent) * maxComponent; } +RenderableGalaxy::Result RenderableGalaxy::loadPointFile(const std::string& file) { + std::vector pointPositions; + std::vector pointColors; + int64_t nPoints; + + std::ifstream pointFile(_pointsFilename, std::ios::in); + + // Read header for OFF (Object File Format) + std::string line; + std::getline(pointFile, line); + + // Read point count + std::getline(pointFile, line); + std::istringstream iss(line); + iss >> nPoints; + + // Prepare point reading + _nPoints = static_cast(nPoints); + + // Read points + float x, y, z, r, g, b, a; + for (size_t i = 0; + i < static_cast(_nPoints * _enabledPointsRatio.maxValue()) + 1; + ++i) + { + std::getline(pointFile, line); + std::istringstream issp(line); + issp >> x >> y >> z >> r >> g >> b >> a; + + // Convert kiloparsec to meters + glm::vec3 position = glm::vec3(x, y, z); + position *= (distanceconstants::Parsec * 100); + + pointPositions.emplace_back(position); + pointColors.emplace_back(r, g, b); + } + + Result res; + res.success = true; + res.positions = std::move(pointPositions); + res.color = std::move(pointColors); + return res; +} + +RenderableGalaxy::Result RenderableGalaxy::loadCachedFile(const std::string& file) { + std::ifstream fileStream(file, std::ifstream::binary); + if (!fileStream.good()) { + LERROR(fmt::format("Error opening file '{}' for loading cache file", file)); + return { false, {}, {} }; + } + + int8_t cacheVersion; + fileStream.read(reinterpret_cast(&cacheVersion), sizeof(int8_t)); + if (cacheVersion != CurrentCacheVersion) { + LINFO(fmt::format("Removing cache file '{}' as the version changed")); + return { false, {}, {} }; + } + + int64_t nPoints; + fileStream.read(reinterpret_cast(&nPoints), sizeof(int64_t)); + _nPoints = static_cast(nPoints); + + float enabledPointsRatio; + fileStream.read(reinterpret_cast(&enabledPointsRatio), sizeof(float)); + _enabledPointsRatio = enabledPointsRatio; + + uint64_t nPositions; + fileStream.read(reinterpret_cast(&nPositions), sizeof(uint64_t)); + std::vector positions; + positions.resize(nPositions); + fileStream.read( + reinterpret_cast(positions.data()), + nPositions * sizeof(glm::vec3) + ); + + uint64_t nColors; + fileStream.read(reinterpret_cast(&nColors), sizeof(uint64_t)); + std::vector colors; + colors.resize(nColors); + fileStream.read( + reinterpret_cast(colors.data()), + nColors * sizeof(glm::vec3) + ); + + Result result; + result.success = true; + result.positions = std::move(positions); + result.color = std::move(colors); + return result; +} + } // namespace openspace diff --git a/modules/galaxy/rendering/renderablegalaxy.h b/modules/galaxy/rendering/renderablegalaxy.h index 0b49d848c4..d48ac6d2ab 100644 --- a/modules/galaxy/rendering/renderablegalaxy.h +++ b/modules/galaxy/rendering/renderablegalaxy.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -33,9 +33,7 @@ #include #include -namespace ghoul::opengl { - class ProgramObject; -} // namespace ghoul::opengl +namespace ghoul::opengl { class ProgramObject; } namespace openspace { @@ -60,8 +58,16 @@ private: void renderBillboards(const RenderData& data); float safeLength(const glm::vec3& vector) const; - glm::vec3 _volumeSize; - glm::vec3 _pointScaling; + struct Result { + bool success; + std::vector positions; + std::vector color; + }; + Result loadPointFile(const std::string& file); + Result loadCachedFile(const std::string& file); + + glm::vec3 _volumeSize = glm::vec3(0.f); + glm::vec3 _pointScaling = glm::vec3(0.f); properties::BoolProperty _volumeRenderingEnabled; properties::BoolProperty _starRenderingEnabled; properties::FloatProperty _stepSize; @@ -71,21 +77,23 @@ private: properties::FloatProperty _enabledPointsRatio; properties::Vec3Property _translation; properties::Vec3Property _rotation; + properties::FloatProperty _downScaleVolumeRendering; + properties::FloatProperty _numberOfRayCastingSteps; std::unique_ptr _pointSpreadFunctionTexture; std::unique_ptr _pointSpreadFunctionFile; std::string _volumeFilename; - glm::ivec3 _volumeDimensions; + glm::ivec3 _volumeDimensions = glm::ivec3(0); std::string _pointsFilename; std::string _pointSpreadFunctionTexturePath; std::unique_ptr _raycaster; std::unique_ptr>> _volume; std::unique_ptr _texture; - glm::mat4 _pointTransform; - glm::vec3 _aspect; - float _opacityCoefficient; + glm::mat4 _pointTransform = glm::mat4(1.f); + glm::vec3 _aspect = glm::vec3(0.f); + float _opacityCoefficient = 0.f; std::unique_ptr _pointsProgram; std::unique_ptr _billboardsProgram; @@ -98,10 +106,10 @@ private: cameraUp, eyePosition, psfTexture ) _uniformCacheBillboards; std::vector _pointsData; - size_t _nPoints; - GLuint _pointsVao; - GLuint _positionVbo; - GLuint _colorVbo; + size_t _nPoints = 0; + GLuint _pointsVao = 0; + GLuint _positionVbo = 0; + GLuint _colorVbo = 0; }; } // namespace openspace diff --git a/modules/galaxy/shaders/billboard_fs.glsl b/modules/galaxy/shaders/billboard_fs.glsl index cf758b3cab..8d6bb8086d 100644 --- a/modules/galaxy/shaders/billboard_fs.glsl +++ b/modules/galaxy/shaders/billboard_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/galaxy/shaders/billboard_ge.glsl b/modules/galaxy/shaders/billboard_ge.glsl index d57daee59a..f6d1514312 100644 --- a/modules/galaxy/shaders/billboard_ge.glsl +++ b/modules/galaxy/shaders/billboard_ge.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/galaxy/shaders/billboard_vs.glsl b/modules/galaxy/shaders/billboard_vs.glsl index 2893bccdd7..ee5fff53fb 100644 --- a/modules/galaxy/shaders/billboard_vs.glsl +++ b/modules/galaxy/shaders/billboard_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/galaxy/shaders/galaxyraycast.glsl b/modules/galaxy/shaders/galaxyraycast.glsl index a16188aa5d..5bc7bcb4c6 100644 --- a/modules/galaxy/shaders/galaxyraycast.glsl +++ b/modules/galaxy/shaders/galaxyraycast.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * -* Copyright (c) 2014-2019 * +* Copyright (c) 2014-2020 * * * * 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 * @@ -29,17 +29,18 @@ uniform float absorptionMultiply#{id} = 50.0; uniform float emissionMultiply#{id} = 1500.0; uniform sampler3D galaxyTexture#{id}; -void sample#{id}(vec3 samplePos, +void sample#{id}( + vec3 samplePos, vec3 dir, inout vec3 accumulatedColor, inout vec3 accumulatedAlpha, - inout float stepSize) - { + inout float stepSize + ) { vec3 aspect = aspect#{id}; stepSize = maxStepSize#{id} / length(dir / aspect); //Early ray termination on black parts of the data - vec3 normalizedPos = samplePos*2.0 - 1.0; + vec3 normalizedPos = samplePos * 2.f - 1.f; if (normalizedPos.x * normalizedPos.x + normalizedPos.y * normalizedPos.y > 0.7) { return; } @@ -51,12 +52,12 @@ void sample#{id}(vec3 samplePos, sampledColor = sampledColor*sampledColor; // Fudge for the dust "spreading" - sampledColor.a = clamp(sampledColor.a, 0.0, 1.0); - sampledColor.a = pow(sampledColor.a, 0.7); + sampledColor.a = clamp(sampledColor.a, 0.f, 1.f); + sampledColor.a = pow(sampledColor.a, 0.7f); // Absorption probability float scaledDensity = sampledColor.a * stepSize * absorptionMultiply#{id}; - vec3 alphaTint = vec3(0.3, 0.54, 0.85); + vec3 alphaTint = vec3(0.3f, 0.54f, 0.85f); vec3 absorption = alphaTint * scaledDensity; // Extinction @@ -67,10 +68,10 @@ void sample#{id}(vec3 samplePos, accumulatedColor.rgb += sampledColor.rgb * stepSize * emissionMultiply#{id} * opacityCoefficient#{id}; - vec3 oneMinusFrontAlpha = vec3(1.0) - accumulatedAlpha; + vec3 oneMinusFrontAlpha = vec3(1.f) - accumulatedAlpha; accumulatedAlpha += oneMinusFrontAlpha * sampledColor.rgb * opacityCoefficient#{id}; } float stepSize#{id}(vec3 samplePos, vec3 dir) { - return maxStepSize#{id} * length(dir * 1.0 / aspect#{id}); + return maxStepSize#{id} * length(dir * 1.f / aspect#{id}); } diff --git a/modules/galaxy/shaders/points_fs.glsl b/modules/galaxy/shaders/points_fs.glsl index 42a13db7b8..702046e45a 100644 --- a/modules/galaxy/shaders/points_fs.glsl +++ b/modules/galaxy/shaders/points_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/galaxy/shaders/points_vs.glsl b/modules/galaxy/shaders/points_vs.glsl index ecfd7b3d15..c8be748996 100644 --- a/modules/galaxy/shaders/points_vs.glsl +++ b/modules/galaxy/shaders/points_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -50,8 +50,6 @@ void main() { dpos.xyz *= 8.0; dpos = modelMatrix * dpos; dpos /= PARSEC; - //It lies about 8 kpc from the center on what is known as the Orion Arm of the Milky Way - dpos.x += 8000; vec4 positionScreenSpace = z_normalization(vec4(cameraViewProjectionMatrix * dpos)); vs_color = in_color; diff --git a/modules/galaxy/shaders/raycasterbounds_fs.glsl b/modules/galaxy/shaders/raycasterbounds_fs.glsl index 7b54a237a2..2ff99f2c5a 100644 --- a/modules/galaxy/shaders/raycasterbounds_fs.glsl +++ b/modules/galaxy/shaders/raycasterbounds_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -32,10 +32,10 @@ Fragment getFragment() { Fragment frag; //Early ray termination on black parts of the data /*vec3 normalizedPos = (modelPosition*2.0)-1.0; - if(abs(modelPosition.x) > 0.9 || abs(modelPosition.y) > 0.9){ + if (abs(modelPosition.x) > 0.9 || abs(modelPosition.y) > 0.9) { frag.color = vec4(0.0, 0.0, 0.0, 1.0); } - else{*/ + else {*/ vec3 pos = modelPosition + 0.5; //vec3 posClamp = clamp(pos, vec3(0.0), vec3(1.0)); frag.color = vec4(pos, 1.0); diff --git a/modules/galaxy/shaders/raycasterbounds_vs.glsl b/modules/galaxy/shaders/raycasterbounds_vs.glsl index 0334e47569..5e1ddaed80 100644 --- a/modules/galaxy/shaders/raycasterbounds_vs.glsl +++ b/modules/galaxy/shaders/raycasterbounds_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/galaxy/tasks/milkywayconversiontask.cpp b/modules/galaxy/tasks/milkywayconversiontask.cpp index cedc01fb2e..ec985ad917 100644 --- a/modules/galaxy/tasks/milkywayconversiontask.cpp +++ b/modules/galaxy/tasks/milkywayconversiontask.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -86,8 +86,8 @@ void MilkywayConversionTask::perform(const Task::ProgressCallback& onProgress) { ); std::function(glm::ivec3)> sampleFunction = [&](glm::ivec3 outCoord) { - const glm::vec3 inCoord = ((glm::vec3(outCoord) + glm::vec3(0.5)) * - resolutionRatio) - glm::vec3(0.5); + const glm::vec3 inCoord = ((glm::vec3(outCoord) + glm::vec3(0.5f)) * + resolutionRatio) - glm::vec3(0.5f); const glm::tvec4 value = sampler.sample(inCoord); return value; }; diff --git a/modules/galaxy/tasks/milkywayconversiontask.h b/modules/galaxy/tasks/milkywayconversiontask.h index 0fefa0eb2b..47ff0707aa 100644 --- a/modules/galaxy/tasks/milkywayconversiontask.h +++ b/modules/galaxy/tasks/milkywayconversiontask.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -50,10 +50,10 @@ public: private: std::string _inFilenamePrefix; std::string _inFilenameSuffix; - size_t _inFirstIndex; - size_t _inNSlices; + size_t _inFirstIndex = 0; + size_t _inNSlices = 0; std::string _outFilename; - glm::ivec3 _outDimensions; + glm::ivec3 _outDimensions = glm::ivec3(0); }; } // namespace openspace diff --git a/modules/galaxy/tasks/milkywaypointsconversiontask.cpp b/modules/galaxy/tasks/milkywaypointsconversiontask.cpp index 53f487bf23..a79de9153e 100644 --- a/modules/galaxy/tasks/milkywaypointsconversiontask.cpp +++ b/modules/galaxy/tasks/milkywaypointsconversiontask.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/galaxy/tasks/milkywaypointsconversiontask.h b/modules/galaxy/tasks/milkywaypointsconversiontask.h index 7b54632167..e2a1be4a4f 100644 --- a/modules/galaxy/tasks/milkywaypointsconversiontask.h +++ b/modules/galaxy/tasks/milkywaypointsconversiontask.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/CMakeLists.txt b/modules/globebrowsing/CMakeLists.txt index 7d46e40e1a..ec5c7f389c 100644 --- a/modules/globebrowsing/CMakeLists.txt +++ b/modules/globebrowsing/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2018 # +# Copyright (c) 2014-2020 # # # # 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 # @@ -51,6 +51,8 @@ set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/rawtile.h ${CMAKE_CURRENT_SOURCE_DIR}/src/rawtiledatareader.h ${CMAKE_CURRENT_SOURCE_DIR}/src/renderableglobe.h + ${CMAKE_CURRENT_SOURCE_DIR}/src/ringscomponent.h + ${CMAKE_CURRENT_SOURCE_DIR}/src/shadowcomponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/skirtedgrid.h ${CMAKE_CURRENT_SOURCE_DIR}/src/tileindex.h ${CMAKE_CURRENT_SOURCE_DIR}/src/tileloadjob.h @@ -80,6 +82,8 @@ set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/rawtile.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/rawtiledatareader.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/renderableglobe.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/ringscomponent.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/shadowcomponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/skirtedgrid.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/tileindex.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/tileloadjob.cpp @@ -94,6 +98,10 @@ set(SHADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/shaders/globalrenderer_vs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/localrenderer_vs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/renderer_fs.glsl + ${CMAKE_CURRENT_SOURCE_DIR}/shaders/rings_vs.glsl + ${CMAKE_CURRENT_SOURCE_DIR}/shaders/rings_fs.glsl + ${CMAKE_CURRENT_SOURCE_DIR}/shaders/rings_geom_vs.glsl + ${CMAKE_CURRENT_SOURCE_DIR}/shaders/rings_geom_fs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/texturetilemapping.hglsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/tile.hglsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/tileheight.hglsl diff --git a/modules/globebrowsing/globebrowsingmodule.cpp b/modules/globebrowsing/globebrowsingmodule.cpp index df7dd2dbc2..4eb99dd7da 100644 --- a/modules/globebrowsing/globebrowsingmodule.cpp +++ b/modules/globebrowsing/globebrowsingmodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -43,8 +43,9 @@ #include #include #include -#include #include +#include +#include #include #include @@ -236,6 +237,8 @@ void GlobeBrowsingModule::internalInitialize(const ghoul::Dictionary& dict) { // Initialize global::callback::initializeGL.emplace_back([&]() { + ZoneScopedN("GlobeBrowsingModule") + _tileCache = std::make_unique( _tileCacheSizeMB ); @@ -252,16 +255,24 @@ void GlobeBrowsingModule::internalInitialize(const ghoul::Dictionary& dict) { }); global::callback::deinitializeGL.emplace_back([]() { + ZoneScopedN("GlobeBrowsingModule") + tileprovider::deinitializeDefaultTile(); }); // Render - global::callback::render.emplace_back([&]() { _tileCache->update(); }); + global::callback::render.emplace_back([&]() { + ZoneScopedN("GlobeBrowsingModule") + + _tileCache->update(); + }); // Postdraw #ifdef OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION global::callback::postDraw.emplace_back([&]() { + ZoneScopedN("GlobeBrowsingModule") + // >= as we might have multiple frames per postDraw call (stereo rendering, // fisheye, etc) const uint16_t next = _frameInfo.lastSavedFrame + _frameInfo.saveEveryNthFrame; @@ -297,7 +308,11 @@ void GlobeBrowsingModule::internalInitialize(const ghoul::Dictionary& dict) { #endif // OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION // Deinitialize - global::callback::deinitialize.emplace_back([&]() { GdalWrapper::destroy(); }); + global::callback::deinitialize.emplace_back([&]() { + ZoneScopedN("GlobeBrowsingModule") + + GdalWrapper::destroy(); + }); auto fRenderable = FactoryManager::ref().factory(); ghoul_assert(fRenderable, "Renderable factory was not created"); diff --git a/modules/globebrowsing/globebrowsingmodule.h b/modules/globebrowsing/globebrowsingmodule.h index 8f9367a0fd..e6af83d999 100644 --- a/modules/globebrowsing/globebrowsingmodule.h +++ b/modules/globebrowsing/globebrowsingmodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/globebrowsingmodule_lua.inl b/modules/globebrowsing/globebrowsingmodule_lua.inl index 82f7690d65..86d474d64c 100644 --- a/modules/globebrowsing/globebrowsingmodule_lua.inl +++ b/modules/globebrowsing/globebrowsingmodule_lua.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/scripts/layer_support.lua b/modules/globebrowsing/scripts/layer_support.lua index d76864112f..4ac0cf6971 100644 --- a/modules/globebrowsing/scripts/layer_support.lua +++ b/modules/globebrowsing/scripts/layer_support.lua @@ -48,6 +48,16 @@ openspace.globebrowsing.documentation = { "}" .. ")" }, + { + Name = "addGibsLayer", + Arguments = "string, string, string, string, string", + Documentation = "Adds a new layer from NASA GIBS to the Earth globe. Arguments " .. + "are: imagery layer name, imagery resolution, start date, end date, format. " .. + "For all specifications, see " .. + "https://wiki.earthdata.nasa.gov/display/GIBS/GIBS+Available+Imagery+Products" .. + "Usage:" .. + "openspace.globebrowsing.addGibsLayer('AIRS_Temperature_850hPa_Night', '2km', '2013-07-15', 'Present', 'png')" + }, { Name = "parseInfoFile", Arguments = "string", @@ -97,6 +107,14 @@ openspace.globebrowsing.documentation = { } } +openspace.globebrowsing.addGibsLayer = function(layer, resolution, format, startDate, endDate) + if endDate == 'Present' then + endDate = '' + end + local xml = openspace.globebrowsing.createTemporalGibsGdalXml(layer, startDate, endDate, '1d', resolution, format) + openspace.globebrowsing.addLayer('Earth', 'ColorLayers', { Identifier = layer, Type = "TemporalTileLayer", FilePath = xml }) +end + openspace.globebrowsing.createTemporalGibsGdalXml = function (layerName, startDate, endDate, timeResolution, resolution, format) temporalTemplate = "" .. @@ -332,5 +350,4 @@ openspace.globebrowsing.loadWMSServersFromFile = function (file_path) ) end end - end diff --git a/modules/globebrowsing/shaders/blending.hglsl b/modules/globebrowsing/shaders/blending.hglsl index ed63e61461..166ec948d1 100644 --- a/modules/globebrowsing/shaders/blending.hglsl +++ b/modules/globebrowsing/shaders/blending.hglsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -78,9 +78,11 @@ vec3 rgb2hsl(in vec3 c) { float h = 0.0; if (r == cMax) { h = (g - b) / cDelta; - } else if (g == cMax) { + } + else if (g == cMax) { h = 2.0 + (b - r) / cDelta; - } else { + } + else { h = 4.0 + (r - g) / cDelta; } diff --git a/modules/globebrowsing/shaders/globalrenderer_vs.glsl b/modules/globebrowsing/shaders/globalrenderer_vs.glsl index 8e91e2e6a4..a72d20dc96 100644 --- a/modules/globebrowsing/shaders/globalrenderer_vs.glsl +++ b/modules/globebrowsing/shaders/globalrenderer_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -48,6 +48,14 @@ out vec3 positionCameraSpace; uniform dmat4 modelTransform; #endif +#if SHADOW_MAPPING_ENABLED + // ShadowMatrix is the matrix defined by: + // textureCoordsMatrix * projectionMatrix * combinedViewMatrix * modelMatrix + // where textureCoordsMatrix is just a scale and bias computation: [-1,1] to [0,1] + uniform dmat4 shadowMatrix; + out vec4 shadowCoords; +#endif + uniform mat4 modelViewProjectionTransform; uniform mat4 modelViewTransform; uniform vec3 radiiSquared; @@ -130,4 +138,8 @@ void main() { #if USE_ECLIPSE_SHADOWS positionWorldSpace = vec3(modelTransform * dvec4(pair.position, 1.0)); #endif + +#if SHADOW_MAPPING_ENABLED + shadowCoords = vec4(shadowMatrix * dvec4(pair.position, 1.0)); +#endif } diff --git a/modules/globebrowsing/shaders/localrenderer_vs.glsl b/modules/globebrowsing/shaders/localrenderer_vs.glsl index 5e6ef0e12b..22a8930f8d 100644 --- a/modules/globebrowsing/shaders/localrenderer_vs.glsl +++ b/modules/globebrowsing/shaders/localrenderer_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -48,6 +48,14 @@ out vec3 positionWorldSpace; uniform dmat4 inverseViewTransform; #endif +#if SHADOW_MAPPING_ENABLED + // ShadowMatrix is the matrix defined by: + // textureCoordsMatrix * projectionMatrix * combinedViewMatrix * modelMatrix + // where textureCoordsMatrix is just a scale and bias computation: [-1,1] to [0,1] + uniform dmat4 shadowMatrix; + out vec4 shadowCoords; +#endif + uniform mat4 projectionTransform; // Input points in camera space uniform vec3 p00; @@ -113,4 +121,8 @@ void main() { #if USE_ECLIPSE_SHADOWS positionWorldSpace = vec3(inverseViewTransform * dvec4(p, 1.0)); #endif + +#if SHADOW_MAPPING_ENABLED + shadowCoords = vec4(shadowMatrix * dvec4(p, 1.0)); +#endif } diff --git a/modules/globebrowsing/shaders/renderer_fs.glsl b/modules/globebrowsing/shaders/renderer_fs.glsl index f0408f7941..ff1bf76f0f 100644 --- a/modules/globebrowsing/shaders/renderer_fs.glsl +++ b/modules/globebrowsing/shaders/renderer_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -51,14 +51,24 @@ uniform Layer WaterMasks[NUMLAYERS_WATERMASK]; uniform vec2 vertexResolution; #endif -#if USE_NIGHTTEXTURE || USE_WATERMASK || PERFORM_SHADING +//#if USE_NIGHTTEXTURE || USE_WATERMASK || PERFORM_SHADING uniform vec3 lightDirectionCameraSpace; -#endif +//#endif #if PERFORM_SHADING uniform float orenNayarRoughness; #endif +#if SHADOW_MAPPING_ENABLED + +#define NSSamplesMinusOne #{nShadowSamples} +#define NSSamples (NSSamplesMinusOne + 1) + +in vec4 shadowCoords; +uniform sampler2DShadow shadowMapTexture; +uniform float zFightingPercentage; +#endif + #if USE_ECLIPSE_SHADOWS /******************************************************************************* @@ -232,7 +242,7 @@ Fragment getFragment() { // Water reflectance is added to the G-Buffer. frag.gNormal.w = waterReflectance; #else - frag.gNormal.w = 0; + frag.gNormal.w = 0.0; #endif // Normal is written View Space (Including SGCT View Matrix). frag.gNormal.xyz = normal; @@ -258,5 +268,30 @@ Fragment getFragment() { } #endif // SHOW_CHUNK_EDGES +#if SHADOW_MAPPING_ENABLED + float shadow = 1.0; + if (shadowCoords.w > 1) { + vec4 normalizedShadowCoords = shadowCoords; + normalizedShadowCoords.z = normalizeFloat(zFightingPercentage * normalizedShadowCoords.w); + normalizedShadowCoords.xy = normalizedShadowCoords.xy / normalizedShadowCoords.w; + normalizedShadowCoords.w = 1.0; + + float sum = 0; + #for i in 0..#{nShadowSamples} + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2(-NSSamples + #{i}, -NSSamples + #{i})); + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2(-NSSamples + #{i}, 0)); + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2(-NSSamples + #{i}, NSSamples - #{i})); + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( 0 , -NSSamples + #{i})); + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( 0 , NSSamples - #{i})); + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( NSSamples - #{i}, -NSSamples + #{i})); + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( NSSamples - #{i}, 0)); + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( NSSamples - #{i}, NSSamples - #{i})); + #endfor + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2(0, 0)); + shadow = sum / (8.0 * NSSamples + 1.f); + } + frag.color.xyz *= shadow < 0.99 ? clamp(shadow + 0.3, 0.0, 1.0) : shadow; +#endif + return frag; } diff --git a/modules/globebrowsing/shaders/rings_fs.glsl b/modules/globebrowsing/shaders/rings_fs.glsl new file mode 100644 index 0000000000..b18d5d71a8 --- /dev/null +++ b/modules/globebrowsing/shaders/rings_fs.glsl @@ -0,0 +1,129 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2020 * + * * + * 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 "PowerScaling/powerScaling_fs.hglsl" +#include "fragment.glsl" + +#define NSSamplesMinusOne #{nShadowSamples} +#define NSSamples (NSSamplesMinusOne + 1) + +in vec2 vs_st; +in float vs_screenSpaceDepth; +in vec4 shadowCoords; + +uniform sampler2DShadow shadowMapTexture; +uniform sampler1D ringTexture; +uniform vec2 textureOffset; +uniform float transparency; + +uniform vec3 sunPosition; +uniform float _nightFactor; +uniform float zFightingPercentage; + +// temp +in vec4 fragPosInLightSpace; + + +Fragment getFragment() { + // Moving the origin to the center + vec2 st = (vs_st - vec2(0.5)) * 2.0; + + // The length of the texture coordinates vector is our distance from the center + float radius = length(st); + + // We only want to consider ring-like objects so we need to discard everything else + if (radius > 1.0) { + discard; + } + + // Remapping the texture coordinates + // Radius \in [0,1], texCoord \in [textureOffset.x, textureOffset.y] + // textureOffset.x -> 0 + // textureOffset.y -> 1 + float texCoord = (radius - textureOffset.x) / (textureOffset.y - textureOffset.x); + if (texCoord < 0.f || texCoord > 1.f) { + discard; + } + + vec4 diffuse = texture(ringTexture, texCoord); + float colorValue = length(diffuse.rgb); + // times 3 as length of vec3(1.0, 1.0, 1.0) will return 3 and we want + // to normalize the transparency value to [0,1] + if (colorValue < 3.0 * transparency) { + diffuse.a = pow(colorValue / (3.0 * transparency), 1); + //diffuse.a = (colorValue / 3.0) * transparency; + if (diffuse.a < 0.65) + discard; + } + + // shadow == 1.0 means it is not in shadow + float shadow = 1.0; + if ( shadowCoords.z >= 0 ) { + vec4 normalizedShadowCoords = shadowCoords; + normalizedShadowCoords.z = normalizeFloat(zFightingPercentage * normalizedShadowCoords.w); + normalizedShadowCoords.xy = normalizedShadowCoords.xy / normalizedShadowCoords.w; + normalizedShadowCoords.w = 1.0; + + float sum = 0; + #for i in 0..#{nShadowSamples} + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2(-NSSamples + #{i}, -NSSamples + #{i})); + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2(-NSSamples + #{i}, 0)); + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2(-NSSamples + #{i}, NSSamples - #{i})); + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( 0 , -NSSamples + #{i})); + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( 0 , NSSamples - #{i})); + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( NSSamples - #{i}, -NSSamples + #{i})); + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( NSSamples - #{i}, 0)); + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( NSSamples - #{i}, NSSamples - #{i})); + #endfor + sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2(0, 0)); + shadow = clamp(sum / (8.0 * NSSamples + 1.f), 0.35, 1.0); + } + + // The normal for the one plane depends on whether we are dealing + // with a front facing or back facing fragment + vec3 normal; + // The plane is oriented on the xz plane + // WARNING: This might not be the case for Uranus + if (gl_FrontFacing) { + normal = vec3(-1.0, 0.0, 0.0); + } + else { + normal = vec3(1.0, 0.0, 0.0); + } + + // Reduce the color of the fragment by the user factor + // if we are facing away from the Sun + if (dot(sunPosition, normal) < 0) { + diffuse.xyz *= _nightFactor; + } + + Fragment frag; + + frag.color = diffuse * shadow; + frag.depth = vs_screenSpaceDepth; + frag.gPosition = vec4(1e30, 1e30, 1e30, 1.0); + frag.gNormal = vec4(normal, 1.0); + + return frag; +} diff --git a/tests/test_temporaltileprovider.inl b/modules/globebrowsing/shaders/rings_geom_fs.glsl similarity index 56% rename from tests/test_temporaltileprovider.inl rename to modules/globebrowsing/shaders/rings_geom_fs.glsl index d58f2ce6a8..48b1174baa 100644 --- a/tests/test_temporaltileprovider.inl +++ b/modules/globebrowsing/shaders/rings_geom_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -22,25 +22,53 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include "PowerScaling/powerScaling_fs.hglsl" +#include "fragment.glsl" -#include +in vec2 vs_st; +in float vs_screenSpaceDepth; -#define _USE_MATH_DEFINES -#include -#include -#include +uniform sampler1D ringTexture; +uniform vec2 textureOffset; +Fragment getFragment() { + // Moving the origin to the center + vec2 st = (vs_st - vec2(0.5)) * 2.0; -class TemporalTileProviderTest : public testing::Test {}; + // The length of the texture coordinates vector is our distance from the center + float radius = length(st); -std::string fileName = "data/scene/debugglobe/map_service_configs/VIIRS_SNPP_CorrectedReflectance_TrueColor_temporal.xml"; + // We only want to consider ring-like objects so we need to discard everything else + if (radius > 1.0) { + discard; + } -TEST_F(TemporalTileProviderTest, Basic) { - double t = 2016.01; - openspace::Time::ref().setTime(t); - openspace::Time::ref().preSynchronization(); - openspace::Time::ref().postSynchronizationPreDraw(); - openspace::TemporalTileProvider provider(absPath(fileName)); + // Remapping the texture coordinates + // Radius \in [0,1], texCoord \in [textureOffset.x, textureOffset.y] + // textureOffset.x -> 0 + // textureOffset.y -> 1 + float texCoord = (radius - textureOffset.x) / (textureOffset.y - textureOffset.x); + if (texCoord < 0.f || texCoord > 1.f) { + discard; + } + + float diffuse = length(texture(ringTexture, texCoord).rgb); + + // The normal for the one plane depends on whether we are dealing + // with a front facing or back facing fragment + //vec3 normal; + // The plane is oriented on the xz plane + // WARNING: This might not be the case for Uranus + // if (gl_FrontFacing) { + // normal = vec3(-1.0, 0.0, 0.0); + // } + // else { + // normal = vec3(1.0, 0.0, 0.0); + // } + + Fragment frag; + frag.color = vec4(vec3(vs_screenSpaceDepth), 1.0); + frag.depth = (diffuse < 0.5) ? 1E30 : vs_screenSpaceDepth; + + return frag; } - diff --git a/modules/globebrowsing/shaders/rings_geom_vs.glsl b/modules/globebrowsing/shaders/rings_geom_vs.glsl new file mode 100644 index 0000000000..63f7eda7a8 --- /dev/null +++ b/modules/globebrowsing/shaders/rings_geom_vs.glsl @@ -0,0 +1,47 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2020 * + * * + * 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/powerScalingMath.hglsl" + +layout(location = 0) in vec2 in_position; +layout(location = 1) in vec2 in_st; + +out vec2 vs_st; +out float vs_screenSpaceDepth; + +uniform dmat4 modelViewProjectionMatrix; + +void main() { + vs_st = in_st; + + dvec4 positionClipSpace = modelViewProjectionMatrix * + dvec4(in_position, 0.0, 1.0); + vec4 positionClipSpaceZNorm = z_normalization(vec4(positionClipSpace)); + + vs_screenSpaceDepth = positionClipSpaceZNorm.w; + + gl_Position = positionClipSpaceZNorm; +} diff --git a/tests/test_powerscalecoordinates.inl b/modules/globebrowsing/shaders/rings_vs.glsl similarity index 68% rename from tests/test_powerscalecoordinates.inl rename to modules/globebrowsing/shaders/rings_vs.glsl index 23b22a70a9..64b7b474dd 100644 --- a/tests/test_powerscalecoordinates.inl +++ b/modules/globebrowsing/shaders/rings_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -22,42 +22,32 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#version __CONTEXT__ -#include +#include "PowerScaling/powerScaling_vs.hglsl" -class PowerscaleCoordinatesTest : public testing::Test { -protected: - PowerscaleCoordinatesTest() { - } +layout(location = 0) in vec2 in_position; +layout(location = 1) in vec2 in_st; - ~PowerscaleCoordinatesTest() { - } +out vec2 vs_st; +out float vs_screenSpaceDepth; +out vec4 vs_positionViewSpace; +out vec4 shadowCoords; - void reset() { - } +uniform dmat4 modelViewProjectionMatrix; - openspace::Scene* scenegraph; -}; +// ShadowMatrix is the matrix defined by: +// textureCoordsMatrix * projectionMatrix * combinedViewMatrix * modelMatrix +// where textureCoordsMatrix is just a scale and bias computation: [-1,1] to [0,1] +uniform dmat4 shadowMatrix; +void main() { + vs_st = in_st; -TEST_F(PowerscaleCoordinatesTest, psc) { - - openspace::psc reference(2.f, 1.f, 1.1f, 1.f); - - openspace::psc first(1.f, 0.f, 1.f, 0.f); - openspace::psc second(1.9f, 1.f, 1.f, 1.f); - - EXPECT_EQ(reference, first + second); - EXPECT_TRUE(reference == (first + second)); - - openspace::psc third = first; - first[0] = 0.0; - - EXPECT_TRUE(third != first); - + dvec4 positionClipSpace = modelViewProjectionMatrix * dvec4(in_position, 0.0, 1.0); + vec4 positionClipSpaceZNorm = z_normalization(vec4(positionClipSpace)); + shadowCoords = vec4(shadowMatrix * dvec4(in_position, 0.0, 1.0)); + vs_screenSpaceDepth = positionClipSpaceZNorm.w; + gl_Position = positionClipSpaceZNorm; } - - - diff --git a/modules/globebrowsing/shaders/smviewer_fs.glsl b/modules/globebrowsing/shaders/smviewer_fs.glsl new file mode 100644 index 0000000000..62719a89a5 --- /dev/null +++ b/modules/globebrowsing/shaders/smviewer_fs.glsl @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2020 * + * * + * 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 "PowerScaling/powerScaling_fs.hglsl" +#include "fragment.glsl" + +precision highp float; + +in vec2 texCoord; + +uniform highp sampler2D shadowMapTexture; + +Fragment getFragment() { + Fragment frag; + frag.color = vec4(vec3(1.f) - texture(shadowMapTexture, texCoord).rrr, 1.f); + frag.depth = 0.f; + + return frag; +} diff --git a/apps/TimelineView/informationwidget.cpp b/modules/globebrowsing/shaders/smviewer_vs.glsl similarity index 78% rename from apps/TimelineView/informationwidget.cpp rename to modules/globebrowsing/shaders/smviewer_vs.glsl index f866ad1b28..c5bb033b36 100644 --- a/apps/TimelineView/informationwidget.cpp +++ b/modules/globebrowsing/shaders/smviewer_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -22,29 +22,30 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include "informationwidget.h" +#version __CONTEXT__ -#include -#include +out vec2 texCoord; -InformationWidget::InformationWidget(QWidget* parent) - : QTextEdit(parent) -{ - setReadOnly(true); -} - -void InformationWidget::socketConnected() { - setDisabled(false); -} - -void InformationWidget::socketDisconnected() { - setDisabled(true); -} - -void InformationWidget::logInformation(QString text) { - QString currentText = toPlainText(); - - currentText += text + "\n"; - - setPlainText(currentText); +const vec3 posData[6] = vec3[] ( + vec3(1.0, -0.5, 0.0), + vec3(0.5, -0.5, 0.0), + vec3(0.5, -1.0, 0.0), + vec3(1.0, -1.0, 0.0), + vec3(1.0, -0.5, 0.0), + vec3(0.5, -1.0, 0.0) +); + +const vec2 texData[6] = vec2[] ( + vec2(1.0, 1.0), + vec2(0.0, 1.0), + vec2(0.0, 0.0), + vec2(1.0, 0.0), + vec2(1.0, 1.0), + vec2(0.0, 0.0) + +); + +void main() { + texCoord = texData[gl_VertexID]; + gl_Position = vec4(posData[gl_VertexID], 1.0); } diff --git a/modules/globebrowsing/shaders/texturetilemapping.hglsl b/modules/globebrowsing/shaders/texturetilemapping.hglsl index 24820242c7..ff4b09eb42 100644 --- a/modules/globebrowsing/shaders/texturetilemapping.hglsl +++ b/modules/globebrowsing/shaders/texturetilemapping.hglsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -64,6 +64,7 @@ #define SHOW_CHUNK_EDGES #{showChunkEdges} #define SHOW_HEIGHT_RESOLUTION #{showHeightResolution} #define SHOW_HEIGHT_INTENSITIES #{showHeightIntensities} +#define SHADOW_MAPPING_ENABLED #{enableShadowMapping} const vec3 DefaultLevelWeights = vec3(1.0, 0.0, 0.0); diff --git a/modules/globebrowsing/shaders/tile.hglsl b/modules/globebrowsing/shaders/tile.hglsl index ceb779fe46..25db3772e8 100644 --- a/modules/globebrowsing/shaders/tile.hglsl +++ b/modules/globebrowsing/shaders/tile.hglsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/shaders/tileheight.hglsl b/modules/globebrowsing/shaders/tileheight.hglsl index 1d7c275997..ef08825538 100644 --- a/modules/globebrowsing/shaders/tileheight.hglsl +++ b/modules/globebrowsing/shaders/tileheight.hglsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/shaders/tilevertexskirt.hglsl b/modules/globebrowsing/shaders/tilevertexskirt.hglsl index a2ae1f5163..3545797091 100644 --- a/modules/globebrowsing/shaders/tilevertexskirt.hglsl +++ b/modules/globebrowsing/shaders/tilevertexskirt.hglsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/asynctiledataprovider.cpp b/modules/globebrowsing/src/asynctiledataprovider.cpp index 86ff2ab39f..45e4fbe84b 100644 --- a/modules/globebrowsing/src/asynctiledataprovider.cpp +++ b/modules/globebrowsing/src/asynctiledataprovider.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/asynctiledataprovider.h b/modules/globebrowsing/src/asynctiledataprovider.h index 1d6fe46e80..00d8230749 100644 --- a/modules/globebrowsing/src/asynctiledataprovider.h +++ b/modules/globebrowsing/src/asynctiledataprovider.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/basictypes.h b/modules/globebrowsing/src/basictypes.h index e4fce70c48..e26d439bf8 100644 --- a/modules/globebrowsing/src/basictypes.h +++ b/modules/globebrowsing/src/basictypes.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -147,8 +147,8 @@ public: struct TileUvTransform { - glm::vec2 uvOffset; - glm::vec2 uvScale; + glm::vec2 uvOffset = glm::vec2(0.f); + glm::vec2 uvScale = glm::vec2(0.f); }; diff --git a/modules/globebrowsing/src/dashboarditemglobelocation.cpp b/modules/globebrowsing/src/dashboarditemglobelocation.cpp index 3b6dcbf462..6fee2ccdc5 100644 --- a/modules/globebrowsing/src/dashboarditemglobelocation.cpp +++ b/modules/globebrowsing/src/dashboarditemglobelocation.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/dashboarditemglobelocation.h b/modules/globebrowsing/src/dashboarditemglobelocation.h index a4528a81d3..12c6f6fc84 100644 --- a/modules/globebrowsing/src/dashboarditemglobelocation.h +++ b/modules/globebrowsing/src/dashboarditemglobelocation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/ellipsoid.cpp b/modules/globebrowsing/src/ellipsoid.cpp index 7cb68b4c05..8045bfb63a 100644 --- a/modules/globebrowsing/src/ellipsoid.cpp +++ b/modules/globebrowsing/src/ellipsoid.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -62,7 +62,7 @@ glm::dvec3 Ellipsoid::geodeticSurfaceProjection(const glm::dvec3& p) const { double alpha = (1.0 - beta) * (glm::length(p) / n); const glm::dvec3 p2 = p * p; - glm::dvec3 d; + glm::dvec3 d = glm::dvec3(0.0); double s = 0.0; double dSdA = 1.0; diff --git a/modules/globebrowsing/src/ellipsoid.h b/modules/globebrowsing/src/ellipsoid.h index 20eb0b29ae..44376ceda0 100644 --- a/modules/globebrowsing/src/ellipsoid.h +++ b/modules/globebrowsing/src/ellipsoid.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -54,7 +54,7 @@ public: /** * \param radii defines three radii for the Ellipsoid */ - Ellipsoid(glm::dvec3 radii = glm::dvec3(1.0, 1.0, 1.0)); + Ellipsoid(glm::dvec3 radii = glm::dvec3(1.0)); /** * Scales a point along the geocentric normal and places it on the surface of the @@ -95,16 +95,16 @@ public: private: struct EllipsoidCache { - glm::dvec3 radiiSquared; - glm::dvec3 oneOverRadiiSquared; - glm::dvec3 radiiToTheFourth; - double minimumRadius; - double maximumRadius; + glm::dvec3 radiiSquared = glm::dvec3(0.0); + glm::dvec3 oneOverRadiiSquared = glm::dvec3(0.0); + glm::dvec3 radiiToTheFourth = glm::dvec3(0.0); + double minimumRadius = 0.0; + double maximumRadius = 0.0; } _cached; void updateInternalCache(); - glm::dvec3 _radii; + glm::dvec3 _radii = glm::dvec3(0.0); // Eclipse shadows conf std::vector _shadowConfArray; diff --git a/modules/globebrowsing/src/gdalwrapper.cpp b/modules/globebrowsing/src/gdalwrapper.cpp index b70fb514e9..976fa193e8 100644 --- a/modules/globebrowsing/src/gdalwrapper.cpp +++ b/modules/globebrowsing/src/gdalwrapper.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -75,7 +75,6 @@ void GdalWrapper::create(size_t maximumCacheSize, size_t maximumMaximumCacheSize } void GdalWrapper::destroy() { - ghoul_assert(_singleton, "Cannot delete null"); delete _singleton; } diff --git a/modules/globebrowsing/src/gdalwrapper.h b/modules/globebrowsing/src/gdalwrapper.h index 24ffd4431c..afbbe2d211 100644 --- a/modules/globebrowsing/src/gdalwrapper.h +++ b/modules/globebrowsing/src/gdalwrapper.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/geodeticpatch.cpp b/modules/globebrowsing/src/geodeticpatch.cpp index 5caf972989..5dc5725426 100644 --- a/modules/globebrowsing/src/geodeticpatch.cpp +++ b/modules/globebrowsing/src/geodeticpatch.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/geodeticpatch.h b/modules/globebrowsing/src/geodeticpatch.h index c4c9f1f257..7ade7987ac 100644 --- a/modules/globebrowsing/src/geodeticpatch.h +++ b/modules/globebrowsing/src/geodeticpatch.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/globelabelscomponent.cpp b/modules/globebrowsing/src/globelabelscomponent.cpp index 9cea901ce7..2e678a03c6 100644 --- a/modules/globebrowsing/src/globelabelscomponent.cpp +++ b/modules/globebrowsing/src/globelabelscomponent.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/globelabelscomponent.h b/modules/globebrowsing/src/globelabelscomponent.h index ed6727edcd..98371f39e6 100644 --- a/modules/globebrowsing/src/globelabelscomponent.h +++ b/modules/globebrowsing/src/globelabelscomponent.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -72,10 +72,10 @@ private: // Labels Structures struct LabelEntry { char feature[256]; - float diameter; - float latitude; - float longitude; - glm::vec3 geoPosition; + float diameter = 0.f; + float latitude = 0.f; + float longitude = 0.f; + glm::vec3 geoPosition = glm::vec3(0.f); }; struct Labels { diff --git a/modules/globebrowsing/src/globetranslation.cpp b/modules/globebrowsing/src/globetranslation.cpp index 560994bed4..708f3ed0b1 100644 --- a/modules/globebrowsing/src/globetranslation.cpp +++ b/modules/globebrowsing/src/globetranslation.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/globetranslation.h b/modules/globebrowsing/src/globetranslation.h index 91c0bdf61b..9d5c130537 100644 --- a/modules/globebrowsing/src/globetranslation.h +++ b/modules/globebrowsing/src/globetranslation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -55,7 +55,7 @@ private: RenderableGlobe* _attachedNode = nullptr; mutable bool _positionIsDirty = true; - mutable glm::dvec3 _position; + mutable glm::dvec3 _position = glm::dvec3(0.0); }; } // namespace openspace::globebrowsing diff --git a/modules/globebrowsing/src/gpulayergroup.cpp b/modules/globebrowsing/src/gpulayergroup.cpp index ab581bbd70..5f7797bf1e 100644 --- a/modules/globebrowsing/src/gpulayergroup.cpp +++ b/modules/globebrowsing/src/gpulayergroup.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/gpulayergroup.h b/modules/globebrowsing/src/gpulayergroup.h index 471a9080e8..796cbb46fb 100644 --- a/modules/globebrowsing/src/gpulayergroup.h +++ b/modules/globebrowsing/src/gpulayergroup.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/layer.cpp b/modules/globebrowsing/src/layer.cpp index b176825333..2345258483 100644 --- a/modules/globebrowsing/src/layer.cpp +++ b/modules/globebrowsing/src/layer.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -31,6 +31,7 @@ #include #include #include +#include namespace openspace::globebrowsing { @@ -308,14 +309,9 @@ Layer::Layer(layergroupid::GroupID id, const ghoul::Dictionary& layerDict, }); _remove.onChange([&]() { - try { - if (_tileProvider) { - tileprovider::reset(*_tileProvider); - } - } - catch (...) { + if (_tileProvider) { + tileprovider::reset(*_tileProvider); _parent.deleteLayer(identifier()); - throw; } }); @@ -454,6 +450,8 @@ void Layer::onChange(std::function callback) { } int Layer::update() { + ZoneScoped + if (_tileProvider) { return tileprovider::update(*_tileProvider); } diff --git a/modules/globebrowsing/src/layer.h b/modules/globebrowsing/src/layer.h index fb8f30dfd4..1b7b50dd39 100644 --- a/modules/globebrowsing/src/layer.h +++ b/modules/globebrowsing/src/layer.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -94,8 +94,8 @@ private: LayerRenderSettings _renderSettings; LayerAdjustment _layerAdjustment; - glm::ivec2 _padTilePixelStartOffset; - glm::ivec2 _padTilePixelSizeDifference; + glm::ivec2 _padTilePixelStartOffset = glm::ivec2(0); + glm::ivec2 _padTilePixelSizeDifference = glm::ivec2(0); const layergroupid::GroupID _layerGroupId; diff --git a/modules/globebrowsing/src/layeradjustment.cpp b/modules/globebrowsing/src/layeradjustment.cpp index 3317133bb0..2497b4ac2c 100644 --- a/modules/globebrowsing/src/layeradjustment.cpp +++ b/modules/globebrowsing/src/layeradjustment.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/layeradjustment.h b/modules/globebrowsing/src/layeradjustment.h index 07c7c9460c..5993366d77 100644 --- a/modules/globebrowsing/src/layeradjustment.h +++ b/modules/globebrowsing/src/layeradjustment.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/layergroup.cpp b/modules/globebrowsing/src/layergroup.cpp index 909eb3dae4..260594489f 100644 --- a/modules/globebrowsing/src/layergroup.cpp +++ b/modules/globebrowsing/src/layergroup.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -27,6 +27,7 @@ #include #include #include +#include namespace { constexpr const char* _loggerCat = "LayerGroup"; @@ -81,18 +82,24 @@ void LayerGroup::setLayersFromDict(const ghoul::Dictionary& dict) { } void LayerGroup::initialize() { + ZoneScoped + for (const std::unique_ptr& l : _layers) { l->initialize(); } } void LayerGroup::deinitialize() { + ZoneScoped + for (const std::unique_ptr& l : _layers) { l->deinitialize(); } } int LayerGroup::update() { + ZoneScoped + int res = 0; _activeLayers.clear(); diff --git a/modules/globebrowsing/src/layergroup.h b/modules/globebrowsing/src/layergroup.h index f02fd0d80a..3f69e4705e 100644 --- a/modules/globebrowsing/src/layergroup.h +++ b/modules/globebrowsing/src/layergroup.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/layergroupid.cpp b/modules/globebrowsing/src/layergroupid.cpp index 69f8163939..bf1ff8f0fc 100644 --- a/modules/globebrowsing/src/layergroupid.cpp +++ b/modules/globebrowsing/src/layergroupid.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/layergroupid.h b/modules/globebrowsing/src/layergroupid.h index ea363420a4..16c0c92c11 100644 --- a/modules/globebrowsing/src/layergroupid.h +++ b/modules/globebrowsing/src/layergroupid.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/layermanager.cpp b/modules/globebrowsing/src/layermanager.cpp index 18b91da259..76178af1ea 100644 --- a/modules/globebrowsing/src/layermanager.cpp +++ b/modules/globebrowsing/src/layermanager.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -31,6 +31,7 @@ #include #include #include +#include namespace openspace::globebrowsing { @@ -53,6 +54,8 @@ documentation::Documentation LayerManager::Documentation() { LayerManager::LayerManager() : properties::PropertyOwner({ "Layers" }) {} void LayerManager::initialize(const ghoul::Dictionary& layerGroupsDict) { + ZoneScoped + // First create empty layer groups in case not all are specified for (size_t i = 0; i < _layerGroups.size(); ++i) { _layerGroups[i] = std::make_unique(layergroupid::GroupID(i)); @@ -91,6 +94,8 @@ void LayerManager::deinitialize() { Layer* LayerManager::addLayer(layergroupid::GroupID groupId, const ghoul::Dictionary& layerDict) { + ZoneScoped + ghoul_assert(groupId != layergroupid::Unknown, "Layer group ID must be known"); try { return _layerGroups[groupId]->addLayer(layerDict); @@ -102,6 +107,8 @@ Layer* LayerManager::addLayer(layergroupid::GroupID groupId, } void LayerManager::deleteLayer(layergroupid::GroupID id, const std::string& layerName) { + ZoneScoped + ghoul_assert(id != layergroupid::Unknown, "Layer group ID must be known"); _layerGroups[id]->deleteLayer(layerName); } @@ -115,6 +122,8 @@ const LayerGroup& LayerManager::layerGroup(layergroupid::GroupID groupId) const } bool LayerManager::hasAnyBlendingLayersEnabled() const { + ZoneScoped + return std::any_of( _layerGroups.begin(), _layerGroups.end(), @@ -124,8 +133,9 @@ bool LayerManager::hasAnyBlendingLayersEnabled() const { ); } -std::array LayerManager::layerGroups() const -{ +std::array LayerManager::layerGroups() const { + ZoneScoped + std::array res = {}; for (int i = 0; i < NumLayerGroups; ++i) { res[i] = _layerGroups[i].get(); @@ -134,6 +144,8 @@ std::array LayerManager::layerGroups( } int LayerManager::update() { + ZoneScoped + int res = 0; for (std::unique_ptr& layerGroup : _layerGroups) { res += layerGroup->update(); @@ -142,6 +154,8 @@ int LayerManager::update() { } void LayerManager::reset(bool includeDisabled) { + ZoneScoped + for (std::unique_ptr& layerGroup : _layerGroups) { for (Layer* layer : layerGroup->layers()) { if (layer->enabled() || includeDisabled) { @@ -152,6 +166,8 @@ void LayerManager::reset(bool includeDisabled) { } void LayerManager::onChange(std::function callback) { + ZoneScoped + for (std::unique_ptr& layerGroup : _layerGroups) { layerGroup->onChange(callback); } diff --git a/modules/globebrowsing/src/layermanager.h b/modules/globebrowsing/src/layermanager.h index 3052f8f4ee..1d9889069e 100644 --- a/modules/globebrowsing/src/layermanager.h +++ b/modules/globebrowsing/src/layermanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/layerrendersettings.cpp b/modules/globebrowsing/src/layerrendersettings.cpp index b876a52c4a..79c27dcbd4 100644 --- a/modules/globebrowsing/src/layerrendersettings.cpp +++ b/modules/globebrowsing/src/layerrendersettings.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/layerrendersettings.h b/modules/globebrowsing/src/layerrendersettings.h index 99c688683a..5577fa965f 100644 --- a/modules/globebrowsing/src/layerrendersettings.h +++ b/modules/globebrowsing/src/layerrendersettings.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/lrucache.h b/modules/globebrowsing/src/lrucache.h index 382534e418..7753737248 100644 --- a/modules/globebrowsing/src/lrucache.h +++ b/modules/globebrowsing/src/lrucache.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/lrucache.inl b/modules/globebrowsing/src/lrucache.inl index 188cd7d0d5..2e67893a80 100644 --- a/modules/globebrowsing/src/lrucache.inl +++ b/modules/globebrowsing/src/lrucache.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -69,7 +69,8 @@ bool LRUCache::touch(const KeyType& key) { _itemMap.emplace(key, _itemList.begin()); return true; - } else { + } + else { return false; } } diff --git a/modules/globebrowsing/src/lruthreadpool.h b/modules/globebrowsing/src/lruthreadpool.h index e2ee9da954..943781bdea 100644 --- a/modules/globebrowsing/src/lruthreadpool.h +++ b/modules/globebrowsing/src/lruthreadpool.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/lruthreadpool.inl b/modules/globebrowsing/src/lruthreadpool.inl index 1690ddb88a..8522ce9cb2 100644 --- a/modules/globebrowsing/src/lruthreadpool.inl +++ b/modules/globebrowsing/src/lruthreadpool.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/memoryawaretilecache.cpp b/modules/globebrowsing/src/memoryawaretilecache.cpp index dffc14c047..efc0175e56 100644 --- a/modules/globebrowsing/src/memoryawaretilecache.cpp +++ b/modules/globebrowsing/src/memoryawaretilecache.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/memoryawaretilecache.h b/modules/globebrowsing/src/memoryawaretilecache.h index 872d016e96..209e0e9aa5 100644 --- a/modules/globebrowsing/src/memoryawaretilecache.h +++ b/modules/globebrowsing/src/memoryawaretilecache.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/prioritizingconcurrentjobmanager.h b/modules/globebrowsing/src/prioritizingconcurrentjobmanager.h index fc8fb5fd56..ec90b4139c 100644 --- a/modules/globebrowsing/src/prioritizingconcurrentjobmanager.h +++ b/modules/globebrowsing/src/prioritizingconcurrentjobmanager.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/prioritizingconcurrentjobmanager.inl b/modules/globebrowsing/src/prioritizingconcurrentjobmanager.inl index 9fcc65ba3d..3c7668823b 100644 --- a/modules/globebrowsing/src/prioritizingconcurrentjobmanager.inl +++ b/modules/globebrowsing/src/prioritizingconcurrentjobmanager.inl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/rawtile.cpp b/modules/globebrowsing/src/rawtile.cpp index 9ac964de28..9e626a2d61 100644 --- a/modules/globebrowsing/src/rawtile.cpp +++ b/modules/globebrowsing/src/rawtile.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/rawtile.h b/modules/globebrowsing/src/rawtile.h index 2e2142d721..d992466ff6 100644 --- a/modules/globebrowsing/src/rawtile.h +++ b/modules/globebrowsing/src/rawtile.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/rawtiledatareader.cpp b/modules/globebrowsing/src/rawtiledatareader.cpp index 4c477da259..6cc980e36d 100644 --- a/modules/globebrowsing/src/rawtiledatareader.cpp +++ b/modules/globebrowsing/src/rawtiledatareader.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/rawtiledatareader.h b/modules/globebrowsing/src/rawtiledatareader.h index 12a51a3fc3..94f437199c 100644 --- a/modules/globebrowsing/src/rawtiledatareader.h +++ b/modules/globebrowsing/src/rawtiledatareader.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index 2a9dabcea7..d205fc4a5a 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -64,13 +65,13 @@ namespace { // Shadow structure struct ShadowRenderingStruct { - double xu; - double xp; - double rs; - double rc; - glm::dvec3 sourceCasterVec; - glm::dvec3 casterPositionVec; - bool isShadowing; + double xu = 0.0; + double xp = 0.0; + double rs = 0.0; + double rc = 0.0; + glm::dvec3 sourceCasterVec = glm::dvec3(0.0); + glm::dvec3 casterPositionVec = glm::dvec3(0.0); + bool isShadowing = false; }; constexpr const char* KeyRadii = "Radii"; @@ -184,6 +185,26 @@ namespace { "Enables the rendering of eclipse shadows using hard shadows" }; + constexpr openspace::properties::Property::PropertyInfo ShadowMappingInfo = { + "ShadowMapping", + "Shadow Mapping", + "Enables shadow mapping algorithm. Used by renderable rings too." + }; + + constexpr openspace::properties::Property::PropertyInfo ZFightingPercentageInfo = { + "ZFightingPercentage", + "Z-Fighting Percentage", + "The percentage of the correct distance to the surface being shadowed. " + "Possible values: [0.0, 1.0]" + }; + + constexpr openspace::properties::Property::PropertyInfo NumberShadowSamplesInfo = { + "NumberShadowSamples", + "Number of Shadow Samples", + "The number of samples used during shadow mapping calculation " + "(Percentage Closer Filtering)." + }; + constexpr openspace::properties::Property::PropertyInfo TargetLodScaleFactorInfo = { "TargetLodScaleFactor", "Target Level of Detail Scale Factor", @@ -283,7 +304,7 @@ BoundingHeights boundingHeightsForChunk(const Chunk& chunk, const LayerManager& const bool hasTileMetaData = chunkTile.tile.metaData.has_value(); if (goodTile && hasTileMetaData) { - const TileMetaData& tileMetaData = chunkTile.tile.metaData.value(); + const TileMetaData& tileMetaData = *chunkTile.tile.metaData; const float minValue = settings->performLayerSettings( tileMetaData.minValues[HeightChannel] @@ -309,7 +330,7 @@ BoundingHeights boundingHeightsForChunk(const Chunk& chunk, const LayerManager& } lastHadMissingData = tileMetaData.hasMissingData[HeightChannel]; } - else if(chunkTile.tile.status == Tile::Status::Unavailable) { + else if (chunkTile.tile.status == Tile::Status::Unavailable) { boundingHeights.tileOK = false; } @@ -495,16 +516,22 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) BoolProperty(AccurateNormalsInfo, false), BoolProperty(EclipseInfo, false), BoolProperty(EclipseHardShadowsInfo, false), + BoolProperty(ShadowMappingInfo, false), + FloatProperty(ZFightingPercentageInfo, 0.995f, 0.000001f, 1.f), + IntProperty(NumberShadowSamplesInfo, 5, 1, 7), FloatProperty(TargetLodScaleFactorInfo, 15.f, 1.f, 50.f), FloatProperty(CurrentLodScaleFactorInfo, 15.f, 1.f, 50.f), FloatProperty(CameraMinHeightInfo, 100.f, 0.f, 1000.f), FloatProperty(OrenNayarRoughnessInfo, 0.f, 0.f, 1.f), IntProperty(NActiveLayersInfo, 0, 0, OpenGLCap.maxTextureUnits() / 3) }) + , _shadowMappingPropertyOwner({ "ShadowMapping" }) , _debugPropertyOwner({ "Debug" }) , _grid(DefaultSkirtedGridSegments, DefaultSkirtedGridSegments) , _leftRoot(Chunk(LeftHemisphereIndex)) , _rightRoot(Chunk(RightHemisphereIndex)) + , _ringsComponent(dictionary) + , _shadowComponent(dictionary) { _generalProperties.currentLodScaleFactor.setReadOnly(true); @@ -535,6 +562,15 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) addProperty(_generalProperties.useAccurateNormals); addProperty(_generalProperties.eclipseShadowsEnabled); addProperty(_generalProperties.eclipseHardShadows); + + _shadowMappingPropertyOwner.addProperty(_generalProperties.shadowMapping); + _shadowMappingPropertyOwner.addProperty(_generalProperties.zFightingPercentage); + _shadowMappingPropertyOwner.addProperty(_generalProperties.nShadowSamples); + _generalProperties.nShadowSamples.onChange([&]() { + _shadersNeedRecompilation = true; + }); + addPropertySubOwner(_shadowMappingPropertyOwner); + _generalProperties.targetLodScaleFactor.onChange([this]() { float sf = _generalProperties.targetLodScaleFactor; _generalProperties.currentLodScaleFactor = sf; @@ -656,6 +692,24 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) _labelsDictionary = dictionary.value(KeyLabels); } + // Components + if (dictionary.hasKey("Rings")) { + _ringsComponent.initialize(); + addPropertySubOwner(_ringsComponent); + _hasRings = true; + + ghoul::Dictionary ringsDic; + dictionary.getValue("Rings", ringsDic); + } + + if (dictionary.hasKey("Shadows")) { + _shadowComponent.initialize(); + addPropertySubOwner(_shadowComponent); + _hasShadows = true; + _generalProperties.shadowMapping = true; + } + _generalProperties.shadowMapping.onChange(notifyShaderRecompilation); + #ifdef OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION _module = global::moduleEngine.module(); #endif // OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION @@ -670,6 +724,15 @@ void RenderableGlobe::initializeGL() { _layerManager.update(); _grid.initializeGL(); + + if (_hasRings) { + _ringsComponent.initializeGL(); + } + + if (_hasShadows) { + _shadowComponent.initializeGL(); + } + // Recompile the shaders directly so that it is not done the first time the render // function is called. recompileShaders(); @@ -691,6 +754,14 @@ void RenderableGlobe::deinitializeGL() { } _grid.deinitializeGL(); + + if (_hasRings) { + _ringsComponent.deinitializeGL(); + } + + if (_hasShadows) { + _shadowComponent.deinitializeGL(); + } } bool RenderableGlobe::isReady() const { @@ -713,8 +784,44 @@ void RenderableGlobe::render(const RenderData& data, RendererTasks& rendererTask if (distanceToCamera < distance) { try { - renderChunks(data, rendererTask); - _globeLabelsComponent.draw(data); + // Before Shadows + //renderChunks(data, rendererTask); + //_globeLabelsComponent.draw(data); + + if (_hasShadows && _shadowComponent.isEnabled()) { + // Set matrices and other GL states + RenderData lightRenderData(_shadowComponent.begin(data)); + + glDisable(GL_BLEND); + + // Render from light source point of view + renderChunks(lightRenderData, rendererTask, {}, true); + if (_hasRings && _ringsComponent.isEnabled()) { + _ringsComponent.draw(lightRenderData, RingsComponent::GeometryOnly); + } + + glEnable(GL_BLEND); + + _shadowComponent.setViewDepthMap(false); + + _shadowComponent.end(); + + // Render again from original point of view + renderChunks(data, rendererTask, _shadowComponent.shadowMapData()); + if (_hasRings && _ringsComponent.isEnabled()) { + _ringsComponent.draw( + data, + RingsComponent::GeometryAndShading, + _shadowComponent.shadowMapData() + ); + } + } + else { + renderChunks(data, rendererTask); + if (_hasRings && _ringsComponent.isEnabled()) { + _ringsComponent.draw(data, RingsComponent::GeometryAndShading); + } + } } catch (const ghoul::opengl::TextureUnit::TextureUnitError&) { std::string layer = _lastChangedLayer ? _lastChangedLayer->guiName() : ""; @@ -807,6 +914,15 @@ void RenderableGlobe::update(const UpdateData& data) { _layerManager.reset(); _debugProperties.resetTileProviders = false; } + + if (_hasRings) { + _ringsComponent.update(data); + } + + if (_hasShadows) { + _shadowComponent.update(data); + } + #ifdef OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION _nUploadedTiles = _layerManager.update(); #else @@ -852,7 +968,12 @@ const glm::dmat4& RenderableGlobe::modelTransform() const { // Rendering code ////////////////////////////////////////////////////////////////////////////////////////// -void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&) { +void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, + const ShadowComponent::ShadowMapData& shadowData, + bool renderGeomOnly) +{ + ZoneScoped + if (_shadersNeedRecompilation) { recompileShaders(); } @@ -987,10 +1108,9 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&) { const bool hasWaterLayer = !_layerManager.layerGroup( layergroupid::GroupID::WaterMasks ).activeLayers().empty(); - if (hasNightLayers || hasWaterLayer || _generalProperties.performShading) { - _globalRenderer.program->setUniform("modelViewTransform", modelViewTransform); - } - + + _globalRenderer.program->setUniform("modelViewTransform", modelViewTransform); + const bool hasHeightLayer = !_layerManager.layerGroup( layergroupid::HeightLayers ).activeLayers().empty(); @@ -1051,6 +1171,8 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&) { auto traversal = [&global, &globalCount, &local, &localCount, cutoff = _debugProperties.modelSpaceRenderingCutoffLevel](const Chunk& node) { + ZoneScopedN("traversal") + std::vector Q; Q.reserve(256); @@ -1086,7 +1208,7 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&) { // Render all chunks that want to be rendered globally _globalRenderer.program->activate(); for (int i = 0; i < std::min(globalCount, ChunkBufferSize); ++i) { - renderChunkGlobally(*global[i], data); + renderChunkGlobally(*global[i], data, shadowData, renderGeomOnly); } _globalRenderer.program->deactivate(); @@ -1094,7 +1216,7 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&) { // Render all chunks that need to be rendered locally _localRenderer.program->activate(); for (int i = 0; i < std::min(localCount, ChunkBufferSize); ++i) { - renderChunkLocally(*local[i], data); + renderChunkLocally(*local[i], data, shadowData, renderGeomOnly); } _localRenderer.program->deactivate(); @@ -1151,7 +1273,13 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&) { } } -void RenderableGlobe::renderChunkGlobally(const Chunk& chunk, const RenderData& data) { +void RenderableGlobe::renderChunkGlobally(const Chunk& chunk, const RenderData& data, + const ShadowComponent::ShadowMapData& shadowData, + bool renderGeomOnly) +{ + ZoneScoped + TracyGpuZone("renderChunkGlobally") + //PerfMeasure("globally"); const TileIndex& tileIndex = chunk.tileIndex; ghoul::opengl::ProgramObject& program = *_globalRenderer.program; @@ -1198,17 +1326,45 @@ void RenderableGlobe::renderChunkGlobally(const Chunk& chunk, const RenderData& calculateEclipseShadows(program, data, ShadowCompType::GLOBAL_SHADOW); } + // Shadow Mapping + ghoul::opengl::TextureUnit shadowMapUnit; + if (_generalProperties.shadowMapping && shadowData.shadowDepthTexture != 0) { + // Adding the model transformation to the final shadow matrix so we have a + // complete transformation from the model coordinates to the clip space of + // the light position. + program.setUniform( + "shadowMatrix", + shadowData.shadowMatrix * modelTransform() + ); + + shadowMapUnit.activate(); + glBindTexture(GL_TEXTURE_2D, shadowData.shadowDepthTexture); + + program.setUniform("shadowMapTexture", shadowMapUnit); + program.setUniform("zFightingPercentage", _generalProperties.zFightingPercentage); + } + glEnable(GL_DEPTH_TEST); - glEnable(GL_CULL_FACE); - glCullFace(GL_BACK); + + if (!renderGeomOnly) { + glEnable(GL_CULL_FACE); + glCullFace(GL_BACK); + } _grid.drawUsingActiveProgram(); + for (GPULayerGroup& l : _globalRenderer.gpuLayerGroups) { l.deactivate(); } } -void RenderableGlobe::renderChunkLocally(const Chunk& chunk, const RenderData& data) { +void RenderableGlobe::renderChunkLocally(const Chunk& chunk, const RenderData& data, + const ShadowComponent::ShadowMapData& shadowData, + bool renderGeomOnly) +{ + ZoneScoped + TracyGpuZone("renderChunkLocally") + //PerfMeasure("locally"); const TileIndex& tileIndex = chunk.tileIndex; ghoul::opengl::ProgramObject& program = *_localRenderer.program; @@ -1300,10 +1456,30 @@ void RenderableGlobe::renderChunkLocally(const Chunk& chunk, const RenderData& d calculateEclipseShadows(program, data, ShadowCompType::LOCAL_SHADOW); } - glEnable(GL_DEPTH_TEST); - glEnable(GL_CULL_FACE); - glCullFace(GL_BACK); + // Shadow Mapping + ghoul::opengl::TextureUnit shadowMapUnit; + if (_generalProperties.shadowMapping && shadowData.shadowDepthTexture != 0) { + // Adding the model transformation to the final shadow matrix so we have a + // complete transformation from the model coordinates to the clip space of + // the light position. + program.setUniform( + "shadowMatrix", + shadowData.shadowMatrix * modelTransform() + ); + shadowMapUnit.activate(); + glBindTexture(GL_TEXTURE_2D, shadowData.shadowDepthTexture); + + program.setUniform("shadowMapTexture", shadowMapUnit); + program.setUniform("zFightingPercentage", _generalProperties.zFightingPercentage); + } + + glEnable(GL_DEPTH_TEST); + if (!renderGeomOnly) { + glEnable(GL_CULL_FACE); + glCullFace(GL_BACK); + } + _grid.drawUsingActiveProgram(); for (GPULayerGroup& l : _localRenderer.gpuLayerGroups) { @@ -1312,7 +1488,10 @@ void RenderableGlobe::renderChunkLocally(const Chunk& chunk, const RenderData& d } void RenderableGlobe::debugRenderChunk(const Chunk& chunk, const glm::dmat4& mvp, - bool renderBounds, bool renderAABB) const { + bool renderBounds, bool renderAABB) const +{ + ZoneScoped + const std::array& modelSpaceCorners = chunk.corners; std::vector clippingSpaceCorners(8); @@ -1351,8 +1530,10 @@ void RenderableGlobe::debugRenderChunk(const Chunk& chunk, const glm::dmat4& mvp ////////////////////////////////////////////////////////////////////////////////////////// void RenderableGlobe::setCommonUniforms(ghoul::opengl::ProgramObject& programObject, - const Chunk& chunk, const RenderData& data) + const Chunk& chunk, const RenderData& data) { + ZoneScoped + if (_generalProperties.useAccurateNormals && !_layerManager.layerGroup(layergroupid::HeightLayers).activeLayers().empty()) { @@ -1399,6 +1580,8 @@ void RenderableGlobe::setCommonUniforms(ghoul::opengl::ProgramObject& programObj } void RenderableGlobe::recompileShaders() { + ZoneScoped + struct LayerShaderPreprocessingData { struct LayerGroupPreprocessingData { int lastLayerIdx; @@ -1465,6 +1648,10 @@ void RenderableGlobe::recompileShaders() { "useEclipseHardShadows", std::to_string(_generalProperties.eclipseHardShadows) ); + pairs.emplace_back( + "enableShadowMapping", + std::to_string(_generalProperties.shadowMapping) + ); pairs.emplace_back("showChunkEdges", std::to_string(_debugProperties.showChunkEdges)); pairs.emplace_back("showHeightResolution", std::to_string(_debugProperties.showHeightResolution) @@ -1558,6 +1745,9 @@ void RenderableGlobe::recompileShaders() { shaderDictionary.setValue(p.first, p.second); } + // Shadow Mapping Samples + shaderDictionary.setValue("nShadowSamples", _generalProperties.nShadowSamples - 1); + // // Create local shader // @@ -1626,6 +1816,8 @@ void RenderableGlobe::recompileShaders() { SurfacePositionHandle RenderableGlobe::calculateSurfacePositionHandle( const glm::dvec3& targetModelSpace) const { + ZoneScoped + glm::dvec3 centerToEllipsoidSurface = _ellipsoid.geodeticSurfaceProjection(targetModelSpace); glm::dvec3 ellipsoidSurfaceToTarget = targetModelSpace - centerToEllipsoidSurface; @@ -1656,6 +1848,8 @@ bool RenderableGlobe::testIfCullable(const Chunk& chunk, const RenderData& renderData, const BoundingHeights& heights) const { + ZoneScoped + return (PreformHorizonCulling && isCullableByHorizon(chunk, renderData, heights)) || (PerformFrustumCulling && isCullableByFrustum(chunk, renderData)); } @@ -1663,6 +1857,8 @@ bool RenderableGlobe::testIfCullable(const Chunk& chunk, int RenderableGlobe::desiredLevel(const Chunk& chunk, const RenderData& renderData, const BoundingHeights& heights) const { + ZoneScoped + const int desiredLevel = _debugProperties.levelByProjectedAreaElseDistance ? desiredLevelByProjectedArea(chunk, renderData, heights) : desiredLevelByDistance(chunk, renderData, heights); @@ -1678,6 +1874,8 @@ int RenderableGlobe::desiredLevel(const Chunk& chunk, const RenderData& renderDa } float RenderableGlobe::getHeight(const glm::dvec3& position) const { + ZoneScoped + float height = 0; // Get the uv coordinates to sample from @@ -1829,6 +2027,8 @@ float RenderableGlobe::getHeight(const glm::dvec3& position) const { void RenderableGlobe::calculateEclipseShadows(ghoul::opengl::ProgramObject& programObject, const RenderData& data, ShadowCompType stype) { + ZoneScoped + constexpr const double KM_TO_M = 1000.0; ghoul_assert( @@ -1969,6 +2169,8 @@ int RenderableGlobe::desiredLevelByDistance(const Chunk& chunk, const RenderData& data, const BoundingHeights& heights) const { + ZoneScoped + // Calculations are done in the reference frame of the globe // (model space). Hence, the camera position needs to be transformed // with the inverse model matrix @@ -2003,6 +2205,8 @@ int RenderableGlobe::desiredLevelByProjectedArea(const Chunk& chunk, const RenderData& data, const BoundingHeights& heights) const { + ZoneScoped + // Calculations are done in the reference frame of the globe // (model space). Hence, the camera position needs to be transformed // with the inverse model matrix @@ -2083,6 +2287,8 @@ int RenderableGlobe::desiredLevelByProjectedArea(const Chunk& chunk, } int RenderableGlobe::desiredLevelByAvailableTileData(const Chunk& chunk) const { + ZoneScoped + const int currLevel = chunk.tileIndex.level; for (size_t i = 0; i < layergroupid::NUM_LAYER_GROUPS; ++i) { @@ -2106,6 +2312,8 @@ int RenderableGlobe::desiredLevelByAvailableTileData(const Chunk& chunk) const { bool RenderableGlobe::isCullableByFrustum(const Chunk& chunk, const RenderData& renderData) const { + ZoneScoped + // Calculate the MVP matrix const glm::dmat4 viewTransform = glm::dmat4(renderData.camera.combinedViewMatrix()); const glm::dmat4 modelViewProjectionTransform = glm::dmat4( @@ -2131,6 +2339,8 @@ bool RenderableGlobe::isCullableByHorizon(const Chunk& chunk, const RenderData& renderData, const BoundingHeights& heights) const { + ZoneScoped + // Calculations are done in the reference frame of the globe. Hence, the camera // position needs to be transformed with the inverse model matrix const GeodeticPatch& patch = chunk.surfacePatch; @@ -2200,6 +2410,8 @@ bool RenderableGlobe::isCullableByHorizon(const Chunk& chunk, ////////////////////////////////////////////////////////////////////////////////////////// void RenderableGlobe::splitChunkNode(Chunk& cn, int depth) { + ZoneScoped + if (depth > 0 && isLeaf(cn)) { std::vector memory = _chunkPool.allocate( static_cast(cn.children.size()) @@ -2228,6 +2440,8 @@ void RenderableGlobe::splitChunkNode(Chunk& cn, int depth) { } void RenderableGlobe::freeChunkNode(Chunk* n) { + ZoneScoped + _chunkPool.free(n); for (Chunk* c : n->children) { if (c) { @@ -2238,6 +2452,8 @@ void RenderableGlobe::freeChunkNode(Chunk* n) { } void RenderableGlobe::mergeChunkNode(Chunk& cn) { + ZoneScoped + for (Chunk* child : cn.children) { if (child) { mergeChunkNode(*child); @@ -2248,6 +2464,8 @@ void RenderableGlobe::mergeChunkNode(Chunk& cn) { } bool RenderableGlobe::updateChunkTree(Chunk& cn, const RenderData& data) { + ZoneScoped + // abock: I tried turning this into a queue and use iteration, rather than recursion // but that made the code harder to understand as the breadth-first traversal // requires parents to be passed through the pipe twice (first to add the diff --git a/modules/globebrowsing/src/renderableglobe.h b/modules/globebrowsing/src/renderableglobe.h index a15d671704..48f77d3042 100644 --- a/modules/globebrowsing/src/renderableglobe.h +++ b/modules/globebrowsing/src/renderableglobe.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include #include #include @@ -127,24 +129,29 @@ private: properties::BoolProperty showHeightIntensities; properties::BoolProperty levelByProjectedAreaElseDistance; properties::BoolProperty resetTileProviders; - properties::IntProperty modelSpaceRenderingCutoffLevel; - properties::IntProperty dynamicLodIterationCount; + properties::IntProperty modelSpaceRenderingCutoffLevel; + properties::IntProperty dynamicLodIterationCount; } _debugProperties; struct { - properties::BoolProperty performShading; - properties::BoolProperty useAccurateNormals; - properties::BoolProperty eclipseShadowsEnabled; - properties::BoolProperty eclipseHardShadows; + properties::BoolProperty performShading; + properties::BoolProperty useAccurateNormals; + properties::BoolProperty eclipseShadowsEnabled; + properties::BoolProperty eclipseHardShadows; + properties::BoolProperty shadowMapping; + properties::FloatProperty zFightingPercentage; + properties::IntProperty nShadowSamples; properties::FloatProperty targetLodScaleFactor; properties::FloatProperty currentLodScaleFactor; properties::FloatProperty cameraMinHeight; properties::FloatProperty orenNayarRoughness; - properties::IntProperty nActiveLayers; + properties::IntProperty nActiveLayers; } _generalProperties; properties::PropertyOwner _debugPropertyOwner; + properties::PropertyOwner _shadowMappingPropertyOwner; + /** * Test if a specific chunk can safely be culled without affecting the rendered * image. @@ -181,7 +188,9 @@ private: */ float getHeight(const glm::dvec3& position) const; - void renderChunks(const RenderData& data, RendererTasks& rendererTask); + void renderChunks(const RenderData& data, RendererTasks& rendererTask, + const ShadowComponent::ShadowMapData& shadowData = {}, bool renderGeomOnly = false + ); /** * Chunks can be rendered either globally or locally. Global rendering is performed @@ -191,7 +200,9 @@ private: * point precision by doing this which means that the camera too close to a global * tile will lead to jagging. We only render global chunks for lower chunk levels. */ - void renderChunkGlobally(const Chunk& chunk, const RenderData& data); + void renderChunkGlobally(const Chunk& chunk, const RenderData& data, + const ShadowComponent::ShadowMapData& shadowData = {}, bool renderGeomOnly = false + ); /** * Local rendering of chunks are done using linear interpolation in camera space. @@ -204,7 +215,9 @@ private: * levels) the better the approximation becomes. This is why we only render local * chunks for higher chunk levels. */ - void renderChunkLocally(const Chunk& chunk, const RenderData& data); + void renderChunkLocally(const Chunk& chunk, const RenderData& data, + const ShadowComponent::ShadowMapData& shadowData = {}, bool renderGeomOnly = false + ); void debugRenderChunk(const Chunk& chunk, const glm::dmat4& mvp, bool renderBounds, bool renderAABB) const; @@ -240,8 +253,8 @@ private: SkirtedGrid _grid; LayerManager _layerManager; - glm::dmat4 _cachedModelTransform; - glm::dmat4 _cachedInverseModelTransform; + glm::dmat4 _cachedModelTransform = glm::dmat4(1.0); + glm::dmat4 _cachedInverseModelTransform = glm::dmat4(1.0); ghoul::ReusableTypedMemoryPool _chunkPool; @@ -275,6 +288,12 @@ private: size_t _iterationsOfUnavailableData = 0; Layer* _lastChangedLayer = nullptr; + // Components + RingsComponent _ringsComponent; + ShadowComponent _shadowComponent; + bool _hasRings = false; + bool _hasShadows = false; + // Labels GlobeLabelsComponent _globeLabelsComponent; ghoul::Dictionary _labelsDictionary; diff --git a/modules/globebrowsing/src/ringscomponent.cpp b/modules/globebrowsing/src/ringscomponent.cpp new file mode 100644 index 0000000000..688b2306a9 --- /dev/null +++ b/modules/globebrowsing/src/ringscomponent.cpp @@ -0,0 +1,497 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2020 * + * * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + constexpr const char* _loggerCat = "RingsComponent"; + + constexpr const std::array UniformNames = { + "modelViewProjectionMatrix", "textureOffset", "transparency", "_nightFactor", + "sunPosition", "ringTexture", "shadowMatrix", "shadowMapTexture", + "zFightingPercentage" + }; + + constexpr const std::array GeomUniformNames = { + "modelViewProjectionMatrix", "textureOffset", "ringTexture" + }; + + constexpr openspace::properties::Property::PropertyInfo TextureInfo = { + "Texture", + "Texture", + "This value is the path to a texture on disk that contains a one-dimensional " + "texture which is used for these rings." + }; + + constexpr openspace::properties::Property::PropertyInfo SizeInfo = { + "Size", + "Size", + "This value specifies the radius of the rings in meter." + }; + + constexpr openspace::properties::Property::PropertyInfo OffsetInfo = { + "Offset", + "Offset", + "This value is used to limit the width of the rings.Each of the two values is a " + "value between 0 and 1, where 0 is the center of the ring and 1 is the maximum " + "extent at the radius. If this value is, for example {0.5, 1.0}, the ring is " + "only shown between radius/2 and radius. It defaults to {0.0, 1.0}." + }; + + constexpr openspace::properties::Property::PropertyInfo NightFactorInfo = { + "NightFactor", + "Night Factor", + "This value is a multiplicative factor that is applied to the side of the rings " + "that is facing away from the Sun. If this value is equal to '1', no darkening " + "of the night side occurs." + }; + + constexpr openspace::properties::Property::PropertyInfo TransparencyInfo = { + "Transparency", + "Transparency", + "This value determines the transparency of part of the rings depending on the " + "color values. For this value v, the transparency is equal to length(color) / v." + }; + + constexpr openspace::properties::Property::PropertyInfo ZFightingPercentageInfo = { + "ZFightingPercentage", + "Z-Fighting Percentage", + "The percentage of the correct distance to the surface being shadowed. " + "Possible values: [0.0, 1.0]" + }; + + constexpr openspace::properties::Property::PropertyInfo NumberShadowSamplesInfo = { + "NumberShadowSamples", + "Number of Shadow Samples", + "The number of samples used during shadow mapping calculation " + "(Percentage Closer Filtering)." + }; +} // namespace + +namespace openspace { + +documentation::Documentation RingsComponent::Documentation() { + using namespace documentation; + return { + "Rings Component", + "globebrowsing_rings_component", + { + { + TextureInfo.identifier, + new StringVerifier, + Optional::Yes, + TextureInfo.description + }, + { + SizeInfo.identifier, + new DoubleVerifier, + Optional::Yes, + SizeInfo.description + }, + { + OffsetInfo.identifier, + new DoubleVector2Verifier, + Optional::Yes, + OffsetInfo.description + }, + { + NightFactorInfo.identifier, + new DoubleVerifier, + Optional::Yes, + NightFactorInfo.description + }, + { + TransparencyInfo.identifier, + new DoubleVerifier, + Optional::Yes, + TransparencyInfo.description + }, + { + ZFightingPercentageInfo.identifier, + new DoubleVerifier, + Optional::Yes, + ZFightingPercentageInfo.description + }, + { + NumberShadowSamplesInfo.identifier, + new IntVerifier, + Optional::Yes, + NumberShadowSamplesInfo.description + } + } + }; +} + +RingsComponent::RingsComponent(const ghoul::Dictionary& dictionary) + : properties::PropertyOwner({ "Rings" }) + , _texturePath(TextureInfo) + , _size(SizeInfo, 1.f, 0.f, 1e25f) + , _offset(OffsetInfo, glm::vec2(0.f, 1.f), glm::vec2(0.f), glm::vec2(1.f)) + , _nightFactor(NightFactorInfo, 0.33f, 0.f, 1.f) + , _transparency(TransparencyInfo, 0.15f, 0.f, 1.f) + , _enabled({ "Enabled", "Enabled", "Enable/Disable Rings" }, true) + , _zFightingPercentage(ZFightingPercentageInfo, 0.995f, 0.000001f, 1.f) + , _nShadowSamples(NumberShadowSamplesInfo, 2, 1, 7) + , _ringsDictionary(dictionary) +{ + using ghoul::filesystem::File; + + if (dictionary.hasKey("Rings")) { + // @TODO (abock, 2019-12-16) It would be better to not store the dictionary long + // term and rather extract the values directly here. This would require a bit of + // a rewrite in the RenderableGlobe class to not create the RingsComponent in the + // class-initializer list though + dictionary.getValue("Rings", _ringsDictionary); + } + + documentation::testSpecificationAndThrow( + Documentation(), + _ringsDictionary, + "RingsComponent" + ); +} + +void RingsComponent::initialize() { + using ghoul::filesystem::File; + + addProperty(_enabled); + + _size = static_cast(_ringsDictionary.value(SizeInfo.identifier)); + //setBoundingSphere(_size); + _size.onChange([&]() { _planeIsDirty = true; }); + addProperty(_size); + + _texturePath = absPath( + _ringsDictionary.value(TextureInfo.identifier) + ); + _textureFile = std::make_unique(_texturePath); + + if (_ringsDictionary.hasKeyAndValue(OffsetInfo.identifier)) { + _offset = _ringsDictionary.value(OffsetInfo.identifier); + } + addProperty(_offset); + + _texturePath.onChange([&]() { loadTexture(); }); + addProperty(_texturePath); + + _textureFile->setCallback([&](const File&) { _textureIsDirty = true; }); + + if (_ringsDictionary.hasKeyAndValue(NightFactorInfo.identifier)) { + _nightFactor = static_cast( + _ringsDictionary.value(NightFactorInfo.identifier) + ); + } + addProperty(_nightFactor); + + if (_ringsDictionary.hasKeyAndValue(TransparencyInfo.identifier)) { + _transparency = static_cast( + _ringsDictionary.value(TransparencyInfo.identifier) + ); + } + + // Shadow Mapping Quality Controls + if (_ringsDictionary.hasKey(ZFightingPercentageInfo.identifier)) { + _zFightingPercentage = _ringsDictionary.value( + ZFightingPercentageInfo.identifier + ); + } + addProperty(_zFightingPercentage); + + if (_ringsDictionary.hasKey(NumberShadowSamplesInfo.identifier)) { + _nShadowSamples = _ringsDictionary.value(NumberShadowSamplesInfo.identifier); + } + _nShadowSamples.onChange([this]() { compileShadowShader(); }); + addProperty(_nShadowSamples); + + addProperty(_transparency); +} + +bool RingsComponent::isReady() const { + return (_shader || _geometryOnlyShader) && _texture; +} + +void RingsComponent::initializeGL() { + compileShadowShader(); + + _geometryOnlyShader = global::renderEngine.buildRenderProgram( + "RingsGeomOnlyProgram", + absPath("${MODULE_GLOBEBROWSING}/shaders/rings_geom_vs.glsl"), + absPath("${MODULE_GLOBEBROWSING}/shaders/rings_geom_fs.glsl") + ); + + ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations( + *_geometryOnlyShader, + _geomUniformCache, + GeomUniformNames + ); + + glGenVertexArrays(1, &_quad); + glGenBuffers(1, &_vertexPositionBuffer); + + createPlane(); + loadTexture(); +} + +void RingsComponent::deinitializeGL() { + glDeleteVertexArrays(1, &_quad); + _quad = 0; + + glDeleteBuffers(1, &_vertexPositionBuffer); + _vertexPositionBuffer = 0; + + _textureFile = nullptr; + _texture = nullptr; + + global::renderEngine.removeRenderProgram(_shader.get()); + _shader = nullptr; + + global::renderEngine.removeRenderProgram(_geometryOnlyShader.get()); + _geometryOnlyShader = nullptr; +} + +void RingsComponent::draw(const RenderData& data, + const RingsComponent::RenderPass renderPass, + const ShadowComponent::ShadowMapData& shadowData) +{ + if (renderPass == GeometryAndShading) { + _shader->activate(); + } + else if (renderPass == GeometryOnly) { + _geometryOnlyShader->activate(); + } + + const glm::dmat4 modelTransform = + glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * + glm::dmat4(data.modelTransform.rotation) * + glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)); + + const glm::dmat4 modelViewProjectionTransform = + glm::dmat4(data.camera.projectionMatrix()) * data.camera.combinedViewMatrix() + * modelTransform; + + ghoul::opengl::TextureUnit ringTextureUnit; + if (renderPass == GeometryAndShading) { + _shader->setUniform( + _uniformCache.modelViewProjectionMatrix, + modelViewProjectionTransform + ); + _shader->setUniform(_uniformCache.textureOffset, _offset); + _shader->setUniform(_uniformCache.transparency, _transparency); + _shader->setUniform(_uniformCache.nightFactor, _nightFactor); + _shader->setUniform(_uniformCache.sunPosition, _sunPosition); + _shader->setUniform(_uniformCache.zFightingPercentage, _zFightingPercentage); + + ringTextureUnit.activate(); + _texture->bind(); + _shader->setUniform(_uniformCache.ringTexture, ringTextureUnit); + + // Adding the model transformation to the final shadow matrix so we have a + // complete transformation from the model coordinates to the clip space of + // the light position. + _shader->setUniform( + _uniformCache.shadowMatrix, + shadowData.shadowMatrix * modelTransform + ); + + ghoul::opengl::TextureUnit shadowMapUnit; + shadowMapUnit.activate(); + glBindTexture(GL_TEXTURE_2D, shadowData.shadowDepthTexture); + + _shader->setUniform(_uniformCache.shadowMapTexture, shadowMapUnit); + } + else if (renderPass == GeometryOnly) { + _geometryOnlyShader->setUniform( + _geomUniformCache.modelViewProjectionMatrix, + modelViewProjectionTransform + ); + _geometryOnlyShader->setUniform(_geomUniformCache.textureOffset, _offset); + + ringTextureUnit.activate(); + _texture->bind(); + _shader->setUniform(_geomUniformCache.ringTexture, ringTextureUnit); + } + + glEnable(GL_DEPTH_TEST); + glDisable(GL_CULL_FACE); + + glBindVertexArray(_quad); + glDrawArrays(GL_TRIANGLES, 0, 6); + + glEnable(GL_CULL_FACE); + + if (renderPass == GeometryAndShading) { + _shader->deactivate(); + } + else if (renderPass == GeometryOnly) { + _geometryOnlyShader->deactivate(); + } +} + +void RingsComponent::update(const UpdateData& data) { + if (_shader->isDirty()) { + compileShadowShader(); + } + + if (_geometryOnlyShader->isDirty()) { + _geometryOnlyShader->rebuildFromFile(); + ghoul::opengl::updateUniformLocations( + *_geometryOnlyShader, + _geomUniformCache, + GeomUniformNames + ); + } + + if (_planeIsDirty) { + createPlane(); + _planeIsDirty = false; + } + + if (_textureIsDirty) { + loadTexture(); + _textureIsDirty = false; + } + + _sunPosition = glm::normalize( + global::renderEngine.scene()->sceneGraphNode("Sun")->worldPosition() - + data.modelTransform.translation + ); +} + +void RingsComponent::loadTexture() { + if (!_texturePath.value().empty()) { + using namespace ghoul::io; + using namespace ghoul::opengl; + std::unique_ptr texture = TextureReader::ref().loadTexture( + absPath(_texturePath) + ); + + if (texture) { + LDEBUGC( + "RingsComponent", + fmt::format("Loaded texture from '{}'", absPath(_texturePath)) + ); + _texture = std::move(texture); + + _texture->uploadTexture(); + _texture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap); + + _textureFile = std::make_unique(_texturePath); + _textureFile->setCallback( + [&](const ghoul::filesystem::File&) { _textureIsDirty = true; } + ); + } + } +} + +void RingsComponent::createPlane() { + const GLfloat size = _size; + + struct VertexData { + GLfloat x; + GLfloat y; + GLfloat s; + GLfloat t; + }; + + VertexData data[] = { + { -size, -size, 0.f, 0.f }, + { size, size, 1.f, 1.f }, + { -size, size, 0.f, 1.f }, + { -size, -size, 0.f, 0.f }, + { size, -size, 1.f, 0.f }, + { size, size, 1.f, 1.f }, + }; + + glBindVertexArray(_quad); + glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); + glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW); + glEnableVertexAttribArray(0); + glVertexAttribPointer( + 0, + 2, + GL_FLOAT, + GL_FALSE, + sizeof(VertexData), + nullptr + ); + glEnableVertexAttribArray(1); + glVertexAttribPointer( + 1, + 2, + GL_FLOAT, + GL_FALSE, + sizeof(VertexData), + reinterpret_cast(offsetof(VertexData, s)) // NOLINT + ); +} + +void RingsComponent::compileShadowShader() { + ghoul::Dictionary dict; + dict.setValue("nShadowSamples", std::to_string(_nShadowSamples - 1)); + + try { + global::renderEngine.removeRenderProgram(_shader.get()); + _shader = global::renderEngine.buildRenderProgram( + "RingsProgram", + absPath("${MODULE_GLOBEBROWSING}/shaders/rings_vs.glsl"), + absPath("${MODULE_GLOBEBROWSING}/shaders/rings_fs.glsl"), + dict + ); + } + catch (const ghoul::RuntimeError& e) { + LERROR(e.message); + } + ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames); +} + +bool RingsComponent::isEnabled() const { + return _enabled; +} + +} // namespace openspace diff --git a/modules/globebrowsing/src/ringscomponent.h b/modules/globebrowsing/src/ringscomponent.h new file mode 100644 index 0000000000..c501c4a9de --- /dev/null +++ b/modules/globebrowsing/src/ringscomponent.h @@ -0,0 +1,112 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2020 * + * * + * 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_GLOBEBROWSING___RINGSCOMPONENT___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___RINGSCOMPONENT___H__ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace ghoul { class Dictionary; } +namespace ghoul::filesystem { class File; } +namespace ghoul::opengl { class ProgramObject; } + +namespace openspace { + struct RenderData; + struct UpdateData; + +namespace documentation { struct Documentation; } + +class RingsComponent : public properties::PropertyOwner { +public: + enum RenderPass { + GeometryOnly, + GeometryAndShading + }; + + RingsComponent(const ghoul::Dictionary& dictionary); + + void initialize(); + void initializeGL(); + void deinitializeGL(); + + bool isReady() const; + + void draw( + const RenderData& data, + const RingsComponent::RenderPass renderPass, + const ShadowComponent::ShadowMapData& shadowData = {} + ); + void update(const UpdateData& data); + + static documentation::Documentation Documentation(); + + bool isEnabled() const; + +private: + void loadTexture(); + void createPlane(); + void compileShadowShader(); + + properties::StringProperty _texturePath; + properties::FloatProperty _size; + properties::Vec2Property _offset; + properties::FloatProperty _nightFactor; + properties::FloatProperty _transparency; + properties::BoolProperty _enabled; + properties::FloatProperty _zFightingPercentage; + properties::IntProperty _nShadowSamples; + + std::unique_ptr _shader; + std::unique_ptr _geometryOnlyShader; + UniformCache(modelViewProjectionMatrix, textureOffset, transparency, nightFactor, + sunPosition, ringTexture, shadowMatrix, shadowMapTexture, zFightingPercentage + ) _uniformCache; + UniformCache(modelViewProjectionMatrix, textureOffset, ringTexture) + _geomUniformCache; + std::unique_ptr _texture; + std::unique_ptr _textureFile; + + ghoul::Dictionary _ringsDictionary; + bool _textureIsDirty = false; + GLuint _quad = 0; + GLuint _vertexPositionBuffer = 0; + bool _planeIsDirty = false; + + glm::vec3 _sunPosition = glm::vec3(0.f); +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___RINGSCOMPONENT___H__ diff --git a/modules/globebrowsing/src/shadowcomponent.cpp b/modules/globebrowsing/src/shadowcomponent.cpp new file mode 100644 index 0000000000..3d59598e7b --- /dev/null +++ b/modules/globebrowsing/src/shadowcomponent.cpp @@ -0,0 +1,652 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2020 * + * * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + constexpr const char* _loggerCat = "ShadowComponent"; + + constexpr openspace::properties::Property::PropertyInfo SaveDepthTextureInfo = { + "SaveDepthTextureInfo", + "Save Depth Texture", + "Debug" + }; + + constexpr openspace::properties::Property::PropertyInfo DistanceFractionInfo = { + "DistanceFraction", + "Distance Fraction", + "Distance fraction of original distance from light source to the globe to be " + "considered as the new light source distance." + }; + + constexpr openspace::properties::Property::PropertyInfo DepthMapSizeInfo = { + "DepthMapSize", + "Depth Map Size", + "The depth map size in pixels. You must entry the width and height values." + }; + + constexpr const GLfloat ShadowBorder[] = { 1.f, 1.f, 1.f, 1.f }; + + void checkFrameBufferState(const std::string& codePosition) { + if (glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { + LERROR("Framework not built. " + codePosition); + GLenum fbErr = glCheckFramebufferStatus(GL_FRAMEBUFFER); + switch (fbErr) { + case GL_FRAMEBUFFER_UNDEFINED: + LERROR("Indefined framebuffer."); + break; + case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: + LERROR("Incomplete, missing attachement."); + break; + case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: + LERROR("Framebuffer doesn't have at least one image attached to it."); + break; + case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: + LERROR( + "Returned if the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is " + "GL_NONE for any color attachment point(s) named by GL_DRAW_BUFFERi." + ); + break; + case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: + LERROR( + "Returned if GL_READ_BUFFER is not GL_NONE and the value of " + "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is GL_NONE for the color " + "attachment point named by GL_READ_BUFFER."); + break; + case GL_FRAMEBUFFER_UNSUPPORTED: + LERROR( + "Returned if the combination of internal formats of the attached " + "images violates an implementation - dependent set of restrictions." + ); + break; + case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: + LERROR( + "Returned if the value of GL_RENDERBUFFE_r_samples is not the same " + "for all attached renderbuffers; if the value of GL_TEXTURE_SAMPLES " + "is the not same for all attached textures; or , if the attached " + "images are a mix of renderbuffers and textures, the value of " + "GL_RENDERBUFFE_r_samples does not match the value of " + "GL_TEXTURE_SAMPLES." + ); + LERROR( + "Returned if the value of GL_TEXTURE_FIXED_SAMPLE_LOCATIONS is not " + "the same for all attached textures; or , if the attached images are " + "a mix of renderbuffers and textures, the value of " + "GL_TEXTURE_FIXED_SAMPLE_LOCATIONS is not GL_TRUE for all attached " + "textures." + ); + break; + case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS: + LERROR( + "Returned if any framebuffer attachment is layered, and any " + "populated attachment is not layered, or if all populated color " + "attachments are not from textures of the same target." + ); + break; + default: + LDEBUG("No error found checking framebuffer: " + codePosition); + break; + } + } + } +} // namespace + +namespace openspace { + +documentation::Documentation ShadowComponent::Documentation() { + using namespace documentation; + return { + "ShadowsRing Component", + "globebrowsing_shadows_component", + { + { + DistanceFractionInfo.identifier, + new DoubleVerifier, + Optional::Yes, + DistanceFractionInfo.description + }, + { + DepthMapSizeInfo.identifier, + new Vector2ListVerifier, + Optional::Yes, + DepthMapSizeInfo.description + } + } + }; +} + +ShadowComponent::ShadowComponent(const ghoul::Dictionary& dictionary) + : properties::PropertyOwner({ "ShadowsComponent" }) + , _saveDepthTexture(SaveDepthTextureInfo) + , _distanceFraction(DistanceFractionInfo, 20, 1, 10000) + , _enabled({ "Enabled", "Enabled", "Enable/Disable Shadows" }, true) + , _shadowMapDictionary(dictionary) +{ + using ghoul::filesystem::File; + + if (dictionary.hasKey("Shadows")) { + // @TODO (abock, 2019-12-16) It would be better to not store the dictionary long + // term and rather extract the values directly here. This would require a bit of + // a rewrite in the RenderableGlobe class to not create the ShadowComponent in the + // class-initializer list though + dictionary.getValue("Shadows", _shadowMapDictionary); + } + + documentation::testSpecificationAndThrow( + Documentation(), + _shadowMapDictionary, + "ShadowComponent" + ); + + if (_shadowMapDictionary.hasKey(DistanceFractionInfo.identifier)) { + _distanceFraction = static_cast( + _shadowMapDictionary.value(DistanceFractionInfo.identifier) + ); + } + _saveDepthTexture.onChange([&]() { _executeDepthTextureSave = true; }); + + + if (_shadowMapDictionary.hasKey(DepthMapSizeInfo.identifier)) { + glm::vec2 depthMapSize = + _shadowMapDictionary.value(DepthMapSizeInfo.identifier); + _shadowDepthTextureWidth = depthMapSize.x; + _shadowDepthTextureHeight = depthMapSize.y; + _dynamicDepthTextureRes = false; + } + else { + glm::ivec2 renderingResolution = global::renderEngine.renderingResolution(); + _shadowDepthTextureWidth = renderingResolution.x * 2; + _shadowDepthTextureHeight = renderingResolution.y * 2; + _dynamicDepthTextureRes = true; + } + + _saveDepthTexture.onChange([&]() { _executeDepthTextureSave = true; }); + + _viewDepthMap = false; + + addProperty(_enabled); + addProperty(_saveDepthTexture); + addProperty(_distanceFraction); +} + +void ShadowComponent::initialize() {} + +bool ShadowComponent::isReady() const { + return true; +} + +void ShadowComponent::initializeGL() { + createDepthTexture(); + createShadowFBO(); +} + +void ShadowComponent::deinitializeGL() { + glDeleteTextures(1, &_shadowDepthTexture); + glDeleteTextures(1, &_positionInLightSpaceTexture); + glDeleteFramebuffers(1, &_shadowFBO); +} + +RenderData ShadowComponent::begin(const RenderData& data) { + // =========================================== + // Builds light's ModelViewProjectionMatrix: + // =========================================== + + glm::dvec3 diffVector = glm::dvec3(_sunPosition) - data.modelTransform.translation; + double originalLightDistance = glm::length(diffVector); + glm::dvec3 lightDirection = glm::normalize(diffVector); + + // Percentage of the original light source distance (to avoid artifacts) + //double multiplier = originalLightDistance * + // (static_cast(_distanceFraction)/1.0E5); + + double multiplier = originalLightDistance * + (static_cast(_distanceFraction) / 1E17); + + // New light source position + //glm::dvec3 lightPosition = data.modelTransform.translation + + // (lightDirection * multiplier); + glm::dvec3 lightPosition = data.modelTransform.translation + + (diffVector * multiplier); + + //// Light Position + //glm::dvec3 lightPosition = glm::dvec3(_sunPosition); + + //=============== Manually Created Camera Matrix =================== + //================================================================== + // camera Z + glm::dvec3 cameraZ = lightDirection; + + // camera X + glm::dvec3 upVector = glm::dvec3(0.0, 1.0, 0.0); + glm::dvec3 cameraX = glm::normalize(glm::cross(upVector, cameraZ)); + + // camera Y + glm::dvec3 cameraY = glm::cross(cameraZ, cameraX); + + // init 4x4 matrix + glm::dmat4 cameraRotationMatrix(1.0); + + double* matrix = glm::value_ptr(cameraRotationMatrix); + matrix[0] = cameraX.x; + matrix[4] = cameraX.y; + matrix[8] = cameraX.z; + matrix[1] = cameraY.x; + matrix[5] = cameraY.y; + matrix[9] = cameraY.z; + matrix[2] = cameraZ.x; + matrix[6] = cameraZ.y; + matrix[10] = cameraZ.z; + + // set translation part + // We aren't setting the position here because it is set in + // the camera->setPosition() + //matrix[12] = -glm::dot(cameraX, lightPosition); + //matrix[13] = -glm::dot(cameraY, lightPosition); + //matrix[14] = -glm::dot(cameraZ, lightPosition); + + + _lightCamera = std::move(std::unique_ptr(new Camera(data.camera))); + _lightCamera->setPositionVec3(lightPosition); + _lightCamera->setRotation(glm::dquat(glm::inverse(cameraRotationMatrix))); + //======================================================================= + //======================================================================= + + + //============= Light Matrix by Camera Matrices Composition ============= + //======================================================================= + glm::dmat4 lightProjectionMatrix = glm::dmat4(_lightCamera->projectionMatrix()); + + // The model transformation missing in the final shadow matrix is add when rendering each + // object (using its transformations provided by the RenderData structure) + _shadowData.shadowMatrix = + _toTextureCoordsMatrix * lightProjectionMatrix * + _lightCamera->combinedViewMatrix(); + + + // Saves current state + glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_defaultFBO); + glGetIntegerv(GL_VIEWPORT, _mViewport); + _faceCulling = glIsEnabled(GL_CULL_FACE); + glGetIntegerv(GL_CULL_FACE_MODE, &_faceToCull); + _polygonOffSet = glIsEnabled(GL_POLYGON_OFFSET_FILL); + glGetFloatv(GL_POLYGON_OFFSET_FACTOR, &_polygonOffSetFactor); + glGetFloatv(GL_POLYGON_OFFSET_UNITS, &_polygonOffSetUnits); + glGetFloatv(GL_COLOR_CLEAR_VALUE, _colorClearValue); + glGetFloatv(GL_DEPTH_CLEAR_VALUE, &_depthClearValue); + _depthIsEnabled = glIsEnabled(GL_DEPTH_TEST); + glGetIntegerv(GL_DEPTH_FUNC, &_depthFunction); + _blendIsEnabled = glIsEnabled(GL_BLEND); + + + glBindFramebuffer(GL_FRAMEBUFFER, _shadowFBO); + GLenum drawBuffers[] = { GL_COLOR_ATTACHMENT0, GL_NONE, GL_NONE }; + glDrawBuffers(3, drawBuffers); + glViewport(0, 0, _shadowDepthTextureWidth, _shadowDepthTextureHeight); + glClearDepth(1.0f); + glDepthFunc(GL_LEQUAL); + glEnable(GL_DEPTH_TEST); + glClearColor(0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + + //glEnable(GL_CULL_FACE); + //checkGLError("begin() -- enabled cull face"); + //glCullFace(GL_FRONT); + //checkGLError("begin() -- set cullface to front"); + //glEnable(GL_POLYGON_OFFSET_FILL); + //checkGLError("begin() -- enabled polygon offset fill"); + //glPolygonOffset(2.5f, 10.0f); + //checkGLError("begin() -- set values for polygon offset"); + + RenderData lightRenderData{ + *_lightCamera, + data.time, + data.doPerformanceMeasurement, + data.renderBinMask, + data.modelTransform + }; + + return lightRenderData; +} + +void ShadowComponent::end() { + if (_executeDepthTextureSave) { + saveDepthBuffer(); + _executeDepthTextureSave = false; + } + + // Restores system state + glBindFramebuffer(GL_FRAMEBUFFER, _defaultFBO); + GLenum drawBuffers[] = { + GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 + }; + glDrawBuffers(3, drawBuffers); + glViewport(_mViewport[0], _mViewport[1], _mViewport[2], _mViewport[3]); + + if (_faceCulling) { + glEnable(GL_CULL_FACE); + glCullFace(_faceToCull); + } + else { + glDisable(GL_CULL_FACE); + } + + if (_depthIsEnabled) { + glEnable(GL_DEPTH_TEST); + } + else { + glDisable(GL_DEPTH_TEST); + } + + glDepthFunc(_depthFunction); + + if (_polygonOffSet) { + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(_polygonOffSetFactor, _polygonOffSetUnits); + } + else { + glDisable(GL_POLYGON_OFFSET_FILL); + } + + glClearColor( + _colorClearValue[0], + _colorClearValue[1], + _colorClearValue[2], + _colorClearValue[3] + ); + glClearDepth(_depthClearValue); + + if (_blendIsEnabled) { + glEnable(GL_BLEND); + } + + if (_viewDepthMap) { + if (!_renderDMProgram) { + _renderDMProgram = global::renderEngine.buildRenderProgram( + "ShadowMappingDebuggingProgram", + absPath("${MODULE_GLOBEBROWSING}/shaders/smviewer_vs.glsl"), + absPath("${MODULE_GLOBEBROWSING}/shaders/smviewer_fs.glsl") + ); + } + + if (!_quadVAO) { + glGenVertexArrays(1, &_quadVAO); + } + + _renderDMProgram->activate(); + + ghoul::opengl::TextureUnit shadowMapUnit; + shadowMapUnit.activate(); + glBindTexture(GL_TEXTURE_2D, _shadowDepthTexture); + + _renderDMProgram->setUniform("shadowMapTexture", shadowMapUnit); + + glBindVertexArray(_quadVAO); + glDrawArrays(GL_TRIANGLES, 0, 6); + + _renderDMProgram->deactivate(); + } +} + +void ShadowComponent::update(const UpdateData&) { + _sunPosition = global::renderEngine.scene()->sceneGraphNode("Sun")->worldPosition(); + + glm::ivec2 renderingResolution = global::renderEngine.renderingResolution(); + if (_dynamicDepthTextureRes && ((_shadowDepthTextureWidth != renderingResolution.x) || + (_shadowDepthTextureHeight != renderingResolution.y))) + { + _shadowDepthTextureWidth = renderingResolution.x * 2; + _shadowDepthTextureHeight = renderingResolution.y * 2; + updateDepthTexture(); + } +} + +void ShadowComponent::createDepthTexture() { + glGenTextures(1, &_shadowDepthTexture); + updateDepthTexture(); + + _shadowData.shadowDepthTexture = _shadowDepthTexture; + //_shadowData.positionInLightSpaceTexture = _positionInLightSpaceTexture; +} + +void ShadowComponent::createShadowFBO() { + // Saves current FBO first + glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_defaultFBO); + + glGenFramebuffers(1, &_shadowFBO); + glBindFramebuffer(GL_FRAMEBUFFER, _shadowFBO); + glFramebufferTexture( + GL_FRAMEBUFFER, + GL_DEPTH_ATTACHMENT, + _shadowDepthTexture, + 0 + ); + + //glFramebufferTexture( + // GL_FRAMEBUFFER, + // GL_COLOR_ATTACHMENT0, + // _positionInLightSpaceTexture, + // 0 + //); + + //GLenum drawBuffers[] = { GL_COLOR_ATTACHMENT0, GL_NONE, GL_NONE }; + GLenum drawBuffers[] = { GL_NONE, GL_NONE, GL_NONE }; + glDrawBuffers(3, drawBuffers); + + checkFrameBufferState("createShadowFBO()"); + + // Restores system state + glBindFramebuffer(GL_FRAMEBUFFER, _defaultFBO); +} + +void ShadowComponent::updateDepthTexture() { + glBindTexture(GL_TEXTURE_2D, _shadowDepthTexture); + + //glTexStorage2D( + // GL_TEXTURE_2D, + // 1, + // GL_DEPTH_COMPONENT32F, + // _shadowDepthTextureWidth, + // _shadowDepthTextureHeight + //); + + glTexImage2D( + GL_TEXTURE_2D, + 0, + GL_DEPTH_COMPONENT32F, + _shadowDepthTextureWidth, + _shadowDepthTextureHeight, + 0, + GL_DEPTH_COMPONENT, + GL_FLOAT, + 0 + ); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, ShadowBorder); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); + + //glGenTextures(1, &_positionInLightSpaceTexture); + //glBindTexture(GL_TEXTURE_2D, _positionInLightSpaceTexture); + //glTexImage2D( + // GL_TEXTURE_2D, + // 0, + // GL_RGB32F, + // _shadowDepthTextureWidth, + // _shadowDepthTextureHeight, + // 0, + // GL_RGBA, + // GL_FLOAT, + // nullptr + //); + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + glBindTexture(GL_TEXTURE_2D, 0); +} + +void ShadowComponent::saveDepthBuffer() { + int size = _shadowDepthTextureWidth * _shadowDepthTextureHeight; + std::vector buffer(size); + + glReadPixels( + 0, + 0, + _shadowDepthTextureWidth, + _shadowDepthTextureHeight, + GL_DEPTH_COMPONENT, + GL_UNSIGNED_BYTE, + buffer.data() + ); + + std::fstream ppmFile; + + ppmFile.open("depthBufferShadowMapping.ppm", std::fstream::out); + if (ppmFile.is_open()) { + + ppmFile << "P3" << std::endl; + ppmFile << _shadowDepthTextureWidth << " " << _shadowDepthTextureHeight + << std::endl; + ppmFile << "255" << std::endl; + + std::cout << "\n\nSaving depth texture to file depthBufferShadowMapping.ppm\n\n"; + int k = 0; + for (int i = 0; i < _shadowDepthTextureWidth; i++) { + for (int j = 0; j < _shadowDepthTextureHeight; j++, k++) { + unsigned int val = static_cast(buffer[k]); + ppmFile << val << " " << val << " " << val << " "; + } + ppmFile << std::endl; + } + + ppmFile.close(); + + std::cout << "Texture saved to file depthBufferShadowMapping.ppm\n\n"; + } + + buffer.clear(); + + std::vector bBuffer(size * 4); + + glReadBuffer(GL_COLOR_ATTACHMENT3); + glReadPixels( + 0, + 0, + _shadowDepthTextureWidth, + _shadowDepthTextureHeight, + GL_RGBA, + GL_FLOAT, + bBuffer.data() + ); + + ppmFile.clear(); + + ppmFile.open("positionBufferShadowMapping.ppm", std::fstream::out); + if (ppmFile.is_open()) { + + ppmFile << "P3" << std::endl; + ppmFile << _shadowDepthTextureWidth << " " << _shadowDepthTextureHeight + << std::endl; + ppmFile << "255" << std::endl; + + std::cout << "\n\nSaving texture position to positionBufferShadowMapping.ppm\n\n"; + + float biggestValue = 0.f; + + int k = 0; + for (int i = 0; i < _shadowDepthTextureWidth; i++) { + for (int j = 0; j < _shadowDepthTextureHeight; j++) { + biggestValue = bBuffer[k] > biggestValue ? + bBuffer[k] : biggestValue; + k += 4; + } + } + + biggestValue /= 255.f; + + k = 0; + for (int i = 0; i < _shadowDepthTextureWidth; i++) { + for (int j = 0; j < _shadowDepthTextureHeight; j++) { + ppmFile << static_cast(bBuffer[k] / biggestValue) << " " + << static_cast(bBuffer[k + 1] / biggestValue) << " " + << static_cast(bBuffer[k + 2] / biggestValue) << " "; + k += 4; + } + ppmFile << std::endl; + } + + ppmFile.close(); + + LINFO("Texture saved to file positionBufferShadowMapping.ppm"); + } +} + +bool ShadowComponent::isEnabled() const { + return _enabled; +} + +ShadowComponent::ShadowMapData ShadowComponent::shadowMapData() const { + return _shadowData; +} + +void ShadowComponent::setViewDepthMap(bool enable) { + _viewDepthMap = enable; +} + +} // namespace openspace diff --git a/modules/globebrowsing/src/shadowcomponent.h b/modules/globebrowsing/src/shadowcomponent.h new file mode 100644 index 0000000000..180b9aeccd --- /dev/null +++ b/modules/globebrowsing/src/shadowcomponent.h @@ -0,0 +1,151 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2020 * + * * + * 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_GLOBEBROWSING___SHADOWCOMPONENT___H__ +#define __OPENSPACE_MODULE_GLOBEBROWSING___SHADOWCOMPONENT___H__ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace ghoul { class Dictionary; } +namespace ghoul::filesystem { class File; } +namespace ghoul::opengl { class ProgramObject; } + +namespace openspace { + struct RenderData; + struct UpdateData; + +namespace documentation { struct Documentation; } + +class ShadowComponent : public properties::PropertyOwner { +public: + struct ShadowMapData { + glm::dmat4 shadowMatrix; + GLuint shadowDepthTexture; + }; + + ShadowComponent(const ghoul::Dictionary& dictionary); + + void initialize(); + void initializeGL(); + void deinitializeGL(); + //bool deinitialize(); + + bool isReady() const; + + RenderData begin(const RenderData& data); + void end(); + void update(const UpdateData& data); + + static documentation::Documentation Documentation(); + + bool isEnabled() const; + + ShadowComponent::ShadowMapData shadowMapData() const; + + void setViewDepthMap(bool enable); + +private: + void createDepthTexture(); + void createShadowFBO(); + void updateDepthTexture(); + + // Debug + void saveDepthBuffer(); + + ShadowMapData _shadowData; + + // Texture coords in [0, 1], while clip coords in [-1, 1] + const glm::dmat4 _toTextureCoordsMatrix = glm::dmat4( + glm::dvec4(0.5, 0.0, 0.0, 0.0), + glm::dvec4(0.0, 0.5, 0.0, 0.0), + glm::dvec4(0.0, 0.0, 1.0, 0.0), + glm::dvec4(0.5, 0.5, 0.0, 1.0) + ); + + // DEBUG + properties::TriggerProperty _saveDepthTexture; + properties::IntProperty _distanceFraction; + properties::BoolProperty _enabled; + + ghoul::Dictionary _shadowMapDictionary; + + int _shadowDepthTextureHeight = 4096; + int _shadowDepthTextureWidth = 4096; + bool _dynamicDepthTextureRes = true; + + GLuint _shadowDepthTexture = 0; + GLuint _positionInLightSpaceTexture = 0; + GLuint _shadowFBO = 0; + GLint _defaultFBO = 0; + GLint _mViewport[4]; + + GLboolean _faceCulling; + GLboolean _polygonOffSet; + GLboolean _depthIsEnabled; + GLboolean _blendIsEnabled = false; + + GLenum _faceToCull; + GLenum _depthFunction; + + GLfloat _polygonOffSetFactor; + GLfloat _polygonOffSetUnits; + GLfloat _colorClearValue[4]; + GLfloat _depthClearValue; + + glm::vec3 _sunPosition = glm::vec3(0.f); + + glm::dmat4 _shadowMatrix = glm::dmat4(1.0); + + glm::dvec3 _cameraPos = glm::dvec3(0.0); + glm::dvec3 _cameraFocus = glm::dvec3(0.0); + glm::dquat _cameraRotation = glm::dquat(1.0, 0.0, 0.0, 0.0); + + std::stringstream _serializedCamera; + + std::unique_ptr _lightCamera; + + // DEBUG + bool _executeDepthTextureSave = false; + bool _viewDepthMap = false; + std::unique_ptr _renderDMProgram; + GLuint _quadVAO = 0u; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_GLOBEBROWSING___SHADOWCOMPONENT___H__ diff --git a/modules/globebrowsing/src/skirtedgrid.cpp b/modules/globebrowsing/src/skirtedgrid.cpp index eaa50fc279..4d897c9920 100644 --- a/modules/globebrowsing/src/skirtedgrid.cpp +++ b/modules/globebrowsing/src/skirtedgrid.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/skirtedgrid.h b/modules/globebrowsing/src/skirtedgrid.h index c07419ea52..5bcbf4e710 100644 --- a/modules/globebrowsing/src/skirtedgrid.h +++ b/modules/globebrowsing/src/skirtedgrid.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/tileindex.cpp b/modules/globebrowsing/src/tileindex.cpp index 2999b95616..e79acff1a4 100644 --- a/modules/globebrowsing/src/tileindex.cpp +++ b/modules/globebrowsing/src/tileindex.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/tileindex.h b/modules/globebrowsing/src/tileindex.h index 841b0e57cc..c29a4a4157 100644 --- a/modules/globebrowsing/src/tileindex.h +++ b/modules/globebrowsing/src/tileindex.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/tileloadjob.cpp b/modules/globebrowsing/src/tileloadjob.cpp index d45868ffd7..a9bdb36700 100644 --- a/modules/globebrowsing/src/tileloadjob.cpp +++ b/modules/globebrowsing/src/tileloadjob.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/tileloadjob.h b/modules/globebrowsing/src/tileloadjob.h index 35b22ad03c..df0486aad1 100644 --- a/modules/globebrowsing/src/tileloadjob.h +++ b/modules/globebrowsing/src/tileloadjob.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/tileprovider.cpp b/modules/globebrowsing/src/tileprovider.cpp index ad72426685..d79aaca8a4 100644 --- a/modules/globebrowsing/src/tileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -40,6 +40,7 @@ #include #include #include +#include #include #include "cpl_minixml.h" @@ -152,6 +153,8 @@ namespace temporal { // void initAsyncTileDataReader(DefaultTileProvider& t, TileTextureInitData initData) { + ZoneScoped + t.asyncTextureDataProvider = std::make_unique( t.name, std::make_unique( @@ -163,12 +166,14 @@ void initAsyncTileDataReader(DefaultTileProvider& t, TileTextureInitData initDat } bool initTexturesFromLoadedData(DefaultTileProvider& t) { + ZoneScoped + if (t.asyncTextureDataProvider) { std::optional tile = t.asyncTextureDataProvider->popFinishedRawTile(); if (tile) { const cache::ProviderTileKey key = { tile->tileIndex, t.uniqueIdentifier }; ghoul_assert(!t.tileCache->exist(key), "Tile must not be existing in cache"); - t.tileCache->createTileAndPut(key, std::move(tile.value())); + t.tileCache->createTileAndPut(key, std::move(*tile)); return true; } } @@ -181,6 +186,8 @@ bool initTexturesFromLoadedData(DefaultTileProvider& t) { // void initialize(TextTileProvider& t) { + ZoneScoped + t.font = global::fontManager.font("Mono", static_cast(t.fontSize)); t.fontRenderer = ghoul::fontrendering::FontRenderer::createDefault(); t.fontRenderer->setFramebufferSize(glm::vec2(t.initData.dimensions)); @@ -192,6 +199,9 @@ void deinitialize(TextTileProvider& t) { } Tile tile(TextTileProvider& t, const TileIndex& tileIndex) { + ZoneScoped + TracyGpuZone("tile") + cache::ProviderTileKey key = { tileIndex, t.uniqueIdentifier }; Tile tile = t.tileCache->get(key); if (!tile.texture) { @@ -231,6 +241,8 @@ Tile tile(TextTileProvider& t, const TileIndex& tileIndex) { } void reset(TextTileProvider& t) { + ZoneScoped + t.tileCache->clear(); } @@ -240,6 +252,8 @@ void reset(TextTileProvider& t) { // TileProvider* levelProvider(TileProviderByLevel& t, int level) { + ZoneScoped + if (!t.levelTileProviders.empty()) { int clampedLevel = glm::clamp( level, @@ -296,6 +310,8 @@ std::string timeStringify(TemporalTileProvider::TimeFormatType type, const Time& std::unique_ptr initTileProvider(TemporalTileProvider& t, const TemporalTileProvider::TimeKey& timekey) { + ZoneScoped + static const std::vector IgnoredTokens = { // From: http://www.gdal.org/frmt_wms.html "${x}", @@ -324,6 +340,8 @@ std::unique_ptr initTileProvider(TemporalTileProvider& t, TileProvider* getTileProvider(TemporalTileProvider& t, const TemporalTileProvider::TimeKey& timekey) { + ZoneScoped + const auto it = t.tileProviderMap.find(timekey); if (it != t.tileProviderMap.end()) { return it->second.get(); @@ -339,6 +357,8 @@ TileProvider* getTileProvider(TemporalTileProvider& t, } TileProvider* getTileProvider(TemporalTileProvider& t, const Time& time) { + ZoneScoped + Time tCopy(time); if (t.timeQuantizer.quantize(tCopy, true)) { TemporalTileProvider::TimeKey timeKey = timeStringify(t.timeFormat, tCopy); @@ -354,6 +374,8 @@ TileProvider* getTileProvider(TemporalTileProvider& t, const Time& time) { } void ensureUpdated(TemporalTileProvider& t) { + ZoneScoped + if (!t.currentTileProvider) { update(t); } @@ -374,6 +396,8 @@ std::string xmlValue(TemporalTileProvider& t, CPLXMLNode* node, const std::strin } std::string consumeTemporalMetaData(TemporalTileProvider& t, const std::string& xml) { + ZoneScoped + CPLXMLNode* node = CPLParseXMLString(xml.c_str()); std::string timeStart = xmlValue(t, node, temporal::TimeStart, "2000 Jan 1"); @@ -397,7 +421,8 @@ std::string consumeTemporalMetaData(TemporalTileProvider& t, const std::string& } try { - t.timeQuantizer = TimeQuantizer(start, end, timeResolution); + t.timeQuantizer.setStartEndRange(start.ISO8601(), end.ISO8601()); + t.timeQuantizer.setResolution(timeResolution); } catch (const ghoul::RuntimeError& e) { throw ghoul::RuntimeError(fmt::format( @@ -420,6 +445,8 @@ std::string consumeTemporalMetaData(TemporalTileProvider& t, const std::string& } bool readFilePath(TemporalTileProvider& t) { + ZoneScoped + std::ifstream in(t.filePath.value().c_str()); std::string xml; if (in.is_open()) { @@ -453,6 +480,8 @@ unsigned int TileProvider::NumTileProviders = 0; // General functions // void initializeDefaultTile() { + ZoneScoped + ghoul_assert(!DefaultTile.texture, "Default tile should not have been created"); using namespace ghoul::opengl; @@ -486,6 +515,8 @@ void deinitializeDefaultTile() { std::unique_ptr createFromDictionary(layergroupid::TypeID layerTypeID, const ghoul::Dictionary& dictionary) { + ZoneScoped + const char* type = layergroupid::LAYER_TYPE_NAMES[static_cast(layerTypeID)]; auto factory = FactoryManager::ref().factory(); std::unique_ptr result = factory->create(type, dictionary); @@ -498,6 +529,8 @@ DefaultTileProvider::DefaultTileProvider(const ghoul::Dictionary& dictionary) : filePath(defaultprovider::FilePathInfo, "") , tilePixelSize(defaultprovider::TilePixelSizeInfo, 32, 32, 2048) { + ZoneScoped + type = Type::DefaultTileProvider; tileCache = global::moduleEngine.module()->tileCache(); @@ -559,6 +592,8 @@ DefaultTileProvider::DefaultTileProvider(const ghoul::Dictionary& dictionary) SingleImageProvider::SingleImageProvider(const ghoul::Dictionary& dictionary) : filePath(singleimageprovider::FilePathInfo) { + ZoneScoped + type = Type::SingleImageTileProvider; filePath = dictionary.value(KeyFilePath); @@ -575,6 +610,8 @@ TextTileProvider::TextTileProvider(TileTextureInitData initData, size_t fontSize : initData(std::move(initData)) , fontSize(fontSize) { + ZoneScoped + tileCache = global::moduleEngine.module()->tileCache(); } @@ -585,6 +622,8 @@ TextTileProvider::TextTileProvider(TileTextureInitData initData, size_t fontSize SizeReferenceTileProvider::SizeReferenceTileProvider(const ghoul::Dictionary& dictionary) : TextTileProvider(tileTextureInitData(layergroupid::GroupID::ColorLayers, false)) { + ZoneScoped + type = Type::SizeReferenceTileProvider; font = global::fontManager.font("Mono", static_cast(fontSize)); @@ -601,6 +640,8 @@ SizeReferenceTileProvider::SizeReferenceTileProvider(const ghoul::Dictionary& di TileIndexTileProvider::TileIndexTileProvider(const ghoul::Dictionary&) : TextTileProvider(tileTextureInitData(layergroupid::GroupID::ColorLayers, false)) { + ZoneScoped + type = Type::TileIndexTileProvider; } @@ -609,6 +650,8 @@ TileIndexTileProvider::TileIndexTileProvider(const ghoul::Dictionary&) TileProviderByIndex::TileProviderByIndex(const ghoul::Dictionary& dictionary) { + ZoneScoped + type = Type::ByIndexTileProvider; const ghoul::Dictionary& defaultProviderDict = dictionary.value( @@ -677,6 +720,8 @@ TileProviderByIndex::TileProviderByIndex(const ghoul::Dictionary& dictionary) { TileProviderByLevel::TileProviderByLevel(const ghoul::Dictionary& dictionary) { + ZoneScoped + type = Type::ByLevelTileProvider; layergroupid::GroupID layerGroupID = dictionary.value( @@ -753,6 +798,8 @@ TemporalTileProvider::TemporalTileProvider(const ghoul::Dictionary& dictionary) : initDict(dictionary) , filePath(temporal::FilePathInfo) { + ZoneScoped + type = Type::TemporalTileProvider; filePath = dictionary.value(KeyFilePath); @@ -771,6 +818,8 @@ TemporalTileProvider::TemporalTileProvider(const ghoul::Dictionary& dictionary) bool initialize(TileProvider& tp) { + ZoneScoped + ghoul_assert(!tp.isInitialized, "TileProvider can only be initialized once."); tp.uniqueIdentifier = TileProvider::NumTileProviders++; @@ -821,6 +870,8 @@ bool initialize(TileProvider& tp) { bool deinitialize(TileProvider& tp) { + ZoneScoped + switch (tp.type) { case Type::DefaultTileProvider: break; @@ -860,6 +911,8 @@ bool deinitialize(TileProvider& tp) { Tile tile(TileProvider& tp, const TileIndex& tileIndex) { + ZoneScoped + switch (tp.type) { case Type::DefaultTileProvider: { DefaultTileProvider& t = static_cast(tp); @@ -973,6 +1026,8 @@ Tile tile(TileProvider& tp, const TileIndex& tileIndex) { Tile::Status tileStatus(TileProvider& tp, const TileIndex& index) { + ZoneScoped + switch (tp.type) { case Type::DefaultTileProvider: { DefaultTileProvider& t = static_cast(tp); @@ -1033,6 +1088,8 @@ Tile::Status tileStatus(TileProvider& tp, const TileIndex& index) { TileDepthTransform depthTransform(TileProvider& tp) { + ZoneScoped + switch (tp.type) { case Type::DefaultTileProvider: { DefaultTileProvider& t = static_cast(tp); @@ -1076,6 +1133,8 @@ TileDepthTransform depthTransform(TileProvider& tp) { int update(TileProvider& tp) { + ZoneScoped + switch (tp.type) { case Type::DefaultTileProvider: { DefaultTileProvider& t = static_cast(tp); @@ -1146,6 +1205,8 @@ int update(TileProvider& tp) { void reset(TileProvider& tp) { + ZoneScoped + switch (tp.type) { case Type::DefaultTileProvider: { DefaultTileProvider& t = static_cast(tp); @@ -1232,6 +1293,8 @@ void reset(TileProvider& tp) { int maxLevel(TileProvider& tp) { + ZoneScoped + switch (tp.type) { case Type::DefaultTileProvider: { DefaultTileProvider& t = static_cast(tp); @@ -1277,6 +1340,8 @@ int maxLevel(TileProvider& tp) { float noDataValueAsFloat(TileProvider& tp) { + ZoneScoped + ghoul_assert(tp.isInitialized, "TileProvider was not initialized."); switch (tp.type) { case Type::DefaultTileProvider: { @@ -1307,6 +1372,8 @@ float noDataValueAsFloat(TileProvider& tp) { ChunkTile chunkTile(TileProvider& tp, TileIndex tileIndex, int parents, int maxParents) { + ZoneScoped + ghoul_assert(tp.isInitialized, "TileProvider was not initialized."); auto ascendToParent = [](TileIndex& tileIndex, TileUvTransform& uv) { @@ -1363,6 +1430,8 @@ ChunkTile chunkTile(TileProvider& tp, TileIndex tileIndex, int parents, int maxP ChunkTilePile chunkTilePile(TileProvider& tp, TileIndex tileIndex, int pileSize) { + ZoneScoped + ghoul_assert(tp.isInitialized, "TileProvider was not initialized."); ghoul_assert(pileSize >= 0, "pileSize must be positive"); diff --git a/modules/globebrowsing/src/tileprovider.h b/modules/globebrowsing/src/tileprovider.h index c7e3cd5196..8f6bcd4772 100644 --- a/modules/globebrowsing/src/tileprovider.h +++ b/modules/globebrowsing/src/tileprovider.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -110,11 +110,11 @@ struct TextTileProvider : public TileProvider { std::unique_ptr fontRenderer; std::shared_ptr font; - size_t fontSize; + size_t fontSize = 0; std::string text; - glm::vec2 textPosition; - glm::vec4 textColor; + glm::vec2 textPosition = glm::vec2(0.f); + glm::vec4 textColor = glm::vec4(0.f); GLuint fbo = 0; diff --git a/modules/globebrowsing/src/tiletextureinitdata.cpp b/modules/globebrowsing/src/tiletextureinitdata.cpp index 0791c282a7..a77e92bcc3 100644 --- a/modules/globebrowsing/src/tiletextureinitdata.cpp +++ b/modules/globebrowsing/src/tiletextureinitdata.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * diff --git a/modules/globebrowsing/src/tiletextureinitdata.h b/modules/globebrowsing/src/tiletextureinitdata.h index 6eee193c17..6a0984f4cf 100644 --- a/modules/globebrowsing/src/tiletextureinitdata.h +++ b/modules/globebrowsing/src/tiletextureinitdata.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -33,9 +33,8 @@ namespace openspace::globebrowsing { -/** - * All information needed to create a texture used for a Tile. - */ + +/// All information needed to create a texture used for a Tile. class TileTextureInitData { public: using HashKey = uint64_t; diff --git a/modules/globebrowsing/src/timequantizer.cpp b/modules/globebrowsing/src/timequantizer.cpp index 102ade1661..68de65ac1f 100644 --- a/modules/globebrowsing/src/timequantizer.cpp +++ b/modules/globebrowsing/src/timequantizer.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * 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 * @@ -25,22 +25,333 @@ #include #include +#include #include #include #include #include +#include +#include namespace openspace::globebrowsing { -TimeQuantizer::TimeQuantizer(const Time& start, const Time& end, double resolution) - : _timerange(start.j2000Seconds(), end.j2000Seconds()) - , _resolution(resolution) -{} +namespace { -TimeQuantizer::TimeQuantizer(const Time& start, const Time& end, +// returns the number of days in a given month and year (takes leap year into account) +int monthSize(int month, int year) { + // A year is a leap year if it is divisible by 4 unless it is also divisible by 100 + // unless it is divisible by 4 *and* 100 + const bool leap = ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0)); + + switch (month) { + case 2: + return leap ? 29 : 28; + case 4: + case 6: + case 9: + case 11: + return 30; + case 1: + case 3: + case 5: + case 7: + case 8: + case 10: + case 12: + default: + return 31; + } +} + +/** + * singleIncrement is used for any of the date/time types, and handles overflow + * values using the min/max parameters + * + * \param oper the date/time variable to operate on (will be changed) + * \param val the value of the increment, which may be changed in this function + * if an overflow occurs + * \param min the minimum allowable value + * \param max the maximum allowable value (determines where overflow occurs) + */ +bool singleIncrement(int& oper, int& val, int min, int max) { + oper += val; + if (oper <= max) { + return true; + } + oper = oper - max - (1 - min); + // Only single increments for the less-significant units on rollover + val = 1; + return false; +} + +/** + * singleDecrement is used for any of the date/time types, and handles underflow + * values using the min/max parameters + * + * \param oper the date/time variable to operate on (will be changed) + * \param val the value of the decrement, which may be changed in this function + * if an underflow occurs + * \param min the minimum allowable value + * \param max the maximum allowable value (determines where underflow occurs) + */ +bool singleDecrement(int& oper, int& val, int min, int max) { + oper -= val; + if (oper >= min) { + return true; + } + oper = oper + max + (1 - min); + // Only single increments for the less-significant units on rollover + val = 1; + return false; +} +} // namespace + +RangedTime::RangedTime(std::string start, std::string end) + : _start(std::move(start)) + , _end(std::move(end)) +{ + setStart(_start); + setEnd(_end); +} + +void RangedTime::setStart(std::string start) { + Time t1; + t1.setTime(start); + _startJ2000 = t1.j2000Seconds(); + _start = start; +} + +void RangedTime::setEnd(const std::string end) { + Time t2; + t2.setTime(end); + _endJ2000 = t2.j2000Seconds(); + _end = end; +} + +bool RangedTime::includes(const std::string& checkTime) { + Time t; + t.setTime(checkTime); + const double tj = t.j2000Seconds(); + return (_startJ2000 <= tj && tj <= _endJ2000); +} + +std::string RangedTime::clamp(const std::string& checkTime) { + Time t; + t.setTime(checkTime); + const double tj = t.j2000Seconds(); + if (tj < _startJ2000) { + return _start; + } + else if (tj > _endJ2000) { + return _end; + } + else { + return checkTime; + } +} + +std::string RangedTime::start() const { + return _start; +} + +std::string RangedTime::end() const { + return _end; +} + +DateTime::DateTime(const std::string& initDateTime) { + setTime(initDateTime); +}; + +void DateTime::setTime(const std::string& input) { + _year = std::stoi(input.substr(index_year, len_year)); + _month = std::stoi(input.substr(index_month, len_nonYear)); + _day = std::stoi(input.substr(index_day, len_nonYear)); + _hour = std::stoi(input.substr(index_hour, len_nonYear)); + _minute = std::stoi(input.substr(index_minute, len_nonYear)); + _second = std::stoi(input.substr(index_second, len_nonYear)); +} + +std::string DateTime::ISO8601() const { + return fmt::format( + "{:0>4}-{:0>2}-{:0>2}T{:0>2}:{:0>2}:{:0>2}", + _year, _month, _day, _hour, _minute, _second + ); +}; + +double DateTime::J2000() const { + Time t; + std::string timeString = ISO8601(); + t.setTime(timeString); + return t.j2000Seconds(); +} + +void DateTime::operator=(DateTime& src) { + _year = src.year(); + _month = src.month(); + _day = src.day(); + _hour = src.hour(); + _minute = src.minute(); + _second = src.second(); +} + +int DateTime::increment(int value, char unit, double error, double resolution) { + unsigned int nIncrements = std::abs(static_cast(error / resolution)); + if (nIncrements == 0) { + nIncrements = 1; + } + for (unsigned int i = 0; i < nIncrements; ++i) { + incrementOnce(value, unit); + } + return nIncrements; +} + +void DateTime::incrementOnce(int value, char unit) { + bool inBounds = true; + switch (unit) { + case 'm': + if (singleIncrement(_minute, value, 0, 59)) + break; + // else fall-through if overflow... + + case 'h': + if (singleIncrement(_hour, value, 0, 23)) + break; + // else fall-through if overflow... + + case 'd': + if (singleIncrement(_day, value, 1, monthSize(_month, _year))) + break; + // else fall-through if overflow... + + case 'M': + inBounds = singleIncrement(_month, value, 1, 12); + _day = std::clamp(_day, 1, monthSize(_month, _year)); + if (inBounds) + break; + // else fall-through if overflow... + + case 'y': + _year += value; + break; + + default: + throw ghoul::RuntimeError( + "Invalid unit format in TQ incrementOnce '" + std::to_string(unit) + + "'. Expected 'y', 'M', 'd', 'h', or 'm'." + ); + } +} + +int DateTime::decrement(int value, char unit, double error, double resolution) { + unsigned int nDecrements = std::abs(static_cast(error / resolution)); + if (nDecrements == 0) { + nDecrements = 1; + } + for (unsigned int i = 0; i < nDecrements; ++i) { + decrementOnce(value, unit); + } + return nDecrements; +} + +void DateTime::decrementOnce(int value, char unit) { + bool inBounds = true; + switch (unit) { + case 'm': + if (singleDecrement(_minute, value, 0, 59)) { + break; + } + // else fall-through if underflow... + + case 'h': + if (singleDecrement(_hour, value, 0, 23)) { + break; + } + // else fall-through if underflow... + + case 'd': + if (singleDecrement(_day, value, 1, + monthSize(_month == 1 ? 12 : _month - 1, _year))) + { + break; + } + // else fall-through if underflow... + + case 'M': + inBounds = singleDecrement(_month, value, 1, 12); + _day = std::clamp(_day, 1, monthSize(_month, _year)); + if (inBounds) { + break; + } + // else fall-through if underflow... + + case 'y': + _year -= value; + break; + + default: + throw ghoul::RuntimeError( + "Invalid unit format in TQ decrementOnce '" + std::to_string(unit) + + "'. Expected 'y', 'M', 'd', 'h', or 'm'." + ); + } +} + +int DateTime::year() const { + return _year; +} + +int DateTime::month() const { + return _month; +} + +int DateTime::day() const { + return _day; +} + +int DateTime::hour() const { + return _hour; +} + +int DateTime::minute() const { + return _minute; +} + +int DateTime::second() const { + return _second; +} + +void DateTime::setYear(int y) { + _year = y; +} + +void DateTime::setMonth(int m) { + _month = m; +} + +void DateTime::setDay(int d) { + _day = d; +} + +void DateTime::setHour(int h) { + _hour = h; +} + +void DateTime::setMinute(int m) { + _minute = m; +} + +void DateTime::setSecond(int s) { + _second = (s > 0) ? ((s <= 59) ? s : 59) : 0; +} + +TimeQuantizer::TimeQuantizer(std::string start, std::string end, const std::string& resolution) - : TimeQuantizer(start, end, parseTimeResolutionStr(resolution)) -{} + : _start(start) + , _timerange(std::move(start), std::move(end)) +{ + verifyStartTimeRestrictions(); + _resolution = parseTimeResolutionStr(resolution); +} double TimeQuantizer::parseTimeResolutionStr(const std::string& resolutionStr) { const char unit = resolutionStr.back(); @@ -48,52 +359,158 @@ double TimeQuantizer::parseTimeResolutionStr(const std::string& resolutionStr) { char* p; double value = strtol(numberString.c_str(), &p, 10); + _resolutionValue = value; + _resolutionUnit = unit; if (*p) { // not a number throw ghoul::RuntimeError("Cannot convert " + numberString + " to number"); } else { - // convert value to seconds, based on unit. - // The switch statment has intentional fall throughs - switch (unit) { - case 'y': - value *= 365; - [[fallthrough]]; - case 'd': - value *= 24.0; - [[fallthrough]]; - case 'h': value *= 60.0; - [[fallthrough]]; - case 'm': - value *= 60.0; - [[fallthrough]]; - case 's': - value *= 1.0; - break; - default: - throw ghoul::RuntimeError( - "Invalid unit format '" + std::string(1, unit) + - "'. Expected 'y', 'd', 'h', 'm' or 's'." - ); - } - return value; + verifyResolutionRestrictions(static_cast(value), unit); + return computeSecondsFromResolution(static_cast(value), unit); } } -bool TimeQuantizer::quantize(Time& t, bool clamp) const { - const double unquantized = t.j2000Seconds(); - if (_timerange.includes(unquantized)) { - const double quantized = std::floor((unquantized - _timerange.start) / - _resolution) * - _resolution + _timerange.start; - t.setTime(quantized); +void TimeQuantizer::setStartEndRange(const std::string& start, const std::string& end) { + _start.setTime(start); + verifyStartTimeRestrictions(); + + _timerange.setStart(start); + _timerange.setEnd(end); +} + +void TimeQuantizer::setResolution(const std::string& resolutionString) { + _resolution = parseTimeResolutionStr(resolutionString); +} + +void TimeQuantizer::verifyStartTimeRestrictions() { + if (_start.day() < 1 || _start.day() > 28) { + throw ghoul::RuntimeError(fmt::format( + "Invalid start day value of {} for day of month. Valid days are 1 - 28", + _start.day() + )); + } + if (_start.hour() != 0 || _start.minute() != 0 || _start.second() != 0) { + throw ghoul::RuntimeError(fmt::format( + "Invalid start time value of {}:{}:{}. Time must be 00:00:00", + _start.hour(), _start.minute(), _start.second() + )); + } +} + +void TimeQuantizer::verifyResolutionRestrictions(const int value, const char unit) { + switch (unit) { + case 'y': + break; + case 'M': + if (value < 1 || value > 6) { + throw ghoul::RuntimeError(fmt::format( + "Invalid resolution count of {} for (M)onth option. Valid counts are " + "1, 2, 3, 4, or 6", value + )); + } + break; + case 'd': + if (value < 1 || value > 28) { + throw ghoul::RuntimeError(fmt::format( + "Invalid resolution count of {} for (d)ay option. Valid counts are " + "1 - 28", value + )); + } + break; + case 'h': + if (!(value >= 1 && value <= 4 || value == 6 || value == 12)) { + throw ghoul::RuntimeError(fmt::format( + "Invalid resolution count of {} for (h)our option. Valid counts are " + "1, 2, 3, 4, 6, or 12", value + )); + } + break; + case 'm': + if (value != 15 && value != 30) { + throw ghoul::RuntimeError(fmt::format( + "Invalid resolution count of {} for (m)inute option. Valid counts " + "are 15 or 30", value + )); + } + break; + default: + throw ghoul::RuntimeError(fmt::format( + "Invalid unit format '{}'. Expected 'y', 'M', 'd', 'h', or 'm'", unit + )); + } +} + +double TimeQuantizer::computeSecondsFromResolution(const int valueIn, const char unit) { + double value = static_cast(valueIn); + // convert value to seconds, based on unit. + // The switch statment has intentional fall throughs + switch (unit) { + case 'y': + value *= 365; + [[fallthrough]]; + case 'd': + value *= 24.0; + [[fallthrough]]; + case 'h': + value *= 60.0; + [[fallthrough]]; + case 'm': + value *= 60.0; + [[fallthrough]]; + case 's': + value *= 1.0; + break; + + case 'M': + value *= (30.4 * 24.0 * 60.0 * 60.0); + break; + + default: + throw ghoul::RuntimeError(fmt::format( + "Invalid resolution unit format '{}'. Expected 'y', 'M', 'd', 'h', 'm', " + "or 's'", unit + )); + } + return value; +} + +bool TimeQuantizer::quantize(Time& t, bool clamp) { + const std::string unquantizedStr = t.ISO8601(); + DateTime unquantized(unquantizedStr); + //resolutionFraction helps to improve iteration performance + const double resolutionFraction = 0.7; + double error = 0.0; + const int iterationLimit = 50; + int iterations = 0; + int lastIncr = 0; + int lastDecr = 0; + + if (_timerange.includes(unquantizedStr)) { + DateTime quantized = DateTime(_timerange.start()); + doFirstApproximation(quantized, unquantized, _resolutionValue, _resolutionUnit); + error = diff(quantized, unquantized); + while (error > (_resolution * resolutionFraction) || error < 0) { + if (error > 0) { + lastIncr = quantized.increment(static_cast(_resolutionValue), + _resolutionUnit, error, _resolution); + } + else if (error < 0) { + lastDecr = quantized.decrement(static_cast(_resolutionValue), + _resolutionUnit, error, _resolution); + } + error = diff(quantized, unquantized); + bool hasSettled = (lastIncr == 1 && lastDecr == 1 && error >= 0.0); + iterations++; + if (hasSettled || iterations > iterationLimit) { + break; + } + } + quantized.setTime(_timerange.clamp(quantized.ISO8601())); + t.setTime(quantized.J2000()); return true; } else if (clamp) { - const double clampedTime = glm::clamp( - unquantized, - _timerange.start, - _timerange.end - ); + const std::string clampedTime = _timerange.clamp(unquantizedStr); t.setTime(clampedTime); return true; } @@ -102,23 +519,101 @@ bool TimeQuantizer::quantize(Time& t, bool clamp) const { } } -std::vector