[osg-users] how do I make the light always hit the front of the camera?

Robert Osfield robert.osfield at gmail.com
Wed Mar 10 00:48:33 PST 2021


If you want a light positioned relative to View's Camera then this is what
the OSG provides by default.  You can probably just remove the LightSource
from the scene graph and rely upon it's settings.  In include/osg/View
you'll find:

       /** Options for controlling the global lighting used for the view.*/
        enum LightingMode
        {
            NO_LIGHT,
            HEADLIGHT,
            SKY_LIGHT
        };

        /** Set the global lighting to use for this view.
          * Defaults to headlight. */
        void setLightingMode(LightingMode lightingMode);

        /** Get the global lighting used for this view.*/
        LightingMode getLightingMode() const { return _lightingMode; }

        /** Get the global light.*/
        void setLight(osg::Light* light) { _light = light; }

        /** Get the global lighting if assigned.*/
        osg::Light* getLight() { return _light.get(); }

        /** Get the const global lighting if assigned.*/
        const osg::Light* getLight() const { return _light.get(); }

The vsgViewer::View class subclasses from osg::View, and osgViewer::Viewer
subclasses from osgViewer::View, so all the above methods are also
available via viewer.setLightingMode(..) etc.

-- 
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+unsubscribe at googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/CAFN7Y%2BXSZedQWexVk7LOsH92KdK%2BtNTfxvHp6d2RDG9vpJdKew%40mail.gmail.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20210310/f0618336/attachment-0001.html>


More information about the osg-users mailing list