Drag[en]gine Game Engine  1.0
deLight Class Reference

Light source. More...

#include <deLight.h>

Inheritance diagram for deLight:
deResource deObject

Public Types

enum  eLightTypes {
  eltPoint, eltSemiPoint, eltSpot, eltProjector,
  eltAmbient
}
 
enum  eMovementHints { emhStatic, emhJittering, emhDynamic }
 
enum  eParameterHints { ephStatic, ephActivation, ephFlicker, ephDynamic }
 

Public Member Functions

Management
eLightTypes GetType () const
 
void SetType (eLightTypes type)
 
const decColorGetColor () const
 
void SetColor (const decColor &color)
 
float GetIntensity () const
 
void SetIntensity (float intensity)
 
float GetRange () const
 
void SetRange (float range)
 
float GetHalfIntensityDistance () const
 
void SetHalfIntensityDistance (float distance)
 
float GetCutOffDistance () const
 
void SetCutOffDistance (float distance)
 
float GetAmbientRatio () const
 
void SetAmbientRatio (float ratio)
 
const decDVectorGetPosition () const
 
void SetPosition (const decDVector &position)
 
const decQuaternionGetOrientation () const
 
void SetOrientation (const decQuaternion &orientation)
 
const decVector2GetAngles () const
 
void SetAngles (const decVector2 &angles)
 
float GetSpotExponent () const
 
void SetSpotExponent (float exponent)
 
const decVectorGetShadowOrigin () const
 
void SetShadowOrigin (const decVector &origin)
 
float GetShadowGap () const
 
void SetShadowGap (float gap)
 
deImageGetProjectorImage () const
 
void SetProjectorImage (deImage *image)
 
deCanvasViewGetProjectorCanvas () const
 
void SetProjectorCanvas (deCanvasView *canvas)
 
int GetHintLightImportance () const
 
void SetHintLightImportance (int importance)
 
int GetHintShadowImportance () const
 
void SetHintShadowImportance (int importance)
 
eMovementHints GetHintMovement () const
 
void SetHintMovement (eMovementHints hint)
 
eParameterHints GetHintParameter () const
 
void SetHintParameter (eParameterHints hint)
 
bool GetActivated () const
 
void SetActivated (bool activated)
 
bool GetCastShadows () const
 
void SetCastShadows (bool castShadows)
 
Light Cage
int GetCageShapeCount () const
 
decShapeGetCageShapeAt (int index) const
 
int IndexOfCageShape (decShape *cageShape) const
 
bool HasCageShape (decShape *cageShape) const
 
void AddCageShape (decShape *cageShape)
 
void RemoveCageShape (decShape *cageShape)
 
void RemoveAllCageShapes ()
 
void NotifyCageChanged ()
 
System Peers
deBaseGraphicLightGetGraphicLight () const
 
void SetGraphicLight (deBaseGraphicLight *graLigSource)
 
Linked List
deWorldGetParentWorld () const
 Parent world or NULL. More...
 
void SetParentWorld (deWorld *world)
 Set parent world or NULL. More...
 
deLightGetLLWorldPrev () const
 Previous light in the parent world linked list. More...
 
void SetLLWorldPrev (deLight *light)
 Set next light in the parent world linked list. More...
 
deLightGetLLWorldNext () const
 Next light in the parent world linked list. More...
 
void SetLLWorldNext (deLight *light)
 Set next light in the parent world linked list. More...
 
- Public Member Functions inherited from deResource
deResourceManagerGetResourceManager () const
 Resource manager or NULL if resource is leaking. More...
 
deEngineGetEngine () const
 Game engine object from resource manager. More...
 
deResourceGetLLManagerPrev () const
 Previous resource in the resource manager linked list. More...
 
void SetLLManagerPrev (deResource *resource)
 Set next resource in the resource manager linked list. More...
 
deResourceGetLLManagerNext () const
 Next resource in the resource manager linked list. More...
 
void SetLLManagerNext (deResource *resource)
 Set next resource in the resource manager linked list. More...
 
void MarkLeaking ()
 Marks the resource leaking. More...
 
 deResource (deResourceManager *resourceManager)
 Create resource. More...
 
- Public Member Functions inherited from deObject
int GetRefCount () const
 Reference count. More...
 
void AddReference ()
 Add reference increasing reference count by 1. More...
 
void FreeReference ()
 Decrease reference count by one and delete object if count reaches 0. More...
 
 deObject ()
 Create object with reference count of 1. More...
 

Constructors and Destructors

 deLight (deLightManager *manager)
 
virtual ~deLight ()
 Clean up light source. More...
 

Additional Inherited Members

- Protected Member Functions inherited from deResource
virtual ~deResource ()
 Clean up resource. More...
 
- Protected Member Functions inherited from deObject
virtual ~deObject ()
 Clean up object. More...
 

Detailed Description

Light source.

Lights are the only light sources you can place in a world. The other light source, the sky layers, light globally while this light sources work locally. Light sources have various parameters influencing the appearance of the lit objects. The color indicates the tint of the light source while the intensities indicate the strength of the light source. Intensities are measured in lumen. Lumen readings for various light sources can be found in literatur providing a good starting ground for realistic lighting. The intensity value indicates the strength of the light at the light source enlighting world elements facing towards the light source. The ambient intensity serves as a sort of backlit to avoid no light contribution on the backside of world elements. It is a sort of local ambient light for only this light source. This way the backlit can be adjusted for worlds if the graphic module does not use a more sophisticated lighting model. The half intensity distance and the attenuation exponent determine how the light attenuates over distance. This model is more powerful than the typical static-linear-quadratic attenuation model and requires also requires less parameters. The light is attenuated to half the strength reaching the distance set in the half intensity distance. The attenuation exponent indicates the power to which the distance of a fragment to the light source is raised. A value of 2 yields physically correct lighting while larger values produce dramatic lighting effects like light staying mostly constant over a given distance then falling off sharply. The cut off distance indicates a maximal distance the light travels before attenuated to zero strength. This is a hint for the graphic module especially for confined light sources which only illuminate objects in a small place. Each light has a position where the light starts from. Depending on the light type additional parameters are used.

Point Light Source
Point light sources emmit light in all directions equally. No additional parameters are used for this light type. Point lights are simple to use but often more expensive than a spot light. Use them therefore with care.
Spot Light Source
Spot lights work like point lights but in addition the light emission is limited to a cone. The cone is defined using the orientation quaternion. The best way to work with this parameter is to create a matrix where the Z Axis points along the center axis of the light cone and retrieving the quaternion thereof. In addition two angles and an exponent can be set. The angles define the inner and outer angle of the cone. The attenuation due to the cone is multiplied with the distance attenuation. Inside the inner angle no attenuation from the cone is contributed. Outside the outer angle light is attenuated to 0. For angles between the two cone angles an exponential decay is used with the spot exponent indicating the power to use. With these three parameters a large variety of spot lights can be modeled.
Projector Light Source
Projector lights work similar to spot lights with the difference that they are in the shape of a pyramid instead of a cone and that they use an image to multiply with the light color. Projectors can be seen as a beamer projecting an image on a world and are useful to produce all kinds of complex spot or projector lights. The image is projected along the Z Axis of matrix corresponding to the orientation with the X Axis corresponding to the image U direction and the Y Axis corresponding to the image V direction. Distance attenuation applies here like in the spot light case but no cone attenuation takes place. Apply the light shape based attenuation into the image instead.
Author
Pl├╝ss Roland
Version
1.0
Date
2008

Member Enumeration Documentation

◆ eLightTypes

Type of the light source.

Enumerator
eltPoint 

Point light source.

eltSemiPoint 

Semi point light source.

eltSpot 

Spot light source.

eltProjector 

Projector light source.

eltAmbient 

Ambient light source.

◆ eMovementHints

Movement hints of the light.

Enumerator
emhStatic 

Light remains static for the entire lifetime.

emhJittering 

Light remains mostly static jittering in a small area.

emhDynamic 

Light moves around freely.

◆ eParameterHints

Parameter hints of the light.

Enumerator
ephStatic 

Light parameters never change.

ephActivation 

Light parameters never change except activation.

ephFlicker 

Geometric light parameters never change but others can.

ephDynamic 

All light parameters can change at will any time.

Constructor & Destructor Documentation

◆ deLight()

deLight::deLight ( deLightManager manager)

Creates a new light source with the given resource manager.

◆ ~deLight()

virtual deLight::~deLight ( )
protectedvirtual

Clean up light source.

Note
Subclasses should set their destructor protected too to avoid users accidently deleting a reference counted object through the object pointer. Only FreeReference() is allowed to delete the object.

Member Function Documentation

◆ AddCageShape()

void deLight::AddCageShape ( decShape cageShape)

Adds a cage shape.

Referenced by GetCastShadows().

◆ GetActivated()

bool deLight::GetActivated ( ) const
inline

Determines if the light is activated and emitting light.

References SetActivated().

◆ GetAmbientRatio()

float deLight::GetAmbientRatio ( ) const
inline

Retrieves the ratio of ambient light in relation to the total intensity.

References SetAmbientRatio().

◆ GetAngles()

const decVector2& deLight::GetAngles ( ) const
inline

Retrieves the light angles.

References SetAngles().

◆ GetCageShapeAt()

decShape* deLight::GetCageShapeAt ( int  index) const

Retrieves the cage shape at the given index.

Referenced by GetCastShadows().

◆ GetCageShapeCount()

int deLight::GetCageShapeCount ( ) const

Retrieves the number of cage shapes.

Referenced by GetCastShadows().

◆ GetCastShadows()

bool deLight::GetCastShadows ( ) const
inline

◆ GetColor()

const decColor& deLight::GetColor ( ) const
inline

Retrieves the color of the light source.

References SetColor().

◆ GetCutOffDistance()

float deLight::GetCutOffDistance ( ) const
inline

Retrieves the light cut-off distance.

References SetCutOffDistance().

◆ GetGraphicLight()

deBaseGraphicLight* deLight::GetGraphicLight ( ) const
inline

Retrieves the graphic system peer object.

References SetGraphicLight().

◆ GetHalfIntensityDistance()

float deLight::GetHalfIntensityDistance ( ) const
inline

Retrieves the distance in meters at which the intensity is halved.

References SetHalfIntensityDistance().

◆ GetHintLightImportance()

int deLight::GetHintLightImportance ( ) const
inline

Retrieves the light importance.

References SetHintLightImportance().

◆ GetHintMovement()

eMovementHints deLight::GetHintMovement ( ) const
inline

Retrieves the movement hint.

References SetHintMovement().

◆ GetHintParameter()

eParameterHints deLight::GetHintParameter ( ) const
inline

Retrieves the parameter hint.

References SetHintParameter().

◆ GetHintShadowImportance()

int deLight::GetHintShadowImportance ( ) const
inline

Retrieves the shadow importance.

References SetHintShadowImportance().

◆ GetIntensity()

float deLight::GetIntensity ( ) const
inline

Retrieves the intensity of the light source.

References SetIntensity().

◆ GetLLWorldNext()

deLight* deLight::GetLLWorldNext ( ) const
inline

Next light in the parent world linked list.

References SetLLWorldNext().

◆ GetLLWorldPrev()

deLight* deLight::GetLLWorldPrev ( ) const
inline

Previous light in the parent world linked list.

References SetLLWorldPrev().

◆ GetOrientation()

const decQuaternion& deLight::GetOrientation ( ) const
inline

Retrieves the orientation of the light source.

References SetOrientation().

◆ GetParentWorld()

deWorld* deLight::GetParentWorld ( ) const
inline

Parent world or NULL.

References SetParentWorld().

◆ GetPosition()

const decDVector& deLight::GetPosition ( ) const
inline

Retrieves the position of the light source.

References SetPosition().

◆ GetProjectorCanvas()

deCanvasView* deLight::GetProjectorCanvas ( ) const
inline

Retrieves the light canvas view or null if no light canvas view is set. Used only by spot lights.

References SetProjectorCanvas().

◆ GetProjectorImage()

deImage* deLight::GetProjectorImage ( ) const
inline

Retrieves the light image or null if no light image is set. Used only by spot lights.

References SetProjectorImage().

◆ GetRange()

float deLight::GetRange ( ) const
inline

Retrieves the light range in meters.

References SetRange().

◆ GetShadowGap()

float deLight::GetShadowGap ( ) const
inline

Retrieves the shadow gap size.

References SetShadowGap().

◆ GetShadowOrigin()

const decVector& deLight::GetShadowOrigin ( ) const
inline

Retrieves the shadow origin.

References SetShadowOrigin().

◆ GetSpotExponent()

float deLight::GetSpotExponent ( ) const
inline

Retrieves the spot exponent.

References SetSpotExponent().

◆ GetType()

eLightTypes deLight::GetType ( ) const
inline

Retrieves the type of the light source.

References SetType().

◆ HasCageShape()

bool deLight::HasCageShape ( decShape cageShape) const

Determines if the cage shape exists.

Referenced by GetCastShadows().

◆ IndexOfCageShape()

int deLight::IndexOfCageShape ( decShape cageShape) const

Retrieves the index of the given cage shape or -1 if not found.

Referenced by GetCastShadows().

◆ NotifyCageChanged()

void deLight::NotifyCageChanged ( )

Notifies the peers that the light cage changed.

Referenced by GetCastShadows().

◆ RemoveAllCageShapes()

void deLight::RemoveAllCageShapes ( )

Removes all cage shapes.

Referenced by GetCastShadows().

◆ RemoveCageShape()

void deLight::RemoveCageShape ( decShape cageShape)

Removes a cage shape.

Referenced by GetCastShadows().

◆ SetActivated()

void deLight::SetActivated ( bool  activated)

Sets if the light is activated and emitting light.

Referenced by GetActivated().

◆ SetAmbientRatio()

void deLight::SetAmbientRatio ( float  ratio)

Sets the ratio of ambient light in relation to the total intensity.

Referenced by GetAmbientRatio().

◆ SetAngles()

void deLight::SetAngles ( const decVector2 angles)

Sets the light angles.

Referenced by GetAngles().

◆ SetCastShadows()

void deLight::SetCastShadows ( bool  castShadows)

Sets if the light casts shadows.

Referenced by GetCastShadows().

◆ SetColor()

void deLight::SetColor ( const decColor color)

Sets the color of the light source.

Referenced by GetColor().

◆ SetCutOffDistance()

void deLight::SetCutOffDistance ( float  distance)

Sets the light cut-off distance.

Referenced by GetCutOffDistance().

◆ SetGraphicLight()

void deLight::SetGraphicLight ( deBaseGraphicLight graLigSource)

Sets the graphic system peer object.

Referenced by GetGraphicLight().

◆ SetHalfIntensityDistance()

void deLight::SetHalfIntensityDistance ( float  distance)

Sets the distance in meters at which the intensity is halved.

Referenced by GetHalfIntensityDistance().

◆ SetHintLightImportance()

void deLight::SetHintLightImportance ( int  importance)

Sets the hint light importance.

Referenced by GetHintLightImportance().

◆ SetHintMovement()

void deLight::SetHintMovement ( eMovementHints  hint)

Sets the movement hint.

Referenced by GetHintMovement().

◆ SetHintParameter()

void deLight::SetHintParameter ( eParameterHints  hint)

Sets the parameter hint.

Referenced by GetHintParameter().

◆ SetHintShadowImportance()

void deLight::SetHintShadowImportance ( int  importance)

Sets the hint shadow importance.

Referenced by GetHintShadowImportance().

◆ SetIntensity()

void deLight::SetIntensity ( float  intensity)

Sets the intensity of the light source.

Referenced by GetIntensity().

◆ SetLLWorldNext()

void deLight::SetLLWorldNext ( deLight light)

Set next light in the parent world linked list.

Referenced by GetLLWorldNext().

◆ SetLLWorldPrev()

void deLight::SetLLWorldPrev ( deLight light)

Set next light in the parent world linked list.

Referenced by GetLLWorldPrev().

◆ SetOrientation()

void deLight::SetOrientation ( const decQuaternion orientation)

Sets the orientation of the light source.

Referenced by GetOrientation().

◆ SetParentWorld()

void deLight::SetParentWorld ( deWorld world)

Set parent world or NULL.

Referenced by GetParentWorld().

◆ SetPosition()

void deLight::SetPosition ( const decDVector position)

Sets the position of the light source.

Referenced by GetPosition().

◆ SetProjectorCanvas()

void deLight::SetProjectorCanvas ( deCanvasView canvas)

Retrieves the light canvas view or null to unset the light canvas view. If the light canvas view is set the light parameters are bypassed and this canvas view is projected onto the object to be lit. The canvas view is used directly without multiplying the colors. Used only by spot lights.

Referenced by GetProjectorCanvas().

◆ SetProjectorImage()

void deLight::SetProjectorImage ( deImage image)

Retrieves the light image or null to unset the light image. If the light image is set the light parameters are bypassed and this image is projected onto the object to be lit. If the image is grayscale the light color is first multiplied otherwise the image is used as it is. Used only by spot lights.

Referenced by GetProjectorImage().

◆ SetRange()

void deLight::SetRange ( float  range)

Sets the light range in meters.

Referenced by GetRange().

◆ SetShadowGap()

void deLight::SetShadowGap ( float  gap)

Sets the shadow gap size.

Referenced by GetShadowGap().

◆ SetShadowOrigin()

void deLight::SetShadowOrigin ( const decVector origin)

Sets the shadow origin.

Referenced by GetShadowOrigin().

◆ SetSpotExponent()

void deLight::SetSpotExponent ( float  exponent)

Sets the spot exponent.

Referenced by GetSpotExponent().

◆ SetType()

void deLight::SetType ( eLightTypes  type)

Sets the type of the light source.

Referenced by GetType().


The documentation for this class was generated from the following file: