<div dir="ltr">Hi,<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Knowing the 3D coordinates of a point, is there an easy way in OSG to compute its 2D projected equivalent (i.e. in pixel coordinates)?</span>

</blockquote><div><br></div><div>Yes. In general your pixel coord is computed as: </div><div><br></div><div>pixel_coords = WindowMatrix * ProjectionMatrix * ViewMatrix * ModelMatrix * point;</div><div><br></div><div>Your solution may vary whether you compute it in Update/Cull stage. Visitiors may have some utility functions making it simpler. But here I present more general solution:</div><div><br></div><div>osg::Vec3 point; // Your 3D point somewhere in the graph as a coord of some vertex under some 

<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">point_parent_node</span>  Node</div><div>osg::Matrix ModelMatrix = point_parent_node->getWorldMatrices()[0]; // Assuming your point have single parental path</div><div>osg::Matrix ViewMatrix = camera->getViewMatrix();</div><div>osg::Matrix ProjectionMatrix = camera->getProjectionMatrix();</div><div>osg::Matrix WindowMatrix = camera->getViewport()->computeWindowMatrix();</div><div><br></div><div>osg::Vec3 <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">pixel_coords = WindowMatrix * ProjectionMatrix * ViewMatrix * ModelMatrix * point;</span>

</div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">// x i y are window screen coords z is depth coord</span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Cheers,</span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Wojtek</span></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-03-16 13:37 GMT+01:00 Antoine Rennuit <span dir="ltr"><<a href="mailto:antoinerennuit@hotmail.com" target="_blank">antoinerennuit@hotmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear OSG forum,<br>
<br>
Knowing the 3D coordinates of a point, is there an easy way in OSG to compute its 2D projected equivalent (i.e. in pixel coordinates)?<br>
<br>
Thanks,<br>
<br>
Antoine.<br>
<br>
------------------<br>
Read this topic online here:<br>
<a href="http://forum.openscenegraph.org/viewtopic.php?p=73112#73112" rel="noreferrer" target="_blank">http://forum.openscenegraph.<wbr>org/viewtopic.php?p=73112#<wbr>73112</a><br>
<br>
<br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.<wbr>openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.<wbr>org/listinfo.cgi/osg-users-<wbr>openscenegraph.org</a><br>
</blockquote></div><br></div>