diff options
author | Bastien Bouclet | 2016-08-15 15:16:22 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2017-07-03 08:50:10 +0200 |
commit | ab2d151541f5d4ae12aeeba6ec5e928109be84f5 (patch) | |
tree | a4551255e05de479655a81658702321c1a473b47 /engines/mohawk/riven_graphics.h | |
parent | 85712e56c8e2cf8a6e04110646f4345c153211fd (diff) | |
download | scummvm-rg350-ab2d151541f5d4ae12aeeba6ec5e928109be84f5.tar.gz scummvm-rg350-ab2d151541f5d4ae12aeeba6ec5e928109be84f5.tar.bz2 scummvm-rg350-ab2d151541f5d4ae12aeeba6ec5e928109be84f5.zip |
MOHAWK: Implement the (fire)flies effect mainly used in jungle island
Diffstat (limited to 'engines/mohawk/riven_graphics.h')
-rw-r--r-- | engines/mohawk/riven_graphics.h | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/engines/mohawk/riven_graphics.h b/engines/mohawk/riven_graphics.h index 2802c8402e..8120879310 100644 --- a/engines/mohawk/riven_graphics.h +++ b/engines/mohawk/riven_graphics.h @@ -28,6 +28,7 @@ namespace Mohawk { class MohawkEngine_Riven; +class FliesEffect; class RivenGraphics : public GraphicsManager { public: @@ -44,11 +45,19 @@ public: void drawImageRect(uint16 id, Common::Rect srcRect, Common::Rect dstRect); void drawExtrasImage(uint16 id, Common::Rect dstRect); + Graphics::Surface *getEffectScreen(); + Graphics::Surface *getBackScreen(); + // Water Effect void scheduleWaterEffect(uint16); void clearWaterEffects(); bool runScheduledWaterEffects(); + // Flies Effect + void setFliesEffect(uint16 count, bool fireflies); + void clearFliesEffect(); + void runFliesEffect(); + // Transitions void scheduleTransition(uint16 id, Common::Rect rect = Common::Rect(0, 0, 608, 392)); void runScheduledTransition(); @@ -88,6 +97,9 @@ private: }; Common::Array<SFXERecord> _waterEffects; + // Flies Effect + FliesEffect *_fliesEffect; + // Transitions int16 _scheduledTransition; Common::Rect _transitionRect; @@ -102,6 +114,7 @@ private: Graphics::Surface *_mainScreen; Graphics::Surface *_effectScreen; bool _dirtyScreen; + Graphics::PixelFormat _pixelFormat; void clearMainScreen(); @@ -109,6 +122,96 @@ private: uint _creditsImage, _creditsPos; }; +/** + * The flies effect draws flies in the scene + * + * It can draw either regular flies or fireflies. + * The flies' movement is simulated in 3 dimensions. + */ +class FliesEffect { +public: + FliesEffect(MohawkEngine_Riven *vm, uint16 count, bool fireflies); + ~FliesEffect(); + + /** Simulate the flies' movement and draw them to the screen */ + void update(); + +private: + struct FliesEffectEntry { + bool light; + int posX; + int posY; + int posZ; + const uint16 *alphaMap; + uint width; + uint height; + int framesTillLightSwitch; + bool hasBlur; + int blurPosX; + int blurPosY; + const uint16 *blurAlphaMap; + uint blurWidth; + uint blurHeight; + float posXFloat; + float posYFloat; + float posZFloat; + float directionAngleRad; + float directionAngleRadZ; + float speed; + }; + + struct FliesEffectData { + bool lightable; + bool unlightIfTooBright; + bool isLarge; + bool canBlur; + float maxSpeed; + float minSpeed; + int maxAcceleration; + float blurSpeedTreshold; + float blurDistance; + uint32 color32; + int minFramesLit; + int maxLightDuration; + }; + + MohawkEngine_Riven *_vm; + + uint _nextUpdateTime; + int _updatePeriodMs; + + Common::Rect _gameRect; + Graphics::Surface *_effectSurface; + Graphics::Surface *_backSurface; + Common::Array<Common::Rect> _screenSurfaceDirtyRects; + Common::Array<Common::Rect> _effectsSurfaceDirtyRects; + + const FliesEffectData *_parameters; + static const FliesEffectData _firefliesParameters; + static const FliesEffectData _fliesParameters; + + Common::Array<FliesEffectEntry> _fly; + + void initFlies(uint16 count); + void initFlyRandomPosition(uint index); + void initFlyAtPosition(uint index, int posX, int posY, int posZ); + + void updateFlies(); + void updateFlyPosition(uint index); + + void draw(); + void updateScreen(); + + void selectAlphaMap(bool horGridOffset, bool vertGridoffset, const uint16 **alphaMap, uint *width, uint *height); + void colorBlending(uint32 flyColor, byte &r, byte &g, byte &b, int alpha); + + void addToScreenDirtyRects(const Common::Rect &rect); + void addToEffectsDirtyRects(const Common::Rect &rect); + void restoreEffectsSurface(); + + int randomBetween(int min, int max); +}; + } // End of namespace Mohawk #endif |