diff --git a/src/Mara/RadiumPlayer.cpp b/src/Mara/RadiumPlayer.cpp index 351781f0f24b1c8a5a927b8c86d2e87acf04fa4f..6d93ff075facbbada9471a927c9de78d1ba16d54 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 993512937d6cacf7b093d2f432d65c9d60af0fa2..bfe42aea8a929a8202f86a37fc418a72b6dc5497 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 ccb7ed1c191751415627ab9d24825c07baa63089..bc82db946ecedaf1c7e72217814b745f64a14c8d 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; } }