diff --git a/src/osgPlugins/obj/OBJWriterNodeVisitor.cpp b/src/osgPlugins/obj/OBJWriterNodeVisitor.cpp index 83bf7d401..46071bc24 100644 --- a/src/osgPlugins/obj/OBJWriterNodeVisitor.cpp +++ b/src/osgPlugins/obj/OBJWriterNodeVisitor.cpp @@ -424,6 +424,7 @@ OBJWriterNodeVisitor::OBJMaterial::OBJMaterial(osg::Material* mat, osg::Texture* diffuse(1,1,1,1), ambient(0.2,0.2,0.2,1), specular(0,0,0,1), + shininess(-1), image("") { static unsigned int s_objmaterial_id = 0; @@ -436,6 +437,7 @@ OBJWriterNodeVisitor::OBJMaterial::OBJMaterial(osg::Material* mat, osg::Texture* diffuse = mat->getDiffuse(osg::Material::FRONT); ambient = mat->getAmbient(osg::Material::FRONT); specular = mat->getSpecular(osg::Material::FRONT); + shininess = mat->getShininess(osg::Material::FRONT)*1000.0f/128.0f; } if (tex) { @@ -456,6 +458,8 @@ std::ostream& operator<<(std::ostream& fout, const OBJWriterNodeVisitor::OBJMate fout << " " << "Ka " << mat.ambient << std::endl; fout << " " << "Kd " << mat.diffuse << std::endl; fout << " " << "Ks " << mat.specular << std::endl; + if (mat.shininess != -1) + fout << " " << "Ns " << mat.shininess<< std::endl; if(!mat.image.empty()) fout << " " << "map_Kd " << mat.image << std::endl; diff --git a/src/osgPlugins/obj/OBJWriterNodeVisitor.h b/src/osgPlugins/obj/OBJWriterNodeVisitor.h index 2b7375751..2d5c71b26 100644 --- a/src/osgPlugins/obj/OBJWriterNodeVisitor.h +++ b/src/osgPlugins/obj/OBJWriterNodeVisitor.h @@ -118,6 +118,7 @@ class OBJWriterNodeVisitor: public osg::NodeVisitor { OBJMaterial(osg::Material* mat, osg::Texture* tex, bool outputTextureFiles = false, const osgDB::Options* options = NULL); osg::Vec4 diffuse, ambient, specular; + float shininess; std::string image; std::string name; };