Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

osg::Light Class Reference

Lights Base class. More...

#include <OSGLight.h>

Inheritance diagram for osg::Light:

osg::LightBase osg::NodeCore osg::AttachmentContainer osg::FieldContainer osg::DirectionalLightBase osg::PointLightBase osg::DirectionalLight osg::PointLight osg::SpotLightBase osg::SpotLight List of all members.

Public Types

typedef LightPtr Ptr
enum  {
  AmbientFieldId = Inherited::NextFieldId, DiffuseFieldId = AmbientFieldId + 1, SpecularFieldId = DiffuseFieldId + 1, BeaconFieldId = SpecularFieldId + 1,
  OnFieldId = BeaconFieldId + 1, ConstantAttenuationFieldId = OnFieldId + 1, LinearAttenuationFieldId = ConstantAttenuationFieldId + 1, QuadraticAttenuationFieldId = LinearAttenuationFieldId + 1,
  NextFieldId = QuadraticAttenuationFieldId + 1
}

Public Member Functions

Set
*void setAmbient (Real32 rRed, Real32 rGreen, Real32 rBlue, Real32 rAlpha)
void setDiffuse (Real32 rRed, Real32 rGreen, Real32 rBlue, Real32 rAlpha)
void setSpecular (Real32 rRed, Real32 rGreen, Real32 rBlue, Real32 rAlpha)
void setAmbient (const Color4f &col)
 Set the value of the Light::_sfAmbient field.
void setDiffuse (const Color4f &col)
 Set the value of the Light::_sfDiffuse field.
void setSpecular (const Color4f &col)
 Set the value of the Light::_sfSpecular field.
Chunk
*LightChunkPtr getChunk (void)
virtual void makeChunk (void)
Sync
*virtual void changed (BitVector whichField, UInt32 origin)
Dump
*virtual void dump (UInt32 uiIndent=0, const BitVector bvFlags=0) const
FieldContainer Get
*virtual FieldContainerTypegetType (void)
virtual const FieldContainerTypegetType (void) const
virtual UInt32 getContainerSize (void) const
Field Get
*SFColor4fgetSFAmbient (void)
 Get the Light::_sfAmbient field.
SFColor4fgetSFDiffuse (void)
 Get the Light::_sfDiffuse field.
SFColor4fgetSFSpecular (void)
 Get the Light::_sfSpecular field.
SFNodePtrgetSFBeacon (void)
 Get the Light::_sfBeacon field.
SFBoolgetSFOn (void)
 Get the Light::_sfOn field.
SFReal32getSFConstantAttenuation (void)
 Get the Light::_sfConstantAttenuation field.
SFReal32getSFLinearAttenuation (void)
 Get the Light::_sfLinearAttenuation field.
SFReal32getSFQuadraticAttenuation (void)
 Get the Light::_sfQuadraticAttenuation field.
Color4fgetAmbient (void)
 Get the value of the Light::_sfAmbient field.
const Color4fgetAmbient (void) const
 Get the value of the Light::_sfAmbient field.
Color4fgetDiffuse (void)
 Get the value of the Light::_sfDiffuse field.
const Color4fgetDiffuse (void) const
 Get the value of the Light::_sfDiffuse field.
Color4fgetSpecular (void)
 Get the value of the Light::_sfSpecular field.
const Color4fgetSpecular (void) const
 Get the value of the Light::_sfSpecular field.
NodePtrgetBeacon (void)
 Get the value of the Light::_sfBeacon field.
const NodePtrgetBeacon (void) const
 Get the value of the Light::_sfBeacon field.
bool & getOn (void)
 Get the value of the Light::_sfOn field.
const bool & getOn (void) const
 Get the value of the Light::_sfOn field.
Real32getConstantAttenuation (void)
 Get the value of the Light::_sfConstantAttenuation field.
const Real32getConstantAttenuation (void) const
 Get the value of the Light::_sfConstantAttenuation field.
Real32getLinearAttenuation (void)
 Get the value of the Light::_sfLinearAttenuation field.
const Real32getLinearAttenuation (void) const
 Get the value of the Light::_sfLinearAttenuation field.
Real32getQuadraticAttenuation (void)
 Get the value of the Light::_sfQuadraticAttenuation field.
const Real32getQuadraticAttenuation (void) const
 Get the value of the Light::_sfQuadraticAttenuation field.
Field Set
void setBeacon (const NodePtr &value)
 Set the value of the Light::_sfBeacon field.
void setOn (const bool &value)
 Set the value of the Light::_sfOn field.
void setConstantAttenuation (const Real32 &value)
 Set the value of the Light::_sfConstantAttenuation field.
void setLinearAttenuation (const Real32 &value)
 Set the value of the Light::_sfLinearAttenuation field.
void setQuadraticAttenuation (const Real32 &value)
 Set the value of the Light::_sfQuadraticAttenuation field.
Binary Access
*virtual UInt32 getBinSize (const BitVector &whichField)
virtual void copyToBin (BinaryDataHandler &pMem, const BitVector &whichField)
virtual void copyFromBin (BinaryDataHandler &pMem, const BitVector &whichField)
Parents
*MFNodePtrgetParents (void)
const MFNodePtrgetParents (void) const
MFNodePtrgetMFParents (void)
Volume
*virtual void invalidateVolume (void)
Clone
*virtual FieldContainerPtr shallowCopy (void) const =0
Parents
*MFNodePtrgetParents (void)
const MFNodePtrgetParents (void) const
MFNodePtrgetMFParents (void)
Volume
*virtual void invalidateVolume (void)

Static Public Member Functions

Class Get
*static FieldContainerTypegetClassType (void)
 access the type of the class
static UInt32 getClassTypeId (void)
 access the numerical type of the class

Static Public Attributes

static const osg::BitVector AmbientFieldMask
static const osg::BitVector DiffuseFieldMask
static const osg::BitVector SpecularFieldMask
static const osg::BitVector BeaconFieldMask
static const osg::BitVector OnFieldMask
static const osg::BitVector ConstantAttenuationFieldMask
static const osg::BitVector LinearAttenuationFieldMask
static const osg::BitVector QuadraticAttenuationFieldMask
static const osg::BitVector MTInfluenceMask
static const BitVector ParentsFieldMask = (1 << NodeCore::ParentsFieldId )
static const BitVector AttachmentsFieldMask
static const BitVector NextFieldMask
CoredNodePtr helper
*static const bool isNodeCore = true
CoredNodePtr helper
*static const bool isNodeCore = true

Protected Types

typedef LightBase Inherited

Protected Member Functions

Constructors
Light (void)
 Light (const Light &source)
Destructors
*virtual ~Light (void)
Actions
*Action::ResultE drawEnter (Action *action)
Action::ResultE drawLeave (Action *action)
Action::ResultE renderEnter (Action *action)
Action::ResultE renderLeave (Action *action)
Sync
*void executeSyncImpl (LightBase *pOther, const BitVector &whichField)
virtual void executeSync (FieldContainer &other, const BitVector &whichField)
Sync
void executeSyncImpl (NodeCore *pOther, const BitVector &whichField)
MT Destruction
*virtual void onDestroy (void)
Set / Get Parents
*void addParent (const NodePtr &parent)
void subParent (const NodePtr &parent)
Pointer
*NodeCorePtr getPtr (void) const
Transformation
*virtual void accumulateMatrix (Matrix &result)
Volume
*virtual void adjustVolume (Volume &volume)
Sync
void executeSyncImpl (NodeCore *pOther, const BitVector &whichField)
MT Destruction
*virtual void onDestroy (void)
Set / Get Parents
*void addParent (const NodePtr &parent)
void subParent (const NodePtr &parent)
Pointer
*NodeCorePtr getPtr (void) const

Protected Attributes

LightChunkPtr _pChunk
Fields
*SFColor4f _sfAmbient
SFColor4f _sfDiffuse
SFColor4f _sfSpecular
SFNodePtr _sfBeacon
SFBool _sfOn
SFReal32 _sfConstantAttenuation
SFReal32 _sfLinearAttenuation
SFReal32 _sfQuadraticAttenuation
Fields
*MFNodePtr _parents
Fields
*MFNodePtr _parents

Private Member Functions

void operator= (const Light &source)
 prohibit default function (move to 'public' if needed)

Static Private Member Functions

static void initMethod (void)
 initialize the static features of the class, e.g. action callbacks

Friends

class FieldContainer
class LightBase

Detailed Description

Light is the base class for all the light source nodes. It contains the field for the general light source attributes (AmbientColor, DiffuseColor, SpecularColor, Beacon). The Beacon defines the reference coordinate system for the lightsource, while the position in the graph defines the objects that are lit.

Definition at line 58 of file OSGLight.h.


Member Typedef Documentation

typedef LightBase osg::Light::Inherited [protected]
 

Reimplemented from osg::LightBase.

Reimplemented in osg::DirectionalLight, osg::DirectionalLightBase, osg::PointLight, osg::PointLightBase, osg::SpotLight, and osg::SpotLightBase.

Definition at line 112 of file OSGLight.h.

typedef LightPtr osg::LightBase::Ptr [inherited]
 

Reimplemented in osg::DirectionalLightBase, osg::PointLightBase, and osg::SpotLightBase.

Definition at line 97 of file OSGLightBase.h.


Member Enumeration Documentation

anonymous enum [inherited]
 

Enumerator:
AmbientFieldId 
DiffuseFieldId 
SpecularFieldId 
BeaconFieldId 
OnFieldId 
ConstantAttenuationFieldId 
LinearAttenuationFieldId 
QuadraticAttenuationFieldId 
NextFieldId 

Reimplemented from osg::NodeCore.

Definition at line 99 of file OSGLightBase.h.

00100     {
00101         AmbientFieldId              = Inherited::NextFieldId,
00102         DiffuseFieldId              = AmbientFieldId              + 1,
00103         SpecularFieldId             = DiffuseFieldId              + 1,
00104         BeaconFieldId               = SpecularFieldId             + 1,
00105         OnFieldId                   = BeaconFieldId               + 1,
00106         ConstantAttenuationFieldId  = OnFieldId                   + 1,
00107         LinearAttenuationFieldId    = ConstantAttenuationFieldId  + 1,
00108         QuadraticAttenuationFieldId = LinearAttenuationFieldId    + 1,
00109         NextFieldId                 = QuadraticAttenuationFieldId + 1
00110     };


Constructor & Destructor Documentation

Light::Light void   )  [protected]
 

Definition at line 131 of file OSGLight.cpp.

00131                  :
00132      Inherited(),
00133     _pChunk   (NullFC)
00134 {
00135 }

Light::Light const Light source  )  [protected]
 

Definition at line 137 of file OSGLight.cpp.

00137                                 :
00138      Inherited(source),
00139     _pChunk   (source._pChunk)
00140 {
00141 }

Light::~Light void   )  [protected, virtual]
 

Definition at line 146 of file OSGLight.cpp.

References _pChunk, osg::NullFC, and osg::subRefCP().

00147 {
00148     if(_pChunk != NullFC)
00149         subRefCP(_pChunk);
00150 }


Member Function Documentation

void Light::setAmbient Real32  rRed,
Real32  rGreen,
Real32  rBlue,
Real32  rAlpha
 

Definition at line 66 of file OSGLight.cpp.

References osg::LightBase::_sfAmbient, and osg::SField< FieldTypeT, fieldNameSpace >::getValue().

00070 {
00071     _sfAmbient.getValue().setValuesRGBA(rRed, rGreen, rBlue, rAlpha);
00072 }

void Light::setDiffuse Real32  rRed,
Real32  rGreen,
Real32  rBlue,
Real32  rAlpha
 

Definition at line 74 of file OSGLight.cpp.

References osg::LightBase::_sfDiffuse, and osg::SField< FieldTypeT, fieldNameSpace >::getValue().

00078 {
00079     _sfDiffuse.getValue().setValuesRGBA(rRed, rGreen, rBlue, rAlpha);
00080 }

void Light::setSpecular Real32  rRed,
Real32  rGreen,
Real32  rBlue,
Real32  rAlpha
 

Definition at line 82 of file OSGLight.cpp.

References osg::LightBase::_sfSpecular, and osg::SField< FieldTypeT, fieldNameSpace >::getValue().

00086 {
00087     _sfSpecular.getValue().setValuesRGBA(rRed, rGreen, rBlue, rAlpha);
00088 }

void osg::Light::setAmbient const Color4f col  )  [inline]
 

Reimplemented from osg::LightBase.

Definition at line 46 of file OSGLight.inl.

References osg::LightBase::setAmbient().

00047 {
00048     Inherited::setAmbient(col);
00049 }

void osg::Light::setDiffuse const Color4f col  )  [inline]
 

Reimplemented from osg::LightBase.

Definition at line 52 of file OSGLight.inl.

References osg::LightBase::setDiffuse().

00053 {
00054     Inherited::setDiffuse(col);
00055 }

void osg::Light::setSpecular const Color4f col  )  [inline]
 

Reimplemented from osg::LightBase.

Definition at line 58 of file OSGLight.inl.

References osg::LightBase::setSpecular().

00059 {
00060     Inherited::setSpecular(col);
00061 }

LightChunkPtr Light::getChunk void   ) 
 

Definition at line 93 of file OSGLight.cpp.

References _pChunk.

Referenced by osg::RenderAction::dropLight().

00094 {
00095     return _pChunk;
00096 }

void Light::makeChunk void   )  [virtual]
 

Reimplemented in osg::DirectionalLight, osg::PointLight, and osg::SpotLight.

Definition at line 98 of file OSGLight.cpp.

References _pChunk, osg::LightChunkBase::create(), osg::LightBase::getAmbient(), osg::LightBase::getDiffuse(), osg::LightBase::getSpecular(), and osg::NullFC.

Referenced by osg::RenderAction::dropLight(), osg::PointLight::makeChunk(), and osg::DirectionalLight::makeChunk().

00099 {
00100     if(_pChunk == NullFC)
00101     {
00102         _pChunk = LightChunk::create();
00103     }
00104 
00105     _pChunk->setAmbient (getAmbient ());
00106     _pChunk->setDiffuse (getDiffuse ());
00107     _pChunk->setSpecular(getSpecular());
00108 }

void Light::changed BitVector  whichField,
UInt32  origin
[virtual]
 

Reimplemented from osg::AttachmentContainer.

Reimplemented in osg::DirectionalLight, osg::PointLight, and osg::SpotLight.

Definition at line 113 of file OSGLight.cpp.

References osg::AttachmentContainer::changed().

Referenced by osg::PointLight::changed(), and osg::DirectionalLight::changed().

00114 {
00115     Inherited::changed(whichField, origin);
00116 }

void Light::dump UInt32  uiIndent = 0,
const BitVector  bvFlags = 0
const [virtual]
 

Reimplemented from osg::NodeCore.

Reimplemented in osg::DirectionalLight, osg::PointLight, and osg::SpotLight.

Definition at line 122 of file OSGLight.cpp.

References osg::NodeCore::dump().

Referenced by osg::PointLight::dump(), and osg::DirectionalLight::dump().

00124 {
00125    Inherited::dump(uiIndent, bvFlags);
00126 }

Action::ResultE Light::drawEnter Action action  )  [protected]
 

Reimplemented in osg::DirectionalLight, osg::PointLight, and osg::SpotLight.

Definition at line 155 of file OSGLight.cpp.

References osg::LightBase::_sfAmbient, osg::LightBase::_sfConstantAttenuation, osg::LightBase::_sfDiffuse, osg::LightBase::_sfLinearAttenuation, osg::LightBase::_sfQuadraticAttenuation, osg::LightBase::_sfSpecular, osg::Action::Continue, osg::Action::getActNode(), osg::LightBase::getBeacon(), osg::DrawAction::getLightCount(), osg::SField< FieldTypeT, fieldNameSpace >::getValue(), osg::TransformationMatrix< ValueTypeT >::getValues(), GLenum, osg::DrawAction::incLightCount(), osg::TransformationMatrix< ValueTypeT >::invert(), osg::TransformationMatrix< ValueTypeT >::mult(), osg::NullFC, osg::DrawActionBase::selectVisibles(), and SINFO.

Referenced by osg::SpotLight::drawEnter(), osg::PointLight::drawEnter(), and osg::DirectionalLight::drawEnter().

00156 {
00157     DrawAction *da    = dynamic_cast<DrawAction *>(action);
00158     GLenum      light = GL_LIGHT0 + da->getLightCount();
00159     
00160     da->incLightCount();
00161     
00162     glEnable (light);
00163     
00164     glLightfv(light, GL_DIFFUSE , _sfDiffuse. getValue().getValuesRGBA());
00165     glLightfv(light, GL_AMBIENT , _sfAmbient. getValue().getValuesRGBA());
00166     glLightfv(light, GL_SPECULAR, _sfSpecular.getValue().getValuesRGBA());
00167 
00168     glLightf( light, 
00169               GL_CONSTANT_ATTENUATION, 
00170              _sfConstantAttenuation.getValue() );
00171     glLightf( light,
00172               GL_LINEAR_ATTENUATION,   
00173              _sfLinearAttenuation.getValue()   );
00174     glLightf( light,
00175               GL_QUADRATIC_ATTENUATION,   
00176              _sfQuadraticAttenuation.getValue());
00177 
00178     // add the matrix to get into the beacon's coordinate system onto the stack
00179 
00180     Matrix fromworld;
00181     Matrix tobeacon;
00182 
00183     action->getActNode()->getToWorld(fromworld);
00184     fromworld.invert();
00185 
00186     NodePtr beacon = getBeacon();
00187 
00188     if(beacon == NullFC)
00189     {
00190         SINFO << "draw: no beacon set!" << std::endl;
00191 
00192         glPushMatrix();
00193     }
00194     else
00195     {
00196         getBeacon()->getToWorld(tobeacon);
00197     
00198         tobeacon.mult(fromworld);
00199     
00200         glPushMatrix();
00201         glMultMatrixf(tobeacon.getValues());
00202     }
00203     
00204     da->selectVisibles();
00205     
00206     return Action::Continue;
00207 }

Action::ResultE Light::drawLeave Action action  )  [protected]
 

Reimplemented in osg::DirectionalLight, osg::PointLight, and osg::SpotLight.

Definition at line 209 of file OSGLight.cpp.

References osg::Action::Continue, osg::DrawAction::decLightCount(), osg::DrawAction::getLightCount(), and GLenum.

Referenced by osg::SpotLight::drawLeave(), osg::PointLight::drawLeave(), and osg::DirectionalLight::drawLeave().

00210 {
00211     DrawAction *da = dynamic_cast<DrawAction *>(action);
00212      
00213     da->decLightCount();
00214 
00215     GLenum light = GL_LIGHT0 + da->getLightCount();
00216    
00217     glDisable(light);
00218    
00219     return Action::Continue;
00220 }

Action::ResultE Light::renderEnter Action action  )  [protected]
 

Reimplemented in osg::DirectionalLight, osg::PointLight, and osg::SpotLight.

Definition at line 225 of file OSGLight.cpp.

References osg::Action::Continue, and osg::RenderAction::dropLight().

Referenced by osg::PointLight::renderEnter(), and osg::DirectionalLight::renderEnter().

00226 {
00227     RenderAction *pAction = dynamic_cast<RenderAction *>(action);
00228 
00229     pAction->dropLight(this);
00230 
00231     return Action::Continue;
00232 }

Action::ResultE Light::renderLeave Action action  )  [protected]
 

Reimplemented in osg::DirectionalLight, osg::PointLight, and osg::SpotLight.

Definition at line 234 of file OSGLight.cpp.

References osg::Action::Continue, and osg::RenderAction::undropLight().

Referenced by osg::SpotLight::renderLeave(), osg::PointLight::renderLeave(), and osg::DirectionalLight::renderLeave().

00235 {
00236     RenderAction *pAction = dynamic_cast<RenderAction *>(action);
00237 
00238     pAction->undropLight(this);
00239 
00240     return Action::Continue;
00241 }

void Light::initMethod void   )  [static, private]
 

Reimplemented in osg::DirectionalLight, osg::PointLight, and osg::SpotLight.

Definition at line 248 of file OSGLight.cpp.

00249 {
00250 }

void osg::Light::operator= const Light source  )  [private]
 

osg::FieldContainerType & osg::LightBase::getClassType void   )  [inline, static, inherited]
 

Reimplemented from osg::NodeCore.

Reimplemented in osg::DirectionalLightBase, osg::PointLightBase, and osg::SpotLightBase.

Definition at line 58 of file OSGLightBase.inl.

References osg::LightBase::_type.

00059 {
00060     return _type; 
00061 } 

osg::UInt32 osg::LightBase::getClassTypeId void   )  [inline, static, inherited]
 

Reimplemented from osg::NodeCore.

Reimplemented in osg::DirectionalLightBase, osg::PointLightBase, and osg::SpotLightBase.

Definition at line 65 of file OSGLightBase.inl.

References osg::LightBase::_type, and osg::TypeBase::getId().

00066 {
00067     return _type.getId(); 
00068 } 

FieldContainerType & LightBase::getType void   )  [virtual, inherited]
 

Reimplemented from osg::NodeCore.

Reimplemented in osg::DirectionalLightBase, osg::PointLightBase, and osg::SpotLightBase.

Definition at line 183 of file OSGLightBase.cpp.

References osg::LightBase::_type.

00184 {
00185     return _type; 
00186 } 

const FieldContainerType & LightBase::getType void   )  const [virtual, inherited]
 

Reimplemented from osg::NodeCore.

Reimplemented in osg::DirectionalLightBase, osg::PointLightBase, and osg::SpotLightBase.

Definition at line 188 of file OSGLightBase.cpp.

References osg::LightBase::_type.

00189 {
00190     return _type;
00191 } 

UInt32 LightBase::getContainerSize void   )  const [virtual, inherited]
 

Reimplemented from osg::NodeCore.

Reimplemented in osg::DirectionalLightBase, osg::PointLightBase, and osg::SpotLightBase.

Definition at line 194 of file OSGLightBase.cpp.

00195 { 
00196     return sizeof(Light); 
00197 }

SFColor4f * osg::LightBase::getSFAmbient void   )  [inline, inherited]
 

Definition at line 75 of file OSGLightBase.inl.

References osg::LightBase::_sfAmbient.

00076 {
00077     return &_sfAmbient;
00078 }

SFColor4f * osg::LightBase::getSFDiffuse void   )  [inline, inherited]
 

Definition at line 82 of file OSGLightBase.inl.

References osg::LightBase::_sfDiffuse.

00083 {
00084     return &_sfDiffuse;
00085 }

SFColor4f * osg::LightBase::getSFSpecular void   )  [inline, inherited]
 

Definition at line 89 of file OSGLightBase.inl.

References osg::LightBase::_sfSpecular.

00090 {
00091     return &_sfSpecular;
00092 }

SFNodePtr * osg::LightBase::getSFBeacon void   )  [inline, inherited]
 

Definition at line 96 of file OSGLightBase.inl.

References osg::LightBase::_sfBeacon.

00097 {
00098     return &_sfBeacon;
00099 }

SFBool * osg::LightBase::getSFOn void   )  [inline, inherited]
 

Definition at line 103 of file OSGLightBase.inl.

References osg::LightBase::_sfOn.

00104 {
00105     return &_sfOn;
00106 }

SFReal32 * osg::LightBase::getSFConstantAttenuation void   )  [inline, inherited]
 

Definition at line 110 of file OSGLightBase.inl.

References osg::LightBase::_sfConstantAttenuation.

00111 {
00112     return &_sfConstantAttenuation;
00113 }

SFReal32 * osg::LightBase::getSFLinearAttenuation void   )  [inline, inherited]
 

Definition at line 117 of file OSGLightBase.inl.

References osg::LightBase::_sfLinearAttenuation.

00118 {
00119     return &_sfLinearAttenuation;
00120 }

SFReal32 * osg::LightBase::getSFQuadraticAttenuation void   )  [inline, inherited]
 

Definition at line 124 of file OSGLightBase.inl.

References osg::LightBase::_sfQuadraticAttenuation.

00125 {
00126     return &_sfQuadraticAttenuation;
00127 }

Color4f & osg::LightBase::getAmbient void   )  [inline, inherited]
 

Definition at line 132 of file OSGLightBase.inl.

References osg::LightBase::_sfAmbient, and osg::SField< FieldTypeT, fieldNameSpace >::getValue().

Referenced by makeChunk().

00133 {
00134     return _sfAmbient.getValue();
00135 }

const Color4f & osg::LightBase::getAmbient void   )  const [inline, inherited]
 

Definition at line