obj plugin: Fix not writing material shininess

This commit is contained in:
Ralf Habacker 2018-01-15 14:22:18 +01:00 committed by Robert Osfield
parent 2f71260c5a
commit cae16c5fd7
2 changed files with 5 additions and 0 deletions

View File

@ -424,6 +424,7 @@ OBJWriterNodeVisitor::OBJMaterial::OBJMaterial(osg::Material* mat, osg::Texture*
diffuse(1,1,1,1), diffuse(1,1,1,1),
ambient(0.2,0.2,0.2,1), ambient(0.2,0.2,0.2,1),
specular(0,0,0,1), specular(0,0,0,1),
shininess(-1),
image("") image("")
{ {
static unsigned int s_objmaterial_id = 0; 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); diffuse = mat->getDiffuse(osg::Material::FRONT);
ambient = mat->getAmbient(osg::Material::FRONT); ambient = mat->getAmbient(osg::Material::FRONT);
specular = mat->getSpecular(osg::Material::FRONT); specular = mat->getSpecular(osg::Material::FRONT);
shininess = mat->getShininess(osg::Material::FRONT)*1000.0f/128.0f;
} }
if (tex) { if (tex) {
@ -456,6 +458,8 @@ std::ostream& operator<<(std::ostream& fout, const OBJWriterNodeVisitor::OBJMate
fout << " " << "Ka " << mat.ambient << std::endl; fout << " " << "Ka " << mat.ambient << std::endl;
fout << " " << "Kd " << mat.diffuse << std::endl; fout << " " << "Kd " << mat.diffuse << std::endl;
fout << " " << "Ks " << mat.specular << std::endl; fout << " " << "Ks " << mat.specular << std::endl;
if (mat.shininess != -1)
fout << " " << "Ns " << mat.shininess<< std::endl;
if(!mat.image.empty()) if(!mat.image.empty())
fout << " " << "map_Kd " << mat.image << std::endl; fout << " " << "map_Kd " << mat.image << std::endl;

View File

@ -118,6 +118,7 @@ class OBJWriterNodeVisitor: public osg::NodeVisitor {
OBJMaterial(osg::Material* mat, osg::Texture* tex, bool outputTextureFiles = false, const osgDB::Options* options = NULL); OBJMaterial(osg::Material* mat, osg::Texture* tex, bool outputTextureFiles = false, const osgDB::Options* options = NULL);
osg::Vec4 diffuse, ambient, specular; osg::Vec4 diffuse, ambient, specular;
float shininess;
std::string image; std::string image;
std::string name; std::string name;
}; };