Hi,
I'm writing a class to get an osg Viewer working from the JUCE framework
(http://www.rawmaterialsoftware.com/juce/)
I've attached the class, things seem to work ok, i can see my node with a mesh
object, expect that the mouse events aren't working.
I'm initializing this class from my main app as:
Code:
... build node tree ...
viewer-setSceneData( root );
//viewer.run();
viewer-setCameraManipulator(new osgGA::TrackballManipulator());
viewer-addEventHandler(new osgViewer::StatsHandler);
viewer-realize();
here's the class:
Code:
class OsgViewerComponent : public osgViewer::Viewer, public OpenGLComponent,
public ChangeListener
{
public:
OsgViewerComponent () :
window(NULL)
{
};
~OsgViewerComponent() {};
void newOpenGLContextCreated()
{
window = setUpViewerAsEmbeddedInWindow(getX(), getY(),
getWidth(), getHeight());
getCamera()-setViewport(new osg::Viewport(0, 0, getWidth(),
getHeight()));
getCamera()-setProjectionMatrixAsPerspective(60.0f,
static_castdouble(getWidth())/static_castdouble(getHeight()), 1.0f,
1.0f);
getCamera()-setGraphicsContext(window.get());
//getCamera()-setClearColor (osg::Vec4(0.2f, 0.2f, 0.2f,
1.f));
setThreadingModel(osgViewer::Viewer::SingleThreaded);
};
void renderOpenGL()
{
frame();
};
void resized()
{
if(window.valid()) {
window-getEventQueue()-windowResize(getX(), getY(),
getWidth(), getHeight() );
window-resized(getX(), getY(), getWidth(),
getHeight());
getCamera()-setViewport(new osg::Viewport(0, 0,
getWidth(), getHeight()));
getCamera()-setProjectionMatrixAsPerspective(60.0f,
static_castdouble(getWidth())/static_castdouble(getHeight()), 1.0f,
1.0f);
}
};
void mouseDown (const MouseEvent e)
{
int mButton = 1;
int flags = e.mods.getRawFlags();
if(flags == ModifierKeys::leftButtonModifier)
mButton = 1;
else if(flags == ModifierKeys::middleButtonModifier)
mButton = 2;
else if(flags == ModifierKeys::rightButtonModifier)
mButton = 3;
window-getEventQueue()-mouseButtonPress(e.x, e.y, mButton);
frame();
}
void mouseUp (const MouseEvent e)
{
int mButton = 1;
int flags = e.mods.getRawFlags();
if(flags == ModifierKeys::leftButtonModifier)
mButton = 1;
else if(flags == ModifierKeys::middleButtonModifier)
mButton = 2;
else if(flags == ModifierKeys::rightButtonModifier)
mButton = 3;
window-getEventQueue()-mouseButtonRelease(e.x, e.y, mButton);
frame();
}
void mouseMove (const MouseEvent e)
{
window-getEventQueue()-mouseMotion(e.x, e.y);
frame();
};
void changeListenerCallback (void*) {};
juce_UseDebuggingNewOperator
private:
osg::observer_ptrosgViewer::GraphicsWindow window;
OsgViewerComponent (const OsgViewerComponent);
const OsgViewerComponent operator= (const OsgViewerComponent);
};
I've tested the juce mouseDown, mouseUp and mouseMove methods and these all
work propperly, returning the required mouse positions (integer window coords)
and buttons as ints.
It just seems the trackballmanipulator is'nt responding to them.
Not sure how it should respond and what mouse/key combinations to say rotate
the node are required as i can't find it anywhere in the openscenegrah docs.
Anyone have a clue ?
Thank you!
Cheers,
Terrence
--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=17304#17304
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org