diff --git a/src/osgPlugins/lwo/Converter.cpp b/src/osgPlugins/lwo/Converter.cpp index 61dc08dae..520fa9967 100644 --- a/src/osgPlugins/lwo/Converter.cpp +++ b/src/osgPlugins/lwo/Converter.cpp @@ -44,9 +44,10 @@ Converter::Converter() { } -Converter::Converter(const Options &options) +Converter::Converter(const Options &options, const osgDB::ReaderWriter::Options* db_options) : root_(new osg::Group), - options_(options) + options_(options), + db_options_(db_options) { } @@ -201,7 +202,8 @@ void Converter::build_scene_graph(Object &obj) rm_rgba_maps.get(), options_.max_tex_units, options_.use_osgfx, - options_.force_arb_compression); + options_.force_arb_compression, + db_options_.get()); if (sgrp) { sgrp->addChild(geode.get()); layer_group->addChild(sgrp); @@ -241,9 +243,9 @@ osg::Group *Converter::convert(const iff::Chunk_list &data) return convert(obj); } -osg::Group *Converter::convert(const std::string &filename, const osgDB::ReaderWriter::Options* options) +osg::Group *Converter::convert(const std::string &filename) { - std::string file = osgDB::findDataFile(filename, options); + std::string file = osgDB::findDataFile(filename, db_options_.get()); if (file.empty()) return 0; std::ifstream ifs(file.c_str(), std::ios_base::in | std::ios_base::binary); diff --git a/src/osgPlugins/lwo/Converter.h b/src/osgPlugins/lwo/Converter.h index f88cfada1..7bfe0ffc9 100644 --- a/src/osgPlugins/lwo/Converter.h +++ b/src/osgPlugins/lwo/Converter.h @@ -35,11 +35,11 @@ namespace lwosg }; Converter(); - Converter(const Options &options); + Converter(const Options &options, const osgDB::ReaderWriter::Options* db_options); osg::Group *convert(Object &obj); osg::Group *convert(const iff::Chunk_list &data); - osg::Group *convert(const std::string &filename, const osgDB::ReaderWriter::Options* options); + osg::Group *convert(const std::string &filename); inline osg::Group *get_root() { return root_.get(); } inline const osg::Group *get_root() const { return root_.get(); } @@ -54,6 +54,7 @@ namespace lwosg private: osg::ref_ptr root_; Options options_; + osg::ref_ptr db_options_; }; } diff --git a/src/osgPlugins/lwo/ReaderWriterLWO.cpp b/src/osgPlugins/lwo/ReaderWriterLWO.cpp index 78698052e..402f4fada 100644 --- a/src/osgPlugins/lwo/ReaderWriterLWO.cpp +++ b/src/osgPlugins/lwo/ReaderWriterLWO.cpp @@ -117,8 +117,8 @@ osgDB::ReaderWriter::ReadResult ReaderWriterLWO::readNode_LWO2(const std::string { lwosg::Converter::Options conv_options = parse_options(options); - lwosg::Converter converter(conv_options); - osg::ref_ptr node = converter.convert(fileName, options); + lwosg::Converter converter(conv_options, options); + osg::ref_ptr node = converter.convert(fileName); if (node.valid()) { return node.take(); } diff --git a/src/osgPlugins/lwo/Surface.cpp b/src/osgPlugins/lwo/Surface.cpp index 5e5dcd91c..7f1df55b9 100644 --- a/src/osgPlugins/lwo/Surface.cpp +++ b/src/osgPlugins/lwo/Surface.cpp @@ -128,7 +128,7 @@ void Surface::compile(const lwo2::FORM::SURF *surf, const Clip_map &clips) } } -void Surface::generate_stateset(int max_tex_units, bool force_arb_compression) const +void Surface::generate_stateset(int max_tex_units, bool force_arb_compression, const osgDB::ReaderWriter::Options* db_options) const { if (!stateset_.valid()) { @@ -188,7 +188,7 @@ void Surface::generate_stateset(int max_tex_units, bool force_arb_compression) c osg::ref_ptr texture = new osg::Texture2D; if (force_arb_compression) texture->setInternalFormatMode(osg::Texture::USE_ARB_COMPRESSION); - texture->setImage(osgDB::readImageFile(image_file)); + texture->setImage(osgDB::readImageFile(image_file, db_options)); texture->setWrap(osg::Texture::WRAP_S, osg_wrap_mode(block.get_image_map().width_wrap)); texture->setWrap(osg::Texture::WRAP_T, osg_wrap_mode(block.get_image_map().height_wrap)); texture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR); @@ -255,7 +255,7 @@ void Surface::generate_stateset(int max_tex_units, bool force_arb_compression) c } } -osg::Group *Surface::apply(osg::Geometry *geo, const VertexMap_map *texture_maps, const VertexMap_map *rgb_maps, const VertexMap_map *rgba_maps, int max_tex_units, bool use_osgfx, bool force_arb_compression) const +osg::Group *Surface::apply(osg::Geometry *geo, const VertexMap_map *texture_maps, const VertexMap_map *rgb_maps, const VertexMap_map *rgba_maps, int max_tex_units, bool use_osgfx, bool force_arb_compression, const osgDB::ReaderWriter::Options* db_options) const { int num_points = 0; @@ -263,7 +263,7 @@ osg::Group *Surface::apply(osg::Geometry *geo, const VertexMap_map *texture_maps num_points = static_cast(geo->getVertexArray()->getNumElements()); } - generate_stateset(max_tex_units, force_arb_compression); + generate_stateset(max_tex_units, force_arb_compression, db_options); geo->setStateSet(stateset_.get()); int unit = 0; diff --git a/src/osgPlugins/lwo/Surface.h b/src/osgPlugins/lwo/Surface.h index e81d4973e..f265b0faa 100644 --- a/src/osgPlugins/lwo/Surface.h +++ b/src/osgPlugins/lwo/Surface.h @@ -19,6 +19,8 @@ #include #include +#include + #include #include @@ -42,9 +44,9 @@ namespace lwosg void compile(const lwo2::FORM::SURF *surf, const Clip_map &clips); - osg::Group *apply(osg::Geometry *geo, const VertexMap_map *texture_maps, const VertexMap_map *rgb_maps, const VertexMap_map *rgba_maps, int max_tex_units = 0, bool use_osgfx = false, bool force_arb_compression = false) const; + osg::Group *apply(osg::Geometry *geo, const VertexMap_map *texture_maps, const VertexMap_map *rgb_maps, const VertexMap_map *rgba_maps, int max_tex_units, bool use_osgfx, bool force_arb_compression, const osgDB::ReaderWriter::Options *db_options) const; - void generate_stateset(int max_tex_units = 0, bool force_arb_compression = false) const; + void generate_stateset(int max_tex_units, bool force_arb_compression, const osgDB::ReaderWriter::Options* options) const; inline const std::string &get_name() const { return name_; } inline void set_name(const std::string &n) { name_ = n; }