add

sphereGeode->getOrCreateStateSet()->setMode( GL_CULL_FACE,
osg::StateAttribute::ON );
peter

On Tue, Jun 17, 2008 at 1:24 PM, Juan Casanueva <[EMAIL PROTECTED]>
wrote:

>
> Hi there,
>
> I am having some problems with transparent objects. They have some
> artefacts (slices) depending on the view point.
> To illustrate the problem, I have done a simple example that draws a
> transparent red sphere with a box inside it.
> I have attached screenshots showing the strange "slices" appearing in the
> sphere.
> I must be missing something… any help would be appreaciated.
>
> Here is the code:
>
> #include <osg/Geode>
> #include <osg/ShapeDrawable>
> #include <osg/Material>
> #include <osgViewer/Viewer>
> #include <osgViewer/ViewerEventHandlers>
>
> int main( int argc, char **argv )
> {
>   osgViewer::Viewer viewer;
>   viewer.addEventHandler(new osgViewer::StatsHandler);
>   viewer.addEventHandler(new osgViewer::WindowSizeHandler);
>
>   osg::Group *root = new osg::Group;
>
>   // transparent sphere
>   osg::Geode  *sphereGeode = new osg::Geode;
>   sphereGeode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::
> Vec3(0.0f,0.0f,0.0f),40.0f)));
>
>   osg::StateSet* pStateSet = sphereGeode->getOrCreateStateSet();
>   pStateSet->setMode(GL_BLEND,osg::StateAttribute::ON);
>   pStateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
>
>   osg::Material *pMat = new osg::Material;
>   pMat->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(1, 0, 0,
> 0.5));
>   pMat->setAlpha(osg::Material::FRONT_AND_BACK, 0.5);
>   sphereGeode->getOrCreateStateSet()->setAttributeAndModes(pMat, osg::
> StateAttribute::ON);
>
>   root->addChild(sphereGeode);
>
>   // box inside sphere
>   osg::Geode *boxGeode = new osg::Geode;
>   boxGeode->addDrawable(new osg::ShapeDrawable(new 
> osg::Box(osg::Vec3(0.0f,0.0f,10.0f),10.0f)));
>
>
>   root->addChild(boxGeode);
>
>   viewer.setSceneData( root );
>
>   return viewer.run();
> }
>
>
> Thanks
> Juan
>
> <<...>> <<...>>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to