HI Patrick,

I'm not aware of any problems with writing of osg::Material objects to a
.osgb file.

Using the spaceship.osgt model from OpenSceneGrapph-Data, that contains
osg::Material instances, I have just done the test:

  osgconv spacedship.osgt spaceship.osgb
  osgviewer spaceship.osgb
  osgconv spaceship.osgb spaceship2.osgt

Everything works correctly, no crashes, no hangs, the osg::Material get
written out and reloaded correctly.

Most likely you have a build issue of some kind on your system.  The most
common problem we see if Windows users getting stuck with VisualStudio's
crappy inability to handle libs built with different options.

As a general note I'd say updated to OSG-3.2.0, using a dev release older
than that last stable release really isn't recommended.

Robert.



On 29 September 2013 16:04, Patrick Keenan <[email protected]> wrote:

> Hello,
>
> I have an osg::ProxyNode model that I change the material on then I try to
> update the file itself so that next time I run the program the changes
> persist. If I save it to my_model.osgb then the next time I go to open it
> osgDB::readNodeFile locks up trying to read the file, however if I save it
> to a .3ds, open that and then save it to .osgb then it loads up fine the
> next time. Is this a bug in the way materials are written to .osgb? It
> seems like writing to each format should act the same. My version of OSG is
> 3.1.6.
>
> Here is my code that does work replace .3ds with .osgb and it will fail
> when reloaded:
>
>
> Code:
>
> void M_model::Set_material(void)
> {
>     osg::ref_ptr<osg::Material> mtl = new osg::Material;
>         float alpha = 0.3f;
>     mtl->setAmbient(osg::Material::FRONT, osg::Vec4(0.75f, 0.53f, 0.19f,
> alpha));
>     mtl->setDiffuse (osg::Material::FRONT, osg::Vec4(0.75f, 0.53f, 0.19f,
> alpha));
>     mtl->setSpecular(osg::Material::FRONT, osg::Vec4(0.75f, 0.53f, 0.19f,
> alpha));
>         mtl->setAlpha(osg::Material::FRONT_AND_BACK, alpha);
>     mtl->setShininess(osg::Material::FRONT, 1.0f);
>
>         osg::StateSet* ss = _prox_node->getOrCreateStateSet();
>         ss->setAttributeAndModes(mtl.get(),
> osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
>         ss->setMode(GL_DEPTH_TEST,osg::StateAttribute::ON);
>         ss->setMode(GL_LIGHTING,osg::StateAttribute::ON);
>         ss->setMode(GL_BLEND,osg::StateAttribute::ON);
>         ss->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
>
>         if(boost::filesystem::exists(_file_name))
>         {
>                 boost::filesystem::remove(_file_name);
>         }
>         osgDB::writeNodeFile(*_prox_node,  "../Models/frame_6.3ds");
> }
>
>
>
>
>
> Thanks,
>
> Patrick
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=56533#56533
>
>
>
>
> Attachments:
> http://forum.openscenegraph.org//files/frame_6_new_mtl_174.png
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to