Hi,

I am trying to get line thickness using osg::LineWidth on a 
TexturedQuadGeometry but I cannot get it working. 

Does it not work on TexturedGeometry ?

Basically i want to get a border on my textured quad using this.

here is sample in which its reproduced
Image size is 300x200

Code:

 osgViewer::Viewer viewer;
 osg::setNotifyLevel(osg::NotifySeverity::INFO);
    
 // use a geode with a Box ShapeDrawable
 osg::Drawable *box = new osg::ShapeDrawable(new 
osg::Box(osg::Vec3(0.0f,0.0f,0.0f),1.0f));

osg::Image *exampleImage = osgDB::readImageFile( "someimage.jpg" );

osg::ref_ptr<osg::Geometry> pictureQuad = 
                                                        
osg::createTexturedQuadGeometry(
                                                        osg::Vec3(0.0f, 0.0f, 
0.0f),
                                                        
osg::Vec3(exampleImage->s(), 0.0f, 0.0f), 
                                                        osg::Vec3(0.0f, 0.0f, 
exampleImage->t()),
                                                        0.0f,
                                                        1.0f,
                                                        exampleImage->s(), 
                                                        exampleImage->t() ); 
        
osg::Geode* basicModel = new osg::Geode();

//creating texture and setting up parameters for video frame
osg::ref_ptr<osg::TextureRectangle> myTexRect= new 
osg::TextureRectangle(exampleImage);
myTexRect->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
myTexRect->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
myTexRect->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
myTexRect->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
            
//apply texture to quad
pictureQuad->getOrCreateStateSet()->setTextureAttributeAndModes(0, 
myTexRect.get(), osg::StateAttribute::ON);

osg::LineWidth* linewidth = new osg::LineWidth();
linewidth->setWidth(30.0f);
pictureQuad->getOrCreateStateSet()->setAttributeAndModes(linewidth,osg::StateAttribute::ON);

basicModel->addDrawable( pictureQuad.get() );
// create the "blocky" shader, a simple animation test
osg::StateSet *ss = basicModel->getOrCreateStateSet();

ss->setAttributeAndModes(linewidth,osg::StateAttribute::ON);
    
        
ss->setMode( GL_BLEND, osg::StateAttribute::ON);
//Adding blend function to node

osg::BlendFunc *bf = new osg::BlendFunc();
bf->setFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
ss->setAttributeAndModes(bf);

osg::MatrixTransform *trans = new osg::MatrixTransform();

trans->addChild(basicModel);

// run the osg::Viewer using our model
osg::Group *m_osg_root = new osg::Group;
m_osg_root->addChild(trans);
osg::ref_ptr<osg::Node> nodePtr = static_cast<osg::Node*>(m_osg_root);
viewer.setSceneData( nodePtr);
return viewer.run();



Thank you!

Cheers,
Abhishek[/code]

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=53624#53624





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to