diff options
author | Peter Kohaut | 2015-09-15 20:26:46 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-09-29 22:33:40 +0200 |
commit | 479d2f5b6293af2ae84fbdc718348a6e1126efb0 (patch) | |
tree | dfd6fd1a84b379aad003e005c0f47c8e211669b0 /engines/bladerunner/mouse.cpp | |
parent | 6672e443a870963354ee43298c75164d382a5636 (diff) | |
download | scummvm-rg350-479d2f5b6293af2ae84fbdc718348a6e1126efb0.tar.gz scummvm-rg350-479d2f5b6293af2ae84fbdc718348a6e1126efb0.tar.bz2 scummvm-rg350-479d2f5b6293af2ae84fbdc718348a6e1126efb0.zip |
BLADERUNNER: still adding structures... and implementing some of script methods...
Diffstat (limited to 'engines/bladerunner/mouse.cpp')
-rw-r--r-- | engines/bladerunner/mouse.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/engines/bladerunner/mouse.cpp b/engines/bladerunner/mouse.cpp index 8a259fd76f..2eede84de1 100644 --- a/engines/bladerunner/mouse.cpp +++ b/engines/bladerunner/mouse.cpp @@ -24,8 +24,10 @@ #include "bladerunner/bladerunner.h" #include "bladerunner/shape.h" +#include "bladerunner/scene.h" #include "graphics/surface.h" +#include "common/rect.h"" namespace BladeRunner { @@ -247,4 +249,48 @@ void Mouse::updateCursorFrame() { } } +void Mouse::tick(int x, int y) +{ + if (!_vm->playerHasControl() || isDisabled()) + return; + + Vector3 mousePosition; + + getXYZ(x, y, &mousePosition); + int isClickable = 0; + int isObstacle = 0; + int isCombatTarget = 0; + int sceneObjectId = _vm->_sceneObjects->findByXYZ(&isClickable, &isObstacle, &isCombatTarget, mousePosition.x, mousePosition.y, mousePosition.z, 1, 0, 1); + //debug("mouse tick: objectid = %d", sceneObjectId); +} + +void Mouse::getXYZ(int x, int y, Vector3* mousePosition) +{ + if (_vm->_scene->_setId == -1) + return; + + int screenRight = 640 - x; + int screenDown = 480 - y; + + float zcoef = 1.0f / tan(_vm->_view->_fovX / 2.0f); + + float x3d = (2.0f / 640.0f * screenRight - 1) * zcoef / (1*zcoef); + float y3d = (2.0f / 480.0f * screenDown- 1) / (4/3 * zcoef) * zcoef; + + uint16 zbufval = _vm->_zBuffer1[x + y * 480]; + + Vector3 vector; + vector.z = zbufval / 25.5f; + vector.x = vector.z / zcoef * x3d; + vector.y = vector.z / zcoef * y3d; + + Matrix4x3 matrix = _vm->_view->_frameViewMatrix; + matrix.unknown(); + vector = matrix * vector; + + mousePosition->x = vector.x; + mousePosition->y = vector.y; + mousePosition->z = vector.z; +} + } // End of namespace BladeRunner |