Workspace 6.21.5
Public Member Functions | List of all members
SpotLight Class Reference

Defines a spot light which is a source at specific position with edge fall-off and attentuation. More...

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

Inheritance diagram for SpotLight:
[legend]

Public Member Functions

 SpotLight ()
 
 SpotLight (const SpotLight &light)
 
 ~SpotLight () override
 
void clearAttenuationFactors ()
 
SpotLightclone () const override
 
double getAttenuationFactor (unsigned power) const
 
double getCutoffAngle () const
 
double getEdgeFalloff () const
 
double getFadeAngle () const
 
unsigned numAttenuationFactors () const
 
SpotLightoperator= (const SpotLight &light)
 
void setAttenuationFactor (unsigned power, double factor)
 
void setCutoffAngle (double angle)
 
void setEdgeFalloff (double f)
 
void setFadeAngle (double angle)
 
bool visit (LightsProcessor &processor) override
 
- Public Member Functions inherited from Light
 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
 

Additional Inherited Members

- Protected Member Functions inherited from Light
 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 &)
 

Detailed Description

Spot lights do support attenuation and edge fall-off. These characteristics can be modified to yield different spot light effects and can be used to generate a reasonably good approximation to a real spot light. This is more complex to set up than a DirectionalLight.

Constructor & Destructor Documentation

◆ SpotLight() [1/2]

SpotLight ( )

◆ SpotLight() [2/2]

SpotLight ( const SpotLight light)

◆ ~SpotLight()

~SpotLight ( )
override

Member Function Documentation

◆ clearAttenuationFactors()

void clearAttenuationFactors ( )

Clears all the attenuation factors. This will result in a light with no attenuation with distance from the light source.

See also
setAttenuationFactors(), numAttenuationFactors()

◆ clone()

SpotLight * clone ( ) const
overridevirtual
Returns
A clone of this item.

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

Implements Light.

◆ getAttenuationFactor()

double getAttenuationFactor ( unsigned  power) const
Parameters
powerThe power of the factor to retrieve.
Returns
The factor being applied to the specified power. If no factor has been set for this power, a value of zero will be returned.

◆ getCutoffAngle()

double getCutoffAngle ( ) const
Returns
The cutoff angle in degrees.
See also
setCutoffAngle()

◆ getEdgeFalloff()

double getEdgeFalloff ( ) const
Returns
The edge fall-off of the light.
See also
setEdgeFalloff()

◆ getFadeAngle()

double getFadeAngle ( ) const
Returns
The angle at which the lights intensity will start to fade (relative to its direction.
See also
setFadeAngle

◆ numAttenuationFactors()

unsigned numAttenuationFactors ( ) const
Returns
The number of attenuation factors set for this light.
See also
setAttenuationFactors()

◆ operator=()

SpotLight & operator= ( const SpotLight light)

◆ setAttenuationFactor()

void setAttenuationFactor ( unsigned  power,
double  factor 
)
Parameters
powerThe integer power whose factor will be set. If this is beyond the end of the current set of factors (ie if power is greater or equal to the result from numAttenuationFactors()), the factors will be zero-filled to extend them up to the specified power.
factorThe factor to apply to the power attenuation factor.

The attentuation factors correspond to integer powers starting with a power of zero. The factors may be interpretted differently by different renderers, so ensure you understand how they will be used when setting them. Most renderers will have a fairly small limit on the number of supported powers, but it would normally be safe to assume that up to at least a power of 2 would be supported (this is the limit OpenGL specifies, for example).

◆ setCutoffAngle()

void setCutoffAngle ( double  angle)
Parameters
angleThe maximum spread angle (in degrees) of the light. This controls the cone angle of the light. It must be non-negative and would normally not exceed 180. Some renderers will treat angles beyond 180 with special meaning (eg the OpenGL fixed function pipeline treats an angle of 180 as giving uniform light distribution and it rejects all other values greater than 90).
See also
getCutoffAngle(), setFalloff(), setFadeAngle()

◆ setEdgeFalloff()

void setEdgeFalloff ( double  f)
Parameters
fThe edge fall-off to use for the light. It must be non-negative. If it is not, the function leaves the fall-off at its old value.

The edge fall-off of a light controls how focused it is. The higher the value, the more tightly focused the light should appear. An edge fall-off of zero results in a uniform light distribution within the cone of the light and a sharp edge.

Note
Some scene renderers will have limits on how high the fall-off can be. For example, OpenGL stipulates that the fall-off (which it calls the "exponent") must be in the range [0,128].
See also
getEdgeFalloff(), setCutoffAngle()

◆ setFadeAngle()

void setFadeAngle ( double  angle)
Parameters
angleThe angle from the light's direction at which its intensity will start to fade. Must be smaller than or equal to the cutoff angle. Some renderers will ignore this angle altogether and only use the cutoff angle.
See also
getFadeAngle(), setFalloff(), setFadeAngle()

◆ visit()

bool visit ( LightsProcessor processor)
overridevirtual
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.

Implements Light.