Added support for the managing the StateSet above a LightSource node,
and made it an osg::Group so that it can be used a decorator above a scene. Added osgclip demo to the test suite.
This commit is contained in:
@@ -22,6 +22,10 @@ echo osgcube
|
||||
osgcube
|
||||
more memleaks.log
|
||||
|
||||
echo osgclip
|
||||
osgclip cow.osg
|
||||
more memleaks.log
|
||||
|
||||
echo osghud glider.osg
|
||||
osghud glider.osg
|
||||
more memleaks.log
|
||||
|
||||
@@ -8,6 +8,8 @@ osgbillboard lz.rgb
|
||||
|
||||
osgcube
|
||||
|
||||
osgclip cow.osg
|
||||
|
||||
osghud glider.osg
|
||||
|
||||
osgimpostor Town.osg
|
||||
|
||||
@@ -7,24 +7,26 @@
|
||||
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/Light>
|
||||
#include <osg/Group>
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** Leaf Node for defining a light in the scene.*/
|
||||
class SG_EXPORT LightSource : public Node
|
||||
class SG_EXPORT LightSource : public Group
|
||||
{
|
||||
public:
|
||||
|
||||
LightSource();
|
||||
|
||||
LightSource(const LightSource& es, const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
Node(es,copyop),
|
||||
_light(dynamic_cast<osg::Light*>(copyop(es._light.get()))) {}
|
||||
LightSource(const LightSource& ls, const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
Group(ls,copyop),
|
||||
_value(ls._value),
|
||||
_light(dynamic_cast<osg::Light*>(copyop(ls._light.get()))) {}
|
||||
|
||||
META_Node(LightSource);
|
||||
|
||||
/** Set the attached light.*/
|
||||
inline void setLight(Light* light) { _light = light; }
|
||||
void setLight(Light* light);
|
||||
|
||||
/** Get the attached light.*/
|
||||
inline Light* getLight() { return _light.get(); }
|
||||
@@ -32,12 +34,19 @@ class SG_EXPORT LightSource : public Node
|
||||
/** Get the const attached light.*/
|
||||
inline const Light* getLight() const { return _light.get(); }
|
||||
|
||||
/** Set the GLModes on StateSet associated with the LightSource.*/
|
||||
void setStateSetModes(StateSet&,const StateAttribute::GLModeValue) const;
|
||||
|
||||
/** Set up the local StateSet */
|
||||
void setLocalStateSetModes(const StateAttribute::GLModeValue=StateAttribute::ON);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~LightSource();
|
||||
|
||||
virtual const bool computeBound() const;
|
||||
|
||||
StateAttribute::GLModeValue _value;
|
||||
ref_ptr<Light> _light;
|
||||
};
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@ LightSource::LightSource()
|
||||
{
|
||||
// switch off culling of light source nodes by default.
|
||||
setCullingActive(false);
|
||||
_dstate = osgNew StateSet;
|
||||
_value = StateAttribute::ON;
|
||||
_light = osgNew Light;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +17,29 @@ LightSource::~LightSource()
|
||||
// ref_ptr<> automactially decrements the reference count of attached lights.
|
||||
}
|
||||
|
||||
|
||||
void LightSource::setLight(Light* light)
|
||||
{
|
||||
_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);
|
||||
}
|
||||
|
||||
const bool LightSource::computeBound() const
|
||||
{
|
||||
// note, don't do anything right now as the light itself is not
|
||||
|
||||
Reference in New Issue
Block a user