Changed the osg::LightSource so its Light attribute is now generalised to

be a StateAttribute.  This allows alternative implementations of Lights
other than the standard osg::Light.
This commit is contained in:
Robert Osfield 2002-06-19 08:34:19 +00:00
parent 5e85cd59ab
commit b3c26d5634
4 changed files with 9 additions and 11 deletions

View File

@ -15,7 +15,7 @@ namespace osg {
class SG_EXPORT LightSource : public Group
{
public:
LightSource();
LightSource(const LightSource& ls, const CopyOp& copyop=CopyOp::SHALLOW_COPY):
@ -26,13 +26,13 @@ class SG_EXPORT LightSource : public Group
META_Node(osg, LightSource);
/** Set the attached light.*/
void setLight(Light* light);
void setLight(StateAttribute* light);
/** Get the attached light.*/
inline Light* getLight() { return _light.get(); }
inline StateAttribute* getLight() { return _light.get(); }
/** Get the const attached light.*/
inline const Light* getLight() const { return _light.get(); }
inline const StateAttribute* getLight() const { return _light.get(); }
/** Set the GLModes on StateSet associated with the LightSource.*/
void setStateSetModes(StateSet&,const StateAttribute::GLModeValue) const;
@ -46,8 +46,8 @@ class SG_EXPORT LightSource : public Group
virtual const bool computeBound() const;
StateAttribute::GLModeValue _value;
ref_ptr<Light> _light;
StateAttribute::GLModeValue _value;
ref_ptr<StateAttribute> _light;
};
}

View File

@ -18,7 +18,7 @@ LightSource::~LightSource()
}
void LightSource::setLight(Light* light)
void LightSource::setLight(StateAttribute* light)
{
_light = light;
setLocalStateSetModes(_value);

View File

@ -27,9 +27,7 @@ bool LightSource_readLocalData(Object& obj, Input& fr)
LightSource& lightsource = static_cast<LightSource&>(obj);
static ref_ptr<Light> s_light = osgNew osg::Light;
Light* light = static_cast<Light*>(fr.readObjectOfType(*s_light));
StateAttribute* light=fr.readStateAttribute();
if (light)
{
lightsource.setLight(light);

View File

@ -383,7 +383,7 @@ void CullVisitor::apply(LightSource& node)
if (node_state) pushStateSet(node_state);
Matrix& matrix = getModelViewMatrix();
Light* light = node.getLight();
StateAttribute* light = node.getLight();
if (light)
{
addPositionedAttribute(&matrix,light);