Added support for "-O OutputTextureFiles" options string in .osg plugin to

allow texture files to be written out when writing out a .osg file.
This commit is contained in:
Robert Osfield
2005-09-19 14:07:44 +00:00
parent ea1ea88a17
commit d1108ea862
9 changed files with 121 additions and 15 deletions

View File

@@ -3,6 +3,7 @@
#include "osgDB/Registry"
#include "osgDB/Input"
#include "osgDB/Output"
#include "osgDB/WriteFile"
using namespace osg;
using namespace osgDB;
@@ -61,9 +62,22 @@ bool TextureRectangle_writeLocalData(const Object& obj, Output& fw)
{
const TextureRectangle& texture = static_cast<const TextureRectangle&>(obj);
if (texture.getImage() && !(texture.getImage()->getFileName().empty()))
if (texture.getImage())
{
fw.indent() << "file "<<fw.wrapString(fw.getFileNameForOutput(texture.getImage()->getFileName()))<< std::endl;
std::string fileName = texture.getImage()->getFileName();
if (fw.getOutputTextureFiles())
{
if (fileName.empty())
{
fileName = fw.getTextureFileNameForOutput();
}
osgDB::writeImageFile(*texture.getImage(), fileName);
}
if (!fileName.empty())
{
fw.indent() << "file "<<fw.wrapString(fw.getFileNameForOutput(fileName))<< std::endl;
}
}
return true;