AGL  0
3D graphics library
Light Class Reference

Light, adds reality to the scene. More...

Inheritance diagram for Light:
Collaboration diagram for Light:

Public Member Functions

 Light (const glm::vec3 &pos=glm::vec3(-2, 3, 2), const glm::vec4 &color=glm::vec4(1))
 Creates a light. More...
 
 Light (const glm::vec3 &pos=glm::vec3(-2, 3, 2), float r=1, float g=1, float b=1, float a=1)
 See Light. More...
 
void setColor (glm::vec4 color=glm::vec4(1))
 Set color of the light. More...
 
void setColor (float r=1, float g=1, float b=1, float a=1)
 Set light color. See setColor and Light(const glm::vec3&, float, float, float, float). More...
 
glm::vec4 getPos ()
 Get the position of the light. More...
 
- Public Member Functions inherited from BaseEntity
virtual ~BaseEntity ()
 

Public Attributes

glm::vec4 ambient
 Ambient, illuminates everything. More...
 
glm::vec4 diffuse
 Diffuse, illuminates surfaces facing the light. More...
 
glm::vec4 specular
 Specular, reflects from surface. More...
 
glm::vec4 position
 Position (direction) of the light. More...
 
glm::vec3 spotDirection
 Direction of spotlight. More...
 
float spotExponent = 0
 Effect of spotlight. More...
 
float spotCosCutoff = -1
 Cosine of angle of spotlight. (range: [1, 0], -1 means disabled) More...
 
float constantAttenuation = 1
 Constant attenuation. More...
 
float linearAttenuation = 0
 Linear attenuation. More...
 
float quadraticAttenuation = 0
 Quadratic attenuation. More...
 
- Public Attributes inherited from BaseEntity
Entityparent = nullptr
 Parent of the entity, whose child this is. All transformations of the parent is also applied to the child. More...
 

Detailed Description

Light, adds reality to the scene.

These are different kinds of lights that can be added to the scene. There are mainly three kinds of light,

  • Point light: Point lights are positioned and cast light in all directions. For a point light, the fourth component of the position vector should be 1.
  • Directional light: Directional lights originates at infinity and propagates straight in a certain direction. For a directional light, the fourth component of the position vector should be 0.
  • Spotlight: Spotlights are positioned and cast light in a cone. For a spotlight, the spotCosCutoff should be between 0 and 1.

Constructor & Destructor Documentation

◆ Light() [1/2]

Light ( const glm::vec3 &  pos = glm::vec3(-2, 3, 2),
const glm::vec4 &  color = glm::vec4(1) 
)

Creates a light.

Parameters
posPosition of the light.
colorColor of the light.

Creates a point light. To create other kinds of light, use the constructor-like functions.

See also
DirectionalLight

◆ Light() [2/2]

Light ( const glm::vec3 &  pos = glm::vec3(-2, 3, 2),
float  r = 1,
float  g = 1,
float  b = 1,
float  a = 1 
)

See Light.

Parameters
posPosition of the light.
rRed.
gGreen.
bBlue.
aAlpha.

Member Function Documentation

◆ getPos()

glm::vec4 getPos ( )
inline

Get the position of the light.

Returns
The position after accounting for the parent transformations.

◆ setColor() [1/2]

void setColor ( glm::vec4  color = glm::vec4(1))

Set color of the light.

Parameters
colorColor to set.

◆ setColor() [2/2]

void setColor ( float  r = 1,
float  g = 1,
float  b = 1,
float  a = 1 
)

Member Data Documentation

◆ ambient

glm::vec4 ambient

Ambient, illuminates everything.

◆ constantAttenuation

float constantAttenuation = 1

Constant attenuation.

◆ diffuse

glm::vec4 diffuse

Diffuse, illuminates surfaces facing the light.

◆ linearAttenuation

float linearAttenuation = 0

Linear attenuation.

◆ position

glm::vec4 position

Position (direction) of the light.

◆ quadraticAttenuation

float quadraticAttenuation = 0

Quadratic attenuation.

◆ specular

glm::vec4 specular

Specular, reflects from surface.

◆ spotCosCutoff

float spotCosCutoff = -1

Cosine of angle of spotlight. (range: [1, 0], -1 means disabled)

◆ spotDirection

glm::vec3 spotDirection

Direction of spotlight.

◆ spotExponent

float spotExponent = 0

Effect of spotlight.


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