ScummVM API documentation
sector.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 #ifndef GRIM_WALKPLANE_H
23 #define GRIM_WALKPLANE_H
24 
25 #include "common/str.h"
26 #include "common/list.h"
27 
28 #include "math/vector3d.h"
29 #include "math/line3d.h"
30 
31 namespace Common {
32  class SeekableReadStream;
33 }
34 
35 namespace Grim {
36 
37 class SaveGame;
38 class TextSplitter;
39 
40 class Sector {
41 public:
42  enum SectorType {
43  NoneType = 0,
44  WalkType = 0x1000,
45  FunnelType = 0x1100,
46  CameraType = 0x2000,
47  SpecialType = 0x4000,
48  HotType = 0x8000
49  };
50 
51  Sector();
52  Sector(const Sector &other);
53  virtual ~Sector();
54 
55  void saveState(SaveGame *savedState) const;
56  bool restoreState(SaveGame *savedState);
57 
58  void load(TextSplitter &ts);
59  void loadBinary(Common::SeekableReadStream *data);
60  void setVisible(bool visible);
61  void shrink(float radius);
62  void unshrink();
63 
64  Common::String getName() const { return _name; }
65  int getSectorId() const { return _id; }
66  SectorType getType() const { return _type; } // FIXME: Implement type de-masking
67  bool isVisible() const { return _visible && !_invalid; }
68  bool isPointInSector(const Math::Vector3d &point) const;
69  float distanceToPoint(const Math::Vector3d &point) const;
70  Common::List<Math::Line3d> getBridgesTo(Sector *sector) const;
71 
72  Math::Vector3d getProjectionToPlane(const Math::Vector3d &point) const;
73  Math::Vector3d getProjectionToPuckVector(const Math::Vector3d &v) const;
74 
75  Math::Vector3d getClosestPoint(const Math::Vector3d &point) const;
76 
77  // Interface to trace a ray to its exit from the polygon
78  struct ExitInfo {
79  Math::Vector3d exitPoint;
80  Math::Angle angleWithEdge;
81  Math::Vector3d edgeDir;
82  int edgeVertex;
83  };
84  void getExitInfo(const Math::Vector3d &start, const Math::Vector3d &dir, struct ExitInfo *result) const;
85 
86  int getNumSortplanes() { return _numSortplanes; }
87  int getSortplane(int setup) { return _sortplanes[setup]; }
88  int getNumVertices() { return _numVertices; }
89  Math::Vector3d *getVertices() const { return _vertices; }
90  Math::Vector3d getNormal() const { return _normal; }
91 
92  Sector &operator=(const Sector &other);
93  bool operator==(const Sector &other) const;
94 
95 private:
96  int _numVertices;
97  int _id;
98  int _numSortplanes;
99  int *_sortplanes;
100 
101  Common::String _name;
102  SectorType _type;
103  bool _visible;
104  bool _invalid;
105  Math::Vector3d *_vertices;
106  Math::Vector3d *_origVertices;
107  float _height;
108  float _shrinkRadius;
109 
110  Math::Vector3d _normal;
111 };
112 
113 } // end of namespace Grim
114 
115 #endif
Definition: str.h:59
Definition: list.h:44
Definition: savegame.h:33
Definition: stream.h:745
Definition: actor.h:33
Definition: sector.h:78
Definition: algorithm.h:29
Definition: textsplit.h:35
Definition: sector.h:40