Hi Andreas,
>>>
>> yes, this way it's working. Thanks.
>>
>> I also managed the problem with material sharing by using deep-clone.
>> However, it still happens, that material changes only come to (visible)
>> effect after I have transformed geometry. I tried adding
>> cmat->rebuildState() to the above code but that didn't help. What would
>> I have to do?
> 
> hmm perhaps a missing begin/endEditCP somewhere?
> 

not sure ..

That's my changer-class:

-----------------------------

class EmissionChanger
{
  public:

          EmissionChanger(osg::Color4f color) : _color(color) {}

    osg::Action::ResultE change(osg::NodePtr& node)
    {
        osg::MaterialGroupPtr mg =
osg::MaterialGroupPtr::dcast(node->getCore());
        if(mg != osg::NullFC)
            color(mg->getMaterial());

        osg::GeometryPtr geo = osg::GeometryPtr::dcast(node->getCore());

        if(geo != osg::NullFC)
            color(geo->getMaterial());

        return osg::Action::Continue;
    }

  private:

    void color(osg::MaterialPtr m)
    {
        if(m == osg::NullFC)
            return;

        osg::ChunkMaterialPtr cm = osg::ChunkMaterialPtr::dcast(m);
        if(cm == osg::NullFC)
        {
            FWARNING(("ChunkAdder::doAdd: Material %p is not a "
                      "ChunkMaterial, can't add!\n", m.getCPtr()));
            return;
        }
                osg::MaterialChunkPtr matc =
osg::MaterialChunkPtr::dcast(cm->find(osg::MaterialChunk::getClassType()));
                if(matc != osg::NullFC)
                {
                        osg::beginEditCP(cm);
                                osg::beginEditCP(matc);
                                                         
matc->setEmission(_color);
                                osg::endEditCP(matc);
                                cm->rebuildState();
                        osg::endEditCP(cm);
                }
    }
    osg::Color4f _color;
};

-------------------------------

And that's how I use it:


EmissionChanger ec(color);
osg::traverse(m_node,
osg::osgTypedMethodFunctor1ObjPtrCPtrRef<osg::Action::ResultE,EmissionChanger,osg::NodePtr>(
&ec,&EmissionChanger::change));
                

What might I be missing?

Matthias


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to