ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

effects.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef EFFECTS_H_
00024 #define EFFECTS_H_
00025 
00026 #include "common/hashmap.h"
00027 #include "common/rect.h"
00028 
00029 #include "engines/myst3/directorysubentry.h"
00030 
00031 namespace Graphics {
00032 struct Surface;
00033 }
00034 
00035 namespace Myst3 {
00036 
00037 class Myst3Engine;
00038 
00039 class Effect {
00040 public:
00041     struct FaceMask {
00042         FaceMask();
00043         ~FaceMask();
00044 
00045         static Common::Rect getBlockRect(uint x, uint y);
00046 
00047         Graphics::Surface *surface;
00048         bool block[10][10];
00049     };
00050 
00051     virtual ~Effect();
00052 
00053     virtual bool update() = 0;
00054     virtual void applyForFace(uint face, Graphics::Surface *src, Graphics::Surface *dst) = 0;
00055 
00056     bool hasFace(uint face) { return _facesMasks.contains(face); }
00057     Common::Rect getUpdateRectForFace(uint face);
00058 
00059     // Public and static for use by the debug console
00060     static FaceMask *loadMask(Common::SeekableReadStream *maskStream);
00061 
00062 protected:
00063     Effect(Myst3Engine *vm);
00064 
00065     bool loadMasks(const Common::String &room, uint32 id, DirectorySubEntry::ResourceType type);
00066 
00067     Myst3Engine *_vm;
00068 
00069     typedef Common::HashMap<uint, FaceMask *> FaceMaskMap;
00070     FaceMaskMap _facesMasks;
00071 };
00072 
00073 class WaterEffect : public Effect {
00074 public:
00075     static WaterEffect *create(Myst3Engine *vm, uint32 id);
00076     virtual ~WaterEffect();
00077 
00078     bool update();
00079     void applyForFace(uint face, Graphics::Surface *src, Graphics::Surface *dst);
00080 
00081 protected:
00082     WaterEffect(Myst3Engine *vm);
00083 
00084     void doStep(float position, bool isFrame);
00085     void apply(Graphics::Surface *src, Graphics::Surface *dst, Graphics::Surface *mask,
00086             bool bottomFace, int32 waterEffectAmpl);
00087 
00088     uint32 _lastUpdate;
00089     int32 _step;
00090 
00091     int8 _bottomDisplacement[640];
00092     int8 _verticalDisplacement[640];
00093     int8 _horizontalDisplacements[5][640];
00094 
00095 private:
00096     bool isRunning();
00097 };
00098 
00099 class LavaEffect : public Effect {
00100 public:
00101     static LavaEffect *create(Myst3Engine *vm, uint32 id);
00102     virtual ~LavaEffect();
00103 
00104     bool update();
00105     void applyForFace(uint face, Graphics::Surface *src, Graphics::Surface *dst);
00106 
00107 protected:
00108     LavaEffect(Myst3Engine *vm);
00109 
00110     void doStep(int32 position, float ampl);
00111 
00112     uint32 _lastUpdate;
00113     int32 _step;
00114 
00115     int32 _displacement[256];
00116 };
00117 
00118 class MagnetEffect : public Effect {
00119 public:
00120     static MagnetEffect *create(Myst3Engine *vm, uint32 id);
00121     virtual ~MagnetEffect();
00122 
00123     bool update();
00124     void applyForFace(uint face, Graphics::Surface *src, Graphics::Surface *dst);
00125 
00126 protected:
00127     MagnetEffect(Myst3Engine *vm);
00128 
00129     void apply(Graphics::Surface *src, Graphics::Surface *dst, Graphics::Surface *mask, int32 position);
00130 
00131     int32 _lastSoundId;
00132     Common::MemoryReadStream *_shakeStrength;
00133 
00134     uint32 _lastTime;
00135     float _position;
00136     float _lastAmpl;
00137     int32 _verticalDisplacement[256];
00138 };
00139 
00140 class ShakeEffect : public Effect {
00141 public:
00142     static ShakeEffect *create(Myst3Engine *vm);
00143     virtual ~ShakeEffect();
00144 
00145     bool update();
00146     void applyForFace(uint face, Graphics::Surface *src, Graphics::Surface *dst);
00147 
00148     float getPitchOffset() { return _pitchOffset; }
00149     float getHeadingOffset() { return _headingOffset; }
00150 
00151 protected:
00152     ShakeEffect(Myst3Engine *vm);
00153 
00154     uint32 _lastTick;
00155     uint _magnetEffectShakeStep;
00156     float _pitchOffset;
00157     float _headingOffset;
00158 
00159 };
00160 
00161 class RotationEffect : public Effect {
00162 public:
00163     static RotationEffect *create(Myst3Engine *vm);
00164     virtual ~RotationEffect();
00165 
00166     bool update();
00167     void applyForFace(uint face, Graphics::Surface *src, Graphics::Surface *dst);
00168 
00169     float getHeadingOffset() { return _headingOffset; }
00170 
00171 protected:
00172     RotationEffect(Myst3Engine *vm);
00173 
00174     uint32 _lastUpdate;
00175     float _headingOffset;
00176 
00177 };
00178 
00179 class ShieldEffect : public Effect {
00180 public:
00181     static ShieldEffect *create(Myst3Engine *vm, uint32 id);
00182     virtual ~ShieldEffect();
00183 
00184     bool update();
00185     void applyForFace(uint face, Graphics::Surface *src, Graphics::Surface *dst);
00186 
00187 protected:
00188     ShieldEffect(Myst3Engine *vm);
00189     bool loadPattern();
00190 
00191     uint32 _lastTick;
00192     float _amplitude;
00193     float _amplitudeIncrement;
00194 
00195     uint8 _pattern[4096];
00196     int32 _displacement[256];
00197 };
00198 
00199 } // End of namespace Myst3
00200 
00201 #endif // EFFECTS_H_


Generated on Sat Dec 7 2019 05:00:34 for ResidualVM by doxygen 1.7.1
curved edge   curved edge