[osg-users] Texture on Cylinder

Robert Osfield robert.osfield at gmail.com
Wed Nov 4 01:14:21 PST 2009


Hi Nils,

It's likely going dark because the surface normals are all pointing
outwards.  Switch lighting of for the ShapeDrawable using:

  stateset->setMode(GL_LIGHTING, osg::StateAttribute::OFF);

Robert.

On Wed, Nov 4, 2009 at 1:19 AM, Nils
<werbung.openscenegraph.org at drego.de> wrote:
>
>
> Hey,
> I would like to build a simple panorma program with  osg.
> I used a Cylinder and a similiar Code to sampleshape:
>
>   osg::Geode* geode = new osg::Geode();
>
>    // ---------------------------------------
>    // Set up a StateSet to texture the objects
>    // ---------------------------------------
>    osg::StateSet* stateset = new osg::StateSet();
>
>    osg::Image* image = osgDB::readImageFile( "Images/lz.rgb" );
>
>    if (image)
>    {
>        osg::Texture2D* texture = new osg::Texture2D;
>        texture->setImage(image);
>
>  stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
>    }
>
>    geode->setStateSet( stateset );
>
>    float radius = 50.0f;
>    float height = 20.0f;
>
>    osg::TessellationHints* hints = new osg::TessellationHints;
>    hints->setDetailRatio(0.5f);
>
>    geode->addDrawable(new osg::ShapeDrawable(new
> osg::Cylinder(osg::Vec3(6.0f,0.0f,0.0f),radius,height),hints));
>
>
>
> When I zoom into the cylinder, everything is dark and I cant see my texture.
> What can I do?
>
> Thanks,
> Nils
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


More information about the osg-users mailing list