Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ZVISION: Implement action:distort and distort sidefx node
- Loading branch information
1 parent
8e9d201
commit 678f47f
Showing
9 changed files
with
229 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |