<div dir="ltr"><div><div><div>Hi Ronny,<br><br></div>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.<br><br></div>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.<br><br></div><div>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.<br></div><div><br></div>Robert.<br><div><div><br><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 14 April 2016 at 12:02, Ronny Hatteland <span dir="ltr"><<a href="mailto:ronnyhatteland@gmail.com" target="_blank">ronnyhatteland@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I have some code for doing picking of objects on the screen:<br>
<br>
<br>
Code:<br>
float dX = ea.getX();<br>
float dY = ea.getY();<br>
<br>
osg::ref_ptr<osg::Camera> camera = view->getCamera();<br>
<br>
// compute model to window transform<br>
// Model*View*Projection*WindowMatrix<br>
osg::Matrixd matrix;<br>
matrix.postMult(camera->getViewMatrix());<br>
matrix.postMult(camera->getProjectionMatrix());<br>
osg::Matrixd windowMatrix = camera->getViewport()->computeWindowMatrix();<br>
matrix.postMult(windowMatrix);<br>
<br>
osg::Matrixd inverse;<br>
inverse.invert(matrix);<br>
<br>
// get the coordinates in screen-space:<br>
osg::Vec3 mouseloc = osg::Vec3(dX, dY, 0) * inverse;<br>
osg::Vec3 normalizedMouseRay = (osg::Vec3(dX, dY, 1) * inverse) - mouseloc;<br>
osg::Plane _dragPlane(osg::Vec4d(0, 1, 0, 0));<br>
<br>
<br>
Which was working perfectly fine in OSG 3.2.1.<br>
However, when I updated to OSG 3.4.0 a vertical offset was introduced, which seems to be constant regardless of the camera.<br>
<br>
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]:<br>
<br>
<br>
Code:<br>
matrix.postMult(camera->getViewMatrix());<br>
3.4.0:<br>
[0] {1.0000000000000000, 0.00000000000000000, 0.00000000000000000, 0.00000000000000000}<br>
[1] {0.00000000000000000, 0.00000000000000000, -1.0000000000000000, 0.00000000000000000}<br>
[2] {0.00000000000000000, 1.0000000000000000, 0.00000000000000000, 0.00000000000000000}<br>
[3] {-1009.2817596644163, 216.03970056772232, -509.02834880430618, 1.0000000000000000}<br>
3.2.1:<br>
[0] {1.0000000000000000, 0.00000000000000000, 0.00000000000000000, 0.00000000000000000}<br>
[1] {0.00000000000000000, 0.00000000000000000, -1.0000000000000000, 0.00000000000000000}<br>
[2] {0.00000000000000000, 1.0000000000000000, 0.00000000000000000, 0.00000000000000000}<br>
[3] {-1061.2815714627504, 239.85043859481812, -599.72003111232948, 1.0000000000000000}<br>
<br>
matrix.postMult(camera->getProjectionMatrix());<br>
3.4.0:<br>
[0] {1.7748398086904795, 0.00000000000000000, 0.00000000000000000, 0.00000000000000000}<br>
[1] {0.00000000000000000, 0.00000000000000000, 1.0000000000000200, 1.0000000000000000}<br>
[2] {0.00000000000000000, 3.8461539872299335, 0.00000000000000000, 0.00000000000000000}<br>
[3] {-1791.3134452375832, 830.92195573850609, 509.02834880411638, 509.02834880430618}<br>
3.2.1<br>
[0] {1.7748398086904795, 0.00000000000000000, 0.00000000000000000, 0.00000000000000000}<br>
[1] {0.00000000000000000, 0.00000000000000000, 1.0000000000000200, 1.0000000000000000}<br>
[2] {0.00000000000000000, 3.8461539872299335, 0.00000000000000000, 0.00000000000000000}<br>
[3] {-1883.6047812616794, 922.50172074030797, 599.72003111214144, 599.72003111232948}<br>
<br>
WindowMatrix<br>
3.4.0:<br>
[0] {960.00000000000000, 0.00000000000000000, 0.00000000000000000, 0.00000000000000000}<br>
[1] {0.00000000000000000, 443.00000000000000, 0.00000000000000000, 0.00000000000000000}<br>
[2] {0.00000000000000000, 0.00000000000000000, 0.50000000000000000, 0.00000000000000000}<br>
[3] {960.00000000000000, 581.00000000000000, 0.50000000000000000, 1.0000000000000000}<br>
3.2.1<br>
[0] {960.00000000000000, 0.00000000000000000, 0.00000000000000000, 0.00000000000000000}<br>
[1] {0.00000000000000000, 443.00000000000000, 0.00000000000000000, 0.00000000000000000}<br>
[2] {0.00000000000000000, 0.00000000000000000, 0.50000000000000000, 0.00000000000000000}<br>
[3] {960.00000000000000, 443.00000000000000, 0.50000000000000000, 1.0000000000000000}<br>
<br>
matrix.postMult(windowMatrix);<br>
3.4.0:<br>
[0] {1703.8462163428603, 0.00000000000000000, 0.00000000000000000, 0.00000000000000000}<br>
[1] {960.00000000000000, 581.00000000000000, 1.0000000000000100, 1.0000000000000000}<br>
[2] {0.00000000000000000, 1703.8462163428605, 0.00000000000000000, 0.00000000000000000}<br>
[3] {-1230993.6925759460, 663843.89704746008, 509.02834880421130, 509.02834880430618}<br>
3.2.1<br>
[0] {1703.8462163428603, 0.00000000000000000, 0.00000000000000000, 0.00000000000000000}<br>
[1] {960.00000000000000, 443.00000000000000, 1.0000000000000100, 1.0000000000000000}<br>
[2] {0.00000000000000000, 1703.8462163428605, 0.00000000000000000, 0.00000000000000000}<br>
[3] {-1232529.3601433760, 674344.23607071838, 599.72003111223546, 599.72003111232948}<br>
<br>
inverse<br>
3.4.0:<br>
[0] {0.00058670300251959689, 1.0310124207250091e-007, 4.3757801540539190e-008, -2.0254518695206543e-010}<br>
[1] {0.00000000000000000, 0.00000000000000000, 0.00058690742768229540, 0.00000000000000000}<br>
[2] {-10086449333416.564, 5087071672824.5107, 2159033860383.4014, -9993690301.8739624}<br>
[3] {10086449333416.104, -5087071672823.5625, -2159033860383.7642, 9993690301.8740635}<br>
3.2.1<br>
[0] {0.00058743635625737895, -2.9889246175079844e-007, -1.1953825839478168e-007, 4.9838665751483716e-010}<br>
[1] {0.00000000000000000, 0.00000000000000000, 0.00058690742768229540, 0.00000000000000000}<br>
[2] {-10634237608903.178, 6009305617996.5537, 2403345750271.9492, -10020184930.042784}<br>
[3] {10634237608902.719, -6009305617995.6123, -2403345750272.2324, 10020184930.042881}<br>
<br>
<br>
Is this a bug or is there a reason why this is different between the two versions?<br>
<br>
Thank you!<br>
<br>
Cheers,<br>
Ronny[/code]<br>
<br>
------------------<br>
Read this topic online here:<br>
<a href="http://forum.openscenegraph.org/viewtopic.php?p=66808#66808" rel="noreferrer" target="_blank">http://forum.openscenegraph.org/viewtopic.php?p=66808#66808</a><br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote></div><br></div>