From Rudolf Weidemann, "in the OpenFlight format materials can have editable names.

In the OSG OpenFlight plugin these names are ignored when reading, and
empty strings are written.

As we need these names in the OSG scene graph by our application, I
changed the plugin code, so the names are now stored in class
"osg::Material" (derived from "osg::Object") by
 material->setName();
(see "PaletteRecords.cpp, line 195) when reading the file, and written
to file by
 dos.writeString( m.Material->getName(), 12 );
(see MaterialPaletteManager.cpp, line 80).

As these names otherwise get lost when reading an OpenFlight file and
writing it again e.g. by
 osgconv example.flt converted_example.flt
these changes make the plugin more complete.

The changes were made to OSG revision 8425, and were tested by
 osgconv example.flt converted_example.flt
comparing the material palettes of both files inside Multigen Creator."
This commit is contained in:
Robert Osfield
2008-06-19 14:35:18 +00:00
parent dd13893861
commit cc9d12f34f
2 changed files with 2 additions and 1 deletions

View File

@@ -77,7 +77,7 @@ MaterialPaletteManager::write( DataOutputStream& dos ) const
dos.writeInt16( (int16) MATERIAL_PALETTE_OP );
dos.writeInt16( 84 ); // Length - FIXME: hard-code/FLT version?
dos.writeInt32( m.Index );
dos.writeString( std::string( "" ), 12 ); // Name - FIXME: put a 'real' name here?
dos.writeString( m.Material->getName(), 12 );
dos.writeInt32( 0 ); // Flags
dos.writeFloat32(ambient.r() );
dos.writeFloat32(ambient.g() );

View File

@@ -192,6 +192,7 @@ protected:
float32 alpha = in.readFloat32();
osg::Material* material = new osg::Material;
material->setName(name);
material->setAmbient(osg::Material::FRONT_AND_BACK,osg::Vec4(ambient,alpha));
material->setDiffuse (osg::Material::FRONT_AND_BACK,osg::Vec4(diffuse,alpha));
material->setSpecular(osg::Material::FRONT_AND_BACK,osg::Vec4(specular,alpha));