<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle18
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Here is a more informed email of what I’m trying to accomplish:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">We have some old code that inherits from the ShadowMapTechnique to do most of it’s work which is based on the fixed-function pipeline. It uses the shadow map’s camera for projection of textures (among other things) and we are redesigning
it so that the base class is independent of the shadow map class. I thought I had everything working when I gutted out this function in the ViewData override function called addShadowReceivingTexGen():<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">_texgen->setMode(osg::TexGen::EYE_LINEAR);<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">// compute the matrix which takes a vertex from view coords into tex coords<o:p></o:p></p>
<p class="MsoNormal">_texgen->setPlanesFromMatrix(<o:p></o:p></p>
<p class="MsoNormal"> mClampCallback->getLastProjection() *<o:p></o:p></p>
<p class="MsoNormal"> osg::Matrix::translate(1.0, 1.0, 1.0) *<o:p></o:p></p>
<p class="MsoNormal"> osg::Matrix::scale(0.5f, 0.5f, 0.5f));<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">osg::RefMatrix * refMatrix = new osg::RefMatrix<o:p></o:p></p>
<p class="MsoNormal"> (_camera->getInverseViewMatrix() * *_cv->getModelViewMatrix());<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">_cv->getRenderStage()->getPositionalStateContainer()-><o:p></o:p></p>
<p class="MsoNormal"> addPositionedTextureAttribute<o:p></o:p></p>
<p class="MsoNormal"> (*_shadowTextureUnitPtr, refMatrix, _texgen.get());<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This is evidently stored in OpenGL’s built-in variables because it’s used in the vertex shader like this:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">{<o:p></o:p></p>
<p class="MsoNormal">gl_TexCoord[1].s = dot(ecPosition, gl_EyePlaneS[1]);<o:p></o:p></p>
<p class="MsoNormal">gl_TexCoord[1].t = dot(ecPosition, gl_EyePlaneT[1]);<o:p></o:p></p>
<p class="MsoNormal">gl_TexCoord[1].p = dot(ecPosition, gl_EyePlaneR[1]);<o:p></o:p></p>
<p class="MsoNormal">gl_TexCoord[1].q = dot(ecPosition, gl_EyePlaneQ[1]);<o:p></o:p></p>
<p class="MsoNormal">}<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">My new solution for the addShadowReceivingTexGen() is a simple updateTextureCoordinates() function:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">mTexGenMatrix = mCamera->getViewMatrix() *mCamera->getProjectionMatrix() * osg::Matrixd::translate(osg::Vec3d(1.0, 1.0, 1.0)) *<o:p></o:p></p>
<p class="MsoNormal">osg::Matrixd::scale(0.5, 0.5, 0.5);<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">And in the new vertex shader, I do this:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">TexCoords[0] = TexGenMatrix0 * gl_Vertex;<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Which goes from modelspace all the way to clip space. This works on simple objects created at the origin in modelspace, but it does NOT work with an entire world with large terrain.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’d like to continue NOT using the gl_EyePlaneSTRQ and just doing a regular transformation. However, going back to the old code for any clues is leading me nowhere. I traced the ‘addPositionedTextureAttribute’ to this:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">virtual void addPositionedTextureAttribute(unsigned int textureUnit, osg::RefMatrix* matrix,const osg::StateAttribute* attr)<o:p></o:p></p>
<p class="MsoNormal">{<o:p></o:p></p>
<p class="MsoNormal">_texAttrListMap[textureUnit].push_back(AttrMatrixPair(attr,matrix));<o:p></o:p></p>
<p class="MsoNormal">}<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">.. but I’m not sure what it’s doing here. The attr is the texgen object but that’s used to store a matrix. So what does the vertex shader ‘see’ from this function?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I apologize for the long and drawn out email but I’ve been thinking on this for a few hours now and am really new to OpenGL and not sure what some of this code is trying to do.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">-M<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1F497D">----------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1F497D">Marlin Rowley<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1F497D">Software Engineer, Staff<o:p></o:p></span></p>
<p class="MsoNormal"><img width="156" height="40" style="width:1.625in;height:.4166in" id="_x0000_i1026" src="cid:image001.jpg@01D3E213.8913D270" alt="cid:image002.jpg@01D39374.DEC5A2E0"><span style="font-size:10.0pt;font-family:"Times New Roman",serif;color:#1F497D"><o:p></o:p></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"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1F497D">972-603-1931 (office)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1F497D">214-926-0622 (mobile)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif"><a href="mailto:marlin.r.rowley@lmco.com">marlin.r.rowley@lmco.com</a></span><o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> osg-users [mailto:osg-users-bounces@lists.openscenegraph.org]
<b>On Behalf Of </b>Rowley, Marlin R (US)<br>
<b>Sent:</b> Wednesday, May 2, 2018 12:05 PM<br>
<b>To:</b> OpenSceneGraph Users <osg-users@lists.openscenegraph.org><br>
<b>Subject:</b> EXTERNAL: [osg-users] Getting the main camera.<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Is there a way to get a pointer to the main rendering camera without passing the Viewer around through classes and functions?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">-M<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1F497D">----------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1F497D">Marlin Rowley<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1F497D">Software Engineer, Staff<o:p></o:p></span></p>
<p class="MsoNormal"><img border="0" width="156" height="40" style="width:1.625in;height:.4166in" id="Picture_x0020_1" src="cid:image001.jpg@01D3E213.8913D270" alt="cid:image002.jpg@01D39374.DEC5A2E0"><span style="font-size:10.0pt;font-family:"Times New Roman",serif;color:#1F497D"><o:p></o:p></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"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1F497D">972-603-1931 (office)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1F497D">214-926-0622 (mobile)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif"><a href="mailto:marlin.r.rowley@lmco.com">marlin.r.rowley@lmco.com</a></span><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>