STARK: Add support for negative lights

This commit is contained in:
Bastien Bouclet 2018-04-14 11:06:02 +02:00
parent d4a890a36e
commit 5f2f1927c4
2 changed files with 7 additions and 4 deletions

View File

@ -39,7 +39,8 @@ Light::Light(Object *parent, byte subType, uint16 index, const Common::String &n
_innerConeAngle(0),
_falloffNear(100.0),
_falloffFar(500.0),
_lightEntry(nullptr) {
_lightEntry(nullptr),
_multiplier(1.0) {
_type = TYPE;
}
@ -67,7 +68,8 @@ void Light::onPostRead() {
_lightEntry->falloffNear = _falloffNear;
_lightEntry->falloffFar = _falloffFar;
// TODO: Add support for negative lights
// Negative lights add darkness
_multiplier = _name.hasPrefix("x_neg") ? -1.0 : 1.0;
}
void Light::saveLoad(ResourceSerializer *serializer) {
@ -88,7 +90,7 @@ void Light::setPosition(const Math::Vector3d &position) {
}
Gfx::LightEntry *Light::getLightEntry() {
_lightEntry->color = _color;
_lightEntry->color = _multiplier * _color;
_lightEntry->position = _position;
return _lightEntry;

View File

@ -49,7 +49,7 @@ public:
static const Type::ResourceType TYPE = Type::kLight;
Light(Object *parent, byte subType, uint16 index, const Common::String &name);
virtual ~Light();
~Light() override;
// Resource API
void readData(Formats::XRCReadStream *stream) override;
@ -75,6 +75,7 @@ protected:
float _outerConeAngle;
float _falloffNear;
float _falloffFar;
float _multiplier;
Gfx::LightEntry *_lightEntry;
};