Re: [osg-users] Getting LigtModel from viewer

2019-04-08 Thread Robert Osfield
Hi Claudio,

On Mon, 8 Apr 2019 at 10:57, Claudio Benghi  wrote:
> Your solution works very well, the code I'm using to get the LightModel is
>
>
> Code:
>
> osg::LightModel *lightModel = dynamic_cast 
> (viewer->getCamera()->getStateSet()->getAttribute(osg::StateAttribute::LIGHTMODEL));
>
>
>
>
> I've already tested that changing its state does affect the render as 
> expected.
>
> It's a good sign that even after years of evolution you have access to nested 
> instances so easily. Keep up the great work.

Good to hear it's working :-)

Cheers,
Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Getting LigtModel from viewer

2019-04-08 Thread Claudio Benghi
Hello Robert,

Your solution works very well, the code I'm using to get the LightModel is 


Code:

osg::LightModel *lightModel = dynamic_cast 
(viewer->getCamera()->getStateSet()->getAttribute(osg::StateAttribute::LIGHTMODEL));




I've already tested that changing its state does affect the render as expected.

It's a good sign that even after years of evolution you have access to nested 
instances so easily. Keep up the great work.

Thank you!
Claudio

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75793#75793





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Getting LigtModel from viewer

2019-04-08 Thread Robert Osfield
Hi Claudio,

On Mon, 8 Apr 2019 at 00:16, Claudio Benghi  wrote:
> I'd like to be able to toggle the setTwoSided() value of the LightModel that 
> gets instantiated with the default osg::viewer class.
>
> I've looked at the code a while but I can't find a way to get the instance of 
> LightModel from the instance of the viewer. I suppose it's attached to the 
> global state that gets instantiated in the sceneView class, but I'm not sure 
> how to get to that one either.
>
> Any help much appreciated.

I have a quick look and it looks like the only assignment of
LightModel by dfault is done by osgUtil::SceneView's setDefaults(),
this is assigning the LightModel to the SceneView::_globalStateSet
which itself is set by the osgViewer::Renderer which assigns the
Camera's StateSet as the global default.   It's rather convoluted, a
bit of hang up of the OSG evolving over many years and at each step
trying to avoid breaking end user code.

So you should be able to do something like:

  viewer.getCamera()->getStaetSet()->setAttribute(myLightModel);

Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org