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.

Robert.

On 18 August 2017 at 18:21, Antoine Rennuit <antoinerenn...@hotmail.com>
wrote:

> 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@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to