<div dir="ltr">HI Marlin,<div><br></div><div>I would hope that you can implement what you need without getting your hands dirty with internals of the OSG. It sound like you want something similar to osg::ClipPlaneNode.  Have a look at osgclip to see how it works.</div><div><br></div><div>Robert.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 13 April 2018 at 22:30, Rowley, Marlin R <span dir="ltr"><<a href="mailto:marlin.r.rowley@lmco.com" target="_blank">marlin.r.rowley@lmco.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="m_-5780567004531616745WordSection1">
<p class="MsoNormal">Hello!<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I’m trying to generate my own texture coordinates (on-the-fly) by having a callback that runs when a piece of geometry intersects my object.  So for example, I create a realworld frustum and when my frustum has a shader that’s bound to
 some arbitrary object in the world.  When my frustum intersects this object, I would like to generate texture coordinates on this object based on how far or near I am to the frustum’s near/far planes (it’s perspective frustum).  We had the following code for
 doing this:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:#569cd6">void</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#4ec9b0">ViewshedOSG</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">::</span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">updateTextur<wbr>eCoordinates</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">()</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">{</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"></span><span style="font-size:14.5pt;font-family:Consolas;color:#57a64a">// write the plane equation <wbr>for all 3 planes</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"></span><span style="font-size:14.5pt;font-family:Consolas;color:#57a64a">// that make up the camera <wbr>view frustum.  We can</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"></span><span style="font-size:14.5pt;font-family:Consolas;color:#57a64a">// then access this from the <wbr>shader to test whether</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"></span><span style="font-size:14.5pt;font-family:Consolas;color:#57a64a">// we are in the frustum's <wbr>volume or not.</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro">   
</span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">osg</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">::</span><span style="font-size:14.5pt;font-family:Consolas;color:#4ec9b0">Matrixd</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">projection</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">=</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada">mCam<wbr>era</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">-></span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">getViewMatrix</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">();</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro">     
</span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada">mTexGen</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">-></span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">setPlanesFromMatrix</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">(</span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">p<wbr>rojection</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">*</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"> <u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro">     
</span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">osg</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">::</span><span style="font-size:14.5pt;font-family:Consolas;color:#4ec9b0">Matrix</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">::</span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">translate</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">(</span><span style="font-size:14.5pt;font-family:Consolas;color:#b5cea8">1.0</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">,</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#b5cea8">1.<wbr>0</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">,</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#b5cea8">1.0</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">)</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">*</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro">     
</span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">osg</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">::</span><span style="font-size:14.5pt;font-family:Consolas;color:#4ec9b0">Matrix</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">::</span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">scale</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">(</span><span style="font-size:14.5pt;font-family:Consolas;color:#b5cea8">0.5f</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">,</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#b5cea8">0.5f</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">,</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"><wbr> </span><span style="font-size:14.5pt;font-family:Consolas;color:#b5cea8">0.5f</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">));</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"></span><span style="font-size:14.5pt;font-family:Consolas;color:#57a64a">// Bring our models viewspace <wbr>coordinates back</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"></span><span style="font-size:14.5pt;font-family:Consolas;color:#57a64a">// into model space <wbr>coordinate of the camera <wbr>frustum</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"></span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">osg</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">::</span><span style="font-size:14.5pt;font-family:Consolas;color:#4ec9b0">RefMatrix</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">*</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">refMatrix</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">=</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#569cd6">n<wbr>ew</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">osg</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">::</span><span style="font-size:14.5pt;font-family:Consolas;color:#4ec9b0">RefMatrix</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro">          
</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">(</span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada">mCamera</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">-></span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">getInverseViewMatrix</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4"><wbr>()</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">*</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">*</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro">_cv</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">-></span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro">getModelViewMatrix</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">(<wbr>));</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"></span><span style="font-size:14.5pt;font-family:Consolas;color:#57a64a">// Copy the texture generator <wbr>to the mesh where you </span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"></span><span style="font-size:14.5pt;font-family:Consolas;color:#57a64a">// can index it's coordinates <wbr>from the ViewshedID</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro">      _cv</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">-></span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro">getRenderStage</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">()-></span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro">getPosi<wbr>tionalStateContainer</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">()-></span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro">            addPositionedTextureAttribute<u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro">           
</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">(</span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada">mId</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">,</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">refMatrix</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">,</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada">mTexGen</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">.</span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">get</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">()<wbr>);</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">}</span><span style="font-size:14.5pt;font-family:Consolas;color:gainsboro"><u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">However, this code was based on a cull visitor calling this function from a callback.  I have my own callback and it’s not based on a visitor. Is there anyway to get the objects modelview matrix() without calling it from a cull visitor? 
 Also only need to write the ‘<wbr>addPositionedTextureAttribute’ on the geometry in order to access the coordinates through a shader.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I’m trying to keep this simple.  Am I in the right direction?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">-M<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1f497d">------------------------------<wbr>----------<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1f497d">Marlin Rowley<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1f497d">Software Engineer, Staff<u></u><u></u></span></p>
<p class="MsoNormal"><img width="156" height="40" style="width:1.625in;height:.4166in" id="m_-5780567004531616745Picture_x0020_1" src="cid:image001.jpg@01D3D33C.612DDB10" alt="cid:image002.jpg@01D39374.DEC5A2E0"><span style="font-size:10.0pt;font-family:"Times New Roman",serif;color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><i><span style="font-size:12.0pt;font-family:"Times New Roman",serif;color:#1f497d">Missiles and Fire Control</span></i><span style="color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1f497d">972-603-1931 (office)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1f497d">214-926-0622 (mobile)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif"><a href="mailto:marlin.r.rowley@lmco.com" target="_blank"><span style="color:#0563c1">marlin.r.rowley@lmco.com</span></a></span><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>

<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>
<br></blockquote></div><br></div>