[osg-users] Texture on Cylinder

Nils werbung.openscenegraph.org at drego.de
Tue Nov 3 17:19:24 PST 2009



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




More information about the osg-users mailing list