Hello Ahmed,
I need to draw a sphere inside a Transparent one.
Can anyone tell me how to set the material and color of the Transparent one.
If you're using ShapeDrawables for your spheres, you can do it like this:
// Sphere of radius 1, red and semi-transparent.
osg::ref_ptrosg::ShapeDrawable sphere = new osg::ShapeDrawable(new
osg::Sphere(osg::Vec3(0,0,0), 1));
sphere-setColor(1, 0, 0, 0.5);// red, with 50% opacity.
sphere-getOrCreateStateSet()-setMode(GL_BLEND,
osg::StateAttribute::ON); // Activate blending.
osg::ref_ptrosg::Geode geode = new osg::Geode;
geode-addDrawable(sphere.get());
// Sphere of radius 0.5, blue.
osg::ref_ptrosg::ShapeDrawable sphere2 = new osg::ShapeDrawable(new
osg::Sphere(osg::Vec3(0,0,0), 0.5));
sphere2-setColor(0, 0, 1, 1);// blue
osg::ref_ptrosg::Geode geode2 = new osg::Geode;
geode2-addDrawable(sphere2.get());
osg::ref_ptrosg::Group root = new osg::Group;
root-addChild(geode.get());
root-addChild(geode2.get());
That should give you a semi-transparent red sphere with an opaque blue
sphere inside. (untested...)
If you're using normal geometry, you need to set a color array with the
opacity you want, and remember to enable blending on it too.
J-S
--
__
Jean-Sebastien Guay[EMAIL PROTECTED]
http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org