1. openscenegraph
  2. osg

Commits

rob...@16af8721-9629-0410-8352-f15c8da7e697  committed 6d8b081 Draft

Added ImageStream support to <image> and <stereo_image> tags in .p3d

  • Participants
  • Parent commits 8ff2a96
  • Branches default

Comments (0)

Files changed (3)

File include/osgPresentation/SlideShowConstructor

View file
 
     void addParagraph(const std::string& paragraph, PositionData& positionData, FontData& fontData);
 
+    osg::Image* readImage(const std::string& filename, const ImageData& imageData);
+
     void addImage(const std::string& filename,const PositionData& positionData, const ImageData& imageData);
 
     void addStereoImagePair(const std::string& filenameLeft, const ImageData& imageDataLeft, const std::string& filenameRight,const ImageData& imageDataRight, const PositionData& positionData);

File src/osgPlugins/p3d/ReaderWriterP3D.cpp

View file
     if (getProperty(cur, "fps", value.fps))
     {
         propertiesRead = true;
-        OSG_NOTIFY(osg::NOTICE)<<"read fps \""<<value.fps<<"\""<<std::endl;
+        OSG_NOTIFY(_notifyLevel)<<"read fps \""<<value.fps<<"\""<<std::endl;
     }
 
     if (getProperty(cur, "duration", value.duration))
     {
         propertiesRead = true;
-        OSG_NOTIFY(osg::NOTICE)<<"read duration \""<<value.duration<<"\""<<std::endl;
+        OSG_NOTIFY(_notifyLevel)<<"read duration \""<<value.duration<<"\""<<std::endl;
     }
 
     /*

File src/osgPresentation/SlideShowConstructor.cpp

View file
     return pictureQuad;
 }
 
-
-void SlideShowConstructor::addImage(const std::string& filename, const PositionData& positionData, const ImageData& imageData)
+osg::Image* SlideShowConstructor::readImage(const std::string& filename, const ImageData& imageData)
 {
     osg::ref_ptr<osgDB::Options> options = _options;
     if (!imageData.options.empty())
         options->setOptionString(imageData.options);
     }
 
-
-    std::string foundFile = filename;
     osg::ref_ptr<osg::Image> image;
-    osg::ref_ptr<osgVolume::Volume> volume;
-    osg::ref_ptr<osgVolume::VolumeTile> tile;
-    osg::ref_ptr<osgVolume::ImageLayer> layer;
-
     osgDB::DirectoryContents filenames;
     bool preLoad = true;
 
+    std::string foundFile = filename;
+
     // check for wild cards
     if (filename.find('*')!=std::string::npos)
     {
         if (fileType == osgDB::DIRECTORY)
         {
             OSG_INFO<<"Reading directory "<<foundFile<<std::endl;
-            
+
             filenames = osgDB::getDirectoryContents(foundFile);
 
             // need to insert the directory path in front of the filenames so it's relative to the appropriate directory.
         }
     }
 
-    if (filenames.empty()) return;
+    if (filenames.empty()) return 0;
 
     if (filenames.size()==1)
     {
         image = imageSequence;
     }
 
+    return image.release();
+}
+
+void SlideShowConstructor::addImage(const std::string& filename, const PositionData& positionData, const ImageData& imageData)
+{
+
+    osg::ref_ptr<osgVolume::Volume> volume;
+    osg::ref_ptr<osgVolume::VolumeTile> tile;
+    osg::ref_ptr<osgVolume::ImageLayer> layer;
+
+    osg::ref_ptr<osg::Image> image = readImage(filename, imageData);
     if (!image) return;
 
     bool isImageTranslucent = false;
 
 void SlideShowConstructor::addStereoImagePair(const std::string& filenameLeft, const ImageData& imageDataLeft, const std::string& filenameRight, const ImageData& imageDataRight,const PositionData& positionData)
 {
-    osg::ref_ptr<osgDB::Options> optionsLeft = _options;
-    if (!imageDataLeft.options.empty())
-    {
-        optionsLeft = _options->cloneOptions();
-        optionsLeft->setOptionString(imageDataLeft.options);
-    }
-
-    osg::ref_ptr<osgDB::Options> optionsRight = _options;
-    if (!imageDataRight.options.empty())
-    {
-        optionsRight = _options->cloneOptions();
-        optionsRight->setOptionString(imageDataRight.options);
-    }
-
-    osg::ref_ptr<osg::Image> imageLeft = osgDB::readImageFile(filenameLeft, optionsLeft.get());
-    if (imageLeft.valid()) recordOptionsFilePath(optionsLeft.get());
-
-    osg::ref_ptr<osg::Image> imageRight = (filenameRight==filenameLeft) ? imageLeft.get() : osgDB::readImageFile(filenameRight, optionsRight.get());
-    if (imageRight.valid()) recordOptionsFilePath(optionsRight.get());
-
+    osg::ref_ptr<osg::Image> imageLeft = readImage(filenameLeft, imageDataLeft);
+    osg::ref_ptr<osg::Image> imageRight = (filenameRight==filenameLeft) ? imageLeft.get() : readImage(filenameRight, imageDataRight);
+    
     if (!imageLeft && !imageRight) return;
 
     bool isImageTranslucent = false;