ScummVM API documentation
effects.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef EFFECTS_H_
23 #define EFFECTS_H_
24 
25 #include "common/hashmap.h"
26 #include "common/rect.h"
27 
28 #include "engines/myst3/archive.h"
29 
30 namespace Graphics {
31 struct Surface;
32 }
33 
34 namespace Myst3 {
35 
36 class Myst3Engine;
37 
38 class Effect {
39 public:
40  struct FaceMask {
41  FaceMask();
42  ~FaceMask();
43 
44  static Common::Rect getBlockRect(uint x, uint y);
45 
46  Graphics::Surface *surface;
47  bool block[10][10];
48  };
49 
50  virtual ~Effect();
51 
52  virtual bool update() = 0;
53  virtual void applyForFace(uint face, Graphics::Surface *src, Graphics::Surface *dst) = 0;
54 
55  bool hasFace(uint face) { return _facesMasks.contains(face); }
56  Common::Rect getUpdateRectForFace(uint face);
57 
58  // Public and static for use by the debug console
59  static FaceMask *loadMask(Common::SeekableReadStream *maskStream);
60 
61 protected:
62  Effect(Myst3Engine *vm);
63 
64  bool loadMasks(const Common::String &room, uint32 id, Archive::ResourceType type);
65 
66  Myst3Engine *_vm;
67 
69  FaceMaskMap _facesMasks;
70 };
71 
72 class WaterEffect : public Effect {
73 public:
74  static WaterEffect *create(Myst3Engine *vm, uint32 id);
75  virtual ~WaterEffect();
76 
77  bool update();
78  void applyForFace(uint face, Graphics::Surface *src, Graphics::Surface *dst);
79 
80 protected:
82 
83  void doStep(float position, bool isFrame);
84  void apply(Graphics::Surface *src, Graphics::Surface *dst, Graphics::Surface *mask,
85  bool bottomFace, int32 waterEffectAmpl);
86 
87  uint32 _lastUpdate;
88  int32 _step;
89 
90  int8 _bottomDisplacement[640];
91  int8 _verticalDisplacement[640];
92  int8 _horizontalDisplacements[5][640];
93 
94 private:
95  bool isRunning();
96 };
97 
98 class LavaEffect : public Effect {
99 public:
100  static LavaEffect *create(Myst3Engine *vm, uint32 id);
101  virtual ~LavaEffect();
102 
103  bool update();
104  void applyForFace(uint face, Graphics::Surface *src, Graphics::Surface *dst);
105 
106 protected:
107  LavaEffect(Myst3Engine *vm);
108 
109  void doStep(int32 position, float ampl);
110 
111  uint32 _lastUpdate;
112  int32 _step;
113 
114  int32 _displacement[256];
115 };
116 
117 class MagnetEffect : public Effect {
118 public:
119  static MagnetEffect *create(Myst3Engine *vm, uint32 id);
120  virtual ~MagnetEffect();
121 
122  bool update();
123  void applyForFace(uint face, Graphics::Surface *src, Graphics::Surface *dst);
124 
125 protected:
127 
128  void apply(Graphics::Surface *src, Graphics::Surface *dst, Graphics::Surface *mask, int32 position);
129 
130  int32 _lastSoundId;
131  Common::SeekableReadStream *_shakeStrength;
132 
133  uint32 _lastTime;
134  float _position;
135  float _lastAmpl;
136  int32 _verticalDisplacement[256];
137 };
138 
139 class ShakeEffect : public Effect {
140 public:
141  static ShakeEffect *create(Myst3Engine *vm);
142  virtual ~ShakeEffect();
143 
144  bool update();
145  void applyForFace(uint face, Graphics::Surface *src, Graphics::Surface *dst);
146 
147  float getPitchOffset() { return _pitchOffset; }
148  float getHeadingOffset() { return _headingOffset; }
149 
150 protected:
152 
153  uint32 _lastTick;
154  uint _magnetEffectShakeStep;
155  float _pitchOffset;
156  float _headingOffset;
157 
158 };
159 
160 class RotationEffect : public Effect {
161 public:
162  static RotationEffect *create(Myst3Engine *vm);
163  virtual ~RotationEffect();
164 
165  bool update();
166  void applyForFace(uint face, Graphics::Surface *src, Graphics::Surface *dst);
167 
168  float getHeadingOffset() { return _headingOffset; }
169 
170 protected:
172 
173  uint32 _lastUpdate;
174  float _headingOffset;
175 
176 };
177 
178 class ShieldEffect : public Effect {
179 public:
180  static ShieldEffect *create(Myst3Engine *vm, uint32 id);
181  virtual ~ShieldEffect();
182 
183  bool update();
184  void applyForFace(uint face, Graphics::Surface *src, Graphics::Surface *dst);
185 
186 protected:
188  bool loadPattern();
189 
190  uint32 _lastTick;
191  float _amplitude;
192  float _amplitudeIncrement;
193 
194  uint8 _pattern[4096];
195  int32 _displacement[256];
196 };
197 
198 } // End of namespace Myst3
199 
200 #endif // EFFECTS_H_
Definition: str.h:59
Definition: surface.h:67
Definition: effects.h:160
Definition: ambient.h:27
Definition: effects.h:40
Definition: effects.h:139
Definition: effects.h:178
Definition: effects.h:72
Definition: rect.h:144
Definition: effects.h:98
Definition: stream.h:745
Definition: formatinfo.h:28
Definition: effects.h:38
Definition: effects.h:117
Definition: myst3.h:87