From 6672e443a870963354ee43298c75164d382a5636 Mon Sep 17 00:00:00 2001 From: Peter Kohaut Date: Sun, 13 Sep 2015 01:48:13 +0200 Subject: BLADERUNNER: just basic objects description scene stuff - lightning and effects movement track actor clues db actor walking info moved view from vqa decoder, because its needed elsewhere does not compile, because new files are not in makefile... --- engines/bladerunner/set_effects.cpp | 83 +++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 engines/bladerunner/set_effects.cpp (limited to 'engines/bladerunner/set_effects.cpp') diff --git a/engines/bladerunner/set_effects.cpp b/engines/bladerunner/set_effects.cpp new file mode 100644 index 0000000000..f524820033 --- /dev/null +++ b/engines/bladerunner/set_effects.cpp @@ -0,0 +1,83 @@ +#include "bladerunner/set_effects.h" + +namespace BladeRunner +{ + SetEffects::SetEffects(BladeRunnerEngine* vm) + { + _vm = vm; + + _distanceColor.r = 1.0f; + _distanceColor.g = 1.0f; + _distanceColor.b = 1.0f; + _distanceCoeficient = 0.1f; + + _fadeColor.r = 0.0f; + _fadeColor.g = 0.0f; + _fadeColor.b = 0.0f; + _fadeDensity = 0.0f; + + _fogsCount = 0; + _fogs = NULL; + } + + SetEffects::~SetEffects() + { + reset(); + } + + void SetEffects::read(Common::ReadStream* stream, int framesCount) + { + _distanceCoeficient = stream->readFloatLE(); + _distanceColor.r = stream->readFloatLE(); + _distanceColor.g = stream->readFloatLE(); + _distanceColor.b = stream->readFloatLE(); + + _fogsCount = stream->readUint32LE(); + int i; + for (i = 0; i < _fogsCount; i++) + { + int type = stream->readUint32LE(); + Fog* fog = NULL; + switch(type) + { + case 0: + fog = new FogCone(); + break; + case 1: + fog = new FogSphere(); + break; + case 2: + fog = new FogBox(); + break; + } + if(!fog) + { + //TODO exception, unknown fog type + } + fog->read(stream, framesCount); + fog->_next = _fogs; + _fogs = fog; + } + } + + void SetEffects::reset() + { + Fog* fog, *nextFog; + + if (!_fogs) + return; + + do + { + fog = _fogs; + nextFog = fog->_next; + delete fog; + fog = nextFog; + } while (nextFog); + + } + + void SetEffects::setupFrame(int frame) + { + } +} \ No newline at end of file -- cgit v1.2.3 From de7f961f484bc29c33240a29376bbd24dc4d6139 Mon Sep 17 00:00:00 2001 From: Peter Kohaut Date: Sat, 19 Sep 2015 01:43:38 +0200 Subject: BLADERUNNER: added implementation of more script methods added combat structure (maybe it combat mode??) --- engines/bladerunner/set_effects.cpp | 173 ++++++++++++++++++++++-------------- 1 file changed, 106 insertions(+), 67 deletions(-) (limited to 'engines/bladerunner/set_effects.cpp') diff --git a/engines/bladerunner/set_effects.cpp b/engines/bladerunner/set_effects.cpp index f524820033..6db81ce631 100644 --- a/engines/bladerunner/set_effects.cpp +++ b/engines/bladerunner/set_effects.cpp @@ -2,82 +2,121 @@ namespace BladeRunner { - SetEffects::SetEffects(BladeRunnerEngine* vm) - { - _vm = vm; - - _distanceColor.r = 1.0f; - _distanceColor.g = 1.0f; - _distanceColor.b = 1.0f; - _distanceCoeficient = 0.1f; - - _fadeColor.r = 0.0f; - _fadeColor.g = 0.0f; - _fadeColor.b = 0.0f; - _fadeDensity = 0.0f; - - _fogsCount = 0; - _fogs = NULL; - } - SetEffects::~SetEffects() - { - reset(); - } +SetEffects::SetEffects(BladeRunnerEngine* vm) { + _vm = vm; + + _distanceColor.r = 1.0f; + _distanceColor.g = 1.0f; + _distanceColor.b = 1.0f; + _distanceCoeficient = 0.1f; + + _fadeColor.r = 0.0f; + _fadeColor.g = 0.0f; + _fadeColor.b = 0.0f; + _fadeDensity = 0.0f; + + _fogsCount = 0; + _fogs = NULL; +} + +SetEffects::~SetEffects() { + reset(); +} - void SetEffects::read(Common::ReadStream* stream, int framesCount) - { - _distanceCoeficient = stream->readFloatLE(); - _distanceColor.r = stream->readFloatLE(); - _distanceColor.g = stream->readFloatLE(); - _distanceColor.b = stream->readFloatLE(); +void SetEffects::read(Common::ReadStream* stream, int framesCount) { + _distanceCoeficient = stream->readFloatLE(); + _distanceColor.r = stream->readFloatLE(); + _distanceColor.g = stream->readFloatLE(); + _distanceColor.b = stream->readFloatLE(); - _fogsCount = stream->readUint32LE(); - int i; - for (i = 0; i < _fogsCount; i++) + _fogsCount = stream->readUint32LE(); + int i; + for (i = 0; i < _fogsCount; i++) { + int type = stream->readUint32LE(); + Fog* fog = NULL; + switch (type) { - int type = stream->readUint32LE(); - Fog* fog = NULL; - switch(type) - { - case 0: - fog = new FogCone(); - break; - case 1: - fog = new FogSphere(); - break; - case 2: - fog = new FogBox(); - break; - } - if(!fog) - { - //TODO exception, unknown fog type - } - fog->read(stream, framesCount); - fog->_next = _fogs; - _fogs = fog; + case 0: + fog = new FogCone(); + break; + case 1: + fog = new FogSphere(); + break; + case 2: + fog = new FogBox(); + break; } + if (!fog) + { + //TODO exception, unknown fog type + } + fog->read(stream, framesCount); + fog->_next = _fogs; + _fogs = fog; } +} - void SetEffects::reset() - { - Fog* fog, *nextFog; - - if (!_fogs) - return; +void SetEffects::reset() { + Fog* fog, *nextFog; - do - { - fog = _fogs; - nextFog = fog->_next; - delete fog; - fog = nextFog; - } while (nextFog); + if (!_fogs) + return; - } + do { + fog = _fogs; + nextFog = fog->_next; + delete fog; + fog = nextFog; + } while (nextFog); + +} + +void SetEffects::setupFrame(int frame) { +} - void SetEffects::setupFrame(int frame) - { +void SetEffects::setFadeColor(float r, float g, float b) { + _fadeColor.r = r; + _fadeColor.r = g; + _fadeColor.b = b; +} + +void SetEffects::setFadeDensity(float density) { + _fadeDensity = density; +} + +void SetEffects::setFogColor(char* fogName, float r, float g, float b) { + Fog* fog = findFog(fogName); + if (fog == nullptr) + return; + + fog->_fogColor.r = r; + fog->_fogColor.g = g; + fog->_fogColor.b = b; +} + +void SetEffects::setFogDensity(char* fogName, float density) { + Fog* fog = findFog(fogName); + if (fog == nullptr) + return; + + fog->_fogDensity = density; +} + +Fog* SetEffects::findFog(char* fogName) { + if (!_fogs) + return nullptr; + + Fog* fog = _fogs; + + while (fog != nullptr) { + if (strcmp(fogName, fog->_name) == 0) { + break; + } + fog = fog->_next; } + + return fog; +} + } \ No newline at end of file -- cgit v1.2.3 From b67bca20b5db7f3d6473341efd7fabfa6532f465 Mon Sep 17 00:00:00 2001 From: Peter Kohaut Date: Sat, 10 Sep 2016 18:16:17 +0200 Subject: BLADERUNNER: Pull in changes from madmoose --- engines/bladerunner/set_effects.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'engines/bladerunner/set_effects.cpp') diff --git a/engines/bladerunner/set_effects.cpp b/engines/bladerunner/set_effects.cpp index 6db81ce631..bc10a0fc2c 100644 --- a/engines/bladerunner/set_effects.cpp +++ b/engines/bladerunner/set_effects.cpp @@ -1,7 +1,6 @@ #include "bladerunner/set_effects.h" -namespace BladeRunner -{ +namespace BladeRunner { SetEffects::SetEffects(BladeRunnerEngine* vm) { _vm = vm; @@ -119,4 +118,4 @@ Fog* SetEffects::findFog(char* fogName) { return fog; } -} \ No newline at end of file +} // End of namespace BladeRunner -- cgit v1.2.3 From f1cb735ee07c11785f67080ea800a72dd551ae19 Mon Sep 17 00:00:00 2001 From: Peter Kohaut Date: Mon, 26 Sep 2016 23:38:35 +0200 Subject: BLADERUNNER: added rendering support for lighting and effects, but its not working correctly yet --- engines/bladerunner/set_effects.cpp | 53 +++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 14 deletions(-) (limited to 'engines/bladerunner/set_effects.cpp') diff --git a/engines/bladerunner/set_effects.cpp b/engines/bladerunner/set_effects.cpp index bc10a0fc2c..f4d2506292 100644 --- a/engines/bladerunner/set_effects.cpp +++ b/engines/bladerunner/set_effects.cpp @@ -2,7 +2,7 @@ namespace BladeRunner { -SetEffects::SetEffects(BladeRunnerEngine* vm) { +SetEffects::SetEffects(BladeRunnerEngine *vm) { _vm = vm; _distanceColor.r = 1.0f; @@ -23,7 +23,7 @@ SetEffects::~SetEffects() { reset(); } -void SetEffects::read(Common::ReadStream* stream, int framesCount) { +void SetEffects::read(Common::ReadStream *stream, int framesCount) { _distanceCoeficient = stream->readFloatLE(); _distanceColor.r = stream->readFloatLE(); _distanceColor.g = stream->readFloatLE(); @@ -33,9 +33,8 @@ void SetEffects::read(Common::ReadStream* stream, int framesCount) { int i; for (i = 0; i < _fogsCount; i++) { int type = stream->readUint32LE(); - Fog* fog = NULL; - switch (type) - { + Fog *fog = NULL; + switch (type) { case 0: fog = new FogCone(); break; @@ -46,8 +45,7 @@ void SetEffects::read(Common::ReadStream* stream, int framesCount) { fog = new FogBox(); break; } - if (!fog) - { + if (!fog) { //TODO exception, unknown fog type } fog->read(stream, framesCount); @@ -57,7 +55,7 @@ void SetEffects::read(Common::ReadStream* stream, int framesCount) { } void SetEffects::reset() { - Fog* fog, *nextFog; + Fog *fog, *nextFog; if (!_fogs) return; @@ -84,8 +82,8 @@ void SetEffects::setFadeDensity(float density) { _fadeDensity = density; } -void SetEffects::setFogColor(char* fogName, float r, float g, float b) { - Fog* fog = findFog(fogName); +void SetEffects::setFogColor(char *fogName, float r, float g, float b) { + Fog *fog = findFog(fogName); if (fog == nullptr) return; @@ -94,19 +92,46 @@ void SetEffects::setFogColor(char* fogName, float r, float g, float b) { fog->_fogColor.b = b; } -void SetEffects::setFogDensity(char* fogName, float density) { - Fog* fog = findFog(fogName); +void SetEffects::setFogDensity(char *fogName, float density) { + Fog *fog = findFog(fogName); if (fog == nullptr) return; fog->_fogDensity = density; } -Fog* SetEffects::findFog(char* fogName) { +void SetEffects::calculateColor(Vector3 viewPosition, Vector3 position, float *outCoeficient, Color *outColor) { + float distanceCoeficient = CLIP((position - viewPosition).length() * _distanceCoeficient, 0.0f, 1.0f); + + *outCoeficient = 1.0f - distanceCoeficient; + outColor->r = _distanceColor.r * distanceCoeficient; + outColor->g = _distanceColor.g * distanceCoeficient; + outColor->b = _distanceColor.b * distanceCoeficient; + + for (Fog *fog = this->_fogs; fog != nullptr; fog = fog->_next) { + float fogCoeficient = 0.0f; + fog->calculateCoeficient(position, viewPosition, &fogCoeficient); + if (fogCoeficient > 0.0f) { + fogCoeficient = CLIP(fog->_fogDensity * fogCoeficient, 0.0f, 1.0f); + + *outCoeficient = *outCoeficient * (1.0f - fogCoeficient); + outColor->r = outColor->r * (1.0f - fogCoeficient) + fog->_fogColor.r * fogCoeficient; + outColor->g = outColor->g * (1.0f - fogCoeficient) + fog->_fogColor.g * fogCoeficient; + outColor->b = outColor->b * (1.0f - fogCoeficient) + fog->_fogColor.b * fogCoeficient; + } + } + + *outCoeficient = *outCoeficient * (1.0f - this->_fadeDensity); + outColor->r = outColor->r * (1.0f - this->_fadeDensity) + this->_fadeColor.r * this->_fadeDensity; + outColor->g = outColor->g * (1.0f - this->_fadeDensity) + this->_fadeColor.g * this->_fadeDensity; + outColor->b = outColor->b * (1.0f - this->_fadeDensity) + this->_fadeColor.b * this->_fadeDensity; +} + +Fog *SetEffects::findFog(char *fogName) { if (!_fogs) return nullptr; - Fog* fog = _fogs; + Fog *fog = _fogs; while (fog != nullptr) { if (strcmp(fogName, fog->_name) == 0) { -- cgit v1.2.3 From fe2add5d5fb955724af9f0308d07c46c3110baad Mon Sep 17 00:00:00 2001 From: Peter Kohaut Date: Sat, 1 Oct 2016 03:20:03 +0200 Subject: BLADERUNNER: fixed endian issue in uncompressed audio (thx madmoose), fixed some warnings, fixed some scene scripts --- engines/bladerunner/set_effects.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/bladerunner/set_effects.cpp') diff --git a/engines/bladerunner/set_effects.cpp b/engines/bladerunner/set_effects.cpp index f4d2506292..318ad37633 100644 --- a/engines/bladerunner/set_effects.cpp +++ b/engines/bladerunner/set_effects.cpp @@ -82,7 +82,7 @@ void SetEffects::setFadeDensity(float density) { _fadeDensity = density; } -void SetEffects::setFogColor(char *fogName, float r, float g, float b) { +void SetEffects::setFogColor(const char *fogName, float r, float g, float b) { Fog *fog = findFog(fogName); if (fog == nullptr) return; @@ -92,7 +92,7 @@ void SetEffects::setFogColor(char *fogName, float r, float g, float b) { fog->_fogColor.b = b; } -void SetEffects::setFogDensity(char *fogName, float density) { +void SetEffects::setFogDensity(const char *fogName, float density) { Fog *fog = findFog(fogName); if (fog == nullptr) return; @@ -127,7 +127,7 @@ void SetEffects::calculateColor(Vector3 viewPosition, Vector3 position, float *o outColor->b = outColor->b * (1.0f - this->_fadeDensity) + this->_fadeColor.b * this->_fadeDensity; } -Fog *SetEffects::findFog(char *fogName) { +Fog *SetEffects::findFog(const char *fogName) { if (!_fogs) return nullptr; -- cgit v1.2.3 From 77be430824ad0cafb0de9952ecb352ba4ad18571 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 3 Oct 2016 11:24:13 +0200 Subject: BLADERUNNER: Added missing copyright headers and normalized the rest --- engines/bladerunner/set_effects.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'engines/bladerunner/set_effects.cpp') diff --git a/engines/bladerunner/set_effects.cpp b/engines/bladerunner/set_effects.cpp index 318ad37633..8954b6f5db 100644 --- a/engines/bladerunner/set_effects.cpp +++ b/engines/bladerunner/set_effects.cpp @@ -1,3 +1,25 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + #include "bladerunner/set_effects.h" namespace BladeRunner { -- cgit v1.2.3