Hi John,

To add custom event handling there isn't normally a need to subclass from
CompositeViewer and Geode.

In snv/trunk and the OSG-3.3.x dev series there is now an osgGA::Event base
class that you can subclass from.  You can add your own events then inject
them in the the View's EventQueue, these events will then be passed on to
the EventHandlers attached to the View(er) and Event callbacks placed in
the scene graph.  In the EventHandler/Calback you get the pointer to the
Event base class and then cast it to your custom type.

In OSG-3.2 and before you can subclass from osgGA::GUIEventAdapter.  It's
not quite as clean as the new osgGA::Event but should work just fine.

Robert.

On 28 February 2015 at 17:09, John Farrier <john.farr...@gmail.com> wrote:

> Hi,
>
> I have a program which is using a custom viewer derived from
> osgViewer::View.  In this custom view's scene may be some custom types
> derived from osg::Geode.  I'll call these MyView and MyGeode for the sake
> of the post.  MyView's are put inside a osgViewer::CompositeViewer.  All
> this works great.  Now, I want to send custom events to MyView and MyGeode.
>
> My original hope was that I could just register a handler on MyView and
> MyGeode and do something like "compositeViewer->accept(new MyEvent)", but
> it doesn't seem that easy.
>
> I ended up creating a "MyCompositeViewer" that has an "accept" function on
> it that takes MyOsgGaEventVisitor and then create a MyGUIEventHandler which
> attempts to dynamic_cast osgGA::GUIEventAdapter to MyEventAdapter.
> MyGUIEventHandler is created with a pointer to its owning MyView and then
> can make calls into MyView based on the event.  I haven't started working
> on getting the event into MyView's scene and onto MyGeode's yet because
> this design is challenging my sanity.
>
> This approach works, but seems like a mess.  Before I get too far down
> this rabbit hole, what is the RIGHT way to get a custom event sent from a
> top-level CompositeViewer to its subordinate views and then onto the view's
> scene nodes?  The examples in OSG seem to address parts of this problem,
> but I can't see a solution to the entire scope of the problem.  Another way
> to phrase the question might be:
>
> "How do I create a custom OSG-wide event that can be responded to by all
> osgViewer::View's and osg::Geode's alike?"
>
> Thank you!
>
> Cheers,
> John
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=62866#62866
>
>
>
>
>
> _______________________________________________
> 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