1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef BLADERUNNER_LIGHT_H
24 #define BLADERUNNER_LIGHT_H
25 
26 #include "bladerunner/matrix.h"
27 #include "bladerunner/color.h"
28 
29 #include "common/stream.h"
30 
31 namespace Common{
32 class ReadStream;
33 }
34 
35 namespace BladeRunner {
36 
37 class Lights;
38 
39 class Light {
40 	friend class Debugger;
41 	friend class Lights;
42 	friend class SliceRenderer;
43 
44 protected:
45 	Common::String _name;
46 
47 	int       _frameCount;
48 	int       _animated;
49 	int       _animatedParameters;
50 	Matrix4x3 _matrix;
51 	Color     _color;
52 	float     _falloffStart;
53 	float     _falloffEnd;
54 	float     _angleStart;
55 	float     _angleEnd;
56 	float    *_animationData;
57 	float    *_m11ptr;
58 	float    *_m12ptr;
59 	float    *_m13ptr;
60 	float    *_m14ptr;
61 	float    *_m21ptr;
62 	float    *_m22ptr;
63 	float    *_m23ptr;
64 	float    *_m24ptr;
65 	float    *_m31ptr;
66 	float    *_m32ptr;
67 	float    *_m33ptr;
68 	float    *_m34ptr;
69 	float    *_colorRPtr;
70 	float    *_colorGPtr;
71 	float    *_colorBPtr;
72 	float    *_falloffStartPtr;
73 	float    *_falloffEndPtr;
74 	float    *_angleStartPtr;
75 	float    *_angleEndPtr;
76 
77 public:
78 	Light();
79 	virtual ~Light();
80 
81 	void read(Common::ReadStream *stream, int frameCount, int frame, int animated);
82 	void readVqa(Common::ReadStream *stream, int frameCount, int frame, int animated);
83 
84 	void setupFrame(int frame);
85 
86 	virtual float calculate(Vector3 start, Vector3 end) const;
87 	virtual void calculateColor(Color *outColor, Vector3 position) const;
88 
89 protected:
90 	float calculateFalloutCoefficient(Vector3 start, Vector3 end, float a3, float a4) const;
91 	float attenuation(float min, float max, float distance) const;
92 };
93 
94 class Light1 : public Light {
95 	float calculate(Vector3 start, Vector3 end) const override;
96 	void calculateColor(Color *outColor, Vector3 position) const override;
97 };
98 
99 class Light2 : public Light {
100 	float calculate(Vector3 start, Vector3 end) const override;
101 	void calculateColor(Color *outColor, Vector3 position) const override;
102 };
103 
104 class Light3 : public Light {
105 	void calculateColor(Color *outColor, Vector3 position) const override;
106 };
107 
108 class Light4 : public Light {
109 	void calculateColor(Color *outColor, Vector3 position) const override;
110 };
111 
112 class LightAmbient : public Light {
113 	float calculate(Vector3 start, Vector3 end) const override;
114 	void calculateColor(Color *outColor, Vector3 position) const override;
115 };
116 
117 } // End of namespace BladeRunner
118 
119 #endif
120