From 3f1eab1571bf99686acdd2228ca46a7b748da085 Mon Sep 17 00:00:00 2001 From: Mathias Paulin <mathias.paulin@irit.fr> Date: Thu, 3 Feb 2022 15:33:01 +0100 Subject: [PATCH] [demo] commit to be removed --- src/Mara/RadiumPlayer.cpp | 42 +++++++++++++++++++ .../RadiumNBR/Gui/NodeGraphControllerGui.cpp | 5 ++- .../RenderGraphEditorView.cpp | 10 ++++- 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/src/Mara/RadiumPlayer.cpp b/src/Mara/RadiumPlayer.cpp index 351781f..6d93ff0 100644 --- a/src/Mara/RadiumPlayer.cpp +++ b/src/Mara/RadiumPlayer.cpp @@ -34,6 +34,31 @@ using namespace Ra::Core::Utils; // for LOG( logLEVEL ) # include <RadiumH3D/h3DLoader.hpp> #endif +// This is temporary; must be removed with the appropriate API to make this +#define SEMINARDEMO +#ifdef SEMINARDEMO + +#include <Engine/Data/RenderParameters.hpp> +#include <Engine/Data/Material.hpp> +#include <Engine/Data/ShaderConfigFactory.hpp> +#include <RadiumNBR/Gui/RenderGraphEditor/NodeAdapterModel.hpp> +#include <RadiumNBR/NodeGraph/PremadeNodes/Demo/SimpleNode.hpp> +#include <RadiumNBR/NodeGraph/PremadeNodes/Demo/DifferenceNode.hpp> + +template <typename T> +class NodeCreator +{ + public: + NodeCreator( RenderGraph* renderGraph ) : m_renderGraph( renderGraph ) {} + + std::unique_ptr<T> operator()() { return std::make_unique<T>( m_renderGraph ); } + + private: + RenderGraph* m_renderGraph; +}; + +#endif + namespace Mara { RadiumPlayer::RadiumPlayer( int& argc, char** argv ) : @@ -155,6 +180,8 @@ void RadiumPlayer::engineOpenGLInitialize() { addRenderers(); } + + void RadiumPlayer::addRenderers() { auto mainWindow = dynamic_cast<MainWindow*>( m_mainWindow.get() ); // add MultipassRenderer with controler renderer @@ -173,6 +200,21 @@ void RadiumPlayer::addRenderers() { { // 1 - Initialize the base node graph system NodeFactory::initializeNodeFactory(); + + #ifdef SEMINARDEMO + // Demo + NodeFactory::registerNode<SimpleNode>( []( const nlohmann::json& data ) { + auto simpleNode = + new SimpleNode( "SimpleNode" + std::to_string( NodeFactory::newNodeId() ) ); + return simpleNode; + } ); + + NodeFactory::registerNode<DifferenceNode>( []( const nlohmann::json& data ) { + auto differenceNode = + new DifferenceNode( "DifferenceNode" + std::to_string( NodeFactory::newNodeId() ) ); + return differenceNode; + } ); + #endif // 2 - Initialize the renderer using default or customized NodeGraphController auto renderControl = new RadiumNBR::NodeGraphController; auto myRenderer = std::make_shared<RadiumNBR::NodeBasedRenderer>( *renderControl ); diff --git a/src/libRender/RadiumNBR/Gui/NodeGraphControllerGui.cpp b/src/libRender/RadiumNBR/Gui/NodeGraphControllerGui.cpp index 9935129..bfe42ae 100644 --- a/src/libRender/RadiumNBR/Gui/NodeGraphControllerGui.cpp +++ b/src/libRender/RadiumNBR/Gui/NodeGraphControllerGui.cpp @@ -8,6 +8,7 @@ #include <QFileDialog> + namespace RadiumNBR { using namespace Gui; @@ -21,7 +22,9 @@ RadiumNBR::Gui::RendererPanel* buildNodeGraphControllerGui( NodeBasedRenderer* r auto nodeEditor = new RenderGraphEditorView( nullptr ); nodeEditor->current = renderer; - nodeEditor->scene->setRegistry( NodeGraphQtEditor::initializeNodeRegistry( renderer->getRenderGraph() ) ); + auto editorRegistry = NodeGraphQtEditor::initializeNodeRegistry( renderer->getRenderGraph() ); + nodeEditor->scene->setRegistry( editorRegistry ); + // TODO: find a way to refresh the main window when a widget gets updated instead of // when the mouse moves nodeEditor->connections.push_back( diff --git a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/RenderGraphEditorView.cpp b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/RenderGraphEditorView.cpp index ccb7ed1..bc82db9 100644 --- a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/RenderGraphEditorView.cpp +++ b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/RenderGraphEditorView.cpp @@ -272,7 +272,15 @@ std::shared_ptr<DataModelRegistry> initializeNodeRegistry(RenderGraph* renderGra ret->registerModel<NodeAdapterModel<DisplaySinkNode>>( NodeCreator<NodeAdapterModel<DisplaySinkNode>>( renderGraph ), "Sinks" ); - +#define SEMINARDEMO +#ifdef SEMINARDEMO + ret->registerModel<NodeAdapterModel<SimpleNode>>( + NodeCreator<NodeAdapterModel<SimpleNode>>( renderGraph ), + "Custom Nodes" ); + ret->registerModel<NodeAdapterModel<DifferenceNode>>( + NodeCreator<NodeAdapterModel<DifferenceNode>>( renderGraph ), + "Custom Nodes" ); +#endif return ret; } } -- GitLab