aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/bladerunner/actor.cpp363
-rw-r--r--engines/bladerunner/actor.h73
-rw-r--r--engines/bladerunner/actor_combat.cpp11
-rw-r--r--engines/bladerunner/actor_combat.h65
-rw-r--r--engines/bladerunner/actor_walk.cpp32
-rw-r--r--engines/bladerunner/actor_walk.h10
-rw-r--r--engines/bladerunner/bladerunner.cpp9
-rw-r--r--engines/bladerunner/bladerunner.h7
-rw-r--r--engines/bladerunner/boundingbox.cpp36
-rw-r--r--engines/bladerunner/boundingbox.h8
-rw-r--r--engines/bladerunner/item.cpp20
-rw-r--r--engines/bladerunner/item.h67
-rw-r--r--engines/bladerunner/items.cpp28
-rw-r--r--engines/bladerunner/items.h50
-rw-r--r--engines/bladerunner/matrix.cpp12
-rw-r--r--engines/bladerunner/matrix.h4
-rw-r--r--engines/bladerunner/mouse.cpp46
-rw-r--r--engines/bladerunner/mouse.h7
-rw-r--r--engines/bladerunner/movement_track.cpp2
-rw-r--r--engines/bladerunner/regions.cpp47
-rw-r--r--engines/bladerunner/regions.h55
-rw-r--r--engines/bladerunner/scene.cpp30
-rw-r--r--engines/bladerunner/scene.h13
-rw-r--r--engines/bladerunner/scene_objects.cpp60
-rw-r--r--engines/bladerunner/scene_objects.h42
-rw-r--r--engines/bladerunner/set.cpp77
-rw-r--r--engines/bladerunner/set.h16
-rw-r--r--engines/bladerunner/slice_animations.cpp6
-rw-r--r--engines/bladerunner/slice_animations.h2
-rw-r--r--engines/bladerunner/slice_renderer.cpp12
-rw-r--r--engines/bladerunner/slice_renderer.h4
-rw-r--r--engines/bladerunner/waypoints.cpp55
-rw-r--r--engines/bladerunner/waypoints.h57
33 files changed, 1194 insertions, 132 deletions
diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp
index af9cef7258..d95c6529e0 100644
--- a/engines/bladerunner/actor.cpp
+++ b/engines/bladerunner/actor.cpp
@@ -27,6 +27,9 @@
#include "bladerunner/boundingbox.h"
#include "bladerunner/gameinfo.h"
#include "bladerunner/slice_renderer.h"
+#include "bladerunner/waypoints.h"
+#include "bladerunner/scene.h"
+#include "bladerunner/items.h"
namespace BladeRunner {
@@ -34,33 +37,35 @@ Actor::Actor(BladeRunnerEngine *vm, int actorId) {
_vm = vm;
_id = actorId;
- // TODO: Construct Walkinfo
-
- _bbox = new BoundingBox();
-
- _clues = new ActorClues(vm, ((actorId && actorId != 99) ? 2 : 4));
-
- // TODO: Construct _movementTrack
+ _walkInfo = new ActorWalk(vm);
+ _movementTrack = new MovementTrack();
+ _clues = new ActorClues(vm, (actorId && actorId != 99) ? 2 : 4);
+ _bbox = new BoundingBox();
+ _combatInfo = new ActorCombat(vm);
_friendlinessToOther = new int[_vm->_gameInfo->getActorCount()];
}
Actor::~Actor() {
+
delete[] _friendlinessToOther;
+ delete _combatInfo;
delete _bbox;
- // delete _clues;
- // delete _movementTrack;
+ delete _clues;
+ delete _movementTrack;
+ delete _walkInfo;
+
}
void Actor::setup(int actorId) {
_id = actorId;
- _set = -1;
+ _setId = -1;
- _position = Vector3(0.0, 0.0, 0.0);
- _facing = 512;
- _walkboxId = -1;
+ _position = Vector3(0.0, 0.0, 0.0);
+ _facing = 512;
+ _targetFacing = -1;
+ _walkboxId = -1;
- _walkboxId = -1;
_animationId = 0;
_animationFrame = 0;
_fps = 15;
@@ -72,8 +77,10 @@ void Actor::setup(int actorId) {
_isRetired = false;
- _width = 0;
- _height = 0;
+ _width = 0;
+ _height = 0;
+ _retiredWidth = 0;
+ _retiredHeight = 0;
for (int i = 0; i != 7; ++i) {
_timersRemain[i] = 0;
@@ -104,32 +111,30 @@ void Actor::setup(int actorId) {
// TODO: Flush movement track
}
-void Actor::set_at_xyz(Vector3 pos, int facing) {
- _position = pos;
- _facing = facing;
-
-
-// this->x = x;
-// this->y = y;
-// this->z = z;
-// actor::set_angle(this, angle, addOrSet);
-// if (scene::get_sceneId(Scene) == this->sceneId)
-// this->walkboxId = set::findWalkbox(Scene->set, x, z);
-// else
-// this->walkboxId = -1;
-// actor::setBoundingBox(this, x, y, z, retired);
-// sceneObjects::removeScreneObject(SceneObjects, this->id);
-// scene = this->sceneId;
-// if (scene == scene::get_sceneId(Scene))
-// sceneObjects::addActor(
-// SceneObjects,
-// this->id,
-// this->boundingBox,
-// &this->screenRect,
-// 1,
-// a7,
-// this->targetable,
-// retired);
+void Actor::set_at_xyz(Vector3 position, int facing, bool halfOrSet, int moving, bool retired) {
+ _position = position;
+ setFacing(facing, halfOrSet);
+
+ if(_vm->_scene->_setId == _setId) {
+ _walkboxId = _vm->_scene->_set->findWalkbox(position.x, position.y);
+ }else {
+ _walkboxId = -1;
+ }
+
+ setBoundingBox(position, retired);
+
+ _vm->_sceneObjects->remove(_id);
+
+ if(_vm->_scene->getSetId() == _setId) {
+ _vm->_sceneObjects->addActor(_id, _bbox, &_screenRectangle, 1, moving, _isTargetable, retired);
+ }
+}
+
+
+void Actor::set_at_waypoint(int waypointId, int angle, int unknown, bool retired) {
+ Vector3 waypointPosition;
+ _vm->_waypoints->getXyz(waypointId, &waypointPosition.x, &waypointPosition.y, &waypointPosition.z);
+ set_at_xyz(waypointPosition, angle, true, unknown, retired);
}
void Actor::draw() {
@@ -144,4 +149,278 @@ void Actor::draw() {
_vm->_sliceRenderer->drawFrame(_vm->_surface2, _vm->_zBuffer2);
}
+
+int Actor::getSetId() {
+ return _setId;
+}
+
+void Actor::setSetId(int setId) {
+ if (_setId == setId) {
+ return;
+ }
+
+ int i;
+
+ if(_setId > 0) {
+ for (i = 0; i < (int)_vm->_gameInfo->getActorCount(); i++) {
+ if (_vm->_actors[i]->_id != _id && _vm->_actors[i]->_setId == _setId) {
+ //actorScript->OtherAgentExitedThisScene( i, _id);
+ }
+ }
+ }
+ _setId = setId;
+ //actorScript->EnteredScene(_id, set);
+ if (_setId > 0) {
+ for (i = 0; i < (int)_vm->_gameInfo->getActorCount(); i++) {
+ if (_vm->_actors[i]->_id != _id && _vm->_actors[i]->_setId == _setId) {
+ //actorScript->OtherAgentEnteredThisScene(i, _id);
+ }
+ }
+ }
+}
+
+
+void Actor::setFacing(int facing, bool halfOrSet) {
+ if (facing < 0 || facing >= 1024) {
+ return;
+ }
+
+ if (halfOrSet) {
+ _facing = facing;
+ return;
+ }
+
+ int cw;
+ int ccw;
+ int offset;
+
+ if (facing > _facing) {
+ cw = facing - _facing;
+ ccw = _facing + 1024 - facing;
+ } else {
+ ccw = _facing - facing;
+ cw = facing + 1024 - _facing;
+ }
+ if (cw < ccw) {
+ if (cw <= 32) {
+ offset = cw;
+ } else {
+ offset = cw / 2;
+ }
+ } else {
+ if (ccw <= 32) {
+ offset = -ccw;
+ } else {
+ offset = -ccw / 2;
+ }
+ }
+ _facing = (_facing + offset) % 1024;
+}
+
+void Actor::setBoundingBox(Vector3 position, bool retired) {
+ if(retired) {
+
+ }else {
+ _bbox->setXyz(position.x - 12.0f, position.y + 6.0f, position.z - 12.0f, position.x + 12.0f, position.y + 72.0f, position.z + 12.0f);
+ }
+}
+
+
+void Actor::changeAnimationMode(int animationMode, int force) {
+ if (force == 1) {
+ _animationMode = -1;
+ }
+ if(animationMode != _animationMode) {
+ //TODO: _vm->actorScript->ChangeAnimationMode(_id, animationMode);
+ _animationMode = animationMode;
+ }
+
+}
+
+bool Actor::isWalking() {
+ return _walkInfo->isWalking();
+}
+
+void Actor::stopWalking(int value) {
+ if (value == 1 && _id == 0) {
+ _vm->_playerActorIdle = true;
+ }
+
+ if(isWalking()) {
+ _walkInfo->stop(_id, 1, _combatAnimationMode, 0);
+ } else if(inCombat()) {
+ changeAnimationMode(_combatAnimationMode, 0);
+ } else {
+ changeAnimationMode(0, 0);
+ }
+}
+
+void Actor::faceActor(int otherActorId, bool animate) {
+ if (_setId != _vm->_scene->_setId) {
+ return;
+ }
+
+ Actor *otherActor = _vm->_actors[otherActorId];
+
+ if (_setId != otherActor->_setId) {
+ return;
+ }
+
+ faceXYZ(otherActor->_position.x, otherActor->_position.y, otherActor->_position.z, animate);
+}
+
+void Actor::faceObject(char *objectName, bool animate) {
+ int objectId = _vm->_scene->findObject(objectName);
+ if (objectId == -1) {
+ return;
+ }
+
+ BoundingBox boundingBox;
+ _vm->_scene->objectGetBoundingBox(objectId, &boundingBox);
+
+ float x0, y0, z0, x1, y1, z1;
+ boundingBox.getXyz(&x0, &y0, &z0, &x1, &y1, &z1);
+
+ float x = (x1 + x0) / 2.0f;
+ float z = (z1 + z0) / 2.0f;
+ faceXYZ(x, y0, z, animate);
+}
+
+void Actor::faceItem(int itemId, bool animate) {
+ float x, y, z;
+ _vm->_items->getXyz(itemId, &x, &y, &z);
+ faceXYZ(x, y, z, animate);
+}
+
+void Actor::faceWaypoint(int waypointId, bool animate) {
+ float x, y, z;
+ _vm->_waypoints->getXyz(waypointId, &x, &y, &z);
+ faceXYZ(x, y, z, animate);
+}
+
+void Actor::faceXYZ(float x, float y, float z, bool animate) {
+ if (isWalking()) {
+ stopWalking(0);
+ }
+ if (x == _position.x && z == _position.z) {
+ return;
+ }
+
+ int heading = int(512.0f * atan2f(_position.x - x, _position.z - z) / M_PI) % 1024;
+ faceHeading(heading, animate);
+}
+
+void Actor::faceCurrentCamera(bool animate) {
+ faceXYZ(_vm->_view->_cameraPosition.x, _vm->_view->_cameraPosition.y, -_vm->_view->_cameraPosition.z, animate);
+}
+
+void Actor::faceHeading(int heading, bool animate) {
+ if (heading != _facing) {
+ if (animate) {
+ _targetFacing = heading;
+ }
+ else {
+ setFacing(heading, true);
+ }
+ }
+}
+
+int Actor::getFriendlinessToOther(int otherActorId) {
+ return _friendlinessToOther[otherActorId];
+}
+
+void Actor::modifyFriendlinessToOther(int otherActorId, signed int change) {
+ _friendlinessToOther[otherActorId] = MIN(MAX(_friendlinessToOther[otherActorId] + change, 0), 100);
+}
+
+void Actor::setFriendlinessToOther(int otherActorId, int friendliness) {
+ _friendlinessToOther[otherActorId] = friendliness;
+}
+
+void Actor::setHonesty(int honesty) {
+ _honesty = honesty;
+}
+
+void Actor::setIntelligence(int intelligence) {
+ _intelligence = intelligence;
+}
+
+void Actor::setStability(int stability) {
+ _stability = stability;
+}
+
+void Actor::setCombatAggressiveness(int combatAggressiveness) {
+ _combatAggressiveness = combatAggressiveness;
+}
+
+int Actor::getCurrentHP() {
+ return _currentHP;
+}
+
+int Actor::getMaxHP() {
+ return _maxHP;
+}
+
+int Actor::getCombatAggressiveness() {
+ return _combatAggressiveness;
+}
+
+int Actor::getHonesty() {
+ return _honesty;
+}
+
+int Actor::getIntelligence() {
+ return _intelligence;
+}
+
+int Actor::getStability() {
+ return _stability;
+}
+
+void Actor::modifyCurrentHP(signed int change) {
+ _currentHP = MIN(MAX(_currentHP + change, 0), 100);
+ if (_currentHP > 0)
+ retire(0, 0, 0, -1);
+}
+
+void Actor::modifyMaxHP(signed int change) {
+ _maxHP = MIN(MAX(_maxHP + change, 0), 100);
+}
+
+void Actor::modifyCombatAggressiveness(signed int change) {
+ _combatAggressiveness = MIN(MAX(_combatAggressiveness + change, 0), 100);
+}
+
+void Actor::modifyHonesty(signed int change) {
+ _honesty = MIN(MAX(_honesty + change, 0), 100);
+}
+
+void Actor::modifyIntelligence(signed int change) {
+ _intelligence = MIN(MAX(_intelligence + change, 0), 100);
+}
+
+void Actor::modifyStability(signed int change) {
+ _stability = MIN(MAX(_stability + change, 0), 100);
+}
+
+void Actor::setFlagDamageAnimIfMoving(bool value) {
+ _damageAnimIfMoving = value;
+}
+
+bool Actor::getFlagDamageAnimIfMoving() {
+ return _damageAnimIfMoving;
+}
+
+void Actor::retire(bool isRetired, int width, int height, int retiredByActorId) {
+ _isRetired = isRetired;
+ _retiredWidth = MAX(width, 0);
+ _retiredHeight = MAX(height, 0);
+ if(_id == 0 && isRetired) {
+ _vm->playerLosesControl();
+ _vm->_playerDead = true;
+ }
+ if(isRetired) {
+ //TODO: _vm->actorScript->Retired(_id, retiredByActorId);
+ }
+}
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/actor.h b/engines/bladerunner/actor.h
index d621d5316a..4da73d4bc6 100644
--- a/engines/bladerunner/actor.h
+++ b/engines/bladerunner/actor.h
@@ -29,6 +29,7 @@
#include "bladerunner/movement_track.h"
#include "bladerunner/actor_clues.h"
#include "bladerunner/actor_walk.h"
+#include "bladerunner/actor_combat.h"
#include "common/rect.h"
@@ -42,8 +43,10 @@ class Actor {
private:
BoundingBox *_bbox;
- Common::Rect _screenRectangle;
+ Common::Rect _screenRectangle;
MovementTrack *_movementTrack;
+ ActorWalk *_walkInfo;
+ ActorCombat *_combatInfo;
int _honesty;
int _intelligence;
@@ -58,28 +61,35 @@ private:
ActorClues* _clues;
int _id;
- int _set;
+ int _setId;
Vector3 _position;
int _facing; // [0, 1024)
+ int _targetFacing;
int _walkboxId;
// Flags
bool _isTargetable;
bool _isInvisible;
bool _isImmuneToObstacles;
-
bool _isRetired;
+ bool _inCombat;
+ bool _isMoving;
+ bool _damageAnimIfMoving;
+
// Animation
- int _width;
+ int _width;
int _height;
int _animationMode;
+ int _combatAnimationMode;
int _fps;
int _frame_ms;
int _animationId;
int _animationFrame;
- ActorWalk* _walkInfo;
+ int _retiredWidth;
+ int _retiredHeight;
+
int _timersRemain[7];
int _timersBegan[7];
@@ -92,15 +102,64 @@ public:
void setup(int actorId);
- void set_at_xyz(Vector3 pos, int facing);
+ void set_at_xyz(Vector3 pos, int facing, bool halfOrSet, int unknown, bool retired);
+ void set_at_waypoint(int waypointId, int angle, int unknown, bool retired);
void draw();
- int getSet() { return _set; }
+ int getSetId();
+ void setSetId(int setId);
BoundingBox* getBoundingBox() { return _bbox; }
Common::Rect* getScreenRectangle() { return &_screenRectangle; }
bool isRetired() { return _isRetired; }
bool isTargetable() { return _isTargetable; }
+ bool inCombat() { return _inCombat; }
+ bool isMoving() { return _isMoving; }
+ void setMoving(bool value) { _isMoving = value; }
+ bool isWalking();
+ void stopWalking(int value);
+
+ void changeAnimationMode(int animationMode, int force);
+
+ void faceActor(int otherActorId, bool animate);
+ void faceObject(char *objectName, bool animate);
+ void faceItem(int itemId, bool animate);
+ void faceWaypoint(int waypointId, bool animate);
+ void faceXYZ(float x, float y, float z, bool animate);
+ void faceCurrentCamera(bool animate);
+ void faceHeading(int heading, bool animate);
+ int getFriendlinessToOther(int otherActorId);
+ void modifyFriendlinessToOther(int otherActorId, signed int change);
+ void setFriendlinessToOther(int otherActorId, int friendliness);
+ void setHonesty(int honesty);
+ void setIntelligence(int intelligence);
+ void setStability(int stability);
+ void setCombatAggressiveness(int combatAggressiveness);
+ int getCurrentHP();
+ int getMaxHP();
+ int getCombatAggressiveness();
+ int getHonesty();
+ int getIntelligence();
+ int getStability();
+ void modifyCurrentHP(signed int change);
+ void modifyMaxHP(signed int change);
+ void modifyCombatAggressiveness(signed int change);
+ void modifyHonesty(signed int change);
+ void modifyIntelligence(signed int change);
+ void modifyStability(signed int change);
+ void setFlagDamageAnimIfMoving(bool value);
+ bool getFlagDamageAnimIfMoving();
+
+
+ void retire(bool isRetired, int unknown1, int unknown2, int retiredByActorId);
+
+
+
+
+private:
+ void setFacing(int facing, bool halfOrSet);
+ void setBoundingBox(Vector3 position, bool retired);
+
};
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/actor_combat.cpp b/engines/bladerunner/actor_combat.cpp
new file mode 100644
index 0000000000..286ec1d938
--- /dev/null
+++ b/engines/bladerunner/actor_combat.cpp
@@ -0,0 +1,11 @@
+#include "bladerunner/actor_combat.h"
+
+namespace BladeRunner {
+
+ActorCombat::ActorCombat(BladeRunnerEngine* vm) {
+ _vm = vm;
+}
+
+ActorCombat::~ActorCombat() {
+}
+} \ No newline at end of file
diff --git a/engines/bladerunner/actor_combat.h b/engines/bladerunner/actor_combat.h
new file mode 100644
index 0000000000..a4ab4c9b78
--- /dev/null
+++ b/engines/bladerunner/actor_combat.h
@@ -0,0 +1,65 @@
+/* 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 BLADERUNNER_ACTOR_COMBAT_H
+#define BLADERUNNER_ACTOR_COMBAT_H
+
+#include "bladerunner/bladerunner.h"
+
+#include "bladerunner/vector.h"
+
+namespace BladeRunner {
+
+ class ActorCombat
+ {
+ BladeRunnerEngine *_vm;
+ private:
+ int _actorId;
+ int _combatOn;
+ int _field2;
+ int _field3;
+ int _otherActorId;
+ int _field5;
+ int _field6;
+ int _field7;
+ int _field8;
+ int _field9;
+ int _field10;
+ int _field11;
+ int _field12;
+ int _actorHp;
+ int _field14;
+ int _field15;
+ Vector3 actorPosition;
+ Vector3 otherActorPosition;
+ int _availableCoversCount;
+ int _availableFleeWaypointsCount;
+ int _field24;
+
+ public:
+ ActorCombat(BladeRunnerEngine *vm);
+ ~ActorCombat();
+
+ };
+}
+
+#endif
diff --git a/engines/bladerunner/actor_walk.cpp b/engines/bladerunner/actor_walk.cpp
index a4cfad7fde..e814180502 100644
--- a/engines/bladerunner/actor_walk.cpp
+++ b/engines/bladerunner/actor_walk.cpp
@@ -1,8 +1,40 @@
#include "bladerunner/actor_walk.h"
+#include "bladerunner/actor.h"
+#include "bladerunner/scene_objects.h"
namespace BladeRunner
{
+ ActorWalk::ActorWalk(BladeRunnerEngine *vm) {
+ _vm = vm;
+}
+ActorWalk::~ActorWalk() {
+}
+
+bool ActorWalk::isWalking() {
+ return _walking;
+}
+
+void ActorWalk::stop(int actorId, bool unknown, int animationMode, int notused) {
+ _vm->_sceneObjects->setMoving(actorId, 0);
+ _vm->_actors[actorId]->setMoving(0);
+
+ if(_vm->_actors[actorId]->inCombat()) {
+ _vm->_actors[actorId]->changeAnimationMode(animationMode, 0);
+ } else {
+ _vm->_actors[actorId]->changeAnimationMode(notused, 0);
+ }
+
+ if(unknown) {
+ _walking = 0;
+ _running = 0;
+ _status = 0;
+ }else {
+ _walking = 1;
+ _running = 0;
+ _status = 5;
+ }
+}
} \ No newline at end of file
diff --git a/engines/bladerunner/actor_walk.h b/engines/bladerunner/actor_walk.h
index c44c15bbe4..c38218937f 100644
--- a/engines/bladerunner/actor_walk.h
+++ b/engines/bladerunner/actor_walk.h
@@ -23,6 +23,7 @@
#ifndef BLADERUNNER_ACTOR_WALK_H
#define BLADERUNNER_ACTOR_WALK_H
+#include "bladerunner/bladerunner.h"
#include "bladerunner/vector.h"
namespace BladeRunner
@@ -35,6 +36,8 @@ namespace BladeRunner
class ActorWalk
{
+ BladeRunnerEngine *_vm;
+ private:
int _walking;
int _running;
Vector3 _wanted;
@@ -46,6 +49,13 @@ namespace BladeRunner
int _actorsCount;
int _field15;
int _status;
+ public:
+ ActorWalk(BladeRunnerEngine *vm);
+ ~ActorWalk();
+
+ bool isWalking();
+ void stop(int actorId, bool unknown, int animationMode, int notused);
+
};
}
diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp
index 22199e6fd7..62d6a819ff 100644
--- a/engines/bladerunner/bladerunner.cpp
+++ b/engines/bladerunner/bladerunner.cpp
@@ -44,6 +44,8 @@
#include "bladerunner/slice_renderer.h"
#include "bladerunner/text_resource.h"
#include "bladerunner/vqa_decoder.h"
+#include "bladerunner/waypoints.h"
+#include "bladerunner/items.h"
#include "common/array.h"
#include "common/error.h"
@@ -89,6 +91,8 @@ BladeRunnerEngine::~BladeRunnerEngine() {
// delete[] _zBuffer1;
// delete[] _zBuffer2;
+ delete _items;
+ delete _waypoints;
delete _lights;
delete _settings;
delete _script;
@@ -150,7 +154,7 @@ bool BladeRunnerEngine::startup(bool hasSavegames) {
}
}
- // TODO: World waypoints
+ _waypoints = new Waypoints(this, _gameInfo->getWaypointCount());
// TODO: Cover waypoints
@@ -171,7 +175,7 @@ bool BladeRunnerEngine::startup(bool hasSavegames) {
_gameFlags = new GameFlags();
_gameFlags->setFlagCount(_gameInfo->getFlagCount());
- // TODO: Items
+ _items = new Items(this);
// Setup sound output
@@ -529,6 +533,7 @@ void BladeRunnerEngine::gameTick() {
// TODO: Draw dialogue menu
Common::Point p = _eventMan->getMousePos();
+ _mouse->tick(p.x, p.y);
_mouse->draw(_surface2, p.x, p.y);
// TODO: Process AUD (audio in Replicant)
diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h
index 814041d0ed..87391d749c 100644
--- a/engines/bladerunner/bladerunner.h
+++ b/engines/bladerunner/bladerunner.h
@@ -55,6 +55,8 @@ class SliceRenderer;
class TextResource;
class Lights;
class View;
+class Waypoints;
+class Items;
class BladeRunnerEngine : public Engine {
@@ -81,6 +83,8 @@ public:
int *_gameVars;
Lights *_lights;
+ Waypoints *_waypoints;
+ Items *_items;
TextResource *_textActorNames;
TextResource *_textCrimes;
@@ -105,6 +109,9 @@ public:
Common::RandomSource _rnd;
+ bool _playerActorIdle;
+ bool _playerDead;
+
private:
static const int kArchiveCount = 10;
MIXArchive _archives[kArchiveCount];
diff --git a/engines/bladerunner/boundingbox.cpp b/engines/bladerunner/boundingbox.cpp
index fb2ae94813..9b36eabe29 100644
--- a/engines/bladerunner/boundingbox.cpp
+++ b/engines/bladerunner/boundingbox.cpp
@@ -34,8 +34,7 @@ BoundingBox::BoundingBox(float x0, float y0, float z0, float x1, float y1, float
_vertices[1].z = z1;
}
-void BoundingBox::expand(float x0, float y0, float z0, float x1, float y1, float z1)
-{
+void BoundingBox::expand(float x0, float y0, float z0, float x1, float y1, float z1) {
_vertices[0].x += x0;
_vertices[0].y += y0;
_vertices[0].z += z0;
@@ -46,11 +45,40 @@ void BoundingBox::expand(float x0, float y0, float z0, float x1, float y1, float
}
-bool BoundingBox::isXYZInside(float x, float y, float z)
-{
+bool BoundingBox::inside(float x, float y, float z) {
return
x >= _vertices[0].x && x <= _vertices[1].x
&& y >= _vertices[0].y && y <= _vertices[1].y
&& z >= _vertices[0].z && z <= _vertices[1].z;
}
+
+
+void BoundingBox::setXyz(float x0, float y0, float z0, float x1, float y1, float z1) {
+ _vertices[0].x = x0;
+ _vertices[0].y = y0;
+ _vertices[0].z = z0;
+
+ _vertices[1].x = x1;
+ _vertices[1].y = y1;
+ _vertices[1].z = z1;
+}
+
+void BoundingBox::getXyz(float *x0, float *y0, float *z0, float *x1, float *y1, float *z1) {
+ *x0 = _vertices[0].x;
+ *y0 = _vertices[0].y;
+ *z0 = _vertices[0].z;
+
+ *x1 = _vertices[1].x;
+ *y1 = _vertices[1].y;
+ *z1 = _vertices[1].z;
+}
+
+
+float BoundingBox::getZ0() {
+ return _vertices[0].z;
+}
+
+float BoundingBox::getZ1() {
+ return _vertices[1].z;
+}
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/boundingbox.h b/engines/bladerunner/boundingbox.h
index 1766973f26..d9f7df6141 100644
--- a/engines/bladerunner/boundingbox.h
+++ b/engines/bladerunner/boundingbox.h
@@ -28,7 +28,7 @@
namespace BladeRunner {
class BoundingBox {
-public:
+private:
Vector3 _vertices[2];
public:
@@ -36,7 +36,11 @@ public:
BoundingBox(float x0, float y0, float z0, float x1, float y1, float z1);
void expand(float x0, float y0, float z0, float x1, float y1, float z1);
- bool isXYZInside(float x, float y, float z);
+ bool inside(float x, float y, float z);
+ void setXyz(float x0, float y0, float z0, float x1, float y1, float z1);
+ void getXyz(float* x0, float* y0, float* z0, float* x1, float* y1, float* z1);
+ float getZ0();
+ float getZ1();
};
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/item.cpp b/engines/bladerunner/item.cpp
new file mode 100644
index 0000000000..7a3ec925aa
--- /dev/null
+++ b/engines/bladerunner/item.cpp
@@ -0,0 +1,20 @@
+#include "bladerunner/item.h"
+
+namespace BladeRunner {
+
+Item::Item() {
+ _animationId = -1;
+ _itemId = -1;
+ _setId = -1;
+}
+
+Item::~Item() {
+}
+
+
+void Item::getXyz(float* x, float* y, float* z) {
+ *x = _position.x;
+ *y = _position.y;
+ *z = _position.z;
+}
+} \ No newline at end of file
diff --git a/engines/bladerunner/item.h b/engines/bladerunner/item.h
new file mode 100644
index 0000000000..a4a9282f20
--- /dev/null
+++ b/engines/bladerunner/item.h
@@ -0,0 +1,67 @@
+/* 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 BLADERUNNER_ITEM_H
+#define BLADERUNNER_ITEM_H
+
+#include "bladerunner/bladerunner.h"
+#include "bladerunner/boundingbox.h"
+
+#include "common/array.h"
+#include "common/rect.h"
+
+namespace BladeRunner {
+ class Items;
+
+ class Item {
+ friend class Items;
+ private:
+ int _itemId;
+ int _setId;
+
+ BoundingBox _boundingBox;
+ Common::Rect _screenRectangle;
+ int _animationId;
+ Vector3 _position;
+ int _facing;
+ float _angle;
+ int _width;
+ int _height;
+ //int field_1C8;
+ int _target;
+ //float field_1D0;
+ int _targetable;
+ int _spinning;
+ int _angleChange;
+ float _cameraAngle;
+ int _obstacle;
+ //int field_1E8;
+ public:
+ Item();
+ ~Item();
+
+ void getXyz(float *x, float *y, float *z);
+ };
+
+}
+
+#endif
diff --git a/engines/bladerunner/items.cpp b/engines/bladerunner/items.cpp
new file mode 100644
index 0000000000..7d717ff1ce
--- /dev/null
+++ b/engines/bladerunner/items.cpp
@@ -0,0 +1,28 @@
+#include "bladerunner/items.h"
+
+namespace BladeRunner {
+
+Items::Items(BladeRunnerEngine *vm) {
+ _vm = vm;
+}
+
+Items::~Items() {
+}
+
+
+void Items::getXyz(int itemId, float* x, float* y, float* z) {
+ int itemIndex = findItem(itemId);
+ assert(itemIndex != -1);
+
+ _items[itemIndex].getXyz(x, y, z);
+}
+
+int Items::findItem(int itemId) {
+ int i;
+ for (i = 0; i < _items.size();i++) {
+ if (_items[i]._itemId == itemId)
+ return i;
+ }
+ return -1;
+}
+} \ No newline at end of file
diff --git a/engines/bladerunner/items.h b/engines/bladerunner/items.h
new file mode 100644
index 0000000000..39f574cacc
--- /dev/null
+++ b/engines/bladerunner/items.h
@@ -0,0 +1,50 @@
+/* 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 BLADERUNNER_ITEMS_H
+#define BLADERUNNER_ITEMS_H
+
+#include "bladerunner/bladerunner.h"
+#include "bladerunner/item.h"
+
+#include "common/array.h"
+#include "common/rect.h"
+
+namespace BladeRunner {
+
+ class Items {
+ BladeRunnerEngine *_vm;
+ private:
+ Common::Array<Item> _items;
+
+ public:
+ Items(BladeRunnerEngine *vm);
+ ~Items();
+
+ void getXyz(int itemId, float *x, float *y, float *z);
+
+ private:
+ int findItem(int itemId);
+ };
+}
+
+#endif
diff --git a/engines/bladerunner/matrix.cpp b/engines/bladerunner/matrix.cpp
index a55271ed39..fae8e43d19 100644
--- a/engines/bladerunner/matrix.cpp
+++ b/engines/bladerunner/matrix.cpp
@@ -166,4 +166,16 @@ Matrix4x3 invertMatrix(const Matrix4x3 &m)
return result;
}
+
+void Matrix4x3::unknown()
+{
+ float m14 = _m[0][3];
+ float m24 = _m[1][3];
+ float m34 = _m[2][3];
+
+ _m[0][3] = -(m34 * _m[0][2]) - m24 * _m[0][1] - m14 * _m[0][0];
+ _m[1][3] = -(m34 * _m[1][2]) - m24 * _m[1][1] - m14 * _m[1][0];
+ _m[2][3] = -(m34 * _m[2][2]) - m24 * _m[2][1] - m14 * _m[2][0];
+
+}
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/matrix.h b/engines/bladerunner/matrix.h
index 64c30701b1..cb7bc2f08e 100644
--- a/engines/bladerunner/matrix.h
+++ b/engines/bladerunner/matrix.h
@@ -93,7 +93,7 @@ public:
float &operator()(int r, int c) { assert(r >= 0 && r < 3); assert(c >= 0 && c < 4); return _m[r][c]; }
const float &operator()(int r, int c) const { assert(r >= 0 && r < 3); assert(c >= 0 && c < 4); return _m[r][c]; }
-
+ void unknown();
};
Matrix4x3 invertMatrix(const Matrix4x3 &m);
@@ -128,6 +128,8 @@ Vector3 operator*(const Matrix4x3 &m, const Vector3 &v)
return r;
}
+
+
} // End of namespace BladeRunner
#endif
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
diff --git a/engines/bladerunner/mouse.h b/engines/bladerunner/mouse.h
index 33f231484f..d708960602 100644
--- a/engines/bladerunner/mouse.h
+++ b/engines/bladerunner/mouse.h
@@ -28,8 +28,9 @@ namespace Graphics {
}
namespace BladeRunner {
+ class Vector3;
-class BladeRunnerEngine;
+ class BladeRunnerEngine;
class Mouse {
BladeRunnerEngine *_vm;
@@ -56,6 +57,10 @@ public:
void draw(Graphics::Surface &surface, int x, int y);
void updateCursorFrame();
+
+ void tick(int x, int y);
+private:
+ void Mouse::getXYZ(int x, int y, Vector3* mousePosition);
};
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/movement_track.cpp b/engines/bladerunner/movement_track.cpp
index fff4508dec..01dff24422 100644
--- a/engines/bladerunner/movement_track.cpp
+++ b/engines/bladerunner/movement_track.cpp
@@ -39,7 +39,7 @@ namespace BladeRunner {
_lastIndex = -1;
_hasNext = 0;
_paused = 0;
- for (int i = 0; i < sizeof(this->_entries); i++)
+ for (int i = 0; i < 100; i++)
{
_entries[i].waypointId = -1;
_entries[i].delay = -1;
diff --git a/engines/bladerunner/regions.cpp b/engines/bladerunner/regions.cpp
new file mode 100644
index 0000000000..fe817e074b
--- /dev/null
+++ b/engines/bladerunner/regions.cpp
@@ -0,0 +1,47 @@
+#include "bladerunner/regions.h"
+
+namespace BladeRunner {
+ Regions::Regions() {
+ _enabled = true;
+ _regions = new Region[10];
+ }
+
+ Regions::~Regions() {
+ delete[] _regions;
+ }
+
+ bool Regions::add(int index, Common::Rect rect, int type) {
+ if (index <= 0 || index >= 10)
+ return false;
+
+ if (_regions[index]._present)
+ return false;
+
+ _regions[index]._rectangle = rect;
+ _regions[index]._type = type;
+ _regions[index]._present = 1;
+
+ return true;
+ }
+
+ bool Regions::remove(int index) {
+ if (index <= 0 || index >= 10)
+ return false;
+
+ _regions[index]._rectangle = Common::Rect(-1, -1, -1, -1);
+ _regions[index]._type = -1;
+ _regions[index]._present = 0;
+
+ return true;
+ }
+
+ void BladeRunner::Regions::clear() {
+ int i;
+ for (i = 0; i < 10; i++)
+ remove(i);
+ }
+
+ void Regions::setEnabled(bool enabled) {
+ _enabled = enabled;
+ }
+} \ No newline at end of file
diff --git a/engines/bladerunner/regions.h b/engines/bladerunner/regions.h
new file mode 100644
index 0000000000..e92e812714
--- /dev/null
+++ b/engines/bladerunner/regions.h
@@ -0,0 +1,55 @@
+/* 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 BLADERUNNER_REGIONS_H
+#define BLADERUNNER_REGIONS_H
+
+#include "bladerunner/bladerunner.h"
+
+#include "common/rect.h"
+
+
+namespace BladeRunner {
+ struct Region
+ {
+ Common::Rect _rectangle;
+ int _type;
+ int _present;
+ };
+
+ class Regions
+ {
+ private:
+ Region* _regions;
+ bool _enabled;
+ public:
+ Regions();
+ ~Regions();
+
+ bool add(int index, Common::Rect rect, int type);
+ bool remove(int index);
+ void clear();
+
+ void setEnabled(bool enabled);
+ };
+}
+#endif
diff --git a/engines/bladerunner/scene.cpp b/engines/bladerunner/scene.cpp
index fc0aa8c20d..c734a1a82f 100644
--- a/engines/bladerunner/scene.cpp
+++ b/engines/bladerunner/scene.cpp
@@ -49,7 +49,8 @@ bool Scene::open(int setId, int sceneId, bool isLoadingGame) {
if (isLoadingGame) {
// TODO: Set up overlays
} else {
- // TODO: Clear regions
+ _regions->clear();
+ _exits->clear();
// reset aesc
// TODO: Destroy all overlays
_defaultLoop = 0;
@@ -93,17 +94,17 @@ bool Scene::open(int setId, int sceneId, bool isLoadingGame) {
// TODO: Set actor position from scene info
//advance frame 0
- _vm->_playerActor->set_at_xyz(_actorStartPosition, _actorStartFacing);
+ _vm->_playerActor->set_at_xyz(_actorStartPosition, _actorStartFacing, false, 0, 0);
// TODO: Set actor set
_vm->_script->SceneLoaded();
- _vm->_sceneObjects->reset();
+ _vm->_sceneObjects->clear();
// Init click map
int actorCount = _vm->_gameInfo->getActorCount();
for (int i = 0; i != actorCount; ++i) {
Actor *actor = _vm->_actors[i];
- if (actor->getSet() == setId) {
+ if (actor->getSetId() == setId) {
_vm->_sceneObjects->addActor(
i,
actor->getBoundingBox(),
@@ -115,7 +116,7 @@ bool Scene::open(int setId, int sceneId, bool isLoadingGame) {
}
}
- _set->addAllObjectsToScene(_vm->_sceneObjects);
+ _set->addObjectsToScene(_vm->_sceneObjects);
//add all items to scene
//calculate walking obstacles??
@@ -131,6 +132,8 @@ int Scene::advanceFrame(Graphics::Surface &surface, uint16 *&zBuffer) {
if (frame >= 0) {
surface.copyFrom(*_vqaPlayer.getSurface());
memcpy(zBuffer, _vqaPlayer.getZBuffer(), 640*480*2);
+
+ memcpy(surface.getPixels(), _vqaPlayer.getZBuffer(), 640 * 480 * 2);
}
return frame;
}
@@ -140,4 +143,21 @@ void Scene::setActorStart(Vector3 position, int facing) {
_actorStartFacing = facing;
}
+
+int Scene::getSetId() {
+ return _setId;
+}
+
+int Scene::findObject(char* objectName) {
+ return _set->findObject(objectName);
+}
+
+bool Scene::objectSetHotMouse(int objectId) {
+ return _set->objectSetHotMouse(objectId);
+}
+
+bool Scene::objectGetBoundingBox(int objectId, BoundingBox* boundingBox) {
+ return _set->objectGetBoundingBox(objectId, boundingBox);
+}
+
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/scene.h b/engines/bladerunner/scene.h
index ee286cabb4..97a9b3409f 100644
--- a/engines/bladerunner/scene.h
+++ b/engines/bladerunner/scene.h
@@ -28,6 +28,7 @@
#include "bladerunner/set.h"
//#include "bladerunner/view.h"
#include "bladerunner/vqa_player.h"
+#include "bladerunner/regions.h"
namespace BladeRunner {
@@ -48,6 +49,8 @@ public:
Vector3 _actorStartPosition;
int _actorStartFacing;
bool _playerWalkedIn;
+ Regions* _regions;
+ Regions* _exits;
public:
Scene(BladeRunnerEngine *vm)
@@ -59,16 +62,24 @@ public:
_defaultLoop(0),
_nextSetId(-1),
_nextSceneId(-1),
- _playerWalkedIn(false)
+ _playerWalkedIn(false),
+ _regions(new Regions()),
+ _exits(new Regions())
{}
~Scene() {
delete _set;
+ delete _regions;
+ delete _exits;
}
bool open(int setId, int sceneId, bool isLoadingGame);
int advanceFrame(Graphics::Surface &surface, uint16 *&zBuffer);
void setActorStart(Vector3 position, int facing);
+ int getSetId();
+ int findObject(char *objectName);
+ bool objectSetHotMouse(int objectId);
+ bool objectGetBoundingBox(int objectId, BoundingBox *boundingBox);
};
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/scene_objects.cpp b/engines/bladerunner/scene_objects.cpp
index f54a9b7120..6ac00dc635 100644
--- a/engines/bladerunner/scene_objects.cpp
+++ b/engines/bladerunner/scene_objects.cpp
@@ -26,15 +26,24 @@ namespace BladeRunner {
}
- void SceneObjects::reset() {
+ void SceneObjects::clear() {
int i;
for (i = 0; i < SCENE_OBJECTS_COUNT; i++) {
+ _sceneObjects[i]._sceneObjectId = -1;
+ _sceneObjects[i]._sceneObjectType = SceneObjectTypeUnknown;
+ _sceneObjects[i]._distanceToCamera = 0;
_sceneObjects[i]._present = 0;
+ _sceneObjects[i]._isClickable = 0;
+ _sceneObjects[i]._isObstacle = 0;
+ _sceneObjects[i]._unknown1 = 0;
+ _sceneObjects[i]._isCombatTarget = 0;
+ _sceneObjects[i]._isMoving = 0;
+ _sceneObjects[i]._isRetired = 0;
}
}
- bool SceneObjects::addActor(int sceneObjectId, BoundingBox* boundingBox, Common::Rect* screenRectangle, uint8 isClickable, uint8 unknown1, uint8 isCombatTarget, uint8 isRetired) {
- return addSceneObject(sceneObjectId, SceneObjectTypeActor, boundingBox, screenRectangle, isClickable, 0, 0, isCombatTarget, unknown1, isRetired);
+ bool SceneObjects::addActor(int sceneObjectId, BoundingBox* boundingBox, Common::Rect* screenRectangle, uint8 isClickable, uint8 isMoving, uint8 isCombatTarget, uint8 isRetired) {
+ return addSceneObject(sceneObjectId, SceneObjectTypeActor, boundingBox, screenRectangle, isClickable, 0, 0, isCombatTarget, isMoving, isRetired);
}
bool SceneObjects::addObject(int sceneObjectId, BoundingBox* boundingBox, uint8 isClickable, uint8 isObstacle, uint8 unknown1, uint8 isCombatTarget) {
@@ -46,7 +55,6 @@ namespace BladeRunner {
return addSceneObject(sceneObjectId, SceneObjectTypeItem, boundingBox, screenRectangle, isObstacle, 0, 0, isCombatTarget, 0, 0);
}
-
bool SceneObjects::remove(int sceneObjectId)
{
int i = findById(sceneObjectId);
@@ -68,7 +76,7 @@ namespace BladeRunner {
return true;
}
- int SceneObjects::findByXYZ(int *isClickable, int *isObstacle, int *isCombatTarget, float x, float y, float z, int firstClickable, int firstObstacle, int firstCombatTarget) {
+ int SceneObjects::findByXYZ(int *isClickable, int *isObstacle, int *isCombatTarget, float x, float y, float z, int mustBeClickable, int mustBeObstacle, int mustBeCombatTarget) {
BoundingBox boundingBox;
*isClickable = 0;
*isObstacle = 0;
@@ -81,10 +89,10 @@ namespace BladeRunner {
for (i = 0; i < _count; i++) {
//assert(_sceneObjectsSortedByDistance[i] < _count);
SceneObject *sceneObject = &_sceneObjects[_sceneObjectsSortedByDistance[i]];
- if ((firstClickable && sceneObject->_isClickable)
- || (firstObstacle && sceneObject->_isObstacle)
- || (firstCombatTarget && sceneObject->_isCombatTarget)) {
- break;
+ if ((mustBeClickable && !sceneObject->_isClickable)
+ || (mustBeObstacle && !sceneObject->_isObstacle)
+ || (mustBeCombatTarget && !sceneObject->_isCombatTarget)) {
+ continue;
}
boundingBox = sceneObject->_boundingBox;
@@ -93,7 +101,7 @@ namespace BladeRunner {
boundingBox.expand(-4.0, 0.0, -4.0, 4.0, 0.0, 4.0);
}
- if (boundingBox.isXYZInside(x, y, z)) {
+ if (boundingBox.inside(x, y, z)) {
*isClickable = sceneObject->_isClickable;
*isObstacle = sceneObject->_isObstacle;
*isCombatTarget = sceneObject->_isCombatTarget;
@@ -115,7 +123,7 @@ namespace BladeRunner {
return -1;
}
- bool SceneObjects::addSceneObject(int sceneObjectId, SceneObjectType sceneObjectType, BoundingBox* boundingBox, Common::Rect* screenRectangle, uint8 isClickable, uint8 isObstacle, uint8 unknown1, uint8 isCombatTarget, uint unknown2, uint isRetired) {
+ bool SceneObjects::addSceneObject(int sceneObjectId, SceneObjectType sceneObjectType, BoundingBox* boundingBox, Common::Rect* screenRectangle, uint8 isClickable, uint8 isObstacle, uint8 unknown1, uint8 isCombatTarget, uint isMoving, uint isRetired) {
int index = findEmpty();
if (_count >= SCENE_OBJECTS_COUNT || index == -1) {
return false;
@@ -130,10 +138,10 @@ namespace BladeRunner {
_sceneObjects[index]._isObstacle = isObstacle;
_sceneObjects[index]._unknown1 = unknown1;
_sceneObjects[index]._isCombatTarget = isCombatTarget;
- _sceneObjects[index]._unknown2 = unknown2;
+ _sceneObjects[index]._isMoving = isMoving;
_sceneObjects[index]._isRetired = isRetired;
- float centerZ = (_sceneObjects[index]._boundingBox._vertices[0].z + _sceneObjects[index]._boundingBox._vertices[1].z) / 2.0;
+ float centerZ = (_sceneObjects[index]._boundingBox.getZ0() + _sceneObjects[index]._boundingBox.getZ1()) / 2.0;
float distanceToCamera = fabs(_view->_cameraPosition.z - centerZ);
_sceneObjects[index]._distanceToCamera = distanceToCamera;
@@ -155,8 +163,7 @@ namespace BladeRunner {
return true;
}
- int SceneObjects::findEmpty()
- {
+ int SceneObjects::findEmpty() {
int i;
for (i = 0; i < SCENE_OBJECTS_COUNT; i++)
{
@@ -166,23 +173,12 @@ namespace BladeRunner {
return -1;
}
-
-
- SceneObject::SceneObject()
- {
- _sceneObjectId = -1;
- _sceneObjectType = SceneObjectTypeUnknown;
- _distanceToCamera = 0;
- _present = 0;
- _isClickable = 0;
- _isObstacle = 0;
- _unknown1 = 0;
- _isCombatTarget = 0;
- _unknown2 = 0;
- _isRetired = 0;
+ void SceneObjects::setMoving(int sceneObjectId, bool isMoving) {
+ int i = findById(sceneObjectId);
+ if (i == -1 || !_sceneObjects[i]._present) {
+ return;
+ }
+ _sceneObjects[i]._isMoving = isMoving;
}
- SceneObject::~SceneObject()
- {
- }
}
diff --git a/engines/bladerunner/scene_objects.h b/engines/bladerunner/scene_objects.h
index 999d82179f..16188d96ab 100644
--- a/engines/bladerunner/scene_objects.h
+++ b/engines/bladerunner/scene_objects.h
@@ -32,7 +32,6 @@
namespace BladeRunner {
class BladeRunnerEngine;
- class SceneObject;
enum SceneObjectType
{
@@ -47,6 +46,21 @@ namespace BladeRunner {
#define SCENE_OBJECTS_ITEMS_OFFSET 74
#define SCENE_OBJECTS_OBJECTS_OFFSET 198
+ struct SceneObject
+ {
+ int _sceneObjectId;
+ SceneObjectType _sceneObjectType;
+ BoundingBox _boundingBox;
+ Common::Rect _screenRectangle;
+ float _distanceToCamera;
+ int _present;
+ int _isClickable;
+ int _isObstacle;
+ int _unknown1;
+ int _isCombatTarget;
+ int _isMoving;
+ int _isRetired;
+ };
class SceneObjects {
@@ -60,37 +74,19 @@ namespace BladeRunner {
public:
SceneObjects(BladeRunnerEngine *vm, View *view);
~SceneObjects();
- void reset();
bool addActor(int sceneObjectId, BoundingBox* boundingBox, Common::Rect* screenRectangle, uint8 isClickable, uint8 unknown1, uint8 isCombatTarget, uint8 isRetired);
bool addObject(int sceneObjectId, BoundingBox* boundingBox, uint8 isClickable, uint8 isObstacle, uint8 unknown1, uint8 isCombatTarget);
bool addItem(int sceneObjectId, BoundingBox* boundingBox, Common::Rect* screenRectangle, uint8 isCombatTarget, uint8 isObstacle);
bool remove(int sceneObjectId);
- int findByXYZ(int* clickable, int* obstacle, int* targetable, float x, float y, float z, int firstClickable, int firstObstacle, int firstTargetable);
+ void clear();
+ int findByXYZ(int *isClickable, int *isObstacle, int *isCombatTarget, float x, float y, float z, int mustBeClickable, int mustBeObstacle, int mustBeCombatTarget);
+ void setMoving(int sceneObjectId, bool isMoving);
private:
int findById(int sceneObjectId);
bool addSceneObject(int sceneObjectId, SceneObjectType sceneObjectType, BoundingBox* boundingBox, Common::Rect* screenRectangle, uint8 isClickable, uint8 isObstacle, uint8 unknown1, uint8 isCombatTarget, uint unknown2, uint isRetired);
int findEmpty();
};
- class SceneObject
- {
- friend class SceneObjects;
- private:
- int _sceneObjectId;
- SceneObjectType _sceneObjectType;
- BoundingBox _boundingBox;
- Common::Rect _screenRectangle;
- float _distanceToCamera;
- int _present;
- int _isClickable;
- int _isObstacle;
- int _unknown1;
- int _isCombatTarget;
- int _unknown2;
- int _isRetired;
- public:
- SceneObject();
- ~SceneObject();
- };
+
}
#endif
diff --git a/engines/bladerunner/set.cpp b/engines/bladerunner/set.cpp
index a2e54107d2..7c1f25dcb0 100644
--- a/engines/bladerunner/set.cpp
+++ b/engines/bladerunner/set.cpp
@@ -117,13 +117,84 @@ bool Set::open(const Common::String &name) {
}
-void Set::addAllObjectsToScene(SceneObjects* sceneObjects)
+void Set::addObjectsToScene(SceneObjects* sceneObjects)
{
uint32 i;
- for (i = 0; i < _objectCount; i++)
- {
+ for (i = 0; i < _objectCount; i++) {
sceneObjects->addObject(i + SCENE_OBJECTS_OBJECTS_OFFSET, &_objects[i]._bbox, _objects[i]._isClickable, _objects[i]._isObstacle, _objects[i]._unknown1, _objects[i]._isCombatTarget);
}
}
+
+int Set::findWalkbox(float x, float z) {
+ int i;
+ float altitude = 0.0f;
+ int foundWalkboxId = -1;
+ for (i = 0; i < _walkboxCount; i++) {
+ if (isXzInWalkbox(x, z, &_walkboxes[i])) {
+ if (foundWalkboxId == -1 || altitude < _walkboxes[i]._altitude) {
+ altitude = _walkboxes[i]._altitude;
+ foundWalkboxId = i;
+ }
+ }
+ }
+ return foundWalkboxId;
+}
+
+bool Set::isXzInWalkbox(float x, float z, Walkbox* walkbox) {
+ int found = 0;
+ int i;
+
+ float lastX = walkbox->_vertices[walkbox->_vertexCount - 1].x;
+ float lastZ = walkbox->_vertices[walkbox->_vertexCount - 1].z;
+ for (i = 0; i < walkbox->_vertexCount; i++) {
+
+ float currentX = walkbox->_vertices[i].x;
+ float currentZ = walkbox->_vertices[i].z;
+
+ if ((currentZ > z && z >= lastZ) || (currentZ <= z && z < lastZ)) {
+ float lineX = (lastX - currentX) / (lastZ - currentZ) * (z - currentZ) + currentX;
+ if (x < lineX)
+ found++;
+ }
+
+ }
+ return found & 1;
+}
+
+
+int Set::findObject(char* objectName) {
+ int i;
+ for (i = 0; i < _objectCount; i++) {
+ if (scumm_stricmp(objectName, _objects[i]._name) == 0) {
+ return i;
+ }
+ }
+ return -1;
+}
+
+bool Set::objectSetHotMouse(int objectId) {
+ if(!_objects || objectId < 0 || objectId >= _objectCount) {
+ return false;
+ }
+
+ _objects[objectId]._isHotMouse = true;
+ return true;
+}
+
+bool Set::objectGetBoundingBox(int objectId, BoundingBox* boundingBox) {
+ assert(boundingBox);
+
+ if (!_objects || objectId < 0 || objectId >= _objectCount) {
+ boundingBox->setXyz(0, 0, 0, 0, 0, 0);
+ return false;
+ }
+ float x0, y0, z0, x1, y1, z1;
+
+ _objects[objectId]._bbox.getXyz(&x0, &y0, &z0, &x1, &y1, &z1);
+ boundingBox->setXyz(x0, y0, z0, x1, y1, z1);
+
+ return true;
+}
+
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/set.h b/engines/bladerunner/set.h
index fba2d2a3ab..395ec6cf6d 100644
--- a/engines/bladerunner/set.h
+++ b/engines/bladerunner/set.h
@@ -35,8 +35,8 @@
namespace BladeRunner {
class BladeRunnerEngine;
-
class VQADecoder;
+class Scene;
struct Object {
char _name[20];
@@ -56,6 +56,8 @@ struct Walkbox {
};
class Set {
+ friend class Scene;
+
BladeRunnerEngine *_vm;
uint32 _objectCount;
@@ -73,9 +75,17 @@ public:
~Set();
bool open(const Common::String &name);
- void addAllObjectsToScene(SceneObjects *sceneObjects);
+ void addObjectsToScene(SceneObjects *sceneObjects);
+
+ int findWalkbox(float x, float z);
+ int findObject(char* objectName);
+
+ bool objectSetHotMouse(int objectId);
+ bool objectGetBoundingBox(int objectId, BoundingBox *boundingBox);
+
+private:
+ bool isXzInWalkbox(float x, float z, Walkbox* walkbox);
-
};
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/slice_animations.cpp b/engines/bladerunner/slice_animations.cpp
index 6d0347c476..efcd4b3987 100644
--- a/engines/bladerunner/slice_animations.cpp
+++ b/engines/bladerunner/slice_animations.cpp
@@ -170,4 +170,10 @@ void *SliceAnimations::getFramePtr(uint32 animation, uint32 frame) {
return (byte*)_pages[page]._data + pageOffset;
}
+
+int SliceAnimations::getNumberOfFrames(int animationId) {
+ if (animationId > _animations.size())
+ return 0;
+ return _animations[animationId].frameCount;
+}
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/slice_animations.h b/engines/bladerunner/slice_animations.h
index cc07b570b6..b0c53b1e05 100644
--- a/engines/bladerunner/slice_animations.h
+++ b/engines/bladerunner/slice_animations.h
@@ -104,6 +104,8 @@ public:
SlicePalette &getPalette(int i) { return _palettes[i]; };
void *getFramePtr(uint32 animation, uint32 frame);
+
+ int getNumberOfFrames(int animationId);
};
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/slice_renderer.cpp b/engines/bladerunner/slice_renderer.cpp
index a1e8497dc9..a52a123f54 100644
--- a/engines/bladerunner/slice_renderer.cpp
+++ b/engines/bladerunner/slice_renderer.cpp
@@ -416,13 +416,17 @@ void SliceRenderer::drawSlice(int slice, uint16 *frameLinePtr, uint16 *zbufLineP
}
}
-void SliceRenderer::setLights(Lights* lights)
-{
+void SliceRenderer::setLights(Lights* lights){
_lights = lights;
}
-void SliceRenderer::setSetEffects(SetEffects* setEffects)
-{
+void SliceRenderer::setSetEffects(SetEffects* setEffects){
_setEffects = setEffects;
}
+
+void SliceRenderer::preload(int animationId) {
+ int i;
+ for (i = 0; i < _vm->_sliceAnimations->getNumberOfFrames(animationId); i++)
+ _vm->_sliceAnimations->getFramePtr(animationId, i);
+}
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/slice_renderer.h b/engines/bladerunner/slice_renderer.h
index c04560a35e..6e21d4f5f3 100644
--- a/engines/bladerunner/slice_renderer.h
+++ b/engines/bladerunner/slice_renderer.h
@@ -53,7 +53,7 @@ class SliceRenderer {
Lights *_lights;
SetEffects *_setEffects;
- void *_sliceFramePtr;
+ void *_sliceFramePtr;
// Animation frame data
Vector2 _frameFront;
@@ -101,6 +101,8 @@ public:
void drawFrame(Graphics::Surface &surface, uint16 *zbuffer);
+ void preload(int animationId);
+
};
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/waypoints.cpp b/engines/bladerunner/waypoints.cpp
new file mode 100644
index 0000000000..d174e26cbc
--- /dev/null
+++ b/engines/bladerunner/waypoints.cpp
@@ -0,0 +1,55 @@
+#include "bladerunner/waypoints.h"
+namespace BladeRunner {
+
+Waypoints::Waypoints(BladeRunnerEngine* vm, int count) {
+ _count = count;
+ _waypoints = new Waypoint[count];
+}
+
+Waypoints::~Waypoints() {
+}
+
+void Waypoints::getXyz(int waypointId, float *x, float *y, float *z) {
+ *x = 0;
+ *y = 0;
+ *z = 0;
+
+ if (waypointId < 0 || waypointId >= _count || !_waypoints[waypointId]._present)
+ return;
+
+ *x = _waypoints[waypointId]._position.x;
+ *y = _waypoints[waypointId]._position.y;
+ *z = _waypoints[waypointId]._position.z;
+}
+
+int Waypoints::getSetId(int waypointId) {
+ if (waypointId < 0 || waypointId >= _count || !_waypoints[waypointId]._present)
+ return -1;
+ return _waypoints[waypointId]._setId;
+}
+
+bool Waypoints::set(int waypointId, int setId, Vector3 position) {
+ if (waypointId < 0 || waypointId >= _count)
+ return false;
+
+ _waypoints[waypointId]._setId = setId;
+ _waypoints[waypointId]._position = position;
+ _waypoints[waypointId]._present = true;
+
+ return true;
+}
+
+bool Waypoints::reset(int waypointId) {
+ if (waypointId < 0 || waypointId >= _count)
+ return false;
+
+ _waypoints[waypointId]._setId = -1;
+ _waypoints[waypointId]._position.x = 0;
+ _waypoints[waypointId]._position.y = 0;
+ _waypoints[waypointId]._position.z = 0;
+ _waypoints[waypointId]._present = false;
+
+ return true;
+
+}
+} \ No newline at end of file
diff --git a/engines/bladerunner/waypoints.h b/engines/bladerunner/waypoints.h
new file mode 100644
index 0000000000..c74e405386
--- /dev/null
+++ b/engines/bladerunner/waypoints.h
@@ -0,0 +1,57 @@
+/* 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 BLADERUNNER_WAYPOINTS_H
+#define BLADERUNNER_WAYPOINTS_H
+
+#include "bladerunner/bladerunner.h"
+#include "bladerunner/vector.h"
+
+#include "common/array.h"
+
+
+namespace BladeRunner {
+
+ struct Waypoint {
+ int _setId;
+ Vector3 _position;
+ bool _present;
+ };
+
+ class Waypoints {
+ BladeRunnerEngine *_vm;
+ private:
+ int _count;
+ Waypoint *_waypoints;
+ public:
+ Waypoints(BladeRunnerEngine *vm, int count);
+ ~Waypoints();
+
+ void getXyz(int waypointId, float *x, float *y, float *z);
+ int getSetId(int waypointId);
+
+ bool set(int waypointId, int setId, Vector3 position);
+ bool reset(int waypointId);
+ };
+}
+
+#endif