Re: [osg-users] Transparent sphere

2008-02-07 Thread Jean-Sébastien Guay
Hi Paul,

 Probably a more interesting question is how to render the transparent sphere
 so that the back half is rendered first and the front half is rendered
 second, for proper blending.

 Best way to do that is to multi-parent the sphere to two Geodes. In one
 Geode cull front faces, and in the other cull back faces. Then set the
 render bin details so that the back half gets rendered before the front half
 -- and both get rendered after the opaque sphere, of course.

Nice catch, I hadn't thought of this. I generally don't use transparency 
that much, and then mostly in test programs, so I normally just accept 
what I get with artifacts and all... :-)

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


Re: [osg-users] Transparent sphere

2008-02-07 Thread Jean-Sébastien Guay
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


[osg-users] Transparent sphere

2008-02-06 Thread Ahmed Nawar

Hi All,

How can I draw a Transparent sphere?

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.

Thanks,
Ahmed Nawar


winmail.dat___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org