diff --git a/include/osgPresentation/PropertyManager b/include/osgPresentation/PropertyManager index 47a402188..a0154fa3c 100644 --- a/include/osgPresentation/PropertyManager +++ b/include/osgPresentation/PropertyManager @@ -89,6 +89,7 @@ extern OSGPRESENTATION_EXPORT bool containsPropertyReference(const std::string& struct PropertyReader { PropertyReader(const osg::NodePath& nodePath, const std::string& str): + _errorGenerated(false), _nodePath(nodePath), _sstream(str) {} @@ -117,11 +118,12 @@ struct PropertyReader } template - PropertyReader& operator>>( T& value ) { read(value); return *this; } + PropertyReader& operator>>( T& value ) { if (!read(value)) _errorGenerated=true; return *this; } - bool ok() { return !_sstream.fail(); } - bool fail() { return _sstream.fail(); } + bool ok() { return !_sstream.fail() && !_errorGenerated; } + bool fail() { return _sstream.fail() || _errorGenerated; } + bool _errorGenerated; osg::NodePath _nodePath; std::istringstream _sstream; }; diff --git a/include/osgPresentation/SlideShowConstructor b/include/osgPresentation/SlideShowConstructor index 28ed5cab0..7f3047306 100644 --- a/include/osgPresentation/SlideShowConstructor +++ b/include/osgPresentation/SlideShowConstructor @@ -255,7 +255,8 @@ public: blendingHint(USE_IMAGE_ALPHA), delayTime(0.0), startTime(0.0), - stopTime(-1.0) + stopTime(-1.0), + volume("") {} std::string options; @@ -293,6 +294,7 @@ public: double delayTime; double startTime; double stopTime; + std::string volume; }; @@ -499,6 +501,7 @@ protected: void findImageStreamsAndAddCallbacks(osg::Node* node); osg::Geometry* createTexturedQuadGeometry(const osg::Vec3& pos, const osg::Vec4& rotation, float width,float height, osg::Image* image, bool& usedTextureRectangle); + void setUpMovieVolume(osg::Node* subgraph, osg::ImageStream* imageStream, const ImageData& imageData); osg::Vec3 computePositionInModelCoords(const PositionData& positionData) const; void updatePositionFromInModelCoords(const osg::Vec3& vertex, PositionData& positionData) const; diff --git a/src/osgPlugins/p3d/ReaderWriterP3D.cpp b/src/osgPlugins/p3d/ReaderWriterP3D.cpp index f28c0c194..105c66567 100644 --- a/src/osgPlugins/p3d/ReaderWriterP3D.cpp +++ b/src/osgPlugins/p3d/ReaderWriterP3D.cpp @@ -974,6 +974,12 @@ bool ReaderWriterP3DXML::getProperties(osgDB::XmlNode*cur, osgPresentation::Slid OSG_NOTIFY(_notifyLevel)<<"read stop \""<getNodePath(), _source); + + float volume=0.0f; + pr>>volume; + + if (pr.ok()) + { + OSG_NOTICE<<"VolumeCallback : volume="<setVolume(volume); + } + else + { + OSG_NOTICE<<"Problem in reading, VolumeCallback : volume="< _movie; + std::string _source; +}; + +void SlideShowConstructor::setUpMovieVolume(osg::Node* subgraph, osg::ImageStream* imageStream, const ImageData& imageData) +{ + if (containsPropertyReference(imageData.volume)) + { + subgraph->addUpdateCallback(new VolumeCallback(imageStream, imageData.volume)); + } + else + { + float volume; + std::istringstream sstream(imageData.volume); + sstream>>volume; + + if (!sstream.fail()) + { + OSG_NOTICE<<"Setting volume "<setVolume( volume ); + } + else + { + OSG_NOTICE<<"Invalid volume setting: "<setMode(GL_BLEND, osg::StateAttribute::ON); } + + if (imageStream && !imageData.volume.empty()) + { + setUpMovieVolume(subgraph, imageStream, imageData); + } + osg::ImageSequence* imageSequence = dynamic_cast(image.get()); if (imageSequence) { @@ -1418,6 +1485,16 @@ void SlideShowConstructor::addStereoImagePair(const std::string& filenameLeft, c subgraph->addChild(pictureLeft); subgraph->addChild(pictureRight); + if (imageStreamLeft && !imageDataLeft.volume.empty()) + { + setUpMovieVolume(subgraph, imageStreamLeft, imageDataLeft); + } + + if (imageStreamRight && !imageDataRight.volume.empty()) + { + setUpMovieVolume(subgraph, imageStreamRight, imageDataRight); + } + osg::ImageSequence* imageSequence = dynamic_cast(imageLeft.get()); if (imageSequence) { @@ -1775,6 +1852,7 @@ std::string SlideShowConstructor::findFileAndRecordPath(const std::string& filen } + struct ClipRegionCallback : public osg::NodeCallback { public: