[osg-users] Lighting behavior and osgViewer::osgViewer

Christophe Medard christophe.medard at oktal.fr
Wed Sep 12 09:10:32 PDT 2007

Hi all,

I'm stuck with an issue that should be extremely simple, but anyway I don't get it.

- How is running the default Lighting Mode set in osgViewer ? 
That class contains an osg::Light _light member that is instanciated but I can find anywhere its linking to the scene graph !?
- What is the difference between HEADLIGHT and SKY_LIGHT ?
The question is raised because I don't see indeed the _light member use...
- Isn't it strange that osgViewer::setLightingMode(NO_LIGHT) doesn't unref and free the _light member ?
The default is HEADLIGHT when the users instanciates his osgViewer : if right after he chooses setLightingMode(NO_LIGHT) before calling run(), _light is allocated even if it is not in use...
- How can I deactivate the lighting set by default by the osgViewer ?
I've been trying :

osgViewer::Viewer viewer(arguments);
viewer.addEventHandler(new osgViewer::XXXHandler);

osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);

viewer.setLight(NULL); // <1>
viewer.setLightingMode(NO_LIGHT);  // <2>
viewer.getCamera()->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); // <3>

viewer.setSceneData( root.get() );

<1>, <2> or <3> seems to be of no use , the default lighting coming with osgViewer adds itself to the one contained in my scene (loadedModel), which harass me to debug my scene content...

Any help or explanation would be great, maybe I missed something obvious...?

Christophe Médard
Société OKTAL (http://www.oktal.fr)
2 impasse Boudeville
31100 Toulouse (France)
Tél. : (+33) 5 62 11 50 10
Fax : (+33) 5 62 11 50 29
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070912/74fa2165/attachment-0002.htm>

More information about the osg-users mailing list