2016-07-12 17:40:45 +00:00
|
|
|
#pragma once
|
2013-12-08 16:56:59 +00:00
|
|
|
|
|
|
|
#include "software_global.h"
|
|
|
|
|
2015-09-24 22:12:31 +00:00
|
|
|
#include "LightComponent.h"
|
|
|
|
|
2015-11-18 18:37:00 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2013-12-08 16:56:59 +00:00
|
|
|
namespace paysages {
|
|
|
|
namespace software {
|
|
|
|
|
|
|
|
/**
|
2016-01-03 18:21:23 +00:00
|
|
|
* Global lighting manager.
|
2013-12-08 16:56:59 +00:00
|
|
|
*
|
2015-09-24 22:12:31 +00:00
|
|
|
* This manager handles the lights, light filters and final light rendering.
|
|
|
|
*
|
|
|
|
* There are both static and dynamic lights.
|
|
|
|
* A dynamic light depends on the location at which the lighting occurs.
|
2013-12-08 16:56:59 +00:00
|
|
|
*/
|
2015-11-09 21:30:46 +00:00
|
|
|
class SOFTWARESHARED_EXPORT LightingManager {
|
|
|
|
public:
|
2013-12-08 16:56:59 +00:00
|
|
|
LightingManager();
|
|
|
|
|
2015-09-24 22:12:31 +00:00
|
|
|
int getStaticLightsCount() const;
|
|
|
|
int getSourcesCount() const;
|
|
|
|
int getFiltersCount() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear the static lights.
|
|
|
|
*/
|
|
|
|
void clearStaticLights();
|
|
|
|
|
2013-12-08 16:56:59 +00:00
|
|
|
/**
|
2015-09-24 22:12:31 +00:00
|
|
|
* Add a static light.
|
2013-12-08 16:56:59 +00:00
|
|
|
*/
|
2015-09-24 22:12:31 +00:00
|
|
|
void addStaticLight(const LightComponent &light);
|
2013-12-08 16:56:59 +00:00
|
|
|
|
2015-09-29 20:31:25 +00:00
|
|
|
/**
|
|
|
|
* Remove all registered sources.
|
|
|
|
*/
|
|
|
|
void clearSources();
|
|
|
|
|
2013-12-08 16:56:59 +00:00
|
|
|
/**
|
2015-09-24 22:12:31 +00:00
|
|
|
* Register a source of dynamic lighting.
|
|
|
|
*/
|
|
|
|
void registerSource(LightSource *source);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a registered light source.
|
|
|
|
*/
|
|
|
|
void unregisterSource(LightSource *source);
|
|
|
|
|
2015-09-29 20:31:25 +00:00
|
|
|
/**
|
|
|
|
* Remove all registered filters.
|
|
|
|
*/
|
|
|
|
void clearFilters();
|
|
|
|
|
2015-09-24 22:12:31 +00:00
|
|
|
/**
|
|
|
|
* Register a filter that will receive all alterable lights.
|
|
|
|
*/
|
|
|
|
void registerFilter(LightFilter *filter);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a registered light filter.
|
|
|
|
*/
|
|
|
|
void unregisterFilter(LightFilter *filter);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Alter the light component at a given location.
|
|
|
|
*
|
|
|
|
* Returns true if the light is useful
|
2013-12-08 16:56:59 +00:00
|
|
|
*/
|
|
|
|
bool alterLight(LightComponent &component, const Vector3 &location);
|
|
|
|
|
|
|
|
/**
|
2015-09-24 22:12:31 +00:00
|
|
|
* Enable or disable the specularity lighting.
|
2013-12-08 16:56:59 +00:00
|
|
|
*/
|
|
|
|
void setSpecularity(bool enabled);
|
|
|
|
|
2015-10-15 22:14:54 +00:00
|
|
|
/**
|
|
|
|
* Enable or disable the filtering (shadows).
|
|
|
|
*/
|
|
|
|
void setFiltering(bool enabled);
|
|
|
|
|
2013-12-08 16:56:59 +00:00
|
|
|
/**
|
2015-09-24 22:12:31 +00:00
|
|
|
* Apply a final component on a surface material.
|
2013-12-08 16:56:59 +00:00
|
|
|
*/
|
2015-11-09 21:30:46 +00:00
|
|
|
Color applyFinalComponent(const LightComponent &component, const Vector3 &eye, const Vector3 &location,
|
|
|
|
const Vector3 &normal, const SurfaceMaterial &material);
|
2013-12-08 16:56:59 +00:00
|
|
|
|
2015-09-29 20:31:25 +00:00
|
|
|
/**
|
|
|
|
* Compute the light status at a given location.
|
|
|
|
*/
|
|
|
|
void fillStatus(LightStatus &status, const Vector3 &location) const;
|
|
|
|
|
2015-09-24 22:12:31 +00:00
|
|
|
/**
|
|
|
|
* Apply lighting to a surface at a given location.
|
|
|
|
*/
|
|
|
|
Color apply(const Vector3 &eye, const Vector3 &location, const Vector3 &normal, const SurfaceMaterial &material);
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
private:
|
2015-10-15 22:14:54 +00:00
|
|
|
bool specularity;
|
|
|
|
bool filtering;
|
2015-12-10 23:36:50 +00:00
|
|
|
vector<LightComponent> static_lights;
|
|
|
|
vector<LightFilter *> filters;
|
|
|
|
vector<LightSource *> sources;
|
2013-12-08 16:56:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|