[osg-users] PrimitiveSet lighting issues

Cysneros, Nelson SPAWAR nelson.cysneros at navy.mil
Mon Sep 24 11:26:06 PDT 2007


 
I'm drawing  osg::PrimitiveSet::LINES deep inside my node architecture.
The lines come up the right color, but depending on the camera position,
the line tends to turn black.  I would like the line color to stay
constant regardless of the camera position.
 
>From doing some research it seems like my problem could be either
normals or light source, but I've played with both a lot and can not get
it to work.
 
This is what my current settings are.  Any suggestions would be greatly
appreciated:
 

//add normals

osg::Vec3Array* norms = new osg::Vec3Array(1);

(*norms)[0] = osg::Vec3(1,0.0f,1.0f);

(*norms)[0].normalize();

lineGeom->setNormalArray(norms);

lineGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);

 

//add light 

/////////////////////////////////////////////////////////////////

//Add light source to geom

osg::LightSource* lightSource = new osg::LightSource;

osg::Light* light = lightSource->getLight();

osg::StateSet* statelightON_OVRD = mgroup->getOrCreateStateSet(); 

statelightON_OVRD->setAttribute(light, osg::StateAttribute::ON
|osg::StateAttribute::PROTECTED );

statelightON_OVRD->setMode(GL_CULL_FACE,osg::StateAttribute::OFF );

light->setLightNum(1);

// light->setPosition(osg::Vec4(0.0f,0.0f,0.0f,1.0f)); // directional
light from above

light->setAmbient(osg::Vec4(0.8f,0.8f,0.8f,1.0f));

light->setDiffuse(osg::Vec4(0.2f,0.2f,0.2f,1.0f));

light->setSpecular(osg::Vec4(0.2f,0.2f,0.2f,1.0f));

light->setSpotExponent(50.0);

light->setDirection(osg::Vec3(1,1,-1));

statelightON_OVRD->setAttribute(light, osg::StateAttribute::ON);

lineGroup->addChild(lightSource);

 

Regards

 
 
 
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070924/f4a3ff74/attachment-0002.htm>


More information about the osg-users mailing list