[osg-users] update slave camera with frame scheme ON_DEMAND

Robert Osfield robert.osfield at gmail.com
Wed Aug 5 09:14:54 PDT 2015


HI Gianni,

There is no need to modify the OSG code, all you need to do is move the
update of your transform to after the call to updateTraversals().  You
could do this lots of different ways - all under your application control.
Personally I'd do it by expanding the call to viewer->frame() to it's
component parts as I suggested earlier.  Alternatively you could subclass
from the Viewer/CompositeViewer and override the updateTraversal() method -
it's a virtual method to allow you to customize things.

Robert.

On 5 August 2015 at 16:58, Gianni Ambrosio <g.ambrosio+osg at gmail.com> wrote:

> Hi Robert, I didn't understand your answer.
>
> I use OSG 3.0.1 but I tried with 3.4.0.-rc8 and the behavior is the same.
> Moreover updateTraversal() of CompositeViewer is basically the same for
> these versions.
> Anyway we are probably talking of a slightly different scenario: I have a
> slave camera which update callback needs an up to date viewer master
> camera's view matrix. In this case, as you told me, since the master camera
> matrix is updated (with the inverse matrix of the manipulator) after the
> slave camera update callback, then the value is that of the previous frame.
> I can understand and the reason is in CompositeViewer::updateTraversal()
> because the for loop "// Do UpdateTraversal for slaves with their own
> subgraph" is done before
> "view->getCameraManipulator()->updateCamera(*(view->getCamera()));".
> So, to make scenarios like mine working, my suggestion is to move:
>
>
> Code:
>
>             // Do UpdateTraversal for slaves with their own subgraph
>             for(unsigned int i=0; i<view->getNumSlaves(); ++i)
>             {
>                 osg::View::Slave& slave = view->getSlave(i);
>                 osg::Camera* camera = slave._camera.get();
>                 if(camera && !slave._useMastersSceneData)
>                 {
>                     camera->accept(*_updateVisitor);
>                 }
>             }
>
>
>
>
> after
>
>
> Code:
>
>         if (view->getCameraManipulator())
>         {
>             view->setFusionDistance(
> view->getCameraManipulator()->getFusionDistanceMode(),
>
> view->getCameraManipulator()->getFusionDistanceValue() );
>
>
> view->getCameraManipulator()->updateCamera(*(view->getCamera()));
>
>         }
>
>
>
>
> I tried this solution and it works fine.
> With this modification the scene remains updated before the main camera,
> so nothing you already told me should be broken.
> Moreover the for loop to move down is related to slave cameras with thier
> own subgraph.
>
> Regards,
> Gianni[/code]
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=64634#64634
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150805/8f53dfd3/attachment-0003.htm>


More information about the osg-users mailing list