Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Protected Attributes | List of all members
vl::Light Class Reference

Wraps the OpenGL function glLight(). More...

#include <Light.hpp>

+ Inheritance diagram for vl::Light:

Public Member Functions

 Light ()
 
virtual ERenderState type () const
 
virtual void apply (int index, const Camera *, OpenGLContext *ctx) const
 The parameter cameara is NULL if we are disabling the state, non-NULL if we are enabling it. More...
 
void setAmbient (const fvec4 &ambientcolor)
 
const fvec4ambient () const
 
void setDiffuse (const fvec4 &diffusecolor)
 
const fvec4diffuse () const
 
void setSpecular (const fvec4 &specularcolor)
 
const fvec4specular () const
 
void setPosition (const fvec4 &position)
 The position or direction of a light. More...
 
const fvec4position () const
 The position or direction of a light. More...
 
void setSpotDirection (const fvec3 &spotdirection)
 
const fvec3spotDirection () const
 
void setSpotExponent (float spotexponent)
 
float spotExponent () const
 
void setSpotCutoff (float spotcutoff)
 Valid values are from 0.0f to 90.0f plus the special value 180.0f (default) which disables the spot lighting. More...
 
float spotCutoff () const
 Valid values are from 0.0f to 90.0f plus the special value 180.0f (default) which disables the spot lighting. More...
 
void setLinearAttenuation (float linearattenuation)
 If the light is positional, rather than directional, its intensity is attenuated by the reciprocal of the sum of the constant attenuation, the linear attenuation times the distance between the light and the vertex being lighted, and the quadratic attenuation times the square of the same distance. More...
 
float linearAttenuation () const
 
void setQuadraticAttenuation (float quadraticattenuation)
 If the light is positional, rather than directional, its intensity is attenuated by the reciprocal of the sum of the constant attenuation, the linear attenuation times the distance between the light and the vertex being lighted, and the quadratic attenuation times the square of the same distance. More...
 
float quadraticAttenuation () const
 
void setConstantAttenuation (float constantattenuation)
 If the light is positional, rather than directional, its intensity is attenuated by the reciprocal of the sum of the constant attenuation, the linear attenuation times the distance between the light and the vertex being lighted, and the quadratic attenuation times the square of the same distance. More...
 
float constantAttenuation () const
 
void bindTransform (Transform *transform)
 If NULL follows the camera otherwise the given transformation node. More...
 
TransformboundTransform ()
 
const TransformboundTransform () const
 
virtual ref< RenderStateclone () const
 
void setEnabled (bool enabled)
 
bool enabled () const
 
- Public Member Functions inherited from vl::RenderStateIndexed
 RenderStateIndexed ()
 
- Public Member Functions inherited from vl::RenderState
 RenderState ()
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

Protected Attributes

fvec4 mAmbient
 
fvec4 mDiffuse
 
fvec4 mSpecular
 
fvec4 mPosition
 
fvec3 mSpotDirection
 
float mSpotExponent
 
float mSpotCutoff
 
float mConstantAttenuation
 
float mLinearAttenuation
 
float mQuadraticAttenuation
 
ref< TransformmBoundTransform
 
bool mEnabled
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Additional Inherited Members

- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 

Detailed Description

Wraps the OpenGL function glLight().

See also http://www.opengl.org/sdk/docs/man/xhtml/glLight.xml for more information.

See also the Lights Tutorial for a practical example of how to use OpenGL lights.

See also
Shader, Effect, Actor, vl::EN_LIGHTING

Definition at line 51 of file Light.hpp.

Constructor & Destructor Documentation

◆ Light()

Light::Light ( )

Member Function Documentation

◆ ambient()

const fvec4& vl::Light::ambient ( ) const
inline

◆ apply()

void Light::apply ( int  index,
const Camera camera,
OpenGLContext ctx 
) const
virtual

◆ bindTransform()

void Light::bindTransform ( Transform transform)

If NULL follows the camera otherwise the given transformation node.

Definition at line 114 of file Light.cpp.

References mBoundTransform.

Referenced by vlX::VLXClassWrapper_Light::importLight(), and vl::DaeLoader::parseLight().

◆ boundTransform() [1/2]

Transform * Light::boundTransform ( )

◆ boundTransform() [2/2]

const Transform * Light::boundTransform ( ) const

Definition at line 124 of file Light.cpp.

References mBoundTransform.

◆ clone()

virtual ref<RenderState> vl::Light::clone ( ) const
inlinevirtual

Implements vl::RenderState.

Definition at line 117 of file Light.hpp.

◆ constantAttenuation()

float vl::Light::constantAttenuation ( ) const
inline

Definition at line 108 of file Light.hpp.

Referenced by vlX::VLXClassWrapper_Light::exportLight().

◆ diffuse()

const fvec4& vl::Light::diffuse ( ) const
inline

◆ enabled()

bool vl::Light::enabled ( ) const
inline

Definition at line 126 of file Light.hpp.

Referenced by apply().

◆ linearAttenuation()

float vl::Light::linearAttenuation ( ) const
inline

Definition at line 96 of file Light.hpp.

Referenced by vlX::VLXClassWrapper_Light::exportLight().

◆ position()

const fvec4& vl::Light::position ( ) const
inline

◆ quadraticAttenuation()

float vl::Light::quadraticAttenuation ( ) const
inline

Definition at line 102 of file Light.hpp.

Referenced by vlX::VLXClassWrapper_Light::exportLight().

◆ setAmbient()

void vl::Light::setAmbient ( const fvec4 ambientcolor)
inline

Definition at line 62 of file Light.hpp.

Referenced by vlX::VLXClassWrapper_Light::importLight(), and vl::DaeLoader::parseLight().

◆ setConstantAttenuation()

void vl::Light::setConstantAttenuation ( float  constantattenuation)
inline

If the light is positional, rather than directional, its intensity is attenuated by the reciprocal of the sum of the constant attenuation, the linear attenuation times the distance between the light and the vertex being lighted, and the quadratic attenuation times the square of the same distance.

Definition at line 107 of file Light.hpp.

Referenced by vlX::VLXClassWrapper_Light::importLight(), and vl::DaeLoader::parseLight().

◆ setDiffuse()

void vl::Light::setDiffuse ( const fvec4 diffusecolor)
inline

Definition at line 65 of file Light.hpp.

Referenced by vlX::VLXClassWrapper_Light::importLight(), and vl::DaeLoader::parseLight().

◆ setEnabled()

void vl::Light::setEnabled ( bool  enabled)
inline

Definition at line 124 of file Light.hpp.

◆ setLinearAttenuation()

void vl::Light::setLinearAttenuation ( float  linearattenuation)
inline

If the light is positional, rather than directional, its intensity is attenuated by the reciprocal of the sum of the constant attenuation, the linear attenuation times the distance between the light and the vertex being lighted, and the quadratic attenuation times the square of the same distance.

Definition at line 95 of file Light.hpp.

Referenced by vlX::VLXClassWrapper_Light::importLight(), and vl::DaeLoader::parseLight().

◆ setPosition()

void vl::Light::setPosition ( const fvec4 position)
inline

The position or direction of a light.

  • If the fourth component of position equals 0.0f then the light is considered a directional light and position points in the direction of the light.
  • If the fourth component of position equals 1.0f then the light is considered a positional light and position contains the position of the light.

Note. The position or direction of a light is relative to the followed Transform or to the camera if the light does not follow any transform.

Definition at line 77 of file Light.hpp.

Referenced by vlX::VLXClassWrapper_Light::importLight(), and vl::DaeLoader::parseLight().

◆ setQuadraticAttenuation()

void vl::Light::setQuadraticAttenuation ( float  quadraticattenuation)
inline

If the light is positional, rather than directional, its intensity is attenuated by the reciprocal of the sum of the constant attenuation, the linear attenuation times the distance between the light and the vertex being lighted, and the quadratic attenuation times the square of the same distance.

Definition at line 101 of file Light.hpp.

Referenced by vlX::VLXClassWrapper_Light::importLight(), and vl::DaeLoader::parseLight().

◆ setSpecular()

void vl::Light::setSpecular ( const fvec4 specularcolor)
inline

Definition at line 68 of file Light.hpp.

Referenced by vlX::VLXClassWrapper_Light::importLight(), and vl::DaeLoader::parseLight().

◆ setSpotCutoff()

void vl::Light::setSpotCutoff ( float  spotcutoff)
inline

Valid values are from 0.0f to 90.0f plus the special value 180.0f (default) which disables the spot lighting.

Definition at line 88 of file Light.hpp.

Referenced by vlX::VLXClassWrapper_Light::importLight(), and vl::DaeLoader::parseLight().

◆ setSpotDirection()

void vl::Light::setSpotDirection ( const fvec3 spotdirection)
inline

Definition at line 81 of file Light.hpp.

Referenced by vlX::VLXClassWrapper_Light::importLight(), and vl::DaeLoader::parseLight().

◆ setSpotExponent()

void vl::Light::setSpotExponent ( float  spotexponent)
inline

Definition at line 84 of file Light.hpp.

Referenced by vlX::VLXClassWrapper_Light::importLight(), and vl::DaeLoader::parseLight().

◆ specular()

const fvec4& vl::Light::specular ( ) const
inline

◆ spotCutoff()

float vl::Light::spotCutoff ( ) const
inline

Valid values are from 0.0f to 90.0f plus the special value 180.0f (default) which disables the spot lighting.

Definition at line 90 of file Light.hpp.

Referenced by vlX::VLXClassWrapper_Light::exportLight(), and vl::DaeLoader::setupLights().

◆ spotDirection()

const fvec3& vl::Light::spotDirection ( ) const
inline

Definition at line 82 of file Light.hpp.

Referenced by vlX::VLXClassWrapper_Light::exportLight().

◆ spotExponent()

float vl::Light::spotExponent ( ) const
inline

Definition at line 85 of file Light.hpp.

Referenced by vlX::VLXClassWrapper_Light::exportLight().

◆ type()

virtual ERenderState vl::Light::type ( ) const
inlinevirtual

Reimplemented from vl::RenderState.

Definition at line 58 of file Light.hpp.

References vl::RS_Light.

Member Data Documentation

◆ mAmbient

fvec4 vl::Light::mAmbient
protected

Definition at line 129 of file Light.hpp.

Referenced by apply(), and Light().

◆ mBoundTransform

ref<Transform> vl::Light::mBoundTransform
protected

Definition at line 139 of file Light.hpp.

Referenced by bindTransform(), boundTransform(), and Light().

◆ mConstantAttenuation

float vl::Light::mConstantAttenuation
protected

Definition at line 136 of file Light.hpp.

Referenced by apply(), and Light().

◆ mDiffuse

fvec4 vl::Light::mDiffuse
protected

Definition at line 130 of file Light.hpp.

Referenced by apply(), and Light().

◆ mEnabled

bool vl::Light::mEnabled
protected

Definition at line 140 of file Light.hpp.

Referenced by Light().

◆ mLinearAttenuation

float vl::Light::mLinearAttenuation
protected

Definition at line 137 of file Light.hpp.

Referenced by apply(), and Light().

◆ mPosition

fvec4 vl::Light::mPosition
protected

Definition at line 132 of file Light.hpp.

Referenced by apply(), and Light().

◆ mQuadraticAttenuation

float vl::Light::mQuadraticAttenuation
protected

Definition at line 138 of file Light.hpp.

Referenced by apply(), and Light().

◆ mSpecular

fvec4 vl::Light::mSpecular
protected

Definition at line 131 of file Light.hpp.

Referenced by apply(), and Light().

◆ mSpotCutoff

float vl::Light::mSpotCutoff
protected

Definition at line 135 of file Light.hpp.

Referenced by apply(), and Light().

◆ mSpotDirection

fvec3 vl::Light::mSpotDirection
protected

Definition at line 133 of file Light.hpp.

Referenced by apply(), and Light().

◆ mSpotExponent

float vl::Light::mSpotExponent
protected

Definition at line 134 of file Light.hpp.

Referenced by apply(), and Light().


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