diff --git a/src/osgPlugins/obj/ReaderWriterOBJ.cpp b/src/osgPlugins/obj/ReaderWriterOBJ.cpp index e5ec4b9d5..5be39494c 100644 --- a/src/osgPlugins/obj/ReaderWriterOBJ.cpp +++ b/src/osgPlugins/obj/ReaderWriterOBJ.cpp @@ -108,6 +108,13 @@ void ReaderWriterOBJ::buildMaterialToStateSetMap(obj::Model& model, MaterialToSt { osg::Texture2D* texture = new osg::Texture2D(image); stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON); + + if (material.textureReflection) + { + osg::TexGen* texgen = new osg::TexGen; + texgen->setMode(osg::TexGen::SPHERE_MAP); + stateset->setTextureAttributeAndModes(0,texgen,osg::StateAttribute::ON); + } } } @@ -439,6 +446,9 @@ osgDB::ReaderWriter::ReadResult ReaderWriterOBJ::readNode(const std::string& fil std::ifstream fin(fileName.c_str()); if (fin) { + + osgDB::PushAndPopDataPath papdp( osgDB::getFilePath(fileName.c_str()) ); + obj::Model model; model.readOBJ(fin); diff --git a/src/osgPlugins/obj/obj.cpp b/src/osgPlugins/obj/obj.cpp index f55cda888..b8d22d88e 100644 --- a/src/osgPlugins/obj/obj.cpp +++ b/src/osgPlugins/obj/obj.cpp @@ -17,6 +17,9 @@ #include +#include +#include + using namespace obj; bool Model::readline(std::istream& fin, char* line, const int LINE_SIZE) @@ -241,6 +244,10 @@ bool Model::readMTL(std::istream& fin) std::string filename(line+7); material->map_Ks = filename; } + else if (strcmp(line,"refl")==0 || strncmp(line,"refl ",5)==0) + { + material->textureReflection = true; + } else { osg::notify(osg::NOTICE) <<"*** line not handled *** :"<