Hi Rogerz?

The OSG has to binding positional state like glLight/osg::Light with a
modelview matrix to position it correctly in space, which is why there
is a special node in the scene graph for positioning it - the
osg::LightSource node.  If you don't attach your osg::Light to this
special node then the light will be applied at an arbitrary point with
an arbitrary modelview matrix that is current when it's applied - the
result will be undefined, there is nothing the OSG can do about this -
which is why the LightSource node exists - so use it.

Robert.

On Mon, Aug 30, 2010 at 4:25 AM, myth0904 <[email protected]> wrote:
> I wanna add a head light into the scene, ie.,the light is always attched
> with camera.
>
> For adding a light source into the scene, there are two different ways as i
> know:
>
> 1 using osg::LightSource::  setLight method
>
>
> osg::LightSource* ls = new osg::LightSource;
> ls->setLight(new osg::Light(0));
> ls->setReferenceFrame(osg::LightSource::ABSOLUTE_RF);
> geode->setStateSet(ls->getOrCreateStateSet());
>
>
> 2 using setAttribute method
>
> ls->getOrCreateStateSet()->setAttribute(new osg::Light(0));
> geode->setStateSet(ls->getOrCreateStateSet());
>
>
> I think two different ways should give the same result. Actually, they are
> different.
>
> No. 1 Method:  the light behaves like directional light, but not head light.
>
> No.2 method:  just like head light.
>
>
> who could tell me why the two ways are different?
> which is correct?
>
>
>
> ________________________________
> Rogerz
> 2010-08-30
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to