[osg-users] access to viewer instances in plugins

Ralf Habacker ralf.habacker at freenet.de
Wed Aug 16 00:31:18 PDT 2017


Hi,

for
http://www.openscenegraph.org/index.php/gallery/use-cases/189-fm-profil
we are trying to add animation trigger support to a scene by a specific
plugins. Animation trigger support means to start an animation
if the user clicks a specific object. The recent implementation uses a
dedicated pick handler to be called if a user selects an object and
starts an animation by using class AnimationViewerModelController, which
is already included in the osg source. The connection between the
trigger object and the related animation has been designed by using a
specific object name postfix including the animation name to make the
pick handler able to find the related animation. The animation itself is
created with blender and exported with the osgexport plugin
(https://github.com/cedricpinson/osgexport).

The pick handler needs to be added to the viewer, which is normally
instantiated in the main application. Because we need to support several
viewers and we do not want to patch all related viewer (some of them are
3rdparty like https://github.com/ChrisDenham/osgopenvrviewer) we are
looking for a way to place all this mentioned stuff into an osg plugin,
which could be loaded by any viewer by appending the plugin extension
(which is animtrigger in our case) to the model file e.g. osgviewer
test.osgt.animtrigger .

The related code to add a pick handler to a viewer looks like that:

    AnimationPickHandler *pickHandler = new AnimationPickHandler();
    viewer->addEventHandler(pickHandler);

To be able to call them in a plugin the plugin needs access to the
viewer instance, which is not possible with recent code and I'm looking
for a way to add such support to osg.

>From my recent osg knowledge I would say that one of the available
viewer related classes needs to be extended to register itself into a
static list located in the class osg::View or in a dedicated new "viewer
manager" class.

Are there any hints for implementing this ?

Regards
Ralf


More information about the osg-users mailing list