#include <osg/TextureRectangle>
#include <osg/TextureCubeMap>
#include <osgDB/FileUtils>
+#include <osgDB/ReadFile>
#include <boost/lexical_cast.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp>
-#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
#include <simgear/scene/util/SGSceneFeatures.hxx>
#include <simgear/scene/util/StateAttributeFactory.hxx>
#include <simgear/math/SGMath.hxx>
TexEnvCombine* buildTexEnvCombine(Effect* effect,
const SGPropertyNode* envProp,
- const SGReaderWriterXMLOptions* options);
+ const SGReaderWriterOptions* options);
TexGen* buildTexGen(Effect* Effect, const SGPropertyNode* tgenProp);
// Hack to force inclusion of TextureBuilder.cxx in library
osg::Texture* TextureBuilder::buildFromType(Effect* effect, const string& type,
const SGPropertyNode*props,
- const SGReaderWriterXMLOptions*
+ const SGReaderWriterOptions*
options)
{
return EffectBuilder<Texture>::buildFromType(effect, type, props, options);
void TextureUnitBuilder::buildAttribute(Effect* effect, Pass* pass,
const SGPropertyNode* prop,
- const SGReaderWriterXMLOptions* options)
+ const SGReaderWriterOptions* options)
{
if (!isAttributeActive(effect, prop))
return;
EffectPropertyMap<Texture::WrapMode> wrapModes(wrapModesInit);
TexTuple makeTexTuple(Effect* effect, const SGPropertyNode* props,
- const SGReaderWriterXMLOptions* options,
+ const SGReaderWriterOptions* options,
const string& texType)
{
Texture::FilterMode minFilter = Texture::LINEAR_MIPMAP_LINEAR;
const SGPropertyNode* pImage
= getEffectPropertyChild(effect, props, "image");
string imageName;
+ string absFileName;
if (pImage)
+ {
imageName = pImage->getStringValue();
- string absFileName = SGModelLib::findDataFile(imageName, options);
+ absFileName = SGModelLib::findDataFile(imageName, options);
+ if (absFileName.empty())
+ {
+ SG_LOG(SG_INPUT, SG_ALERT, "Texture file not found: '"
+ << imageName << "'");
+ }
+ }
const SGPropertyNode* pMipmapControl
= getEffectPropertyChild(effect, props, "mipmap-control");
}
void setAttrs(const TexTuple& attrs, Texture* tex,
- const SGReaderWriterXMLOptions* options)
+ const SGReaderWriterOptions* options)
{
const string& imageName = attrs.get<0>();
if (imageName.empty()) {
throw BuilderException("no image file");
} else {
- osgDB::ReaderWriter::ReadResult result
- = osgDB::Registry::instance()->readImage(imageName, options);
+ osgDB::ReaderWriter::ReadResult result;
+ result = osgDB::readImageFile(imageName, options);
if (result.success()) {
osg::ref_ptr<osg::Image> image = result.getImage();
image = computeMipmap( image.get(), attrs.get<7>() );
public:
TexBuilder(const string& texType) : _type(texType) {}
Texture* build(Effect* effect, const SGPropertyNode*,
- const SGReaderWriterXMLOptions* options);
+ const SGReaderWriterOptions* options);
protected:
typedef map<TexTuple, ref_ptr<T> > TexMap;
TexMap texMap;
template<typename T>
Texture* TexBuilder<T>::build(Effect* effect, const SGPropertyNode* props,
- const SGReaderWriterXMLOptions* options)
+ const SGReaderWriterOptions* options)
{
TexTuple attrs = makeTexTuple(effect, props, options, _type);
typename TexMap::iterator itr = texMap.find(attrs);
{
public:
Texture* build(Effect* effect, const SGPropertyNode*,
- const SGReaderWriterXMLOptions* options);
+ const SGReaderWriterOptions* options);
};
Texture* WhiteTextureBuilder::build(Effect* effect, const SGPropertyNode*,
- const SGReaderWriterXMLOptions* options)
+ const SGReaderWriterOptions* options)
{
return StateAttributeFactory::instance()->getWhiteTexture();
}
{
public:
Texture* build(Effect* effect, const SGPropertyNode*,
- const SGReaderWriterXMLOptions* options);
+ const SGReaderWriterOptions* options);
};
Texture* TransparentTextureBuilder::build(Effect* effect, const SGPropertyNode*,
- const SGReaderWriterXMLOptions* options)
+ const SGReaderWriterOptions* options)
{
return StateAttributeFactory::instance()->getTransparentTexture();
}
{
public:
Texture* build(Effect* effect, const SGPropertyNode*,
- const SGReaderWriterXMLOptions* options);
+ const SGReaderWriterOptions* options);
protected:
typedef map<int, ref_ptr<Texture3D> > NoiseMap;
NoiseMap _noises;
};
Texture* NoiseBuilder::build(Effect* effect, const SGPropertyNode* props,
- const SGReaderWriterXMLOptions* options)
+ const SGReaderWriterOptions* options)
{
int texSize = 64;
const SGPropertyNode* sizeProp = getEffectPropertyChild(effect, props,
{
public:
Texture* build(Effect* effect, const SGPropertyNode*,
- const SGReaderWriterXMLOptions* options);
+ const SGReaderWriterOptions* options);
protected:
typedef map<CubeMapTuple, ref_ptr<TextureCubeMap> > CubeMap;
typedef map<string, ref_ptr<TextureCubeMap> > CrossCubeMap;
Texture* CubeMapBuilder::build(Effect* effect, const SGPropertyNode* props,
- const SGReaderWriterXMLOptions* options)
+ const SGReaderWriterOptions* options)
{
// First check that there is a <images> tag
const SGPropertyNode* texturesProp = getEffectPropertyChild(effect, props, "images");
cubeTexture->setWrap(osg::Texture3D::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
cubeTexture->setWrap(osg::Texture3D::WRAP_R, osg::Texture::CLAMP_TO_EDGE);
- osgDB::ReaderWriter::ReadResult result =
- osgDB::Registry::instance()->readImage(_tuple.get<0>(), options);
+ osgDB::ReaderWriter::ReadResult result;
+ result = osgDB::readImageFile(_tuple.get<0>(), options);
if(result.success()) {
osg::Image* image = result.getImage();
cubeTexture->setImage(TextureCubeMap::POSITIVE_X, image);
}
- result = osgDB::Registry::instance()->readImage(_tuple.get<1>(), options);
+ result = osgDB::readImageFile(_tuple.get<1>(), options);
if(result.success()) {
osg::Image* image = result.getImage();
cubeTexture->setImage(TextureCubeMap::NEGATIVE_X, image);
}
- result = osgDB::Registry::instance()->readImage(_tuple.get<2>(), options);
+ result = osgDB::readImageFile(_tuple.get<2>(), options);
if(result.success()) {
osg::Image* image = result.getImage();
cubeTexture->setImage(TextureCubeMap::POSITIVE_Y, image);
}
- result = osgDB::Registry::instance()->readImage(_tuple.get<3>(), options);
+ result = osgDB::readImageFile(_tuple.get<3>(), options);
if(result.success()) {
osg::Image* image = result.getImage();
cubeTexture->setImage(TextureCubeMap::NEGATIVE_Y, image);
}
- result = osgDB::Registry::instance()->readImage(_tuple.get<4>(), options);
+ result = osgDB::readImageFile(_tuple.get<4>(), options);
if(result.success()) {
osg::Image* image = result.getImage();
cubeTexture->setImage(TextureCubeMap::POSITIVE_Z, image);
}
- result = osgDB::Registry::instance()->readImage(_tuple.get<5>(), options);
+ result = osgDB::readImageFile(_tuple.get<5>(), options);
if(result.success()) {
osg::Image* image = result.getImage();
cubeTexture->setImage(TextureCubeMap::NEGATIVE_Z, image);
if (itr != _crossmaps.end())
return itr->second.get();
- osgDB::ReaderWriter::ReadResult result =
- osgDB::Registry::instance()->readImage(texname, options);
+ osgDB::ReaderWriter::ReadResult result;
+ result = osgDB::readImageFile(texname, options);
if(result.success()) {
osg::Image* image = result.getImage();
image->flipVertical(); // Seems like the image coordinates are somewhat funny, flip to get better ones
EffectPropertyMap<TexEnvCombine::OperandParam> operandParams(opParamInit);
TexEnvCombine* buildTexEnvCombine(Effect* effect, const SGPropertyNode* envProp,
- const SGReaderWriterXMLOptions* options)
+ const SGReaderWriterOptions* options)
{
if (!isAttributeActive(effect, envProp))
return 0;