2001-10-22 05:27:40 +08:00
|
|
|
#include <osg/LightSource>
|
2001-01-11 00:32:10 +08:00
|
|
|
|
|
|
|
using namespace osg;
|
|
|
|
|
|
|
|
LightSource::LightSource()
|
|
|
|
{
|
2002-04-11 05:51:34 +08:00
|
|
|
// switch off culling of light source nodes by default.
|
|
|
|
setCullingActive(false);
|
2002-05-04 00:47:16 +08:00
|
|
|
_dstate = osgNew StateSet;
|
|
|
|
_value = StateAttribute::ON;
|
|
|
|
_light = osgNew Light;
|
2001-01-11 00:32:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LightSource::~LightSource()
|
|
|
|
{
|
|
|
|
// ref_ptr<> automactially decrements the reference count of attached lights.
|
|
|
|
}
|
|
|
|
|
2002-05-04 00:47:16 +08:00
|
|
|
|
2002-06-19 16:34:19 +08:00
|
|
|
void LightSource::setLight(StateAttribute* light)
|
2002-05-04 00:47:16 +08:00
|
|
|
{
|
|
|
|
_light = light;
|
|
|
|
setLocalStateSetModes(_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the GLModes on StateSet associated with the ClipPlanes.
|
|
|
|
void LightSource::setStateSetModes(StateSet& stateset,const StateAttribute::GLModeValue value) const
|
|
|
|
{
|
|
|
|
if (_light.valid())
|
|
|
|
{
|
|
|
|
_light->setStateSetModes(stateset,value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LightSource::setLocalStateSetModes(const StateAttribute::GLModeValue value)
|
|
|
|
{
|
|
|
|
if (!_dstate) _dstate = osgNew StateSet;
|
|
|
|
_dstate->setAllToInherit();
|
|
|
|
setStateSetModes(*_dstate,value);
|
|
|
|
}
|
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
const bool LightSource::computeBound() const
|
2001-01-11 00:32:10 +08:00
|
|
|
{
|
|
|
|
// note, don't do anything right now as the light itself is not
|
|
|
|
// visualised, just having an effect on the lighting of geodes.
|
|
|
|
_bsphere.init();
|
2001-09-20 05:08:56 +08:00
|
|
|
|
2001-01-11 00:32:10 +08:00
|
|
|
_bsphere_computed = true;
|
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
return true;
|
2001-01-11 00:32:10 +08:00
|
|
|
}
|