Re: setUpdateCallback fails under slave-camera
Hi Timm,
I ran into a similar problem to what you have and solved it without having to modify the OSG Core source code. The problem is that osgViewer does not do eventTraversal and updateTraversal on the slave's subgraph regardless if they are using the mastersSceneData or not. I'm submitting a fix to this on osg-submission today, so hopefully it will be a part of the next OSG release.
To get around the problem you can add an eventCallback and a updateCallback to the slave camera that is not using the mastersSceneData and modify the traversal mode of the visitor within the callback to traverse the camera's subgraph.
class SlaveCameraUpdateCallback : public osg::NodeCallback
{
public:
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
if(nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)
{
osg::NodeVisitor::TraversalMode tm = nv->getTraversalMode();
nv->setTraversalMode(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN);
traverse(node,nv);
nv->setTraversalMode(tm);
}
else
{
traverse(node,nv);
}
}
};
{
//Rigging up slave camera with it's own subgraph
viewer.addSlave(camera,false);
//Set updateCallback for camera to ensure subgraph updateTraversal
camera->setUpdateCallback(new SlaveCameraUpdateCallback);
}
Filip
On Mon, Jul 20, 2009 at 5:25 PM, Timm Linder
<timmlinder <at> yahoo.de> wrote:
Hi Robert,
I'm picking up this somewhat outdated topic since we are having a similar problem. We need to render some of our geometry with a separate depth buffer because of precision issues: In the first pass, we are rendering a very large landscape that was created using VirtualPlanetBuilder. This puts the far clipping plane very far away from the viewer.
Then, however, we need to draw some objects that are flying very close to the camera and need a lot of precision here. This is what makes us require a second rendering pass with a separate depth buffer and projection matrix (where the far plane is very close to the eye point). It is guaranteed that this geometry is always above the landscape, so we need no further sorting here.
In both passes, we require our update callbacks to work. As should have become clear from my description, the master and slave camera do not share their geometry.
Do you think there is a way of making the update callbacks work in the slave camera *without* tampering with the original OSG Core source code?
Any hint would be greatly appreciated.
Thanks a lot for your help,
Timm
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=15145#15145
_______________________________________________
osg-users mailing list
osg-users-ZwoEplunGu0hajLcUbyfC12AsgEQdTeF@public.gmane.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
<div>
<div>Hi Timm,</div>
<div> </div>
<div>I ran into a similar problem to what you have and solved it without having to modify the OSG Core source code. The problem is that osgViewer does not do eventTraversal and updateTraversal on the slave's subgraph regardless if they are using the mastersSceneData or not. I'm submitting a fix to this on osg-submission today, so hopefully it will be a part of the next OSG release.</div>
<div> </div>
<div>To get around the problem you can add an eventCallback and a updateCallback to the slave camera that is not using the mastersSceneData and modify the traversal mode of the visitor within the callback to traverse the camera's subgraph.</div>
<div> </div>
<div> </div>
<div>class SlaveCameraUpdateCallback : public osg::NodeCallback<br>{<br>public:<br> virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)<br> { <br> if(nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)<br>
{<br> osg::NodeVisitor::TraversalMode tm = nv->getTraversalMode();<br> nv->setTraversalMode(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN);<br> traverse(node,nv);<br> nv->setTraversalMode(tm);<br> }<br> else<br>
{<br> traverse(node,nv);<br> }<br> }<br>};</div>
<div>{<br> //Rigging up slave camera with it's own subgraph<br> viewer.addSlave(camera,false);<br> //Set updateCallback for camera to ensure subgraph updateTraversal<br> camera->setUpdateCallback(new SlaveCameraUpdateCallback);<br>
}<br>
</div>
<div>Filip</div>
<div>
<br> </div>
<div class="gmail_quote">On Mon, Jul 20, 2009 at 5:25 PM, Timm Linder <span dir="ltr"><<a href="mailto:timmlinder@...">timmlinder <at> yahoo.de</a>></span> wrote:<br><blockquote class="gmail_quote">Hi Robert,<br><br>I'm picking up this somewhat outdated topic since we are having a similar problem. We need to render some of our geometry with a separate depth buffer because of precision issues: In the first pass, we are rendering a very large landscape that was created using VirtualPlanetBuilder. This puts the far clipping plane very far away from the viewer.<br><br>Then, however, we need to draw some objects that are flying very close to the camera and need a lot of precision here. This is what makes us require a second rendering pass with a separate depth buffer and projection matrix (where the far plane is very close to the eye point). It is guaranteed that this geometry is always above the landscape, so we need no further sorting here.<br><br>In both passes, we require our update callbacks to work. As should have become clear from my description, the master and slave camera do not share their geometry.<br><br>Do you think there is a way of making the update callbacks work in the slave camera *without* tampering with the original OSG Core source code?<br><br>Any hint would be greatly appreciated.<br><br>Thanks a lot for your help,<br><br>Timm<br><br>------------------<br>Read this topic online here:<br><a href="http://forum.openscenegraph.org/viewtopic.php?p=15145#15145" target="_blank">http://forum.openscenegraph.org/viewtopic.php?p=15145#15145</a><br><br><br><br><br><br>_______________________________________________<br>osg-users mailing list<br><a href="mailto:osg-users@...">osg-users@...</a><br><a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote>
</div>
<br>
</div>