Hi Yigang,

At a guess I would say that you need to enable the second light for
the subraph you want to illuminate in addition to adding the light to
the scene.  See the osglight example.

Robert.

On 7/11/06, Yigang Wang <[EMAIL PROTECTED]> wrote:
Hi, All,

When I use multiple lights, the program is the attachment. Though I set two 
lights in the scene, but one light brighten objects. So what is the problem?

Thanks for your reply.

PS. the program is as follows.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

 _scene = new osg::Group;

 osg::ref_ptr<osg::LightSource> oneLight = new osg::LightSource;

 osg::ref_ptr<osg::Light> light = new osg::Light;
    light->setLightNum(0);

 osg::Vec4 ambient(0.1f,0.1f,0.1f,1.0f);
 osg::Vec4 specular(0.5f,0.5f,0.5f,1.0f);
 float shineness = 30;


 light->setAmbient(ambient);
 light->setSpecular(specular);
 //light->setSpotExponent(shineness);
 light->setPosition(osg::Vec4(0.0,0.0,2000.0,1.0f));

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

 oneLight->setLight(light.get());

 //_scene->setReferenceFrame(osg::LightSource::ABSOLUTE_RF); // headlight.
 oneLight->setReferenceFrame(osg::LightSource::RELATIVE_RF); // sun
 oneLight->setLocalStateSetModes(osg::StateAttribute::ON);

 // add either a headlight or sun light to the scene.
 osg::ref_ptr< osg::LightSource> anotherLight = new osg::LightSource;
 osg::ref_ptr<osg::Light> light1 = new osg::Light;
 light1->setLightNum(1);
 light1->setAmbient(ambient);
 light1->setSpecular(specular);
 //light->setSpotExponent(shineness);
 light1->setPosition(osg::Vec4(0.0,0.0,1.0, 0.0));

 light1->setDiffuse(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
 light1->setConstantAttenuation(1.0f);

 anotherLight->setLight(light1.get());


 anotherLight->setReferenceFrame(osg::LightSource::ABSOLUTE_RF);
 anotherLight->setLocalStateSetModes(osg::StateAttribute::ON);

 _scene->addChild( oneLight.get());
 _scene->addChild( anotherLight.get());
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/


_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to