![]() |
Jopnal Engine
alpha 0.4
Simple Component Based 2D/3D Game Engine
|
#include <LightSource.hpp>
Public Types | |
enum | Type { Type::Point, Type::Spot, Type::Directional } |
enum | Intensity { Intensity::Ambient, Intensity::Diffuse, Intensity::Specular } |
enum | Attenuation { Attenuation::Constant, Attenuation::Linear, Attenuation::Quadratic } |
Public Member Functions | |
LightSource (Object &object, Renderer &renderer, const Type type) | |
Constructor. More... | |
~LightSource () override | |
Destructor. More... | |
void | setRenderMask (const uint32 mask) |
Set the render mask. More... | |
uint32 | getRenderMask () const |
Get the render mask. More... | |
Type | getType () const |
Get the light type. More... | |
LightSource & | setCastShadows (const bool castShadows, const glm::uvec2 &resolution=glm::uvec2(0)) |
Set shadow casting for this light. More... | |
bool | castsShadows () const |
Check if this light casts shadows. More... | |
const glm::mat4 & | getLightspaceMatrix (const Cubemap::Face face=Cubemap::Face::First) const |
Get a light space matrix. More... | |
const Texture * | getShadowMap () const |
Get the shadow map. More... | |
LightSource & | setIntensity (const Intensity intensity, const Color &color) |
Set a specific intensity value. More... | |
LightSource & | setIntensity (const Color &ambient, const Color &diffuse, const Color &specular) |
Set all intensity values. More... | |
LightSource & | setIntensity (const Color &intensity) |
Set all intensity values. More... | |
const Color & | getIntensity (const Intensity intensity) const |
Get an intensity value. More... | |
LightSource & | setAttenuation (const Attenuation attenuation, const float value) |
Set a single attenuation value. More... | |
LightSource & | setAttenuation (const float constant, const float linear, const float quadratic) |
Set the attenuation values. More... | |
LightSource & | setAttenuation (const float range) |
Set the attenuation values using a range. More... | |
float | getAttenuation (const Attenuation attenuation) const |
Get an attenuation value. More... | |
glm::vec3 | getAttenuation () const |
Get the attenuation values as a vector. More... | |
float | getRange () const |
Get the approximate maximum range. More... | |
LightSource & | setCutoff (const float inner, const float outer) |
Set the cutoff. More... | |
const glm::vec2 & | getCutoff () const |
Get the cutoff values. More... | |
![]() | |
virtual | ~Component ()=0 |
Virtual destructor. More... | |
Message::Result | sendMessage (const Message &message) |
Send a message to this component. More... | |
virtual void | update (const float deltaTime) |
Update function. More... | |
uint32 | getID () const |
Get the identifier. More... | |
void | setID (const uint32 ID) |
Set the identifier. More... | |
WeakReference< Object > | getObject () |
Get the object this component is bound to. More... | |
WeakReference< const Object > | getObject () const |
Get the object this component is bound to. More... | |
bool | isActive () const |
Check if this component is active. More... | |
void | removeSelf () |
Remove this component from its object. More... | |
Static Public Member Functions | |
static unsigned int | getMaximumLights (const Type type) |
Get the setting for the maximum number of lights. More... | |
static void | makeCubemapMatrices (const glm::mat4 &projection, const glm::vec3 &position, std::vector< glm::mat4 > &viewMats) |
Calculate cube map view matrices. More... | |
Protected Member Functions | |
Message::Result | receiveMessage (const Message &message) override |
Receive a message. More... | |
![]() | |
Component (Object &object, const uint32 ID) | |
Constructor. More... | |
Component (const Component &other, Object &newObj) | |
Copy constructor. More... | |
Friends | |
class | Renderer |
Definition at line 48 of file LightSource.hpp.
|
strong |
The attenuation attribute
Enumerator | |
---|---|
Constant | |
Linear | |
Quadratic |
Definition at line 78 of file LightSource.hpp.
|
strong |
The intensity attribute
Enumerator | |
---|---|
Ambient | |
Diffuse | |
Specular |
Definition at line 69 of file LightSource.hpp.
|
strong |
Constructor.
object | Reference to created object in object class |
renderer | Reference to the renderer |
type | The light type |
|
override |
Destructor.
bool jop::LightSource::castsShadows | ( | ) | const |
Check if this light casts shadows.
float jop::LightSource::getAttenuation | ( | const Attenuation | attenuation | ) | const |
Get an attenuation value.
attenuation | The attenuation type |
glm::vec3 jop::LightSource::getAttenuation | ( | ) | const |
Get the attenuation values as a vector.
x = constant y = linear z = quadratic
const glm::vec2& jop::LightSource::getCutoff | ( | ) | const |
Get the cutoff values.
x = inner y = outer
Get an intensity value.
intensity | The intensity type |
const glm::mat4& jop::LightSource::getLightspaceMatrix | ( | const Cubemap::Face | face = Cubemap::Face::First | ) | const |
Get a light space matrix.
Faces other than First are only available with point lights. Trying to get these matrices when the light type is Spot or Directional will result in overstepping the array
face | The face whose matrix to fetch |
|
static |
Get the setting for the maximum number of lights.
type | The light type |
float jop::LightSource::getRange | ( | ) | const |
Get the approximate maximum range.
The returned value may deviate from what was possibly previously passed to setAttenuation(). The calculation is a mere approximation but is to usually enough to determine the range in which the light is at all visible.
uint32 jop::LightSource::getRenderMask | ( | ) | const |
Get the render mask.
const Texture* jop::LightSource::getShadowMap | ( | ) | const |
Get the shadow map.
Type jop::LightSource::getType | ( | ) | const |
Get the light type.
|
static |
Calculate cube map view matrices.
projection | The projection matrix |
position | The view position |
viewMats | Reference to a vector with the matrices. This must have a size of at least 6 |
|
overrideprotectedvirtual |
Receive a message.
Override this to handle messages sent to this. Don't forget to call the base class' method as well to ensure that the message gets forwarded correctly.
message | The message |
Reimplemented from jop::Component.
LightSource& jop::LightSource::setAttenuation | ( | const Attenuation | attenuation, |
const float | value | ||
) |
Set a single attenuation value.
attenuation | The attenuation type |
value | The value to set |
LightSource& jop::LightSource::setAttenuation | ( | const float | constant, |
const float | linear, | ||
const float | quadratic | ||
) |
Set the attenuation values.
constant | The constant attenuation |
linear | The linear attenuation |
quadratic | The quadratic attenuation |
LightSource& jop::LightSource::setAttenuation | ( | const float | range | ) |
Set the attenuation values using a range.
This roughly estimates the attenuation values for the given range. This aims for realism, which in some cases might mean that the light will become too dark.
range | The range |
LightSource& jop::LightSource::setCastShadows | ( | const bool | castShadows, |
const glm::uvec2 & | resolution = glm::uvec2(0) |
||
) |
Set shadow casting for this light.
This can be an expensive function, do not call frequently.
castShadows | True to cast shadows |
resolution | The shadow map resolution, glm::uvec2(0) to use the default |
LightSource& jop::LightSource::setCutoff | ( | const float | inner, |
const float | outer | ||
) |
Set the cutoff.
This only affects spot lights. The inner and outer cutoff control the dimming near the edges of the spot light.
inner | The inner cutoff in radians. The light will be at its maximum intensity inside this angle |
outer | The outer cutoff in radians |
LightSource& jop::LightSource::setIntensity | ( | const Intensity | intensity, |
const Color & | color | ||
) |
Set a specific intensity value.
intensity | The intensity type |
color | The color value to set |
LightSource& jop::LightSource::setIntensity | ( | const Color & | ambient, |
const Color & | diffuse, | ||
const Color & | specular | ||
) |
Set all intensity values.
ambient | Ambient intensity |
diffuse | Diffuse intensity |
specular | Specular intensity |
LightSource& jop::LightSource::setIntensity | ( | const Color & | intensity | ) |
Set all intensity values.
All the intensity values will be set to the given color value.
intensity | The intensity to set |
void jop::LightSource::setRenderMask | ( | const uint32 | mask | ) |
Set the render mask.
mask | The new mask to set |
|
friend |
Definition at line 54 of file LightSource.hpp.