ScummVM API documentation
object.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_OBJECT_H
26 #define FREESCAPE_OBJECT_H
27 
28 #include "math/aabb.h"
29 
30 #include "freescape/gfx.h"
31 
32 namespace Freescape {
33 
34 enum ObjectType {
35  kEntranceType = 0,
36  kCubeType = 1,
37  kSensorType = 2,
38  kRectangleType = 3,
39 
40  kEastPyramidType = 4,
41  kWestPyramidType = 5,
42  kUpPyramidType = 6,
43  kDownPyramidType = 7,
44  kNorthPyramidType = 8,
45  kSouthPyramidType = 9,
46 
47  kLineType = 10,
48  kTriangleType = 11,
49  kQuadrilateralType = 12,
50  kPentagonType = 13,
51  kHexagonType = 14,
52 
53  kGroupType = 15
54 };
55 
56 class Object {
57 public:
58  virtual ObjectType getType() { return _type; }
59  uint16 getObjectID() { return _objectID; }
60  uint16 getObjectFlags() { return _flags; }
61  bool isGeometric() {
62  return _type != kEntranceType && _type != kGroupType && _type != kSensorType;
63  }
64  void setObjectFlags(uint32 flags_) { _flags = flags_; }
65  Math::Vector3d getOrigin() { return _origin; }
66  virtual void setOrigin(Math::Vector3d origin_) { _origin = origin_; };
67  Math::Vector3d getSize() { return _size; }
68 
69  virtual bool isDrawable() { return false; }
70  virtual bool isPlanar() { return false; }
71  virtual void scale(int factor) = 0;
72 
73  bool isInvisible() { return _flags & 0x40; }
74  void makeInvisible() { _flags = _flags | 0x40; }
75  void makeVisible() { _flags = _flags & ~0x40; }
76  bool isInitiallyInvisible() { return _flags & 0x80; }
77  void makeInitiallyInvisible() { _flags = _flags | 0x80; }
78  void makeInitiallyVisible() { _flags = _flags & ~0x80; }
79  bool isDestroyed() { return _flags & 0x20; }
80  void destroy() { _flags = _flags | 0x20; }
81  void restore() { _flags = _flags & ~0x20; }
82  void toggleVisibility() { _flags = _flags ^ 0x40; }
83 
84  virtual ~Object() {}
85  virtual Object *duplicate() = 0;
86 
87  virtual void draw(Freescape::Renderer *gfx, float offset = 0.0) = 0;
88 
89  uint16 _flags;
90  ObjectType _type;
91  uint16 _objectID;
92  Math::Vector3d _origin, _size, _rotation;
93  Math::AABB _boundingBox;
94  Object *_partOfGroup = nullptr;
95 };
96 
97 } // End of namespace Freescape
98 
99 #endif // FREESCAPE_OBJECT_H
Definition: area.h:36
Definition: gfx.h:60
Definition: object.h:56