Hi Gulianzhang (BTW, do you have a shorted name we could use?) Management of lights is complicated by the fact the lights are positional state i.e. they rely on specific values of the modelview matrix to position them in the right place so you can't them apply arbitrary times with arbitrary modelview matrices as they jump around in your scene. The OSG solves this problem by handling positional state differently than the rest of OpenGL state - and positions it via the osg::LightSource, and once positioned you can only have one position for a whole stage in rendering (implemented via the osgUtil::RenderStage in the rendering backend). This does mean that one light source can only be in one place at a time - you can't just reassign it as you wish.
If you want to do the reassignment then you'll need to create a multiple stage rendering setup, and place objects you wish to associate with a particular light source into the same rendering stage. In scene graph terms this would mean dividing your scene up so that you have a series of subgraphs each with the LightSource for that subgraph, and a callback above each subgraph that setups up the rendering backend. Robert. On Thu, Aug 28, 2008 at 8:01 AM, guilianzhang <[EMAIL PROTECTED]> wrote: > Hi, > I build a scene using osg which is composed of many objects and many lights, > I want to traverse each object to find the nearest light away from it and > associate the light with GL_LIGHT0, so each object has its own GL_LIGHT0 > parameters. > The problem is that the light is added to the scene by adding a > osg::LightSource, and the LightSource node then is added to the scene graph, > Must I add LightSources for each object to set its own light parameters? Is > there any better method? > > Thanks very much! > > ________________________________ > guilianzhang > 2008-08-28 > _______________________________________________ > 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

