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