From 071b0b9986c5a4a517f541412a7b38423377d701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Mon, 5 Apr 2010 23:06:11 +0000 Subject: [PATCH] Added global status nodes for new light handling git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@8910 383ad7c9-94d9-4d36-a494-682f7c89f535 --- BasePlugin/PluginFunctions.cc | 34 ++++++++++++++++++++++++++++++- BasePlugin/PluginFunctions.hh | 31 +++++++++++++++++++++++++++- BasePlugin/PluginFunctionsCore.hh | 12 ++++++++++- Core/Core.cc | 12 +++++++++-- Core/Core.hh | 3 +++ widgets/glWidget/QtBaseViewer.cc | 4 ++++ 6 files changed, 91 insertions(+), 5 deletions(-) diff --git a/BasePlugin/PluginFunctions.cc b/BasePlugin/PluginFunctions.cc index c7d50e81..b84168ee 100644 --- a/BasePlugin/PluginFunctions.cc +++ b/BasePlugin/PluginFunctions.cc @@ -81,6 +81,8 @@ static glViewer* examiner_widget_; /// Contains the currently active examiner static unsigned int activeExaminer_ = 0; +static bool internalLightHandling_ = true; + /** \brief DONT USE DIRECTLY!! * * The pointer to the beginning of the scenegraph nodes ( only the nodes belonging to objects ) @@ -94,6 +96,10 @@ static SeparatorNode* dataRootNode_ = 0; */ static SeparatorNode* dataSeparatorNode_ = 0; +/** \brief Scenegraph global nodes root + */ +static SeparatorNode* sceneGraphRootNodeGlobal_ = 0; + /** \brief Scenegraph root node */ static SeparatorNode* sceneGraphRootNode_ = 0; @@ -137,6 +143,14 @@ int viewers( ) { return examiner_widgets_.size(); } +void disableExaminerLightHandling() { + internalLightHandling_ = false; +} + +bool examinerLightHandling() { + return internalLightHandling_; +} + int viewerId() { return viewerId_; } @@ -230,6 +244,10 @@ void setSceneGraphRootNode( SeparatorNode* _root_node ) { PluginFunctions::sceneGraphRootNode_ = _root_node; } +void setSceneGraphRootNodeGlobal( SeparatorNode* _root_node ) { + PluginFunctions::sceneGraphRootNodeGlobal_ = _root_node; +} + bool getPickedObject(const unsigned int _node_idx , BaseObjectData*& _object) { for ( ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) { if ( o_it->picked( _node_idx ) ) { @@ -815,9 +833,23 @@ ACG::SceneGraph::BaseNode* getRootNode() { return PluginFunctions::dataRootNode_; } +void addGlobalStatusNode(ACG::SceneGraph::BaseNode* _node) { + if (PluginFunctions::sceneGraphRootNode_){ + + // get the current parent Node + ACG::SceneGraph::BaseNode* parent = sceneGraphRootNodeGlobal_->parent(); + + // Move the node to the new parent + _node->set_parent(parent); + + // move dataRootNode_ to the new parent + sceneGraphRootNodeGlobal_->set_parent(_node); + } +} + void addGlobalNode(ACG::SceneGraph::BaseNode* _node){ if (PluginFunctions::sceneGraphRootNode_) - _node->set_parent( PluginFunctions::sceneGraphRootNode_ ); + _node->set_parent( PluginFunctions::sceneGraphRootNodeGlobal_ ); } diff --git a/BasePlugin/PluginFunctions.hh b/BasePlugin/PluginFunctions.hh index 99ddf60f..4292e830 100644 --- a/BasePlugin/PluginFunctions.hh +++ b/BasePlugin/PluginFunctions.hh @@ -189,6 +189,24 @@ int visibleCount(); DLLEXPORT int viewers( ); +/** \brief Disable the core light handling +* +* Use this function to disable OpenFlippers Core light handling. +* Use this function only if the light is handled by your plugin +* Normally this function is called by the light plugin which +* fully takes control over the glLighting and adds its own light nodes. +*/ +DLLEXPORT +void disableExaminerLightHandling(); + +/** \brief returns if internal light handling is active. +* +* Internal light handling could only be deactivated. From than on a plugin +* has to manage all light handling. +*/ +DLLEXPORT +bool examinerLightHandling(); + /// Set the active id of the examiner which got the last mouse events DLLEXPORT void setActiveExaminer( const unsigned int _id ); @@ -295,10 +313,21 @@ ACG::SceneGraph::BaseNode* getSceneGraphRootNode(); DLLEXPORT ACG::SceneGraph::BaseNode* getRootNode(); -/// Add a node under the root node +/** \brief Add a global node +* +* The node will be added as a global node. Only the global status nodes +* will be above this node. +*/ DLLEXPORT void addGlobalNode(ACG::SceneGraph::BaseNode* _node); +/** \brief Adds a global status node. +* +* The node will be added at the top of the scenegraph, before all other nodes except +* The scenegraphs real node. It will therefore influence all nodes in the scenegraph. +*/ +void addGlobalStatusNode(ACG::SceneGraph::BaseNode* _node); + /** \brief Add scenegraph node modifing object rendering * * This function adds nodes in front of the object root node. diff --git a/BasePlugin/PluginFunctionsCore.hh b/BasePlugin/PluginFunctionsCore.hh index 8f55508b..97dda80a 100644 --- a/BasePlugin/PluginFunctionsCore.hh +++ b/BasePlugin/PluginFunctionsCore.hh @@ -83,10 +83,20 @@ glViewer* viewer(int _viewerId ); DLLEXPORT void setViewerProperties( std::vector< Viewer::ViewerProperties* > _viewerProperties ); -/// Set the internal scenegraph root node pointer ( DO NOT USE!! ) +/** Set the internal scenegraph root node pointer. This is the topmost +* node of the whole scenegraph ( DO NOT USE!! ) +*/ DLLEXPORT void setSceneGraphRootNode( SeparatorNode* _root_node ); +/** Set the internal scenegraph root node pointer for global nodes +* +* This node is below the global status nodes and takes global nodes +* at one level. ( DO NOT USE!! ) +*/ +DLLEXPORT +void setSceneGraphRootNodeGlobal( SeparatorNode* _root_node ); + /// Set the internal data root node pointers ( DO NOT USE!! ) DLLEXPORT void setDataSeparatorNodes( SeparatorNode* _dataRootNode ); diff --git a/Core/Core.cc b/Core/Core.cc index f5a2216e..d76345f1 100644 --- a/Core/Core.cc +++ b/Core/Core.cc @@ -133,8 +133,11 @@ Core() : //init nodes root_node_scenegraph_ = new ACG::SceneGraph::SeparatorNode(0, "SceneGraph Root Node"); + // init global data node + root_node_scenegraph_global_ = new ACG::SceneGraph::SeparatorNode(root_node_scenegraph_ , "SceneGraph Root Node"); + // This seperator will manage the cores nodes - core_nodes_ = new ACG::SceneGraph::SeparatorNode(root_node_scenegraph_, "Core Nodes"); + core_nodes_ = new ACG::SceneGraph::SeparatorNode(root_node_scenegraph_global_, "Core Nodes"); // Coordsys rendering nodes coordsysMaterialNode_ = new ACG::SceneGraph::MaterialNode(core_nodes_,"Coordsys Material Node"); @@ -142,7 +145,7 @@ Core() : coordsysNode_->setTraverseMode (BaseNode::NodeFirst | BaseNode::SecondPass); // seperator handling the nodes for data - dataSeparatorNode_ = new ACG::SceneGraph::SeparatorNode(root_node_scenegraph_, "Data Separator Root Node"); + dataSeparatorNode_ = new ACG::SceneGraph::SeparatorNode(root_node_scenegraph_global_, "Data Separator Root Node"); // seperator handling the nodes for data dataRootNode_ = new ACG::SceneGraph::SeparatorNode(dataSeparatorNode_, "Data Root Node"); @@ -209,7 +212,12 @@ Core::init() { // Make root_node available to the plugins ( defined in PluginFunctions.hh) PluginFunctions::setDataSeparatorNodes( dataSeparatorNode_ ); + // Topmost node of the scenegraph PluginFunctions::setSceneGraphRootNode( root_node_scenegraph_ ); + + // Node below the global status nodes. All nodes with global rendering + // will be attached here. + PluginFunctions::setSceneGraphRootNodeGlobal(root_node_scenegraph_global_); // Initialize the first object as the root Object for the object tree objectRoot_ = dynamic_cast< BaseObject* > ( new GroupObject("ObjectRoot") ); diff --git a/Core/Core.hh b/Core/Core.hh index 674340c7..0e9c2a2b 100644 --- a/Core/Core.hh +++ b/Core/Core.hh @@ -653,6 +653,9 @@ private slots: private: /// Scenegraphs root node SeparatorNode* root_node_scenegraph_; + + /// Seperator node for global nodes + SeparatorNode* root_node_scenegraph_global_; /// Separator Node holding all core scenegraph nodes SeparatorNode* core_nodes_; diff --git a/widgets/glWidget/QtBaseViewer.cc b/widgets/glWidget/QtBaseViewer.cc index bd09ea31..021ac79f 100644 --- a/widgets/glWidget/QtBaseViewer.cc +++ b/widgets/glWidget/QtBaseViewer.cc @@ -1051,6 +1051,10 @@ void glViewer::draw_lights() { void glViewer::update_lights() { + // PluginFunction can disable the cores light handling and use its own one + if (!PluginFunctions::examinerLightHandling() ) + return; + makeCurrent(); glMatrixMode(GL_MODELVIEW); -- GitLab