Workspace 6.21.5
Public Member Functions | Protected Member Functions | List of all members
Light Class Referenceabstract

Base class for all light types supported in a Scene.

#include <Rendering/SceneComponents/Lights/light.h>

Inheritance diagram for Light:
[legend]

Public Member Functions

 Light (const QString &id="")
 
 ~Light () override
 
Lightclone () const override=0
 
const QColor & getColor () const
 
double getIntensity () const
 
Mesh::Vector3d getOrientation () const
 
Mesh::Vector3d getPosition () const
 
void setColor (const QColor &color)
 
void setIntensity (double d)
 
virtual bool visit (LightsProcessor &processor)=0
 
bool visit (SceneProcessor &processor) override
 
- Public Member Functions inherited from SceneItem
 ~SceneItem () override
 
SceneItemclone () const override=0
 
bool getEnabled () const
 
const QString & getId () const
 
const Mesh::BoundingBoxMinimalgetLocalBoundingBox () const
 
virtual Mesh::TransformMatrix getMatrixGlobal () const
 
virtual Mesh::TransformMatrix getMatrixLocal () const
 
const QString & getName () const
 
Mesh::TransformMatrix getParentMatrixGlobal () const
 
TransformgetParentTransform ()
 
void setEnabled (bool b)
 
void setId (const QString &itemId)
 
virtual void setLocalBoundingBox (const Mesh::BoundingBoxMinimal &bb)
 
void setName (const QString &name)
 
virtual TransformtoTransform ()
 
virtual const TransformtoTransform () const
 
virtual void updateGlobalMatrix ()
 
virtual bool visit (SceneProcessor &processor)=0
 
- Public Member Functions inherited from Observable
virtual ~Observable ()
 
void attachObserver (Observer &observer)
 
void destroy ()
 
void detachObserver (Observer &observer)
 
void notifyEvent (const ObservableEvent &event)
 
- Public Member Functions inherited from Clonable
virtual ~Clonable ()=default
 
virtual Clonableclone () const =0
 

Protected Member Functions

 Light (const Light &light)
 
Lightoperator= (const Light &light)
 
- Protected Member Functions inherited from SceneItem
 SceneItem (const QString &id)
 
 SceneItem (const SceneItem &item)
 
virtual void addToScene (Scene &scene, const QString &opIdPath="")
 
bool isTransformModified () const
 
SceneItemoperator= (const SceneItem &item)
 
void setTransformModified (bool b)
 
- Protected Member Functions inherited from Observable
 Observable ()
 
 Observable (const Observable &)
 

Constructor & Destructor Documentation

◆ Light() [1/2]

Light ( const Light light)
protected

◆ Light() [2/2]

Light ( const QString &  id = "")

Creates a light with full intensity (ie intensity == 1) and with a white color. The light will be enabled by default.

◆ ~Light()

~Light ( )
override

Member Function Documentation

◆ clone()

Light * clone ( ) const
overridepure virtual
Returns
A clone of this item.

Subclasses must reimplement this function to return a clone of themselves.

Implements SceneItem.

Implemented in AmbientLight, DirectionalLight, PointLight, and SpotLight.

◆ getColor()

const QColor & getColor ( ) const
Returns
The color of the light.
See also
setColor()

◆ getIntensity()

double getIntensity ( ) const
Returns
The intensity of the light.
See also
setIntensity()

◆ getOrientation()

Vector3d getOrientation ( ) const
Returns
The light's orientation in global co-ordinates of the scene it is part of. If it is not part of a scene, then the orientation will be looking down the negative Z axis direction.

A light with no transformation points in the direction of the negative Z axis. This is the same convention as used by cameras and it also matches the default direction of spot lights for OpenGL.

Note
Not all lights make use of the orientation, since some are only positional with no directionality (eg ambient and point lights).
See also
getPosition()

◆ getPosition()

Vector3d getPosition ( ) const
Returns
The light's position in global co-ordinates of the scene it is part of. If it is not part of a scene, then the position will be the origin because the light will have no parent transform.

This is just the translation component of the parent global matrix. It is defined in the same way as for Camera objects except a Camera also has its own local transform, whereas a Light does not.

See also
getOrientation()

◆ operator=()

Light & operator= ( const Light light)
protected

◆ setColor()

void setColor ( const QColor &  color)
Parameters
colorThe new color for the light.

The light's color controls what color content the light casts into the scene. You can think of the color as being similar to applying a color filter in front of a white light. The color is multiplied by the light's intensity when used in a scene.

See also
getColor()

◆ setIntensity()

void setIntensity ( double  d)
Parameters
dThe new intensity for the light.

The intensity of the light acts like a multiplier on the light's color (only its red, green and blue components, not the alpha component). It allows the light intensity to be easily adjusted without affecting the color balance. Setting the intensity to zero does not disable the light, it only has the effect of turning the light off but it is still processed by LightsProcessor subclasses. For some rendering engines with support for only a limited number of lights, this is important because only the enabled/disabled state determines whether or not the processor can skip the light.

It should also be noted that some rendering engines might allow negative intensities to give the artificial effect of subtracting light from a surface. Not all renderers will support this behavior though, in which case they must treat the negative intensities the same as a zero intensity.

See also
getIntensity(), setEnabled()

◆ visit() [1/2]

virtual bool visit ( LightsProcessor processor)
pure virtual
Parameters
processorThe light processor visiting this light.

Light subclasses should reimplement this function to call processor.visit() and return the result of that call. This is the usual visitor pattern as used for other scene items and model processors.

Implemented in AmbientLight, DirectionalLight, PointLight, and SpotLight.

◆ visit() [2/2]

bool visit ( SceneProcessor processor)
overridevirtual

Implements SceneItem.