Image Component Library (ICL)
|
Wrapper class for OpenGL lights. More...
#include <SceneLight.h>
Public Member Functions | |
~SceneLight () | |
Destructor. | |
SceneLightObject * | getLightObject () |
returns the associated light object | |
const SceneLightObject * | getLightObject () const |
returns the associated light object (const) | |
void | setObjectSize (float size) |
sets the light objects scaling (default is 1) | |
void | setOn (bool on=true) |
globally switches the light on or off | |
void | setAnchorToWorld () |
sets that this camera's position is given relatively to the world | |
void | setAnchor (SceneObject *sceneObject) |
sets an object, the light is liked to | |
void | setCameraAnchor (int cameraIndex=-1) |
sets that this light's position is given relatively to a camera in the scene | |
void | setPosition (const Vec &position) |
sets the light's position | |
void | setAmbient (const GeomColor &color) |
sets the light's ambient color | |
void | setDiffuse (const GeomColor &color) |
sets the light's diffuse color | |
void | setSpecular (const GeomColor &color) |
sets the light's specular color | |
void | setAmbientEnabled (bool on=true) |
sets whether the light's ambient component is enabled | |
void | setDiffuseEnabled (bool on=true) |
sets whether the light's diffuse component is enabled | |
void | setSpecularEnabled (bool on=true) |
sets whether the light's specular component is enabled | |
void | setSpotDirection (const Vec &vec=Vec(0, 0,-1, 1)) |
sets the spot direction of this light | |
void | setSpotExponent (float value=0) |
sets the spot exponent of this light | |
void | setSpotCutoff (float value=180) |
sets the spot cutoff of this light | |
void | setAttenuation (float constant=1, float linear=0, float quadratic=0) |
sets the attenuation factors of this light | |
void | setShadowEnabled (bool on=true) |
sets whether the light casts shadows or not | |
void | setTwoSidedEnabled (bool on=true) |
sets whether the light casts two-sided light or not | |
bool | isOn () const |
returns whether the light is activated | |
bool | getShadowEnabled () const |
returns whether the light casts shadows or not | |
bool | getTwoSidedEnabled () const |
returns whether the light casts two-sided light or not | |
const Camera * | getShadowCam () const |
returns the camera used for casting the shadows | |
Camera * | getShadowCam () |
returns the camera used for casting the shadows | |
void | setShadowCam (Camera *cam) |
changes the shadowcam to the provided camera | |
void | reset () |
sets all paramters to OpenGL's default values | |
Private Types | |
enum | Anchor { WorldAnchor, CamAnchor, ObjectAnchor } |
internally used anchor mode More... | |
Private Member Functions | |
void | setupGL (const Scene &scene, const Camera &cam) const |
called by the scene | |
void | updatePositions (const Scene &scene, const Camera &cam) const |
SceneLight (Scene *parent, int index) | |
private constructor -> only Scene's can create lights | |
SceneLight (const SceneLight &other) | |
copies everything (overwrites uncopyable) | |
Private Attributes | |
const int | index |
wrapped opengl light index | |
bool | on |
flag that is used to swith off/on the light entirely | |
Vec | position |
the light's position | |
bool | ambientOn |
flag whether ambient light component is enabled | |
bool | diffuseOn |
flag whether diffuse light component is enabled | |
bool | specularOn |
flag whether specular light component is enabled | |
bool | shadowOn |
bool | twoSidedOn |
GeomColor | ambient |
ambient light color | |
GeomColor | diffuse |
diffuse light color | |
GeomColor | specular |
specular light color | |
Vec | spotDirection |
direction vector for directed light (0,0,-1) at default | |
float | spotExponent |
defines the intensity distribution of the light | |
float | spotCutoff |
defines the cutoff for spot-lights | |
Vec | attenuation |
special factor for light attenuation | |
enum icl::geom::SceneLight::Anchor | anchor |
current anchor mode | |
int | camAnchor |
for camera anchor-mode | |
Camera * | shadowCam |
Shadow Camera for rendering ShadowMaps. | |
SceneObject * | objectAnchor |
for the object anchor mode | |
SceneLightObject * | lightObject |
associated scene light Object | |
Friends | |
class | Scene |
for tight integration with the Scene class |
Wrapper class for OpenGL lights.
The light is integrated with the scene and is used to define lights in scenes. Each light is associated with one of the eight lights provided by OpenGL.
The class allows casting shadows, which can be enabled by using setShadowEnabled(). To change the direction of the shadow use getShadowCam() to get the shadow camera. Do not change the position of the camera since it will be back changed to the lights position every frame.
enum icl::geom::SceneLight::Anchor [private] |
icl::geom::SceneLight::SceneLight | ( | Scene * | parent, |
int | index | ||
) | [private] |
private constructor -> only Scene's can create lights
icl::geom::SceneLight::SceneLight | ( | const SceneLight & | other | ) | [private] |
copies everything (overwrites uncopyable)
Only accessible by friends, object anchor must be tackled manually
Destructor.
SceneLightObject* icl::geom::SceneLight::getLightObject | ( | ) | [inline] |
returns the associated light object
const SceneLightObject* icl::geom::SceneLight::getLightObject | ( | ) | const [inline] |
returns the associated light object (const)
const Camera* icl::geom::SceneLight::getShadowCam | ( | ) | const |
returns the camera used for casting the shadows
returns the camera used for casting the shadows
bool icl::geom::SceneLight::getShadowEnabled | ( | ) | const |
returns whether the light casts shadows or not
bool icl::geom::SceneLight::getTwoSidedEnabled | ( | ) | const |
returns whether the light casts two-sided light or not
bool icl::geom::SceneLight::isOn | ( | ) | const |
returns whether the light is activated
void icl::geom::SceneLight::reset | ( | ) |
sets all paramters to OpenGL's default values
void icl::geom::SceneLight::setAmbient | ( | const GeomColor & | color | ) |
sets the light's ambient color
void icl::geom::SceneLight::setAmbientEnabled | ( | bool | on = true | ) |
sets whether the light's ambient component is enabled
void icl::geom::SceneLight::setAnchor | ( | SceneObject * | sceneObject | ) |
sets an object, the light is liked to
In this case, the light's position and spot- direction is given relatively to the given object.
sets that this camera's position is given relatively to the world
void icl::geom::SceneLight::setAttenuation | ( | float | constant = 1 , |
float | linear = 0 , |
||
float | quadratic = 0 |
||
) |
sets the attenuation factors of this light
void icl::geom::SceneLight::setCameraAnchor | ( | int | cameraIndex = -1 | ) |
sets that this light's position is given relatively to a camera in the scene
If the given cameraIndex is < 0, then the light is positioned relatively to the current rendering camera. This is default.
void icl::geom::SceneLight::setDiffuse | ( | const GeomColor & | color | ) |
sets the light's diffuse color
void icl::geom::SceneLight::setDiffuseEnabled | ( | bool | on = true | ) |
sets whether the light's diffuse component is enabled
void icl::geom::SceneLight::setObjectSize | ( | float | size | ) |
sets the light objects scaling (default is 1)
void icl::geom::SceneLight::setOn | ( | bool | on = true | ) |
globally switches the light on or off
At default: only light 0 is on
void icl::geom::SceneLight::setPosition | ( | const Vec & | position | ) |
sets the light's position
How the position is interpreted depends on the current internal anchor mode. Please note, that the internal anchor mode cannot be set explicitly using a setAnchorMode method. Instead, the AnchorMode is always implicitly adapted when one of the methods
void icl::geom::SceneLight::setShadowCam | ( | Camera * | cam | ) |
changes the shadowcam to the provided camera
void icl::geom::SceneLight::setShadowEnabled | ( | bool | on = true | ) |
sets whether the light casts shadows or not
void icl::geom::SceneLight::setSpecular | ( | const GeomColor & | color | ) |
sets the light's specular color
void icl::geom::SceneLight::setSpecularEnabled | ( | bool | on = true | ) |
sets whether the light's specular component is enabled
void icl::geom::SceneLight::setSpotCutoff | ( | float | value = 180 | ) |
sets the spot cutoff of this light
void icl::geom::SceneLight::setSpotDirection | ( | const Vec & | vec = Vec(0, 0,-1, 1) | ) |
sets the spot direction of this light
void icl::geom::SceneLight::setSpotExponent | ( | float | value = 0 | ) |
sets the spot exponent of this light
void icl::geom::SceneLight::setTwoSidedEnabled | ( | bool | on = true | ) |
sets whether the light casts two-sided light or not
void icl::geom::SceneLight::setupGL | ( | const Scene & | scene, |
const Camera & | cam | ||
) | const [private] |
called by the scene
This method is called by the scene and sets up the light in OpenGL by using the instances parameters
void icl::geom::SceneLight::updatePositions | ( | const Scene & | scene, |
const Camera & | cam | ||
) | const [private] |
GeomColor icl::geom::SceneLight::ambient [private] |
ambient light color
bool icl::geom::SceneLight::ambientOn [private] |
flag whether ambient light component is enabled
enum icl::geom::SceneLight::Anchor icl::geom::SceneLight::anchor [private] |
current anchor mode
Vec icl::geom::SceneLight::attenuation [private] |
special factor for light attenuation
only positive values are allowed
int icl::geom::SceneLight::camAnchor [private] |
for camera anchor-mode
GeomColor icl::geom::SceneLight::diffuse [private] |
diffuse light color
bool icl::geom::SceneLight::diffuseOn [private] |
flag whether diffuse light component is enabled
const int icl::geom::SceneLight::index [private] |
wrapped opengl light index
associated scene light Object
SceneObject* icl::geom::SceneLight::objectAnchor [private] |
for the object anchor mode
bool icl::geom::SceneLight::on [private] |
flag that is used to swith off/on the light entirely
Vec icl::geom::SceneLight::position [private] |
the light's position
Camera* icl::geom::SceneLight::shadowCam [private] |
Shadow Camera for rendering ShadowMaps.
bool icl::geom::SceneLight::shadowOn [private] |
GeomColor icl::geom::SceneLight::specular [private] |
specular light color
bool icl::geom::SceneLight::specularOn [private] |
flag whether specular light component is enabled
float icl::geom::SceneLight::spotCutoff [private] |
defines the cutoff for spot-lights
possible values are 0-90 and one special value 180 which is default and defines a uniform light distribution
Vec icl::geom::SceneLight::spotDirection [private] |
direction vector for directed light (0,0,-1) at default
float icl::geom::SceneLight::spotExponent [private] |
defines the intensity distribution of the light
possible values are 0-128
bool icl::geom::SceneLight::twoSidedOn [private] |