[osg-users] Using callbacks for all graph modifications?

Robert Osfield robert.osfield at gmail.com
Fri Aug 18 13:57:55 PDT 2017

HI Antoine,

Callbacks are just one way of managing updates to the scene graph, whether
they are the most appropriate tool for each job depends entirely and usage
case, within one application you may well use multiple approaches, using
the appropriate tool for each task.

As a general guide I would suggest that one would use a node callback when
you want to encapsulate updates to particular subgraphs so that once you
add the callback it looks after its subgraph largely by itself.  For
instance a subgraph that you want to spin constantly you create/load the
subgraph put a transform above it and attach a callback.  Once setup you
then can just pass the whole subgraph into the main scene graph and not
have worry about the implementation details any more.

If your updates related closely with high level operations then you'd
typically push these high level updates into the frame loop - similar to
what you seem to be doing right now.


On 18 August 2017 at 18:21, Antoine Rennuit <antoinerennuit at hotmail.com>

> Hi all,
> I have a custom DataModel describing objects, relations between them. The
> objects of my custom DataModel are rendered using OSG.
> Depending on user events in my app, the objects of my DataModel are
> modified and OSG is being notified of all these modifications. These
> modifications leads to e.g. osg::PositionAttitudeTransforms being
> updated, node masks being modified, osg::Geodes being added or removed of
> the graph (via addChild() / removeChild()). This leads to a live 3D
> rendering with animations...
> I do all the updates of my OSG graph in a raw way, without using
> callbacks. This gives code such as
> Code:
> m_worldFrame->setPosition(EigenToOsgVector3(m_node->m_worldFrame->m_pos));
> m_worldFrame->setAttitude(EigenToOsgQuat(m_node->m_worldFrame->m_quat));
> if (m_worldFrame)
>     m_worldFrame->setNodeMask(0xffffffff);
> if (m_mesh)
>     m_mesh->setNodeMask(0xffffffff);
> Now I am currently reading the Beginners' Guide and have read callbacks
> should be used for animation (chapter 8).
> Does that mean I should use callbacks for all modifications of the osg
> graph?
> This could be implemented in such a way that when my DataModel is updated
> a flag is updated which is read by the callbacks and depending on the state
> of the flag the callback performs the osg graph update of not. This is
> possible but this looks very heavy to implement...
> Am I getting something wrong? Or should I really use update callbacks for
> all modifications of the OSG graph (objects moving, setting masks...)?
> Thanks a lot,
> Antoine.[/code]
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=71456#71456
> _______________________________________________
> 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/20170818/e0f3edae/attachment.htm>

More information about the osg-users mailing list