[osg-users] qtquick & setMirrorVertically mouse position problem

Wojtek Kowalski karcios at poczta.onet.pl
Wed Apr 11 05:45:58 PDT 2018


Hi,

QtQuick is integrated with OpenSceneGraph method (via QQuickFramebufferObject)
Inside QQuickFramebufferObject I had to use     setMirrorVertically(true);
to get right osg view (not mirrored).
The problem is with picking objects.
To get world coords from mouse position I use:


Code:

...
osg::Matrixd matrix;
matrix.postMult(camera->getViewMatrix());
matrix.postMult(camera->getProjectionMatrix());
matrix.postMult(camera->getViewport()->computeWindowMatrix());
...




but it doesn't work
If I comment line:

Code:

//matrix.postMult(camera->getViewport()->computeWindowMatrix());




everything works fine.

But I also checked and when I use


Code:

osg::Matrixd matrix;
matrix.postMult(camera->getViewMatrix());
matrix.postMult(camera->getProjectionMatrix());

osg::Matrix testWindowMatrix = osg::Matrix::translate(1.0,1.0,1.0)*osg::Matrix::scale(0.5*Windowwidth(),0.5*Windowheight(),0.5f)*osg::Matrix::translate(-XMousePosition,Windowheight()-YMousePosition,0.0f);
matrix.postMult(testWindowMatrix);




Everything is fine.
Is it possible to inject somewhere right XMousePosition and YMousePosition in the osg system?

Or maybe
ProjectionMatrix and WindowMatrix should be const, so It looks like a problem with ViewMatrix (inverted mouse positions etc)

Any ideas?


Thank you!

Cheers,
Wojtek

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







More information about the osg-users mailing list