Dear all
In my scene graph i have some boxes defined in this way:
shape= new osg::Box(osg::Vec3(0.0,0.0,0.0), 4.0);
shape->setName("Shape");
shape->setDataVariance( osg::Object::STATIC );
draw = new osg::ShapeDrawable;
draw->setDataVariance( osg::Object::DYNAMIC );
draw->setColor( color );
draw->setShape( shape.get() );
geode->addDrawable( draw.get() );
The position, color appearance and scale of each box are modified through a
PositionAttitudeTransform node:
osg::ref_ptr<osg::PositionAttitudeTransform> trans = new
osg::PositionAttitudeTransform;
trans->setName("Trans");
trans->setDataVariance( osg::Object::DYNAMIC );
trans->addChild( geode.get() );
trans->setPosition(position);
trans->setScale(osg::Vec3d(dimension, dimension, dimension));
osg::StateSet* state = trans->getOrCreateStateSet();
osg::ref_ptr<osg::Material> mat = new osg::Material;
mat->setDiffuse( osg::Material::FRONT, color);
mat->setSpecular( osg::Material::FRONT, osg::Vec4( 0.7f, 0.7f, 0.7f, 1.0f ) );
mat->setShininess( osg::Material::FRONT, 15.f );
//transparences
mat->setAlpha( osg::Material::FRONT_AND_BACK, trasparence)state->setMode(
GL_BLEND, osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON );
state->setMode( GL_CULL_FACE, osg::StateAttribute::OVERRIDE |
osg::StateAttribute::ON );
state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
state->setAttribute( mat.get() );
The scene contain 3 light...I enable light and material in the node animation
containing all the boxes:
//Activate light and material
//Set Color Property for all object
osg::StateSet* state = animationNode->getOrCreateStateSet();
state->setMode( GL_LIGHTING, osg::StateAttribute::ON );
state->setMode( GL_LIGHT0, osg::StateAttribute::ON );
state->setMode( GL_LIGHT1, osg::StateAttribute::ON );
// Should be off by default, but osgviewer enables it.
state->setMode( GL_COLOR_MATERIAL, osg::StateAttribute::OFF );
If i set the scale to 1
trans->scale(osg::Vec3d(1.0, 1.0, 1.0))
The color aof the boxes are nice.
If i reduce the scale...te boxes become very shining....instead if i increase
the boxes scale they become quite dark.
Where is my mistake?...are the material property set properly?
I remmember that modifing the directly the dimension of the osg::Box the
problem was not present...using also the same material property.
Does a PositionAttitudeTransform rescaling influence the "Shininess" of the
objects??
Thanks!!
Matteo
PhD BioIngegneria
Università di Bologna
+393471137908
------------------------------------------------------
Leggi GRATIS le tue mail con il telefonino i-mode di Wind
http://i-mode.wind.it/
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/