Loading...
Searching...
No Matches
Gfx::CLightManager Class Reference

Manager for dynamic lights in 3D scene. More...

`#include <src/graphics/engine/lightman.h>`

## Classes

class | CLightsComparator

## Public Member Functions

| CLightManager (CEngine *engine)
| Constructor.
virtual | ~CLightManager ()
| Destructor.
void | SetDevice (CDevice *device)
| Sets the device to be used.
void | DebugDumpLights ()
| Prints debug info.
void | FlushLights ()
| Clears and disables all lights.
int | CreateLight (LightPriority priority=LIGHT_PRI_LOW)
| Creates a new dynamic light and returns its index (lightRank).
bool | DeleteLight (int lightRank)
| Deletes and disables the given dynamic light.
bool | SetLight (int lightRank, const Light &light)
| Sets the light parameters for dynamic light.
bool | GetLight (int lightRank, Light &light)
| Returns the light parameters for given dynamic light.
bool | SetLightEnabled (int lightRank, bool enabled)
| Enables/disables the given dynamic light.
bool | SetLightPriority (int lightRank, LightPriority priority)
| Changes the light priority.
bool | SetLightIncludeType (int lightRank, EngineObjectType type)
| Sets what objects are included in given dynamic light.
bool | SetLightExcludeType (int lightRank, EngineObjectType type)
| Sets what objects are excluded from given dynamic light.
bool | SetLightPos (int lightRank, const Math::Vector &pos)
| Sets the position of dynamic light.
Math::Vector | GetLightPos (int lightRank)
| Returns the position of dynamic light.
bool | SetLightDir (int lightRank, const Math::Vector &dir)
| Sets the direction of dynamic light.
Math::Vector | GetLightDir (int lightRank)
| Returns the direction of dynamic light.
bool | SetLightIntensity (int lightRank, float value)
| Sets the destination intensity for dynamic light's intensity progression.
float | GetLightIntensity (int lightRank)
| Returns the current light intensity.
bool | SetLightIntensitySpeed (int lightRank, float speed)
| Sets the rate of change for dynamic light intensity.
void | AdaptLightColor (const Color &color, float factor)
| Adjusts the color of all dynamic lights.
bool | SetLightColor (int lightRank, const Color &color)
| Sets the destination color for dynamic light's color progression.
Color | GetLightColor (int lightRank)
| Returns current light color.
bool | SetLightColorSpeed (int lightRank, float speed)
| Sets the rate of change for dynamic light colors (RGB).
void | UpdateProgression (float rTime)
| Updates progression of dynamic lights.
void | UpdateLights ()
| Updates (recalculates) all dynamic lights.
void | UpdateDeviceLights (EngineObjectType type)
| Enables or disables dynamic lights affecting the given object type.

## Protected Attributes

CEngine * | m_engine
CDevice * | m_device
float | m_time
| Current time.
std::vector< DynamicLight > | m_dynLights
| List of dynamic lights.
std::vector< int > | m_lightMap
| Map of current light allocation: graphics light -> dynamic light.

## Detailed Description

Manager for dynamic lights in 3D scene.

The class is responsible for managing dynamic lights (struct DynamicLight) used in 3D scene. The dynamic lights are created, updated and deleted through the class' interface.

Since there is a limit on total number of lights available in OpenGL (usually up to 8), the dynamic lights must be emulated by displaying only some of them. All functions normally operate only on DynamicLight structs, updating the models with new values, while only one function, UpdateDeviceLights(), performs the actual synchronization to the device. It allocates device's light slots as necessary, with two priority levels for lights.

## Constructor & Destructor Documentation

## CLightManager()

Gfx::CLightManager::CLightManager | ( | CEngine * | engine | ) |

Constructor.

## ~CLightManager()

Gfx::CLightManager::~CLightManager | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## SetDevice()

void Gfx::CLightManager::SetDevice | ( | CDevice * | device | ) |

Sets the device to be used.

## DebugDumpLights()

void Gfx::CLightManager::DebugDumpLights | ( |  | ) |

Prints debug info.

## FlushLights()

void Gfx::CLightManager::FlushLights | ( |  | ) |

Clears and disables all lights.

## CreateLight()

int Gfx::CLightManager::CreateLight | ( | LightPriority | priority = LIGHT_PRI_LOW | ) |

Creates a new dynamic light and returns its index (lightRank).

Returns the index of light created.

## DeleteLight()

bool Gfx::CLightManager::DeleteLight | ( | int | lightRank | ) |

Deletes and disables the given dynamic light.

## SetLight()

bool Gfx::CLightManager::SetLight | ( | int | lightRank,
|  | const Light & | light )

Sets the light parameters for dynamic light.

## GetLight()

bool Gfx::CLightManager::GetLight | ( | int | lightRank,
|  | Light & | light )

Returns the light parameters for given dynamic light.

## SetLightEnabled()

bool Gfx::CLightManager::SetLightEnabled | ( | int | lightRank,
|  | bool | enabled )

Enables/disables the given dynamic light.

## SetLightPriority()

bool Gfx::CLightManager::SetLightPriority | ( | int | lightRank,
|  | LightPriority | priority )

Changes the light priority.

## SetLightIncludeType()

bool Gfx::CLightManager::SetLightIncludeType | ( | int | lightRank,
|  | EngineObjectType | type )

Sets what objects are included in given dynamic light.

## SetLightExcludeType()

bool Gfx::CLightManager::SetLightExcludeType | ( | int | lightRank,
|  | EngineObjectType | type )

Sets what objects are excluded from given dynamic light.

## SetLightPos()

bool Gfx::CLightManager::SetLightPos | ( | int | lightRank,
|  | const Math::Vector & | pos )

Sets the position of dynamic light.

## GetLightPos()

Math::Vector Gfx::CLightManager::GetLightPos | ( | int | lightRank | ) |

Returns the position of dynamic light.

## SetLightDir()

bool Gfx::CLightManager::SetLightDir | ( | int | lightRank,
|  | const Math::Vector & | dir )

Sets the direction of dynamic light.

## GetLightDir()

Math::Vector Gfx::CLightManager::GetLightDir | ( | int | lightRank | ) |

Returns the direction of dynamic light.

## SetLightIntensity()

bool Gfx::CLightManager::SetLightIntensity | ( | int | lightRank,
|  | float | value )

Sets the destination intensity for dynamic light's intensity progression.

## GetLightIntensity()

float Gfx::CLightManager::GetLightIntensity | ( | int | lightRank | ) |

Returns the current light intensity.

## SetLightIntensitySpeed()

bool Gfx::CLightManager::SetLightIntensitySpeed | ( | int | lightRank,
|  | float | speed )

Sets the rate of change for dynamic light intensity.

## AdaptLightColor()

void Gfx::CLightManager::AdaptLightColor | ( | const Color & | color,
|  | float | factor )

Adjusts the color of all dynamic lights.

## SetLightColor()

bool Gfx::CLightManager::SetLightColor | ( | int | lightRank,
|  | const Color & | color )

Sets the destination color for dynamic light's color progression.

## GetLightColor()

Color Gfx::CLightManager::GetLightColor | ( | int | lightRank | ) |

Returns current light color.

## SetLightColorSpeed()

bool Gfx::CLightManager::SetLightColorSpeed | ( | int | lightRank,
|  | float | speed )

Sets the rate of change for dynamic light colors (RGB).

## UpdateProgression()

void Gfx::CLightManager::UpdateProgression | ( | float | rTime | ) |

Updates progression of dynamic lights.

## UpdateLights()

void Gfx::CLightManager::UpdateLights | ( |  | ) |

Updates (recalculates) all dynamic lights.

## UpdateDeviceLights()

void Gfx::CLightManager::UpdateDeviceLights | ( | EngineObjectType | type | ) |

Enables or disables dynamic lights affecting the given object type.

## Member Data Documentation

## m_time

float Gfx::CLightManager::m_time

protected

Current time.

## m_dynLights

std::vector<DynamicLight> Gfx::CLightManager::m_dynLights

protected

List of dynamic lights.

## m_lightMap

std::vector<int> Gfx::CLightManager::m_lightMap

protected

Map of current light allocation: graphics light -> dynamic light.

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

- src/graphics/engine/lightman.h
- src/graphics/engine/lightman.cpp