From d37bf97592c830accfd0f5f266a4652e8fed5c7b Mon Sep 17 00:00:00 2001 From: Christian Adamsson Date: Tue, 28 Jul 2020 09:36:24 +0200 Subject: [PATCH] Created and moved files to separate module for streamnodes --- modules/fieldlinessequence/CMakeLists.txt | 8 --- .../fieldlinessequencemodule.cpp | 4 -- modules/streamnodes/CMakeLists.txt | 51 ++++++++++++++ modules/streamnodes/include.cmake | 3 + .../rendering/renderablelighttravel.cpp | 6 +- .../rendering/renderablelighttravel.h | 0 .../rendering/renderablestreamnodes.cpp | 6 +- .../rendering/renderablestreamnodes.h | 0 .../shaders/lighttravel_fs.glsl | 0 .../shaders/lighttravel_vs.glsl | 0 .../shaders/streamnodes_fs.glsl | 0 .../shaders/streamnodes_vs.glsl | 0 modules/streamnodes/streamnodesmodule.cpp | 67 +++++++++++++++++++ modules/streamnodes/streamnodesmodule.h | 46 +++++++++++++ 14 files changed, 173 insertions(+), 18 deletions(-) create mode 100644 modules/streamnodes/CMakeLists.txt create mode 100644 modules/streamnodes/include.cmake rename modules/{fieldlinessequence => streamnodes}/rendering/renderablelighttravel.cpp (98%) rename modules/{fieldlinessequence => streamnodes}/rendering/renderablelighttravel.h (100%) rename modules/{fieldlinessequence => streamnodes}/rendering/renderablestreamnodes.cpp (99%) rename modules/{fieldlinessequence => streamnodes}/rendering/renderablestreamnodes.h (100%) rename modules/{fieldlinessequence => streamnodes}/shaders/lighttravel_fs.glsl (100%) rename modules/{fieldlinessequence => streamnodes}/shaders/lighttravel_vs.glsl (100%) rename modules/{fieldlinessequence => streamnodes}/shaders/streamnodes_fs.glsl (100%) rename modules/{fieldlinessequence => streamnodes}/shaders/streamnodes_vs.glsl (100%) create mode 100644 modules/streamnodes/streamnodesmodule.cpp create mode 100644 modules/streamnodes/streamnodesmodule.h diff --git a/modules/fieldlinessequence/CMakeLists.txt b/modules/fieldlinessequence/CMakeLists.txt index 33456b7fc0..9af2549997 100644 --- a/modules/fieldlinessequence/CMakeLists.txt +++ b/modules/fieldlinessequence/CMakeLists.txt @@ -29,28 +29,20 @@ set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/util/fieldlinesstate.h ${CMAKE_CURRENT_SOURCE_DIR}/util/commons.h ${CMAKE_CURRENT_SOURCE_DIR}/util/kameleonfieldlinehelper.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablestreamnodes.h - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablelighttravel.h ) source_group("Header Files" FILES ${HEADER_FILES}) set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablefieldlinessequence.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablestreamnodes.cpp ${CMAKE_CURRENT_SOURCE_DIR}/util/fieldlinesstate.cpp ${CMAKE_CURRENT_SOURCE_DIR}/util/commons.cpp ${CMAKE_CURRENT_SOURCE_DIR}/util/kameleonfieldlinehelper.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablelighttravel.cpp ) source_group("Source Files" FILES ${SOURCE_FILES}) set(SHADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/shaders/fieldlinessequence_vs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/fieldlinessequence_fs.glsl - ${CMAKE_CURRENT_SOURCE_DIR}/shaders/streamnodes_fs.glsl - ${CMAKE_CURRENT_SOURCE_DIR}/shaders/streamnodes_vs.glsl - ${CMAKE_CURRENT_SOURCE_DIR}/shaders/lighttravel_fs.glsl - ${CMAKE_CURRENT_SOURCE_DIR}/shaders/lighttravel_vs.glsl ) source_group("Shader Files" FILES ${SHADER_FILES}) diff --git a/modules/fieldlinessequence/fieldlinessequencemodule.cpp b/modules/fieldlinessequence/fieldlinessequencemodule.cpp index 058a1c9504..6fd64755c1 100644 --- a/modules/fieldlinessequence/fieldlinessequencemodule.cpp +++ b/modules/fieldlinessequence/fieldlinessequencemodule.cpp @@ -25,8 +25,6 @@ #include #include -#include -#include #include #include #include @@ -63,8 +61,6 @@ void FieldlinesSequenceModule::internalInitialize(const ghoul::Dictionary&) { ghoul_assert(factory, "No renderable factory existed"); factory->registerClass("RenderableFieldlinesSequence"); - factory->registerClass("RenderableStreamNodes"); - factory->registerClass("RenderableLightTravel"); } } // namespace openspace diff --git a/modules/streamnodes/CMakeLists.txt b/modules/streamnodes/CMakeLists.txt new file mode 100644 index 0000000000..3bed2ec546 --- /dev/null +++ b/modules/streamnodes/CMakeLists.txt @@ -0,0 +1,51 @@ +########################################################################################## +# # +# 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(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) + +set(HEADER_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablestreamnodes.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablelighttravel.h +) +source_group("Header Files" FILES ${HEADER_FILES}) + +set(SOURCE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablestreamnodes.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablelighttravel.cpp +) +source_group("Source Files" FILES ${SOURCE_FILES}) + +set(SHADER_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/shaders/streamnodes_fs.glsl + ${CMAKE_CURRENT_SOURCE_DIR}/shaders/streamnodes_vs.glsl + ${CMAKE_CURRENT_SOURCE_DIR}/shaders/lighttravel_fs.glsl + ${CMAKE_CURRENT_SOURCE_DIR}/shaders/lighttravel_vs.glsl +) +source_group("Shader Files" FILES ${SHADER_FILES}) + +create_new_module( + "StreamNodes" + streamnodes_module + ${HEADER_FILES} ${SOURCE_FILES} ${SHADER_FILES} +) diff --git a/modules/streamnodes/include.cmake b/modules/streamnodes/include.cmake new file mode 100644 index 0000000000..a746e4569e --- /dev/null +++ b/modules/streamnodes/include.cmake @@ -0,0 +1,3 @@ +set (OPENSPACE_DEPENDENCIES + space +) diff --git a/modules/fieldlinessequence/rendering/renderablelighttravel.cpp b/modules/streamnodes/rendering/renderablelighttravel.cpp similarity index 98% rename from modules/fieldlinessequence/rendering/renderablelighttravel.cpp rename to modules/streamnodes/rendering/renderablelighttravel.cpp index aab9d27cae..f0823bbd37 100644 --- a/modules/fieldlinessequence/rendering/renderablelighttravel.cpp +++ b/modules/streamnodes/rendering/renderablelighttravel.cpp @@ -22,7 +22,7 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ //including our own h file -#include +#include // Includes from fieldlinessequence, might not need all of them #include @@ -156,8 +156,8 @@ void RenderableLightTravel::initializeGL() { _dictionary.reset(); _shaderProgram = global::renderEngine.buildRenderProgram( "Lighttravel", - absPath("${MODULE_FIELDLINESSEQUENCE}/shaders/lighttravel_vs.glsl"), - absPath("${MODULE_FIELDLINESSEQUENCE}/shaders/lighttravel_fs.glsl") + absPath("${MODULE_STREAMNODES}/shaders/lighttravel_vs.glsl"), + absPath("${MODULE_STREAMNODES}/shaders/lighttravel_fs.glsl") ); if(_font == nullptr){ diff --git a/modules/fieldlinessequence/rendering/renderablelighttravel.h b/modules/streamnodes/rendering/renderablelighttravel.h similarity index 100% rename from modules/fieldlinessequence/rendering/renderablelighttravel.h rename to modules/streamnodes/rendering/renderablelighttravel.h diff --git a/modules/fieldlinessequence/rendering/renderablestreamnodes.cpp b/modules/streamnodes/rendering/renderablestreamnodes.cpp similarity index 99% rename from modules/fieldlinessequence/rendering/renderablestreamnodes.cpp rename to modules/streamnodes/rendering/renderablestreamnodes.cpp index bd615cafb0..53d6f221a1 100644 --- a/modules/fieldlinessequence/rendering/renderablestreamnodes.cpp +++ b/modules/streamnodes/rendering/renderablestreamnodes.cpp @@ -22,7 +22,7 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ //including our own h file -#include +#include // Includes from fieldlinessequence, might not need all of them #include @@ -577,8 +577,8 @@ void RenderableStreamNodes::initializeGL() { // Setup shader program _shaderProgram = global::renderEngine.buildRenderProgram( "Streamnodes", - absPath("${MODULE_FIELDLINESSEQUENCE}/shaders/streamnodes_vs.glsl"), - absPath("${MODULE_FIELDLINESSEQUENCE}/shaders/streamnodes_fs.glsl") + absPath("${MODULE_STREAMNODES}/shaders/streamnodes_vs.glsl"), + absPath("${MODULE_STREAMNODES}/shaders/streamnodes_fs.glsl") ); _uniformCache.streamColor = _shaderProgram->uniformLocation("streamColor"); diff --git a/modules/fieldlinessequence/rendering/renderablestreamnodes.h b/modules/streamnodes/rendering/renderablestreamnodes.h similarity index 100% rename from modules/fieldlinessequence/rendering/renderablestreamnodes.h rename to modules/streamnodes/rendering/renderablestreamnodes.h diff --git a/modules/fieldlinessequence/shaders/lighttravel_fs.glsl b/modules/streamnodes/shaders/lighttravel_fs.glsl similarity index 100% rename from modules/fieldlinessequence/shaders/lighttravel_fs.glsl rename to modules/streamnodes/shaders/lighttravel_fs.glsl diff --git a/modules/fieldlinessequence/shaders/lighttravel_vs.glsl b/modules/streamnodes/shaders/lighttravel_vs.glsl similarity index 100% rename from modules/fieldlinessequence/shaders/lighttravel_vs.glsl rename to modules/streamnodes/shaders/lighttravel_vs.glsl diff --git a/modules/fieldlinessequence/shaders/streamnodes_fs.glsl b/modules/streamnodes/shaders/streamnodes_fs.glsl similarity index 100% rename from modules/fieldlinessequence/shaders/streamnodes_fs.glsl rename to modules/streamnodes/shaders/streamnodes_fs.glsl diff --git a/modules/fieldlinessequence/shaders/streamnodes_vs.glsl b/modules/streamnodes/shaders/streamnodes_vs.glsl similarity index 100% rename from modules/fieldlinessequence/shaders/streamnodes_vs.glsl rename to modules/streamnodes/shaders/streamnodes_vs.glsl diff --git a/modules/streamnodes/streamnodesmodule.cpp b/modules/streamnodes/streamnodesmodule.cpp new file mode 100644 index 0000000000..4674e87173 --- /dev/null +++ b/modules/streamnodes/streamnodesmodule.cpp @@ -0,0 +1,67 @@ +/***************************************************************************************** + * * + * 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 + +namespace { + constexpr const char* DefaultTransferfunctionSource = +R"( +width 5 +lower 0.0 +upper 1.0 +mappingkey 0.0 0 0 0 255 +mappingkey 0.25 255 0 0 255 +mappingkey 0.5 255 140 0 255 +mappingkey 0.75 255 255 0 255 +mappingkey 1.0 255 255 255 255 +)"; +} // namespace + +namespace openspace { + +std::string StreamNodesModule::DefaultTransferFunctionFile = ""; + +StreamNodesModule::StreamNodesModule() : OpenSpaceModule(Name) { + DefaultTransferFunctionFile = absPath("${TEMPORARY}/default_transfer_function.txt"); + + std::ofstream file(DefaultTransferFunctionFile); + file << DefaultTransferfunctionSource; +} + +void StreamNodesModule::internalInitialize(const ghoul::Dictionary&) { + auto factory = FactoryManager::ref().factory(); + ghoul_assert(factory, "No renderable factory existed"); + + factory->registerClass("RenderableStreamNodes"); + factory->registerClass("RenderableLightTravel"); +} + +} // namespace openspace diff --git a/modules/streamnodes/streamnodesmodule.h b/modules/streamnodes/streamnodesmodule.h new file mode 100644 index 0000000000..fbf15b7d2e --- /dev/null +++ b/modules/streamnodes/streamnodesmodule.h @@ -0,0 +1,46 @@ +/***************************************************************************************** + * * + * 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_STREAMNODES___STREAMNODESMODULE___H__ +#define __OPENSPACE_MODULE_STREAMNODES___STREAMNODESMODULE___H__ + +#include + +namespace openspace { + +class StreamNodesModule : public OpenSpaceModule { +public: + constexpr static const char* Name = "StreamNodes"; + + StreamNodesModule(); + + static std::string DefaultTransferFunctionFile; + +private: + void internalInitialize(const ghoul::Dictionary&) override; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_STREAMNODES___STREAMNODESMODULE___H__