obj plugin: Fix not writing material shininess

This commit is contained in:
Ralf Habacker 2018-01-15 14:22:18 +01:00
parent fa0f09ff84
commit 34b9cceca3
2 changed files with 5 additions and 0 deletions

View File

@ -411,6 +411,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;
@ -423,6 +424,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) {
@ -440,6 +442,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;

View File

@ -116,6 +116,7 @@ class OBJWriterNodeVisitor: public osg::NodeVisitor {
OBJMaterial(osg::Material* mat, osg::Texture* tex);
osg::Vec4 diffuse, ambient, specular;
float shininess;
std::string image;
std::string name;
};