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_FOG_H
24 #define BLADERUNNER_FOG_H
25 
26 #include "bladerunner/color.h"
27 #include "bladerunner/matrix.h"
28 
29 namespace Common {
30 	class ReadStream;
31 }
32 
33 namespace BladeRunner {
34 
35 class SetEffects;
36 
37 class Fog {
38 	friend class SetEffects;
39 	friend class Debugger;
40 
41 protected:
42 	Common::String _name;
43 
44 	int        _frameCount;
45 	int        _animatedParameters;
46 	Matrix4x3  _matrix;
47 	Matrix4x3  _inverted;
48 	Color      _fogColor;
49 	float      _fogDensity;
50 	float     *_animationData;
51 	float     *_m11ptr;
52 	float     *_m12ptr;
53 	float     *_m13ptr;
54 	float     *_m14ptr;
55 	float     *_m21ptr;
56 	float     *_m22ptr;
57 	float     *_m23ptr;
58 	float     *_m24ptr;
59 	float     *_m31ptr;
60 	float     *_m32ptr;
61 	float     *_m33ptr;
62 	float     *_m34ptr;
63 
64 	Fog       *_next;
65 
66 public:
67 	Fog();
68 	virtual ~Fog();
69 
70 	virtual void read(Common::ReadStream *stream, int frameCount) = 0;
71 	virtual void calculateCoeficient(Vector3 position, Vector3 viewPosition, float *coeficient) = 0;
72 	void reset();
73 
74 	void setupFrame(int frame);
75 
76 protected:
77 	int readCommon(Common::ReadStream *stream);
78 	void readAnimationData(Common::ReadStream *stream, int count);
79 
80 };
81 
82 class FogSphere : public Fog {
83 private:
84 	float _radius;
85 
86 public:
FogSphere()87 	FogSphere():_radius(0.0f) {};
88 
89 	void read(Common::ReadStream *stream, int frameCount) override;
90 	void calculateCoeficient(Vector3 position, Vector3 viewPosition, float *coeficient) override;
91 };
92 
93 class FogCone : public Fog {
94 private:
95 	float _coneAngle;
96 
97 public:
FogCone()98 	FogCone():_coneAngle(0.0f) {};
99 
100 	void read(Common::ReadStream *stream, int frameCount) override;
101 	void calculateCoeficient(Vector3 position, Vector3 viewPosition, float *coeficient) override;
102 };
103 
104 class FogBox : public Fog {
105 private:
106 	Vector3 _size;
107 
108 public:
FogBox()109 	FogBox():_size() {};
110 
111 	void read(Common::ReadStream *stream, int frameCount) override;
112 	void calculateCoeficient(Vector3 position, Vector3 viewPosition, float *coeficient) override;
113 };
114 
115 } // End of namespace BladeRunner
116 
117 #endif
118