From Marco Jez, fixed handling of loading of relative file paths.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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<osg::Group> root_;
|
||||
Options options_;
|
||||
osg::ref_ptr<const osgDB::ReaderWriter::Options> db_options_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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<osg::Node> node = converter.convert(fileName, options);
|
||||
lwosg::Converter converter(conv_options, options);
|
||||
osg::ref_ptr<osg::Node> node = converter.convert(fileName);
|
||||
if (node.valid()) {
|
||||
return node.take();
|
||||
}
|
||||
|
||||
@@ -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<osg::Texture2D> 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<int>(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;
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include <osg/StateSet>
|
||||
#include <osg/Geometry>
|
||||
|
||||
#include <osgDB/ReaderWriter>
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user