OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

OSG & QtQuick(QML) & setMirrorVertically mouse position problem with Picking


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
karcios
Newbie


Joined: 12 Feb 2016
Posts: 11

PostPosted: Wed Apr 11, 2018 12:45 pm    Post subject:
OSG & QtQuick(QML) & setMirrorVertically mouse position problem with Picking
Reply with quote

Hi,

QtQuick is integrated with OpenSceneGraph (osgEarth) via method 'QQuickFramebufferObject'
In QQuickFramebufferObject I had to use setMirrorVertically(true);
to get the right osg view (without mirror reflection).
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 remove line:
Code:
matrix.postMult(camera->getViewport()->computeWindowMatrix());


everything works fine.

But I also checked other solution and when I use

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

//ORIGINAL Viewport:
//inline const osg::Matrix computeWindowMatrix() const
//{
//return osg::Matrix::translate(1.0,1.0,1.0)*osg::Matrix::scale(0.5*width(),0.5*height(),0.5f)*osg::Matrix::translate(x(),y(),0.0f); // usually x()=0, y()=0, camera->setViewport(new osg::Viewport(0, 0, width(), height()));
//}

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(-MousePositionX, -WindowHeight()+MousePositionY,0.0f);
matrix.postMult(testWindowMatrix);
...


then everything is fine.
Is it possible to inject somewhere MousePositionX,MousePositionY into the osg system?
(Then I would use osgEarth IntersectionPicker/getWorldCoordsUnderMouse() out of box)

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

Any ideas?


Thank you!

Cheers,
Wojtek
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts [Help] OSG + ArKit: Problem convertin... Brayner General 4 Mon Oct 08, 2018 7:07 pm View latest post
No new posts Absolute final world position matrix ... Steal General 1 Mon Sep 24, 2018 11:25 am View latest post
No new posts Problem with output - OSG/Shader romulogcerqueira General 3 Sat Aug 04, 2018 6:36 pm View latest post
No new posts How to create a 3D ray from cursor po... Waaayoff General 2 Mon Jul 16, 2018 3:34 pm View latest post
No new posts problem with picking/intersecting in ... mue General 1 Sat Jun 09, 2018 11:18 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP