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

This commit is contained in:
Robert Osfield
2012-06-08 10:26:23 +00:00
parent 5d3cb4f754
commit c39ee015d6
3 changed files with 23 additions and 32 deletions

View File

@@ -397,6 +397,8 @@ public:
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);

View File

@@ -870,13 +870,13 @@ bool ReaderWriterP3DXML::getProperties(osgDB::XmlNode*cur, osgPresentation::Slid
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;
}
/*

View File

@@ -843,8 +843,7 @@ osg::Geometry* SlideShowConstructor::createTexturedQuadGeometry(const osg::Vec3&
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())
@@ -853,16 +852,12 @@ void SlideShowConstructor::addImage(const std::string& filename, const PositionD
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)
{
@@ -882,7 +877,7 @@ void SlideShowConstructor::addImage(const std::string& filename, const PositionD
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.
@@ -914,7 +909,7 @@ void SlideShowConstructor::addImage(const std::string& filename, const PositionD
}
}
if (filenames.empty()) return;
if (filenames.empty()) return 0;
if (filenames.size()==1)
{
@@ -964,6 +959,17 @@ void SlideShowConstructor::addImage(const std::string& filename, const PositionD
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;
@@ -1095,26 +1101,9 @@ void SlideShowConstructor::addImage(const std::string& filename, const PositionD
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;