Added <switch> tag to .p3d to allow one to provide multiple ways to render children within a layer.
This commit is contained in:
parent
a72508bc71
commit
865a47bd6b
@ -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(); }
|
||||
|
@ -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;
|
||||
@ -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<osgPresentation::Timeout> timeout = new osgPresentation::Timeout(constructor.getHUDSettings());
|
||||
|
||||
osg::ref_ptr<osgPresentation::Timeout> 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"<<std::endl;
|
||||
|
||||
@ -1641,10 +1644,10 @@ void ReaderWriterP3DXML::parseTimeout(osgPresentation::SlideShowConstructor& con
|
||||
|
||||
}
|
||||
|
||||
|
||||
constructor.popCurrentLayer(); // return the
|
||||
constructor.popCurrentLayer(); // return the parent level
|
||||
}
|
||||
|
||||
|
||||
bool ReaderWriterP3DXML::parseLayerChild(osgPresentation::SlideShowConstructor& constructor, osgDB::XmlNode* cur, float& totalIndent) const
|
||||
{
|
||||
if (cur->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<osg::Switch> 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"<<std::endl;
|
||||
|
||||
parseLayer(constructor, cur);
|
||||
|
||||
switchNode->setSingleChildOn(0);
|
||||
|
||||
constructor.popCurrentLayer(); // return the parent level
|
||||
}
|
||||
|
||||
void ReaderWriterP3DXML::parseLayer(osgPresentation::SlideShowConstructor& constructor, osgDB::XmlNode* root) const
|
||||
{
|
||||
OSG_INFO<<std::endl<<"parseLayer"<<std::endl;
|
||||
@ -1890,6 +1910,10 @@ void ReaderWriterP3DXML::parseLayer(osgPresentation::SlideShowConstructor& const
|
||||
{
|
||||
// no need to do anything
|
||||
}
|
||||
else if (cur->name == "switch")
|
||||
{
|
||||
parseSwitch(constructor, cur);
|
||||
}
|
||||
else if (cur->name == "timeout")
|
||||
{
|
||||
parseTimeout(constructor, cur);
|
||||
|
@ -409,18 +409,16 @@ void SlideShowConstructor::setSlideDuration(double duration)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Timeout* SlideShowConstructor::addTimeout()
|
||||
void SlideShowConstructor::pushCurrentLayer(osg::Group* group)
|
||||
{
|
||||
osg::ref_ptr<osgPresentation::Timeout> 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());
|
||||
}
|
||||
|
||||
void SlideShowConstructor::pushCurrentLayer()
|
||||
{
|
||||
_layerStack.push_back(_currentLayer.get());
|
||||
_currentLayer = group;
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user