[osg-users] osg::Material and shapes

Peter Wraae Marino osghelp at gmail.com
Thu Sep 18 00:26:53 PDT 2008


Hi users,

I'm trying to apply a material color to a shape. I assume material color is
a state and can be applied to the group that contains the shape.
This being said the basic code looks like this:


osg::Group* pGroup = new osg::Group;
osg::Geode* pGeode = new osg::Geode();
pGeode->addDrawable( new osg::ShapeDrawable(
newosg::Capsule(osg::Vec3(8.0f,0.0f,1.0f),0.5f,3.0f) ) );
pGroup->addChild( pGeode );

osg::Material* mat = new osg::Material();
mat->setColorMode( osg::Material::DIFFUSE );
mat->setDiffuse( osg::Material::FRONT_AND_BACK, osg::Vec4(0.0, 1.0, 0.0,
1.0) );
pGroup->getOrCreateStateSet()->setAttribute( mat, osg::StateAttribute::ON );

I would expect my capsule to be green.. but it's still gray?
searching the archive I fould this:
http://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg04463.html
and he states at the bottom that osg::Material can be used with shapes

so,.. am I missing something? Can someone shed a little light and give me a
push in the right direction.

-- 
Regards,
Peter Wraae Marino

www.osghelp.com - OpenSceneGraph support site
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080918/75a7f39d/attachment-0002.htm>


More information about the osg-users mailing list