Commit 071b0b99 authored by Jan Möbius's avatar Jan Möbius

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
parent 62768859
......@@ -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_ );
}
......
......@@ -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.
......
......@@ -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 );
......
......@@ -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") );
......
......@@ -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_;
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment