aboutsummaryrefslogtreecommitdiff
path: root/engines/zvision
diff options
context:
space:
mode:
authorMarisa-Chan2014-10-23 17:09:58 +0700
committerMarisa-Chan2014-10-23 17:09:58 +0700
commit678f47f043fc5498daae5d4331e02d23a2186528 (patch)
treeaa8a67fcc6f7dfa46f06d4727c8aa837e06fe081 /engines/zvision
parent8e9d201cc3496f79fa30d1e05c7372998895c0e6 (diff)
downloadscummvm-rg350-678f47f043fc5498daae5d4331e02d23a2186528.tar.gz
scummvm-rg350-678f47f043fc5498daae5d4331e02d23a2186528.tar.bz2
scummvm-rg350-678f47f043fc5498daae5d4331e02d23a2186528.zip
ZVISION: Implement action:distort and distort sidefx node
Diffstat (limited to 'engines/zvision')
-rw-r--r--engines/zvision/graphics/render_manager.cpp4
-rw-r--r--engines/zvision/graphics/render_manager.h2
-rw-r--r--engines/zvision/graphics/render_table.cpp18
-rw-r--r--engines/zvision/graphics/render_table.h2
-rw-r--r--engines/zvision/scripting/actions.cpp23
-rw-r--r--engines/zvision/scripting/actions.h7
-rw-r--r--engines/zvision/scripting/scr_file_handling.cpp2
-rw-r--r--engines/zvision/scripting/sidefx/distort_node.cpp109
-rw-r--r--engines/zvision/scripting/sidefx/distort_node.h63
9 files changed, 229 insertions, 1 deletions
diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp
index 0aa062214f..ce1962a8ee 100644
--- a/engines/zvision/graphics/render_manager.cpp
+++ b/engines/zvision/graphics/render_manager.cpp
@@ -1046,4 +1046,8 @@ EffectMap *RenderManager::makeEffectMap(const Graphics::Surface &surf, uint16 tr
return newMap;
}
+void RenderManager::markDirty() {
+ _bkgDirtyRect = Common::Rect(_bkgWidth, _bkgHeight);
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h
index 665a27bf64..e0fc5c248c 100644
--- a/engines/zvision/graphics/render_manager.h
+++ b/engines/zvision/graphics/render_manager.h
@@ -281,6 +281,8 @@ public:
EffectMap *makeEffectMap(const Graphics::Surface &surf, uint16 transp);
Common::Rect bkgRectToScreen(const Common::Rect &src);
+
+ void markDirty();
};
} // End of namespace ZVision
diff --git a/engines/zvision/graphics/render_table.cpp b/engines/zvision/graphics/render_table.cpp
index 9bf40d3745..aeba729196 100644
--- a/engines/zvision/graphics/render_table.cpp
+++ b/engines/zvision/graphics/render_table.cpp
@@ -264,4 +264,22 @@ float RenderTable::getTiltGap() {
return _tiltOptions.gap;
}
+float RenderTable::getAngle() {
+ if (_renderState == TILT)
+ return _tiltOptions.fieldOfView;
+ else if (_renderState == PANORAMA)
+ return _panoramaOptions.fieldOfView;
+ else
+ return 1.0;
+}
+
+float RenderTable::getLinscale() {
+ if (_renderState == TILT)
+ return _tiltOptions.linearScale;
+ else if (_renderState == PANORAMA)
+ return _panoramaOptions.linearScale;
+ else
+ return 1.0;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/graphics/render_table.h b/engines/zvision/graphics/render_table.h
index a268ee615f..7153738c6f 100644
--- a/engines/zvision/graphics/render_table.h
+++ b/engines/zvision/graphics/render_table.h
@@ -81,6 +81,8 @@ public:
void setTiltReverse(bool reverse);
float getTiltGap();
+ float getAngle();
+ float getLinscale();
private:
void generatePanoramaLookupTable();
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 2464f54861..9733c5cae8 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -33,6 +33,7 @@
#include "zvision/scripting/sidefx/music_node.h"
#include "zvision/scripting/sidefx/syncsound_node.h"
#include "zvision/scripting/sidefx/animation_node.h"
+#include "zvision/scripting/sidefx/distort_node.h"
#include "zvision/scripting/sidefx/ttytext_node.h"
#include "zvision/scripting/sidefx/region_node.h"
#include "zvision/scripting/controls/titler_control.h"
@@ -193,6 +194,28 @@ bool ActionDisplayMessage::execute() {
}
//////////////////////////////////////////////////////////////////////////////
+// ActionDistort
+//////////////////////////////////////////////////////////////////////////////
+
+ActionDistort::ActionDistort(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ sscanf(line.c_str(), "%hd %hd %f %f %f %f", &_distSlot, &_speed, &_st_angl, &_en_angl, &_st_lin, &_en_lin);
+}
+
+ActionDistort::~ActionDistort() {
+ _engine->getScriptManager()->killSideFx(_distSlot);
+}
+
+bool ActionDistort::execute() {
+ if (_engine->getScriptManager()->getSideFX(_distSlot))
+ return true;
+
+ _engine->getScriptManager()->addSideFX(new DistortNode(_engine, _distSlot, _speed, _st_angl, _en_angl, _st_lin, _en_lin));
+
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////////
// ActionEnableControl
//////////////////////////////////////////////////////////////////////////////
diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h
index b3c46d16ce..f51847ed05 100644
--- a/engines/zvision/scripting/actions.h
+++ b/engines/zvision/scripting/actions.h
@@ -202,9 +202,16 @@ public:
class ActionDistort : public ResultAction {
public:
ActionDistort(ZVision *engine, int32 slotkey, const Common::String &line);
+ ~ActionDistort();
bool execute();
private:
+ int16 _distSlot;
+ int16 _speed;
+ float _st_angl;
+ float _en_angl;
+ float _st_lin;
+ float _en_lin;
};
class ActionEnableControl : public ResultAction {
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index 8140d09a6a..df60b0b8d4 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -242,7 +242,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("dissolve", true)) {
// TODO: Implement ActionDissolve
} else if (act.matchString("distort", true)) {
- // TODO: Implement ActionDistort
+ actionList.push_back(new ActionDistort(_engine, slot, args));
} else if (act.matchString("enable_control", true)) {
actionList.push_back(new ActionEnableControl(_engine, slot, args));
} else if (act.matchString("flush_mouse_events", true)) {
diff --git a/engines/zvision/scripting/sidefx/distort_node.cpp b/engines/zvision/scripting/sidefx/distort_node.cpp
new file mode 100644
index 0000000000..576a1f8592
--- /dev/null
+++ b/engines/zvision/scripting/sidefx/distort_node.cpp
@@ -0,0 +1,109 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * 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.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/scripting/sidefx/distort_node.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/graphics/render_table.h"
+
+#include "common/stream.h"
+
+
+namespace ZVision {
+
+DistortNode::DistortNode(ZVision *engine, uint32 key, int16 speed, float st_angl, float en_angl, float st_lin, float en_lin)
+ : SideFX(engine, key, SIDEFX_DISTORT) {
+
+ _angle = _engine->getRenderManager()->getRenderTable()->getAngle();
+ _linScale = _engine->getRenderManager()->getRenderTable()->getLinscale();
+
+ _speed = speed;
+ _incr = true;
+ _st_angl = st_angl;
+ _en_angl = en_angl;
+ _st_lin = st_lin;
+ _en_lin = en_lin;
+
+ _curFrame = 1.0;
+
+ _diff_angl = en_angl - st_angl;
+ _diff_lin = en_lin - st_lin;
+
+ _frmSpeed = (float)speed / 15.0;
+ _frames = ceil((5.0 - _frmSpeed * 2.0) / _frmSpeed);
+ if (_frames <= 0)
+ _frames = 1;
+
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 1);
+}
+
+DistortNode::~DistortNode() {
+ setParams(_angle, _linScale);
+}
+
+bool DistortNode::process(uint32 deltaTimeInMillis) {
+
+ float updTime = deltaTimeInMillis / (1000.0 / 60.0);
+
+ if (_incr)
+ _curFrame += updTime;
+ else
+ _curFrame -= updTime;
+
+ if (_curFrame < 1.0) {
+ _curFrame = 1.0;
+ _incr = true;
+ } else if (_curFrame > _frames) {
+ _curFrame = _frames;
+ _incr = false;
+ }
+
+ float diff = (1.0 / (5.0 - (_curFrame * _frmSpeed))) / (5.0 - _frmSpeed);
+
+
+ setParams(_st_angl + diff * _diff_angl, _st_lin + diff * _diff_lin);
+
+ return false;
+}
+
+void DistortNode::setParams(float angl, float linScale) {
+ RenderTable *table = _engine->getRenderManager()->getRenderTable();
+ if (table->getRenderState() == RenderTable::PANORAMA) {
+ table->setPanoramaFoV(angl);
+ table->setPanoramaScale(linScale);
+ table->generateRenderTable();
+ _engine->getRenderManager()->markDirty();
+ } else if (table->getRenderState() == RenderTable::TILT) {
+ table->setTiltFoV(angl);
+ table->setTiltScale(linScale);
+ table->generateRenderTable();
+ _engine->getRenderManager()->markDirty();
+ }
+}
+
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/sidefx/distort_node.h b/engines/zvision/scripting/sidefx/distort_node.h
new file mode 100644
index 0000000000..cba9c5eff2
--- /dev/null
+++ b/engines/zvision/scripting/sidefx/distort_node.h
@@ -0,0 +1,63 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * 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 ZVISION_DISTORT_NODE_H
+#define ZVISION_DISTORT_NODE_H
+
+#include "zvision/scripting/sidefx.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class DistortNode : public SideFX {
+public:
+ DistortNode(ZVision *engine, uint32 key, int16 speed, float st_angl, float en_angl, float st_lin, float en_lin);
+ ~DistortNode();
+
+ bool process(uint32 deltaTimeInMillis);
+
+private:
+ int16 _speed;
+ float _st_angl;
+ float _en_angl;
+ float _st_lin;
+ float _en_lin;
+
+ float _frmSpeed;
+ float _diff_angl;
+ float _diff_lin;
+ bool _incr;
+ int16 _frames;
+
+ float _curFrame;
+
+ float _angle;
+ float _linScale;
+
+private:
+ void setParams(float angl, float linScale);
+};
+
+} // End of namespace ZVision
+
+#endif