ScummVM API documentation
area.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22// Based on Phantasma code by Thomas Harte (2013),
23// available at https://github.com/TomHarte/Phantasma/ (MIT)
24
25#ifndef FREESCAPE_AREA_H
26#define FREESCAPE_AREA_H
27
28#include "math/ray.h"
29#include "math/vector3d.h"
30
31#include "freescape/language/instruction.h"
32#include "freescape/objects/object.h"
33#include "freescape/objects/group.h"
34
35
36namespace Freescape {
37
40
41class Area {
42public:
43 enum RenderDepthLayer {
44 kRenderDepthAll,
45 kRenderDepthBackground,
46 kRenderDepthForeground
47 };
48
49 Area(uint16 areaID, uint16 areaFlags, ObjectMap *objectsByID, ObjectMap *entrancesByID, bool isCastle);
50 virtual ~Area();
51
52 Common::String _name;
53 Object *objectWithID(uint16 objectID);
54 Object *entranceWithID(uint16 objectID);
55 Common::List<int> getEntranceIds();
56
57 void changeObjectID(uint16 objectID, uint16 newObjectID);
58 ObjectArray getSensors();
59 uint16 getAreaID();
60 Common::Array<Object *> &getSortedObjects() { return _sortedObjects; }
61 ObjectMap *getObjectsByID() { return _objectsByID; }
62 ObjectMap *getEntrancesByID() { return _entrancesByID; }
63 uint16 getAreaFlags();
64 uint8 getScale();
65 void remapColor(int index, int color);
66 void unremapColor(int index);
67 void draw(Renderer *gfx, uint32 animationTicks, Math::Vector3d camera, Math::Vector3d direction, float roll, bool insideWait, float fov, float aspectRatio, float nearClipPlane, float farClipPlane);
68 void drawDepthLayer(Renderer *gfx, uint32 animationTicks, Math::Vector3d camera, Math::Vector3d direction, float roll, bool insideWait, RenderDepthLayer depthLayer, float foregroundDistance, float fov, float aspectRatio, float nearClipPlane, float farClipPlane);
69 void drawGroup(Renderer *gfx, Group *group, bool runAnimation);
70 void show();
71
72 Object *checkCollisionRay(const Math::Ray &ray, int raySize, bool skipTransparent = false);
73 bool checkInSight(const Math::Ray &ray, float maxDistance);
74 Math::Vector3d separateFromWall(const Math::Vector3d &position);
75 Math::Vector3d separateCameraFromWall(const Math::Vector3d &eye, float separation);
76 ObjectArray checkCollisions(const Math::AABB &boundingBox);
77 bool checkIfPlayerWasCrushed(const Math::AABB &boundingBox);
78 Math::Vector3d resolveCollisions(Math::Vector3d const &lastPosition, Math::Vector3d const &newPosition, int playerHeight);
79 void addObjectFromArea(int16 id, Area *global);
80 void addGroupFromArea(int16 id, Area *global);
81 void addObject(Object *obj);
82 void addFloor(uint8 extraColor = 0);
83 void addStructure(Area *global);
84 void removeObject(int16 id);
85 void resetArea();
86 void resetAreaGroups();
87 bool isOutside();
88 bool hasDrawableObjects() const { return !_drawableObjects.empty(); }
89 bool hasActiveGroups();
90
91 Common::Array<Common::String> _conditionSources;
93
94 // Serialization
95 void saveObjects(Common::WriteStream *stream);
96 void loadObjects(Common::SeekableReadStream *stream, Area *global);
97
98 // Driller specific
99 Common::Point _gasPocketPosition;
100 uint32 _gasPocketRadius;
101
102 // Castle Master specific
103 bool _isCastle;
104
105 uint8 _scale;
106 uint8 _skyColor;
107 uint8 _groundColor;
108 uint8 _usualBackgroundColor;
109 uint8 _underFireBackgroundColor;
110 uint8 _inkColor;
111 uint8 _paperColor;
112 uint8 _extraColor[4];
113 bool _colorCycling; // Amiga/Atari: bit 14 of area header enables COLOR15 cycling
114 ColorReMap _colorRemaps;
115
116 uint32 _lastTick;
117
118private:
119 Math::Vector3d _lastCameraPosition;
120 Math::Vector3d _lastCameraDirection;
121 float _lastCameraRoll;
122 float _lastFov;
123 float _lastAspectRatio;
124 float _lastNearClipPlane;
125 float _lastFarClipPlane;
126 ObjectArray _sortedObjects;
127 ObjectArray _depthLayerSortedObjects;
128 Math::Vector3d _lastDepthLayerCameraPosition;
129 Math::Vector3d _lastDepthLayerCameraDirection;
130 float _lastDepthLayerCameraRoll;
131 float _lastDepthLayerFov;
132 float _lastDepthLayerAspectRatio;
133 float _lastDepthLayerNearClipPlane;
134 float _lastDepthLayerFarClipPlane;
135 RenderDepthLayer _lastRenderDepthLayer;
136 float _lastForegroundDistance;
137 uint32 _lastDepthLayerTick;
138
139 uint16 _areaID;
140 uint16 _areaFlags;
141 bool _hasSyntheticFloor;
142 ObjectMap *_objectsByID;
143 ObjectMap *_entrancesByID;
144 ObjectArray _drawableObjects;
145 ObjectMap _addedObjects;
146 Object *objectWithIDFromMap(ObjectMap *map, uint16 objectID);
147};
148
149} // End of namespace Freescape
150
151#endif // FREESCAPE_AREA_H
bool empty() const
Definition: array.h:352
Definition: stream.h:745
Definition: str.h:59
Definition: stream.h:77
Definition: area.h:41
Definition: group.h:40
Definition: object.h:56
Definition: gfx.h:63
Definition: area.h:36
Definition: rect.h:144