[osg-users] Accessing StateSets

Robert Osfield robert.osfield at gmail.com
Tue Apr 12 03:35:13 PDT 2011


Hi Ethan,

You code segment looks OK, and if the the getAttribute is returning a
NULL then the most likley reason is that there in no osg::Material
attached to that particular StateSet.  It's perfectly normals for
StateSet to not contain an osg::Material, so returning NULL is nothing
out of the oridinary.

To have a look at what state is attached where in your scene graph it
is best to write the scene graph out to a .osg (or .osgt) ascii file
and then simply browse the file to see what data is stored where.

Robert.

On Fri, Apr 8, 2011 at 8:19 PM, Ethan Kerzner <ethan.kerzner at survice.com> wrote:
> Hi,
>
> I am trying to access the material stored in a stateset. Is this possible?
>
> My approach is below- the first line returns a null pointer.
>
>
> Code:
> osg::StateAttribute* sa = myGeode.getOrCreateStateSet()->getAttribute(osg::StateAttribute::MATERIAL);
> osg::Material* mat = dynamic_cast<osg::Material*>(sa);
>
>
>
>
> Thank you!
>
> Cheers,
> ethan
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=38337#38337
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



More information about the osg-users mailing list