Colobot
|
Manager for dynamic lights in 3D scene. More...
#include <lightman.h>
Classes | |
class | LightsComparator |
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) More... | |
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 enable) |
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. | |
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.
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.