我想将状态集应用于 .iv 文件中渲染的几何体。例如。。
// 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文件仅包含材料属性 ( ambient,specular,shininess.......
)它没有任何要渲染的几何图形。
gold.osg 包含如下代码:-
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
}
}
如果您的第二个文件只有一个包含所需状态集的节点,您可以执行以下操作:
root->setStateSet(osgDB::ReadNodeFile("gold.osg")->getOrCreateStateSet());