0

I want to apply state set to rendered geometry from .iv file. For example..

// this will render the geometry;
osg::ref_ptr<osg::Group> root = dynamic_cast <osg::Group*>(osgDB::ReadNodeFile("cow.osg"));

// want to apply stateset for above rendered file from .iv file 
`osg::ref_ptr<osg::Stateset> state = dynamic_cast <osg::Stateset*>(osgDB::ReadNodeFile("gold.osg"));`

.IV file contains only material properties (ambient,specular,shininess.......) It doesn't have any geometry to render.

gold.osg contains code as follows:-

stateset{
name c:/Documents And Settings/Gthm/Desktop/gold.osg
DataVariance 1
rendering_hint DEFAULT_BIN
renderingBinMode INHERIT
binNumber  0
binName
Material{
          ambientColor 0.5 0.6 0.8
          diffuseColor  0.5 0.6 0.8
         specularColor 0.5 0.6 0.8
          emissiveColor  0 0 0
          shininess 128
          transparency 0
 }
 }

1 Answers1

0

If your second file only has a node with your desired Stateset, you can do:

root->setStateSet(osgDB::ReadNodeFile("gold.osg")->getOrCreateStateSet());
user2658323
  • 543
  • 4
  • 15
  • it is not applying.. i tried by change the osg file to but it is not applying root->setStateSet(osgDB::ReadNodeFile("cow.osg")->getOrCreateStateSet()); –  Apr 04 '14 at 08:02
  • Then it's likely that the first node in `"gold.osg"` is not holding the material. Can you enhance your question by showing the content of that file? – user2658323 Apr 04 '14 at 08:28