Well I thought I'd post my conclusions on the off chance that someone else
wants to build a user interface with OSG, AND is as ignorant as I am about
OpenGL and 3D graphics.
Let's start off by saying that OSG is a low-level graphics package - quite a
good one in my opinion. The expertise to understand all the 'clip space'
'DelaunayTriangulator' and all the other real-time 3D graphic techno-wizardry
that I rely on OSG to provide - doesn't really carry over into supporting a
fancy GUI (graphical user interface). Further - someone that can argue the
nuances of quaternion multiplication - which I cannot - probably isn't going to
be really gifted in event handling to any fancy degree. If someone *can* do
both - then they probably don't need to wear a life vest since they can
probably walk on water!
So - using the excellent CompositeViewer and using an osgViewer::View to
present a menu and with the requisite event handler to handle menu picks. (See
examples osgHUD, osgPICK, and osgCompositeViewer for the basics.)
The Rules
(1) Thou shalt not remove a view with an event handler. The logic of the
processing assumes that the number of views doesn't change from start to
finish, and I can't fix it without making things worse.
(2) Thou shalt use the viewer with osgViewer::ViewerBase::SingleThreaded. It
appears to my testing that popping GUI menus (aka Views) in and out while it's
multithreading works _most_ of the time. I want my project to work _all_ of
the time - hence The Rule.
You can add a view (popup a GUI menu) in an event, but the trick is to remove
a view (close a GUI menu). You can't do that when you run OSG with the simple
viewer.run call. You must run the viewer one frame at a time.
This is what I've done. Make a boolean global variable something link
RemoveGUI.
Then implement OSG with the 'old school':
do while()
{
viewer.frame
}
type loop. In the appropriate event handler(s) - "schedule" the view to be
removed by setting your global variable. You'll need logic after the
viewer.frame call to check this variable and remove the view. Something like:
do while()
{
viewer.frame
if (RemoveGUI)
{
viewer.removeView
RemoveGUI = false
}
}
I've not tried to use the available OpenGL eye-candy (slider bars and all
that) - is the technical term widgets? - to create a full on GUI experience.
In my own case I'm not sure I need to.
So: Elegant? No. Spiffy? No. That's not what OSG is about.
Effective? You bet.
-Steve Schneider
---------------------------------
Never miss a thing. Make Yahoo your homepage.
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org