dtCore::Light Class Reference

An abstract class declaring the base functionality for a vertex light. More...

#include <light.h>

Inheritance diagram for dtCore::Light:

dtCore::Transformable dtCore::DeltaDrawable dtCore::Base dtCore::InfiniteLight dtCore::PositionalLight dtCore::SpotLight

List of all members.

Public Types

enum  LightingMode { GLOBAL = 0, LOCAL = 1 }
 GLOBAL lights everything in scene, LOCAL only lights children. More...

Public Member Functions

 Light (int number, const std::string &name="defaultLight", LightingMode mode=GLOBAL)
 Constructor.
 Light (const osg::LightSource &lightSource, const std::string &name="defaultLight", LightingMode mode=GLOBAL)
 Copy constructor from an osg::LightSource.
const osg::LightSource * GetLightSource () const
 Get the const internal osg::LightSource.
osg::LightSource * GetLightSource ()
 Get the non-const internal osg::LightSource.
void SetLightingMode (LightingMode mode)
 Change lighting mode to GLOBAL or LOCAL mode.
LightingMode GetLightingMode () const
void SetEnabled (bool enabled)
 Turn light on or off.
bool GetEnabled ()
void SetNumber (int number)
 Sets the OpenGL light number associated with this light.
int GetNumber () const
 Returns the number of the light as specified in the constructor.
void SetAmbient (float r, float g, float b, float a)
 sets the ambient light color
void SetAmbient (const osg::Vec4 &rgba)
void GetAmbient (float &r, float &g, float &b, float &a) const
 gets the ambient light color
const osg::Vec4 & GetAmbient () const
void SetDiffuse (float r, float g, float b, float a)
 sets the diffuse light color
void SetDiffuse (const osg::Vec4 &rgba)
void GetDiffuse (float &r, float &g, float &b, float &a) const
 Gets the diffuse light color.
const osg::Vec4 & GetDiffuse () const
void SetSpecular (float r, float g, float b, float a)
 sets the specular light color
void SetSpecular (const osg::Vec4 &rgba)
void GetSpecular (float &r, float &g, float &b, float &a) const
 gets the specular light color
const osg::Vec4 & GetSpecular () const
virtual void AddedToScene (Scene *scene)
 adds the light to the root node of the scene
virtual bool AddChild (DeltaDrawable *child)
 adds a drawable as a child of this node
virtual void RemoveChild (DeltaDrawable *child)
 removes a drawable as a child of this node

Protected Member Functions

virtual ~Light ()=0
virtual void ApplyDefaults ()
 Called from the constructor to setup any default Light attributes.

Protected Attributes

LightingMode mLightingMode
RefPtr< osg::LightSource > mLightSource
bool mEnabled


Detailed Description

An abstract class declaring the base functionality for a vertex light.

It's properties are thin wrappers of OpenGL light calls.


Member Enumeration Documentation

enum dtCore::Light::LightingMode

GLOBAL lights everything in scene, LOCAL only lights children.

Enumerator:
GLOBAL 
LOCAL 


Constructor & Destructor Documentation

Light::Light ( int  number,
const std::string &  name = "defaultLight",
LightingMode  mode = GLOBAL 
)

Constructor.

Parameters:
number,: the light number, 0-7, this will overright any other light with that number
name,: a name for the light, defaulted to defaultLight
mode,: specifys a lighting mode, GLOBAL effects whole scene, LOCAL only effects children

Light::Light ( const osg::LightSource &  lightSource,
const std::string &  name = "defaultLight",
LightingMode  mode = GLOBAL 
)

Copy constructor from an osg::LightSource.

Light::~Light (  )  [protected, pure virtual]


Member Function Documentation

void Light::ApplyDefaults (  )  [protected, virtual]

Called from the constructor to setup any default Light attributes.

const osg::LightSource * Light::GetLightSource (  )  const

Get the const internal osg::LightSource.

osg::LightSource * Light::GetLightSource (  ) 

Get the non-const internal osg::LightSource.

void Light::SetLightingMode ( LightingMode  mode  ) 

Change lighting mode to GLOBAL or LOCAL mode.

Changes the LightingMode of this Light.

Can be set to either GLOBAL or LOCAL. GLOBAL mode illuminates the entire scene. LOCAL mode only illuminates children of this Light.

Parameters:
mode : The child to add to this Transformable

LightingMode dtCore::Light::GetLightingMode (  )  const [inline]

void Light::SetEnabled ( bool  enabled  ) 

Turn light on or off.

bool dtCore::Light::GetEnabled (  )  [inline]

void Light::SetNumber ( int  number  ) 

Sets the OpenGL light number associated with this light.

Lights numbers must be in the range 0-7. There is a default scene light setup at light number 0, so that will be overwritten if you set your own light to 0.

Parameters:
number : The OpenGL light number

int Light::GetNumber (  )  const

Returns the number of the light as specified in the constructor.

void Light::SetAmbient ( float  r,
float  g,
float  b,
float  a 
)

sets the ambient light color

void Light::SetAmbient ( const osg::Vec4 &  rgba  ) 

void Light::GetAmbient ( float &  r,
float &  g,
float &  b,
float &  a 
) const

gets the ambient light color

const osg::Vec4 & Light::GetAmbient (  )  const

void Light::SetDiffuse ( float  r,
float  g,
float  b,
float  a 
)

sets the diffuse light color

void Light::SetDiffuse ( const osg::Vec4 &  rgba  ) 

void Light::GetDiffuse ( float &  r,
float &  g,
float &  b,
float &  a 
) const

Gets the diffuse light color.

const osg::Vec4 & Light::GetDiffuse (  )  const

void Light::SetSpecular ( float  r,
float  g,
float  b,
float  a 
)

sets the specular light color

void Light::SetSpecular ( const osg::Vec4 &  rgba  ) 

void Light::GetSpecular ( float &  r,
float &  g,
float &  b,
float &  a 
) const

gets the specular light color

const osg::Vec4 & Light::GetSpecular (  )  const

void Light::AddedToScene ( Scene scene  )  [virtual]

adds the light to the root node of the scene

Reimplemented from dtCore::Transformable.

bool Light::AddChild ( DeltaDrawable child  )  [virtual]

adds a drawable as a child of this node

Reimplemented from dtCore::Transformable.

void Light::RemoveChild ( DeltaDrawable child  )  [virtual]

removes a drawable as a child of this node

Reimplemented from dtCore::Transformable.


Member Data Documentation

LightingMode dtCore::Light::mLightingMode [protected]

RefPtr<osg::LightSource> dtCore::Light::mLightSource [protected]

bool dtCore::Light::mEnabled [protected]


http://www.delta3d.org
2.0.0 generated 14 Feb 2008