diff --git a/src/osgDB/OutputStream.cpp b/src/osgDB/OutputStream.cpp index 397c73776..6db556d55 100644 --- a/src/osgDB/OutputStream.cpp +++ b/src/osgDB/OutputStream.cpp @@ -495,6 +495,12 @@ void OutputStream::writeImage( const osg::Image* img ) imageFileName = "image.dds"; } + std::string imagePath = osgDB::getFilePath(imageFileName); + if (!imagePath.empty() && !osgDB::fileExists(imagePath)) + { + osgDB::makeDirectory(imagePath); + } + bool result = osgDB::writeImageFile( *img, imageFileName ); OSG_NOTICE << "OutputStream::writeImage(): Write image data to external file " << imageFileName << std::endl; if ( !result ) diff --git a/src/osgPlugins/obj/OBJWriterNodeVisitor.cpp b/src/osgPlugins/obj/OBJWriterNodeVisitor.cpp index 30be4b164..457d3c25a 100644 --- a/src/osgPlugins/obj/OBJWriterNodeVisitor.cpp +++ b/src/osgPlugins/obj/OBJWriterNodeVisitor.cpp @@ -446,8 +446,16 @@ OBJWriterNodeVisitor::OBJMaterial::OBJMaterial(osg::Material* mat, osg::Texture* if ((img) && (!img->getFileName().empty())) { image = img->getFileName(); - if(outputTextureFiles) + if (outputTextureFiles) + { + std::string imagePath = osgDB::getFilePath(image); + if (!imagePath.empty() && !osgDB::fileExists(imagePath)) + { + osgDB::makeDirectory(imagePath); + } + osgDB::writeImageFile(*img, image, options); + } } }