[osg-users] access to viewer instances in plugins

Robert Osfield robert.osfield at gmail.com
Wed Aug 16 04:31:10 PDT 2017


Hi Ralf.

The viewer and the plugins are completely decoupled in the OSG, this is by
design.  There is no global viewer instances or registry that would allow
you to force such a coupling.

However, for most applications this should not be an issue as you don't
need to get the viewer when constructing nodes and images as done in the
plugins, and for your usage case it might not be an issue either.

I don't know the full details of your usage case but the usual approach I
would take for adding event handling to subgraphs that are loaded
indepdently from the viewer is to use an event callback assigned to a
node.  The osgPresentation::SlideEventHandler is an example of an event
handler that be assigned to the viewer or to the scene graph as a
callback.  osgPresentation uses this approach to allow you to load .p3d
files to create interactive presentations just by loading the appropriate
.p3d into any OSG viewer.

There is a introduction.p3d in the OpenSceneGraph-Data set so try:

  osgviewer introduction.p3d

Then press arrow keys or page up/down or space to advance to the next
slide.  osgPresentation also has support for clicking on elements in the
scene using picking, all done using node event callbacks.

Would this work for you?
Robert.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20170816/30be8188/attachment.htm>


More information about the osg-users mailing list