Image Component Library (ICL)
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
icl::geom::SceneLight Class Reference

Wrapper class for OpenGL lights. More...

#include <SceneLight.h>

Inheritance diagram for icl::geom::SceneLight:
icl::utils::Uncopyable

Public Member Functions

 ~SceneLight ()
 Destructor. More...
 
SceneLightObjectgetLightObject ()
 returns the associated light object More...
 
const SceneLightObjectgetLightObject () const
 returns the associated light object (const) More...
 
void setObjectSize (float size)
 sets the light objects scaling (default is 1) More...
 
void setOn (bool on=true)
 globally switches the light on or off More...
 
void setAnchorToWorld ()
 sets that this camera's position is given relatively to the world More...
 
void setAnchor (SceneObject *sceneObject)
 sets an object, the light is liked to More...
 
void setCameraAnchor (int cameraIndex=-1)
 sets that this light's position is given relatively to a camera in the scene More...
 
void setPosition (const Vec &position)
 sets the light's position More...
 
void setAmbient (const GeomColor &color)
 sets the light's ambient color More...
 
void setDiffuse (const GeomColor &color)
 sets the light's diffuse color More...
 
void setSpecular (const GeomColor &color)
 sets the light's specular color More...
 
void setAmbientEnabled (bool on=true)
 sets whether the light's ambient component is enabled More...
 
void setDiffuseEnabled (bool on=true)
 sets whether the light's diffuse component is enabled More...
 
void setSpecularEnabled (bool on=true)
 sets whether the light's specular component is enabled More...
 
void setSpotDirection (const Vec &vec=Vec(0, 0,-1, 1))
 sets the spot direction of this light More...
 
void setSpotExponent (float value=0)
 sets the spot exponent of this light More...
 
void setSpotCutoff (float value=180)
 sets the spot cutoff of this light More...
 
void setAttenuation (float constant=1, float linear=0, float quadratic=0)
 sets the attenuation factors of this light More...
 
void setShadowEnabled (bool on=true)
 sets whether the light casts shadows or not More...
 
void setProjectionEnabled (bool on=true)
 sets whether the light projects a texture or not More...
 
void setTwoSidedEnabled (bool on=true)
 sets whether the light casts two-sided light or not More...
 
bool isOn () const
 returns whether the light is activated More...
 
bool getShadowEnabled () const
 returns whether the light casts shadows or not More...
 
bool getProjectionEnabled () const
 returns whether the light casts shadows or not More...
 
bool getTwoSidedEnabled () const
 returns whether the light casts two-sided light or not More...
 
const CameragetShadowCam () const
 returns the camera used for casting the shadows More...
 
CameragetShadowCam ()
 returns the camera used for casting the shadows More...
 
void setShadowCam (Camera *cam)
 changes the shadowcam to the provided camera More...
 
void setProjectionImage (qt::GLImg *img)
 set the projection image More...
 
qt::GLImggetProjectionImage () const
 get the projection image More...
 
void reset ()
 sets all paramters to OpenGL's default values More...
 

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 More...
 
void updatePositions (const Scene &scene, const Camera &cam) const
 
 SceneLight (Scene *parent, int index)
 private constructor -> only Scene's can create lights More...
 
 SceneLight (const SceneLight &other)
 copies everything (overwrites uncopyable) More...
 

Private Attributes

const int index
 wrapped opengl light index More...
 
bool on
 flag that is used to swith off/on the light entirely More...
 
Vec position
 the light's position More...
 
bool ambientOn
 flag whether ambient light component is enabled More...
 
bool diffuseOn
 flag whether diffuse light component is enabled More...
 
bool specularOn
 flag whether specular light component is enabled More...
 
bool shadowOn
 
bool projectionOn
 
bool twoSidedOn
 
GeomColor ambient
 ambient light color More...
 
GeomColor diffuse
 diffuse light color More...
 
GeomColor specular
 specular light color More...
 
Vec spotDirection
 direction vector for directed light (0,0,-1) at default More...
 
float spotExponent
 defines the intensity distribution of the light More...
 
float spotCutoff
 defines the cutoff for spot-lights More...
 
Vec attenuation
 special factor for light attenuation More...
 
enum icl::geom::SceneLight::Anchor anchor
 current anchor mode More...
 
int camAnchor
 for camera anchor-mode More...
 
CamerashadowCam
 Shadow Camera for rendering ShadowMaps. More...
 
qt::GLImgprojectionImage
 
SceneObjectobjectAnchor
 for the object anchor mode More...
 
SceneLightObjectlightObject
 associated scene light Object More...
 

Friends

class Scene
 for tight integration with the Scene class More...
 

Additional Inherited Members

- Protected Member Functions inherited from icl::utils::Uncopyable
 Uncopyable ()
 Empty base constructor. More...
 

Detailed Description

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.

Shadows

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.

Member Enumeration Documentation

◆ Anchor

internally used anchor mode

Enumerator
WorldAnchor 

light's position is relative to the world

CamAnchor 

light's position is relative to a camera

ObjectAnchor 

light's position is relative to an object

Constructor & Destructor Documentation

◆ SceneLight() [1/2]

icl::geom::SceneLight::SceneLight ( Scene parent,
int  index 
)
private

private constructor -> only Scene's can create lights

◆ SceneLight() [2/2]

icl::geom::SceneLight::SceneLight ( const SceneLight other)
private

copies everything (overwrites uncopyable)

Only accessible by friends, object anchor must be tackled manually

◆ ~SceneLight()

icl::geom::SceneLight::~SceneLight ( )

Destructor.

Member Function Documentation

◆ getLightObject() [1/2]

SceneLightObject* icl::geom::SceneLight::getLightObject ( )
inline

returns the associated light object

◆ getLightObject() [2/2]

const SceneLightObject* icl::geom::SceneLight::getLightObject ( ) const
inline

returns the associated light object (const)

◆ getProjectionEnabled()

bool icl::geom::SceneLight::getProjectionEnabled ( ) const

returns whether the light casts shadows or not

◆ getProjectionImage()

qt::GLImg* icl::geom::SceneLight::getProjectionImage ( ) const

get the projection image

◆ getShadowCam() [1/2]

const Camera* icl::geom::SceneLight::getShadowCam ( ) const

returns the camera used for casting the shadows

◆ getShadowCam() [2/2]

Camera* icl::geom::SceneLight::getShadowCam ( )

returns the camera used for casting the shadows

◆ getShadowEnabled()

bool icl::geom::SceneLight::getShadowEnabled ( ) const

returns whether the light casts shadows or not

◆ getTwoSidedEnabled()

bool icl::geom::SceneLight::getTwoSidedEnabled ( ) const

returns whether the light casts two-sided light or not

◆ isOn()

bool icl::geom::SceneLight::isOn ( ) const

returns whether the light is activated

◆ reset()

void icl::geom::SceneLight::reset ( )

sets all paramters to OpenGL's default values

◆ setAmbient()

void icl::geom::SceneLight::setAmbient ( const GeomColor color)

sets the light's ambient color

◆ setAmbientEnabled()

void icl::geom::SceneLight::setAmbientEnabled ( bool  on = true)

sets whether the light's ambient component is enabled

◆ setAnchor()

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.

◆ setAnchorToWorld()

void icl::geom::SceneLight::setAnchorToWorld ( )

sets that this camera's position is given relatively to the world

◆ setAttenuation()

void icl::geom::SceneLight::setAttenuation ( float  constant = 1,
float  linear = 0,
float  quadratic = 0 
)

sets the attenuation factors of this light

◆ setCameraAnchor()

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.

◆ setDiffuse()

void icl::geom::SceneLight::setDiffuse ( const GeomColor color)

sets the light's diffuse color

◆ setDiffuseEnabled()

void icl::geom::SceneLight::setDiffuseEnabled ( bool  on = true)

sets whether the light's diffuse component is enabled

◆ setObjectSize()

void icl::geom::SceneLight::setObjectSize ( float  size)

sets the light objects scaling (default is 1)

◆ setOn()

void icl::geom::SceneLight::setOn ( bool  on = true)

globally switches the light on or off

At default: only light 0 is on

◆ setPosition()

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

◆ setProjectionEnabled()

void icl::geom::SceneLight::setProjectionEnabled ( bool  on = true)

sets whether the light projects a texture or not

◆ setProjectionImage()

void icl::geom::SceneLight::setProjectionImage ( qt::GLImg img)

set the projection image

◆ setShadowCam()

void icl::geom::SceneLight::setShadowCam ( Camera cam)

changes the shadowcam to the provided camera

◆ setShadowEnabled()

void icl::geom::SceneLight::setShadowEnabled ( bool  on = true)

sets whether the light casts shadows or not

◆ setSpecular()

void icl::geom::SceneLight::setSpecular ( const GeomColor color)

sets the light's specular color

◆ setSpecularEnabled()

void icl::geom::SceneLight::setSpecularEnabled ( bool  on = true)

sets whether the light's specular component is enabled

◆ setSpotCutoff()

void icl::geom::SceneLight::setSpotCutoff ( float  value = 180)

sets the spot cutoff of this light

◆ setSpotDirection()

void icl::geom::SceneLight::setSpotDirection ( const Vec vec = Vec(0, 0,-1, 1))

sets the spot direction of this light

◆ setSpotExponent()

void icl::geom::SceneLight::setSpotExponent ( float  value = 0)

sets the spot exponent of this light

◆ setTwoSidedEnabled()

void icl::geom::SceneLight::setTwoSidedEnabled ( bool  on = true)

sets whether the light casts two-sided light or not

◆ setupGL()

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

◆ updatePositions()

void icl::geom::SceneLight::updatePositions ( const Scene scene,
const Camera cam 
) const
private

Friends And Related Function Documentation

◆ Scene

friend class Scene
friend

for tight integration with the Scene class

Member Data Documentation

◆ ambient

GeomColor icl::geom::SceneLight::ambient
private

ambient light color

◆ ambientOn

bool icl::geom::SceneLight::ambientOn
private

flag whether ambient light component is enabled

◆ anchor

enum icl::geom::SceneLight::Anchor icl::geom::SceneLight::anchor
private

current anchor mode

◆ attenuation

Vec icl::geom::SceneLight::attenuation
private

special factor for light attenuation

only positive values are allowed

◆ camAnchor

int icl::geom::SceneLight::camAnchor
private

for camera anchor-mode

◆ diffuse

GeomColor icl::geom::SceneLight::diffuse
private

diffuse light color

◆ diffuseOn

bool icl::geom::SceneLight::diffuseOn
private

flag whether diffuse light component is enabled

◆ index

const int icl::geom::SceneLight::index
private

wrapped opengl light index

◆ lightObject

SceneLightObject* icl::geom::SceneLight::lightObject
private

associated scene light Object

◆ objectAnchor

SceneObject* icl::geom::SceneLight::objectAnchor
private

for the object anchor mode

◆ on

bool icl::geom::SceneLight::on
private

flag that is used to swith off/on the light entirely

◆ position

Vec icl::geom::SceneLight::position
private

the light's position

◆ projectionImage

qt::GLImg* icl::geom::SceneLight::projectionImage
private

◆ projectionOn

bool icl::geom::SceneLight::projectionOn
private

◆ shadowCam

Camera* icl::geom::SceneLight::shadowCam
private

Shadow Camera for rendering ShadowMaps.

◆ shadowOn

bool icl::geom::SceneLight::shadowOn
private

◆ specular

GeomColor icl::geom::SceneLight::specular
private

specular light color

◆ specularOn

bool icl::geom::SceneLight::specularOn
private

flag whether specular light component is enabled

◆ spotCutoff

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

◆ spotDirection

Vec icl::geom::SceneLight::spotDirection
private

direction vector for directed light (0,0,-1) at default

◆ spotExponent

float icl::geom::SceneLight::spotExponent
private

defines the intensity distribution of the light

possible values are 0-128

◆ twoSidedOn

bool icl::geom::SceneLight::twoSidedOn
private

The documentation for this class was generated from the following file: