Hello Mathieu,

On 19/07/10 2:02 , Mathieu Scorpionis wrote:
> When you say to give each geode the copy of its stateset, could you please 
> indicate me how to do ?
> Do we still use getOrCreateStateSet() method for each node ?

More likely you'd use getStateSet() to find out if the node already has a 
StateSet associated.

<code>
for geode in geodes:

    stateSet = geode.getStateSet()
    if stateSet != null:
        # Create private copy (shallow copy)
        stateSet = new osg::StateSet(stateSet)
    else:
        # Create empty StateSet
        stateSet = new osg::StateSet()

    # Set copy or new StateSet to Geode
    geode.setStateSet(stateSet)

    # Setup PolygonMode on StateSet
    polygonMode = stateSet.getAttribute(osg::StateAttribute::POLYGONMODE)
    if polygonMode == null:
        # Create and add PolygonMode
        stateSet.setAttributeAndModes(new osg::PolygonMode)
</code>

The important bit is the 'stateSet = new osg::StateSet(stateSet)' line, which 
creates a
copy of the shared StateSet, so that changes to this new StateSet don't affect 
other nodes
in the scene graph.

HTH,
/ulrich
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to