[osg-users] Trackball Manipulator in OpenGL + OSG

Lingyun Yu Lingyun.Yu.06 at gmail.com
Tue Mar 24 08:13:48 PDT 2009


Hi, everybody,

I used viewer->setUpViewerAsEmbeddedInWindow way as Robert suggested to embed an OSG window in OpenGL context.

Then I tried to setup Manipulator like Trackball,
I did some code like this:

osg::observer_ptr<osgViewer::GraphicsWindow> gw = viewer->setUpViewerAsEmbeddedInWindow(...)

if(event->button() == Qt::LeftButton) 
	button = 0;
else if(event->button() == Qt::RightButton)
	button = 2;
In mousePressEvent:
if(gw->valid() && isInRange(event->x(), height - event->y()))
	(gw->getEventQueue())->mouseButtonPress(event->x(), event->y(), button + 1);

In mouseReleaseEvent:
	if(gw->valid() && isInRange(event->x(), height - event->y()))
		(gw->getEventQueue())->mouseButtonPress(event->x(), event->y(), button + 1);

isInRange Function judge if event happen in the OSG window.

Problem is when I only use left key, or only use right key, no problem at all. 

But if I switch once, then it just pan the whole scene, both keys lost their own ability. 

anybody has any idea about it?
Thank you.

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=9097#9097








More information about the osg-users mailing list