I'm using a shared Geode/Billboard multiparented to several transforms and want
to attach a unique color and transparency to each of these.
(Also they will have unique positions, rotations and scalings, but those I
already got using PositionAttitudeTransform).
What would be the best way to set and change color and transparency?
(If possible, I'd stay with the PositionAttitudeTransform rather than
calculating the MatrixTransform myself)
Right now I can set a unique color to each PAT, but it's just a constant color
and I need a 3D-Effect. I'm not really firm with all those Blend-Enums and
could need a hint how to set source and destination, if this is the solution.
Best regards
Hartmut
// -------------------------------------------------
osg::ref_ptr<osg::Group> myGroup = new osg::Group;
osg::ref_ptr<osg::PositionAttitudeTransform> myPat1 = new
osg::PositionAttitudeTransform,
myPat2 = new osg::PositionAttitudeTransform;
osg::ref_ptr<osg::Geode> myGeode = new osg::Geode;
osg::ref_ptr<osg::Geometry> myGeom = CloneNode3D(); // this is the shared
geometry
myGeode->addDrawable(myGeom.get());
// -------------------------------------------------
const osg::StateAttribute::GLModeValue modeValue =
osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE;
osg::ref_ptr<osg::BlendFunc> myBF1 = new osg::BlendFunc(),
myBF2 = new osg::BlendFunc;
osg::ref_ptr<osg::BlendColor> myBC1 = new osg::BlendColor,
myBC2 = new osg::BlendColor;
myBF1->setSource(osg::BlendFunc::SRC_ALPHA);
myBF1->setDestination(osg::BlendFunc::ONE_MINUS_SRC_ALPHA);
myPat1->getOrCreateStateSet()->setAttributeAndModes(myBF1,osg::StateAttribute::ON);
myPat1->getOrCreateStateSet()->setAttributeAndModes(myBC1,osg::StateAttribute::ON);
myBC1->setConstantColor(osg::Vec4(0,0,1,0.1));
myBC2->setConstantColor(osg::Vec4(0,1,0,1));
osg::ref_ptr<osg::StateSet> state1 = new osg::StateSet,
state2 = new osg::StateSet;
state1->setAttributeAndModes( myBC1, modeValue );
state2->setAttributeAndModes( myBC2, modeValue );
// osg::BlendFunc* bf = new osg::BlendFunc(
osg::BlendFunc::CONSTANT_ALPHA,osg::BlendFunc::ONE_MINUS_CONSTANT_ALPHA );
// -------------------------------------------------
myPat1->setScale(osg::Vec3(2,2,2));
myPat1->setPosition(osg::Vec3(4,4,4));
myPat1->setStateSet(state1.get());
myPat1->addChild(myGeode);
m_PAT_to_Id[myPat1] = 1;
myPat2->setScale(osg::Vec3(1,1,1));
myPat2->setPosition(osg::Vec3(0,-2,0));
myPat2->setStateSet(state2.get());
myPat2->addChild(myGeode);
m_PAT_to_Id[myPat2] = 2;
// -------------------------------------------------
myGroup->addChild(myPat1);
myGroup->addChild(myPat2);
loadedModel->addChild(myGroup);
--
frag nicht - du könntest eine antwort erhalten
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org