Ray Tracer
2020
|
Abstract base class for LightSources. More...
#include <LightSource.h>
Public Member Functions | |
virtual Colour | getIlluminationAt (const Point &point) const =0 |
Determine how much light reaches a Point from this LightSource. More... | |
virtual double | getDistanceToLight (const Point &point) const =0 |
Determine how far away the light source is from a given Point. More... | |
virtual Direction | getLightDirection (const Point &point) const =0 |
Direction from light source to a point. More... | |
Protected Member Functions | |
LightSource (const Colour &colour) | |
LightSource constructor. More... | |
LightSource (const LightSource &lightSource) | |
LightSource copy constructor. More... | |
virtual | ~LightSource () |
LightSource destructor. More... | |
LightSource & | operator= (const LightSource &lightSource) |
LightSource assignment operator. More... | |
Protected Attributes | |
Colour | colour_ |
The Colour of this LightSource's illumination. More... | |
Abstract base class for LightSources.
LightSources provide illumination to the scene. All light sources have a Colour, but other properties may vary.
As an abstract base class, you cannot create a LightSource directly. Instead one of its concrete subclasses must be created.
|
protected |
LightSource constructor.
colour | The Colour of this LightSource's illumination. |
|
protected |
LightSource copy constructor.
lightSource | The LightSource to copy. |
|
protectedvirtual |
LightSource destructor.
|
pure virtual |
Determine how far away the light source is from a given Point.
This is a bit tricky, to get around the fact that there are several general types of light. There are basically three types we are interested in:
For a PointLightSource or SpotLightSource the direction is well defined. For a DirectionalLightSource we can return infinity. For an AmbientLightSource we can return -1. This is never a valid distance, so can be used to indicate that we can skip the lighting computations for this source.
Implemented in PointLightSource, DirectionalLightSource, and AmbientLightSource.
Determine how much light reaches a Point from this LightSource.
The amount of light emitted by a LightSource is determined by its colour property, but this generally varies across the Scene. This method returns a scaled value to apply to the colour of the light at a given Point in the Scene.
point | The Point at which light is measured. |
Implemented in PointLightSource, DirectionalLightSource, and AmbientLightSource.
Direction from light source to a point.
Return a Direction pointing from the given point towards the light source. For most light sources this is well-defined, but for AmbientLightSources it is not. This Direction is used for lighting and shadow calculations, however, so this is not a problem. We can return any value for AmbientLightSource, since it will never be used.
point | The point where the ray is being computed. |
Implemented in PointLightSource, DirectionalLightSource, and AmbientLightSource.
|
protected |
LightSource assignment operator.
lightSource | The LightSource to assign to this . |
this
to allow for chaining of assignment.
|
protected |
The Colour of this LightSource's illumination.