> Could you just remove the uniform when you remove the leaf node? Or reset the
> uniforms value?
No, I can't because it is part of a generic management system and the leaf node
may be removed by many ways.
Since this application is single-threaded, use multiple viewer instance (no
composite viewer) and use a camera instance per viewer, I think he following
workaround is safe :
(I know this is not the best way to build an osg application...)
1. subclass the osgViewer::Viewer class and reimplement the frame method :
Code:
void OsgViewer::frame(double simulationTime)
{
if (_done) return;
if (_firstFrame)
{
viewerInit();
if (!isRealized())
{
realize();
}
_firstFrame = false;
}
advance(simulationTime);
eventTraversal();
updateTraversal();
// Store the camera stateset
osg::ref_ptr<osg::StateSet> pOriginalCameraStateSet =
p_osgCamera->getOrCreateStateSet();
osg::ref_ptr<osg::StateSet> pCameraStateSet =
dynamic_cast<osg::StateSet*>(pOriginalCameraStateSet->clone(osg::CopyOp()));
renderingTraversals();
// Reset the camera stateset
p_osgCamera->setStateSet(pCameraStateSet);
}
2. In my leaf node cull callback, I add my global stateset to the camera
stateset :
Code:
osg::Camera* pCamera = pCullVisitor->getCurrentCamera();
if (pCamera != NULL)
{
osg::StateSet* pCameraStateSet = pCamera->getStateSet();
pCameraStateSet->merge(*myGlobalStateSet());
}
> One might also want a more general way of doing global uniforms as
> well, where the modelview matrix isn't required, so it's isn't a
> positional state.
Yes, this is exactly my issue here, if you can give me some guidelines on how
to implement this I may have some free time in a near future to work on it.
Aurelien
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=46483#46483
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org