<div dir="ltr">Hi,<div><br></div><div>I think you can get the current material like this : (didn't compiled but maybe as a hint)</div><div><br></div><div><div>osg::State* state = renderInfo.getState();</div><div><span class="" style="white-space:pre">       </span>osg::State::AttributeMap& attrMap = state->getAttributeMap();</div><div><span class="" style="white-space:pre">       </span>osg::StateAttribute::TypeMemberPair typeMember = std::make_pair<osg::StateAttribute::Type,int>(osg::StateAttribute::MATERIAL,0);</div><div><span class="" style="white-space:pre">     </span>osg::State::AttributeStack stack = attrMap[typeMember];</div><div><span class="" style="white-space:pre">    </span>osg::State::AttributeVec attributes = stack.attributeVec;</div></div><div><br></div><div>you iterate over attributes and dynamic_cast osg::StateAttribute to osg::Material</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 23, 2015 at 6:15 PM, Sebastian Messerschmidt <span dir="ltr"><<a href="mailto:sebastian.messerschmidt@gmx.de" target="_blank">sebastian.messerschmidt@gmx.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF"><span class="">
    <br>
    <div>Am 23.06.2015 18:05, schrieb Gianluca
      Natale:<br>
    </div>
    <blockquote type="cite">
      
      
      
      <div>
        <p class="MsoNormal"><span lang="EN-US">Hi all,<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">I’m using OSG 3.0.1.<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">I have an issue when I
            try to retrieve the material properties from the rendering
            info, in my custom drawable.<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">To be clearer:<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US">I have a custom
            drawable, for which I implemented a<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">myDrawable::drawImplementation(</span><span lang="EN-US">osg::RenderInfo& osgRenderInfo</span><span lang="EN-US">).<u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">When I try to get the material properties
            inside that function, by following code:<u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">osg::StateSet  drwbStateSet;<u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">osg::State *state =
          </span><span lang="EN-US">osgRenderInfo.getState();<u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">state->captureCurrentState(</span><span lang="EN-US">drwbStateSet</span><span lang="EN-US">);<u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">the returned material properties is invalid.<u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">Specifically, I put a breakpoint in following
            function:<u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none">StateSet::setAttribute(StateAttribute
          *attribute, StateAttribute::OverrideValue value)<u></u><u></u></p>
        <p class="MsoNormal" style="text-autospace:none"><u></u> <u></u></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">that is called inside captureCurrentState.<u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">When the attribute is an osg::Material, the
            _ptr is different from the one allocated when the material
            has been set, in the state set associated to a parent node
            of that drawable.<u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">Furthermore, _userDataContainer is
            0x0000000000000000, so no valid osg::Material is returned in
            the captured state set.</span></p>
      </div>
    </blockquote></span>
    User data defaults to nullptr. So if you're not setting it up that
    is expected.<br>
    As you don't explain why you are trying to inspect state during draw
    it is hard to guess what you are after.<br>
    I simply guess that your state is set up somewhere further up in the
    stategraph (i.e. in one of the parents) and that state is set up
    lazy. <br>
    Maybe Robert can give some insights here. <br><span class="">
    <br>
    <br>
    <blockquote type="cite">
      <div>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">Any idea of the possible cause of the issue?
            Where did I go wrong?<u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">BTW, all other attributes (polygon offset,
            polygon mode, etc…) are returned correctly.</span></p>
      </div>
    </blockquote></span>
    Are you sure you are setting up an osg::Material state attribute
    somewhere?<br>
    <blockquote type="cite">
      <div>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US"><u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">Thanks,<u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US">Gianluca Natale<u></u><u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US"><u></u> <u></u></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span lang="EN-US"><u></u> <u></u></span></p>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
osg-users mailing list
<a href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.openscenegraph.org</a>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a>
</pre>
    </blockquote>
    <br>
  </div>

<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>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">trajce nikolov nick<br></div>
</div>