Re: [osg-users] Different results from camera->getViewMatrix() in OSG 3.4.0 compared to OSG 3.2.1
> > I have no suggestions, because you have have said nothing at all about how > you are setting up your viewer - so there is absolutely no clues for us to go > on to why you might be seeing this difference. All we have to go on is some > unknown application is producing difference results for some reason. > > You have access to all the source code to OSG-3.4.0 and OSG-3.2.1, you have > access to your application and your data, you have all the tools available to > put breakpoints into your application code that sets up your viewer and the > OSG. > > > > Robert. Thank you for the reply. It was the osg::GraphicsContext::createGraphicsContext(traits.get())) that now modifies the traits->y value to 138 (The size of the ribbon above the viewport). -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=66818#66818 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Different results from camera->getViewMatrix() in OSG 3.4.0 compared to OSG 3.2.1
On 14 April 2016 at 13:50, Ronny Hatteland wrote: > > Thank you for the quick reply! You are right. I fixed the input and now it > is evident that the difference is in the windowMatrix: > > > Code: > WindowMatrix > 3.4.0: > [0] {960.00, 0.0, 0.0, > 0.0} > [1] {0.0, 443.00, 0.0, > 0.0} > [2] {0.0, 0.0, 0.5, > 0.0} > [3] {960.00, 581.00, 0.5, > 1.} > 3.2.1 > [0] {960.00, 0.0, 0.0, > 0.0} > [1] {0.0, 443.00, 0.0, > 0.0} > [2] {0.0, 0.0, 0.5, > 0.0} > [3] {960.00, 443.00, 0.5, > 1.} > > > > Is seems like the difference in value [3][1] is what gives the vertical > offset on the screen of 138 pixels (between the cursor and the object I > normally display on the cursor position). > > Do you have any suggestion of how I could solve this? > I have no suggestions, because you have have said nothing at all about how you are setting up your viewer - so there is absolutely no clues for us to go on to why you might be seeing this difference. All we have to go on is some unknown application is producing difference results for some reason. You have access to all the source code to OSG-3.4.0 and OSG-3.2.1, you have access to your application and your data, you have all the tools available to put breakpoints into your application code that sets up your viewer and the OSG. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Different results from camera->getViewMatrix() in OSG 3.4.0 compared to OSG 3.2.1
robertosfield wrote: > Hi Ronny, > > > I don't recall any specific changes to view matrix management between > OSG-3.2.1 and OSG-3.4.0. I'm also not aware of any bugs being reported that > look relevant to this what you are describing. > > > Printing out two sets of view matrices for the two versions without the > view's being identical isn't useful. Try to create the exactly same input > conditions - for instance by explictly setting the view matrix. The mouse > input are another variable you'd need to standardize. > > > Also when describing the problem you'll need to do more than saying a > "vertical offset", this has so many different possible interpretations that > it's pointless even starting to guess what you mean. > > > > Robert. > Thank you for the quick reply! You are right. I fixed the input and now it is evident that the difference is in the windowMatrix: Code: WindowMatrix 3.4.0: [0] {960.00, 0.0, 0.0, 0.0} [1] {0.0, 443.00, 0.0, 0.0} [2] {0.0, 0.0, 0.5, 0.0} [3] {960.00, 581.00, 0.5, 1.} 3.2.1 [0] {960.00, 0.0, 0.0, 0.0} [1] {0.0, 443.00, 0.0, 0.0} [2] {0.0, 0.0, 0.5, 0.0} [3] {960.00, 443.00, 0.5, 1.} Is seems like the difference in value [3][1] is what gives the vertical offset on the screen of 138 pixels (between the cursor and the object I normally display on the cursor position). Do you have any suggestion of how I could solve this? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=66811#66811 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Different results from camera->getViewMatrix() in OSG 3.4.0 compared to OSG 3.2.1
The plug-in you used to load your model may behave differently and as a result the scene's bounding sphere center could have shifted . 2016-04-14 13:21 GMT+02:00 Robert Osfield : > Hi Ronny, > > I don't recall any specific changes to view matrix management between > OSG-3.2.1 and OSG-3.4.0. I'm also not aware of any bugs being reported > that look relevant to this what you are describing. > > Printing out two sets of view matrices for the two versions without the > view's being identical isn't useful. Try to create the exactly same input > conditions - for instance by explictly setting the view matrix. The mouse > input are another variable you'd need to standardize. > > Also when describing the problem you'll need to do more than saying a > "vertical offset", this has so many different possible interpretations that > it's pointless even starting to guess what you mean. > > Robert. > > > > On 14 April 2016 at 12:02, Ronny Hatteland > wrote: > >> Hi, >> >> I have some code for doing picking of objects on the screen: >> >> >> Code: >> float dX = ea.getX(); >> float dY = ea.getY(); >> >> osg::ref_ptr camera = view->getCamera(); >> >> // compute model to window transform >> // Model*View*Projection*WindowMatrix >> osg::Matrixd matrix; >> matrix.postMult(camera->getViewMatrix()); >> matrix.postMult(camera->getProjectionMatrix()); >> osg::Matrixd windowMatrix = camera->getViewport()->computeWindowMatrix(); >> matrix.postMult(windowMatrix); >> >> osg::Matrixd inverse; >> inverse.invert(matrix); >> >> // get the coordinates in screen-space: >> osg::Vec3 mouseloc = osg::Vec3(dX, dY, 0) * inverse; >> osg::Vec3 normalizedMouseRay = (osg::Vec3(dX, dY, 1) * inverse) - >> mouseloc; >> osg::Plane _dragPlane(osg::Vec4d(0, 1, 0, 0)); >> >> >> Which was working perfectly fine in OSG 3.2.1. >> However, when I updated to OSG 3.4.0 a vertical offset was introduced, >> which seems to be constant regardless of the camera. >> >> Positioning the camera at approximately the same place in both cases, and >> looking at the matrices, it looks like the offset was introduced already by >> the getViewMatrix() method, value[3][3]: >> >> >> Code: >> matrix.postMult(camera->getViewMatrix()); >> 3.4.0: >> [0] {1., 0.0, 0.0, >> 0.0} >> [1] {0.0, 0.0, -1., >> 0.0} >> [2] {0.0, 1., 0.0, >> 0.0} >> [3] {-1009.2817596644163, 216.03970056772232, -509.02834880430618, >> 1.} >> 3.2.1: >> [0] {1., 0.0, 0.0, >> 0.0} >> [1] {0.0, 0.0, -1., >> 0.0} >> [2] {0.0, 1., 0.0, >> 0.0} >> [3] {-1061.2815714627504, 239.85043859481812, -599.72003111232948, >> 1.} >> >> matrix.postMult(camera->getProjectionMatrix()); >> 3.4.0: >> [0] {1.7748398086904795, 0.0, 0.0, >> 0.0} >> [1] {0.0, 0.0, 1.0200, >> 1.} >> [2] {0.0, 3.8461539872299335, 0.0, >> 0.0} >> [3] {-1791.3134452375832, 830.92195573850609, 509.02834880411638, >> 509.02834880430618} >> 3.2.1 >> [0] {1.7748398086904795, 0.0, 0.0, >> 0.0} >> [1] {0.0, 0.0, 1.0200, >> 1.} >> [2] {0.0, 3.8461539872299335, 0.0, >> 0.0} >> [3] {-1883.6047812616794, 922.50172074030797, 599.72003111214144, >> 599.72003111232948} >> >> WindowMatrix >> 3.4.0: >> [0] {960.00, 0.0, 0.0, >> 0.0} >> [1] {0.0, 443.00, 0.0, >> 0.0} >> [2] {0.0, 0.0, 0.5, >> 0.0} >> [3] {960.00, 581.00, 0.5, >> 1.} >> 3.2.1 >> [0] {960.00, 0.0, 0.0, >> 0.0} >> [1] {0.0, 443.00, 0.0, >> 0.0} >> [2] {0.0, 0.0, 0.5, >> 0.0} >> [3] {960.00, 443.00, 0.5, >> 1.} >> >> matrix.postMult(windowMatrix); >> 3.4.0: >> [0] {1703.8462163428603, 0.0, 0.0, >> 0.0} >> [1] {960.00, 581.00, 1.0100, >> 1.} >> [2] {0.0, 1703.8462163428605, 0.0, >> 0.0} >> [3] {-1230993.6925759460, 663843.89704746008, 509.02834880421130, >> 509.02834880430618}
Re: [osg-users] Different results from camera->getViewMatrix() in OSG 3.4.0 compared to OSG 3.2.1
Hi Ronny, I don't recall any specific changes to view matrix management between OSG-3.2.1 and OSG-3.4.0. I'm also not aware of any bugs being reported that look relevant to this what you are describing. Printing out two sets of view matrices for the two versions without the view's being identical isn't useful. Try to create the exactly same input conditions - for instance by explictly setting the view matrix. The mouse input are another variable you'd need to standardize. Also when describing the problem you'll need to do more than saying a "vertical offset", this has so many different possible interpretations that it's pointless even starting to guess what you mean. Robert. On 14 April 2016 at 12:02, Ronny Hatteland wrote: > Hi, > > I have some code for doing picking of objects on the screen: > > > Code: > float dX = ea.getX(); > float dY = ea.getY(); > > osg::ref_ptr camera = view->getCamera(); > > // compute model to window transform > // Model*View*Projection*WindowMatrix > osg::Matrixd matrix; > matrix.postMult(camera->getViewMatrix()); > matrix.postMult(camera->getProjectionMatrix()); > osg::Matrixd windowMatrix = camera->getViewport()->computeWindowMatrix(); > matrix.postMult(windowMatrix); > > osg::Matrixd inverse; > inverse.invert(matrix); > > // get the coordinates in screen-space: > osg::Vec3 mouseloc = osg::Vec3(dX, dY, 0) * inverse; > osg::Vec3 normalizedMouseRay = (osg::Vec3(dX, dY, 1) * inverse) - mouseloc; > osg::Plane _dragPlane(osg::Vec4d(0, 1, 0, 0)); > > > Which was working perfectly fine in OSG 3.2.1. > However, when I updated to OSG 3.4.0 a vertical offset was introduced, > which seems to be constant regardless of the camera. > > Positioning the camera at approximately the same place in both cases, and > looking at the matrices, it looks like the offset was introduced already by > the getViewMatrix() method, value[3][3]: > > > Code: > matrix.postMult(camera->getViewMatrix()); > 3.4.0: > [0] {1., 0.0, 0.0, > 0.0} > [1] {0.0, 0.0, -1., > 0.0} > [2] {0.0, 1., 0.0, > 0.0} > [3] {-1009.2817596644163, 216.03970056772232, -509.02834880430618, > 1.} > 3.2.1: > [0] {1., 0.0, 0.0, > 0.0} > [1] {0.0, 0.0, -1., > 0.0} > [2] {0.0, 1., 0.0, > 0.0} > [3] {-1061.2815714627504, 239.85043859481812, -599.72003111232948, > 1.} > > matrix.postMult(camera->getProjectionMatrix()); > 3.4.0: > [0] {1.7748398086904795, 0.0, 0.0, > 0.0} > [1] {0.0, 0.0, 1.0200, > 1.} > [2] {0.0, 3.8461539872299335, 0.0, > 0.0} > [3] {-1791.3134452375832, 830.92195573850609, 509.02834880411638, > 509.02834880430618} > 3.2.1 > [0] {1.7748398086904795, 0.0, 0.0, > 0.0} > [1] {0.0, 0.0, 1.0200, > 1.} > [2] {0.0, 3.8461539872299335, 0.0, > 0.0} > [3] {-1883.6047812616794, 922.50172074030797, 599.72003111214144, > 599.72003111232948} > > WindowMatrix > 3.4.0: > [0] {960.00, 0.0, 0.0, > 0.0} > [1] {0.0, 443.00, 0.0, > 0.0} > [2] {0.0, 0.0, 0.5, > 0.0} > [3] {960.00, 581.00, 0.5, > 1.} > 3.2.1 > [0] {960.00, 0.0, 0.0, > 0.0} > [1] {0.0, 443.00, 0.0, > 0.0} > [2] {0.0, 0.0, 0.5, > 0.0} > [3] {960.00, 443.00, 0.5, > 1.} > > matrix.postMult(windowMatrix); > 3.4.0: > [0] {1703.8462163428603, 0.0, 0.0, > 0.0} > [1] {960.00, 581.00, 1.0100, > 1.} > [2] {0.0, 1703.8462163428605, 0.0, > 0.0} > [3] {-1230993.6925759460, 663843.89704746008, 509.02834880421130, > 509.02834880430618} > 3.2.1 > [0] {1703.8462163428603, 0.0, 0.0, > 0.0} > [1] {960.00, 443.00, 1.0100, > 1.} > [2] {0.0, 1703.8462163428605, 0.0, > 0.0} > [3] {-1232529.3601433760, 674344.23607071838,
[osg-users] Different results from camera->getViewMatrix() in OSG 3.4.0 compared to OSG 3.2.1
Hi, I have some code for doing picking of objects on the screen: Code: float dX = ea.getX(); float dY = ea.getY(); osg::ref_ptr camera = view->getCamera(); // compute model to window transform // Model*View*Projection*WindowMatrix osg::Matrixd matrix; matrix.postMult(camera->getViewMatrix()); matrix.postMult(camera->getProjectionMatrix()); osg::Matrixd windowMatrix = camera->getViewport()->computeWindowMatrix(); matrix.postMult(windowMatrix); osg::Matrixd inverse; inverse.invert(matrix); // get the coordinates in screen-space: osg::Vec3 mouseloc = osg::Vec3(dX, dY, 0) * inverse; osg::Vec3 normalizedMouseRay = (osg::Vec3(dX, dY, 1) * inverse) - mouseloc; osg::Plane _dragPlane(osg::Vec4d(0, 1, 0, 0)); Which was working perfectly fine in OSG 3.2.1. However, when I updated to OSG 3.4.0 a vertical offset was introduced, which seems to be constant regardless of the camera. Positioning the camera at approximately the same place in both cases, and looking at the matrices, it looks like the offset was introduced already by the getViewMatrix() method, value[3][3]: Code: matrix.postMult(camera->getViewMatrix()); 3.4.0: [0] {1., 0.0, 0.0, 0.0} [1] {0.0, 0.0, -1., 0.0} [2] {0.0, 1., 0.0, 0.0} [3] {-1009.2817596644163, 216.03970056772232, -509.02834880430618, 1.} 3.2.1: [0] {1., 0.0, 0.0, 0.0} [1] {0.0, 0.0, -1., 0.0} [2] {0.0, 1., 0.0, 0.0} [3] {-1061.2815714627504, 239.85043859481812, -599.72003111232948, 1.} matrix.postMult(camera->getProjectionMatrix()); 3.4.0: [0] {1.7748398086904795, 0.0, 0.0, 0.0} [1] {0.0, 0.0, 1.0200, 1.} [2] {0.0, 3.8461539872299335, 0.0, 0.0} [3] {-1791.3134452375832, 830.92195573850609, 509.02834880411638, 509.02834880430618} 3.2.1 [0] {1.7748398086904795, 0.0, 0.0, 0.0} [1] {0.0, 0.0, 1.0200, 1.} [2] {0.0, 3.8461539872299335, 0.0, 0.0} [3] {-1883.6047812616794, 922.50172074030797, 599.72003111214144, 599.72003111232948} WindowMatrix 3.4.0: [0] {960.00, 0.0, 0.0, 0.0} [1] {0.0, 443.00, 0.0, 0.0} [2] {0.0, 0.0, 0.5, 0.0} [3] {960.00, 581.00, 0.5, 1.} 3.2.1 [0] {960.00, 0.0, 0.0, 0.0} [1] {0.0, 443.00, 0.0, 0.0} [2] {0.0, 0.0, 0.5, 0.0} [3] {960.00, 443.00, 0.5, 1.} matrix.postMult(windowMatrix); 3.4.0: [0] {1703.8462163428603, 0.0, 0.0, 0.0} [1] {960.00, 581.00, 1.0100, 1.} [2] {0.0, 1703.8462163428605, 0.0, 0.0} [3] {-1230993.6925759460, 663843.89704746008, 509.02834880421130, 509.02834880430618} 3.2.1 [0] {1703.8462163428603, 0.0, 0.0, 0.0} [1] {960.00, 443.00, 1.0100, 1.} [2] {0.0, 1703.8462163428605, 0.0, 0.0} [3] {-1232529.3601433760, 674344.23607071838, 599.72003111223546, 599.72003111232948} inverse 3.4.0: [0] {0.00058670300251959689, 1.0310124207250091e-007, 4.3757801540539190e-008, -2.0254518695206543e-010} [1] {0.0, 0.0, 0.00058690742768229540, 0.0} [2] {-10086449333416.564, 5087071672824.5107, 2159033860383.4014, -9993690301.8739624} [3] {10086449333416.104, -5087071672823.5625, -2159033860383.7642, 9993690301.8740635} 3.2.1 [0] {0.00058743635625737895, -2.9889246175079844e-007, -1.1953825839478168e-007, 4.9838665751483716e-010} [1] {0.0, 0.0, 0.00058690742768229540, 0.0} [2] {-10634237608903.178, 6009305617996.5537, 2403345750271.9492, -10020184930.042784} [3] {10634237608902.719, -6009305617995.6123, -2403345750272.2324, 10020184930.042881} Is this a bug or is there a reason why this is different between the two versions? Thank you! Cheers, Ronny[