diff --git a/include/osgPresentation/deprecated/SlideShowConstructor b/include/osgPresentation/deprecated/SlideShowConstructor index a93342cd1..a9f860e1c 100644 --- a/include/osgPresentation/deprecated/SlideShowConstructor +++ b/include/osgPresentation/deprecated/SlideShowConstructor @@ -506,7 +506,7 @@ public: osg::Switch* getCurrentSlide() { return _slide.get(); } - void pushCurrentLayer(); + void pushCurrentLayer(osg::Group* newLayerGroup); void popCurrentLayer(); osg::Group* getCurrentLayer() { return _currentLayer.get(); } diff --git a/src/osgPlugins/p3d/ReaderWriterP3D.cpp b/src/osgPlugins/p3d/ReaderWriterP3D.cpp index 8c03c43d6..1491ed009 100644 --- a/src/osgPlugins/p3d/ReaderWriterP3D.cpp +++ b/src/osgPlugins/p3d/ReaderWriterP3D.cpp @@ -42,7 +42,7 @@ public: ReaderWriterP3DXML() { supportsOption("suppressEnvTags", "if set to (true|1) all env-tags in the p3d-file will be suppressed"); - + _colorMap["WHITE"] .set(1.0f,1.0f,1.0f,1.0f); _colorMap["BLACK"] .set(0.0f,0.0f,0.0f,1.0f); _colorMap["PURPLE"] .set(1.0f,0.0f,1.0f,1.0f); @@ -114,7 +114,7 @@ public: return osgDB::equalCaseInsensitive(extension,"p3d") || osgDB::equalCaseInsensitive(extension,"xml") ; } - + virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const; @@ -133,10 +133,13 @@ public: osg::TransferFunction1D* readTransferFunctionFile(const std::string& filename, float scale) const; void parseVolume(osgPresentation::SlideShowConstructor& constructor, osgDB::XmlNode*cur) const; + void parseStereoPair(osgPresentation::SlideShowConstructor& constructor, osgDB::XmlNode*cur) const; void parseTimeout(osgPresentation::SlideShowConstructor& constructor, osgDB::XmlNode*cur) const; + void parseSwitch(osgPresentation::SlideShowConstructor& constructor, osgDB::XmlNode*cur) const; + bool parseLayerChild(osgPresentation::SlideShowConstructor& constructor, osgDB::XmlNode* cur, float& totalIndent) const; void parseLayer(osgPresentation::SlideShowConstructor& constructor, osgDB::XmlNode*cur) const; @@ -178,7 +181,7 @@ public: inline bool read(const char* str, osg::Vec2& value) const; inline bool read(const char* str, osg::Vec3& value) const; inline bool read(const char* str, osg::Vec4& value) const; - + inline bool read(const std::string& str, bool& value) const; inline bool read(const std::string& str, int& value) const; inline bool read(const std::string& str, float& value) const; @@ -1478,7 +1481,7 @@ bool ReaderWriterP3DXML::getKeyPositionInner(osgDB::XmlNode*cur, osgPresentation // v in range 0.0 to 1, from bottom to top y = v*2.0f-1.0f; } - + bool forward_to_devices = false; getProperty(cur, "forward_to_devices", forward_to_devices); @@ -1526,10 +1529,10 @@ bool ReaderWriterP3DXML::getKeyPositionInner(osgDB::XmlNode*cur, osgPresentation void ReaderWriterP3DXML::parseTimeout(osgPresentation::SlideShowConstructor& constructor, osgDB::XmlNode* root) const { - // to allow the timeout to be nested with a Layer but still behave like a Layer itself we push the timeout as a Layer, saving the original Layer - constructor.pushCurrentLayer(); + osg::ref_ptr timeout = new osgPresentation::Timeout(constructor.getHUDSettings()); - osg::ref_ptr timeout = constructor.addTimeout(); + // to allow the timeout to be nested with a Layer but still behave like a Layer itself we push the timeout as a Layer, saving the original Layer + constructor.pushCurrentLayer(timeout.get()); OSG_NOTICE<<"parseTimeout"<name == "newline") @@ -1864,6 +1867,23 @@ bool ReaderWriterP3DXML::parseLayerChild(osgPresentation::SlideShowConstructor& return false; } + +void ReaderWriterP3DXML::parseSwitch(osgPresentation::SlideShowConstructor& constructor, osgDB::XmlNode*cur) const +{ + osg::ref_ptr switchNode = new osg::Switch;; + + // to allow the timeout to be nested with a Layer but still behave like a Layer itself we push the timeout as a Layer, saving the original Layer + constructor.pushCurrentLayer(switchNode.get()); + + OSG_NOTICE<<"parseSwitch"<setSingleChildOn(0); + + constructor.popCurrentLayer(); // return the parent level +} + void ReaderWriterP3DXML::parseLayer(osgPresentation::SlideShowConstructor& constructor, osgDB::XmlNode* root) const { OSG_INFO<name == "switch") + { + parseSwitch(constructor, cur); + } else if (cur->name == "timeout") { parseTimeout(constructor, cur); diff --git a/src/osgPresentation/deprecated/SlideShowConstructor.cpp b/src/osgPresentation/deprecated/SlideShowConstructor.cpp index 7c520a4d9..3d29447e1 100644 --- a/src/osgPresentation/deprecated/SlideShowConstructor.cpp +++ b/src/osgPresentation/deprecated/SlideShowConstructor.cpp @@ -409,18 +409,16 @@ void SlideShowConstructor::setSlideDuration(double duration) } } - -Timeout* SlideShowConstructor::addTimeout() +void SlideShowConstructor::pushCurrentLayer(osg::Group* group) { - osg::ref_ptr timeout = new osgPresentation::Timeout(_hudSettings.get()); - if (_currentLayer.valid()) _currentLayer->addChild(timeout.get()); - _currentLayer = timeout.get(); - return timeout.release(); -} + if (_currentLayer.valid()) + { + _currentLayer->addChild(group); + _layerStack.push_back(_currentLayer.get()); + } + + _currentLayer = group; -void SlideShowConstructor::pushCurrentLayer() -{ - _layerStack.push_back(_currentLayer.get()); } void SlideShowConstructor::popCurrentLayer() @@ -430,6 +428,10 @@ void SlideShowConstructor::popCurrentLayer() _currentLayer = _layerStack.back(); _layerStack.pop_back(); } + else + { + _currentLayer = 0; + } } void SlideShowConstructor::addLayer(bool inheritPreviousLayers, bool defineAsBaseLayer)