Skyscraper 2.0
shaft.h
Go to the documentation of this file.
1/*
2 Scalable Building Simulator - Shaft Object
3 The Skyscraper Project - Version 2.0
4 Copyright (C)2004-2024 Ryan Thoryk
5 https://www.skyscrapersim.net
6 https://sourceforge.net/projects/skyscraper/
7 Contact - ryan@skyscrapersim.net
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22*/
23
24#ifndef _SBS_SHAFT_H
25#define _SBS_SHAFT_H
26
27namespace SBS {
28
29class SBSIMPEXP Shaft : public Object
30{
31public:
32 class Level;
33
34 int ShaftNumber; //shaft number
35 int startfloor; //starting floor
36 int endfloor; //ending floor
37 std::vector<int> elevators; //list of elevators that use this shaft
38 bool InsideShaft; //true if user/camera is in the shaft
39 Real bottom; //shaft base
40 Real top; //shaft top
41 Vector2 cutstart; //cut starting vector
42 Vector2 cutend; //cut ending vector
43 bool IsEnabled; //true if the entire shaft has been enabled
44 int ShowFloors; //determines if floors should be shown while inside the shaft/elevator; 0 is off, 1 shows a portion at a time, 2 shows all in list - floor list in ShowFloorsList
45 bool ShowOutside; //true if outside should be shown while inside the shaft/elevator; floor list in ShowOutsideList
46 bool ShowInterfloors; //true if interfloors should be shown while inside the shaft/elevator
48
49 Shaft(Object *parent, int number, Real CenterX, Real CenterZ, int startfloor, int endfloor);
50 ~Shaft();
51 void EnableWhole(bool value, bool EnableShaftDoors, bool force = false);
52 bool IsInside(const Vector3 &position);
53 void CutFloors(bool relative, const Vector2 &start, const Vector2 &end, Real startvoffset, Real endvoffset);
54 void EnableRange(int floor, int range, bool value, bool EnableShaftDoors);
55 void AddShowFloor(int floor);
56 void RemoveShowFloor(int floor);
57 bool IsShowFloor(int floor);
58 void AddShowOutside(int floor);
59 void RemoveShowOutside(int floor);
60 bool IsShowOutside(int floor);
61 void AddShowInterfloor(int floor);
62 void RemoveShowInterfloor(int floor);
63 bool IsShowInterfloor(int floor);
64 bool IsValidFloor(int floor);
65 void AddElevator(int number);
66 void RemoveElevator(int number);
67 void Report(const std::string &message);
68 bool ReportError(const std::string &message);
69 void ReplaceTexture(const std::string &oldtexture, const std::string &newtexture);
70 void OnInit();
71 void Check(Vector3 position, int current_floor);
72 void Loop();
73 DynamicMesh* GetShaftDoorContainer() { return ShaftDoorContainer; }
74 void SetShowFull(bool value);
75 bool GetShowFull() { return ShowFullShaft; }
76 Level* GetLevel(int floor);
77 DynamicMesh* GetDynamicMesh();
78 DynamicMesh* GetDoorWrapper();
79
80 class SBSIMPEXP Level : public Object
81 {
82 public:
83
84 Level(Shaft *parent, int number);
85 ~Level();
86 Wall* AddWall(const std::string &name, const std::string &texture, Real thickness, Real x1, Real z1, Real x2, Real z2, Real height1, Real height2, Real voffset1, Real voffset2, Real tw, Real th);
87 bool AddWall(Wall *wall, const std::string &name, const std::string &texture, Real thickness, Real x1, Real z1, Real x2, Real z2, Real height1, Real height2, Real voffset1, Real voffset2, Real tw, Real th);
88 Wall* AddFloor(const std::string &name, const std::string &texture, Real thickness, Real x1, Real z1, Real x2, Real z2, Real voffset1, Real voffset2, bool reverse_axis, bool texture_direction, Real tw, Real th, bool legacy_behavior = false);
89 bool AddFloor(Wall *wall, const std::string &name, const std::string &texture, Real thickness, Real x1, Real z1, Real x2, Real z2, Real voffset1, Real voffset2, bool reverse_axis, bool texture_direction, Real tw, Real th, bool legacy_behavior = false);
90 void Enabled(bool value, bool EnableShaftDoors);
91 bool Cut(bool relative, const Vector3 &start, const Vector3 &end, bool cutwalls, bool cutfloors, int checkwallnumber = 0);
92 bool IsEnabled();
93 void RemoveLight(Light *light);
94 void RemoveModel(Model *model);
95 void RemovePrimitive(Primitive *prim);
96 void RemoveCustomObject(CustomObject *object);
97 void RemoveControl(Control *control);
98 void RemoveTrigger(Trigger *trigger);
99 MeshObject* GetMeshObject();
100 Light* AddLight(const std::string &name, int type);
101 Light* GetLight(const std::string &name);
102 Model* AddModel(const std::string &name, const std::string &filename, bool center, Vector3 position, Vector3 rotation, Real max_render_distance = 0, Real scale_multiplier = 1, bool enable_physics = false, Real restitution = 0, Real friction = 0, Real mass = 0);
103 void AddModel(Model *model);
104 Primitive* AddPrimitive(const std::string &name);
105 void AddPrimitive(Primitive *primitive);
106 CustomObject* AddCustomObject(const std::string &name, const Vector3 &position, const Vector3 &rotation, Real max_render_distance = 0, Real scale_multiplier = 1);
107 void AddCustomObject(CustomObject *object);
108 Control* AddControl(const std::string &name, const std::string &sound, const std::string &direction, Real CenterX, Real CenterZ, Real width, Real height, Real voffset, int selection_position, std::vector<std::string> &action_names, std::vector<std::string> &textures);
109 Trigger* AddTrigger(const std::string &name, const std::string &sound_file, Vector3 &area_min, Vector3 &area_max, std::vector<std::string> &action_names);
110 void ReplaceTexture(const std::string &oldtexture, const std::string &newtexture);
111 Door* AddDoor(std::string name, const std::string &open_sound, const std::string &close_sound, bool open_state, const std::string &texture, const std::string &side_texture, Real thickness, const std::string &face_direction, const std::string &open_direction, bool rotate, Real open_speed, Real close_speed, Real CenterX, Real CenterZ, Real width, Real height, Real voffset, Real tw, Real th, Real side_tw, Real side_th);
112 Door* CreateDoor(std::string name, const std::string &open_sound, const std::string &close_sound, bool rotate);
113 Door* GetDoor(const std::string &name);
114 void RemoveDoor(Door *door);
115 Model* GetModel(std::string name);
116 Primitive* GetPrimitive(std::string name);
117 CustomObject* GetCustomObject(std::string name);
118 int GetFloor();
119 void Loop();
120 CameraTexture* AddCameraTexture(const std::string &name, int quality, Real fov, const Vector3 &position, bool use_rotation, const Vector3 &rotation);
121 void RemoveCameraTexture(CameraTexture* camtex);
122
124
125 private:
126 MeshObject* mesh; //level mesh
127
128 //Doors
129 std::vector<Door*> DoorArray;
130
131 //Lights
132 std::vector<Light*> lights;
133
134 //Models
135 std::vector<Model*> ModelArray;
136
137 //Primitives
138 std::vector<Primitive*> PrimArray;
139
140 //custom objects
141 std::vector<CustomObject*> CustomObjectArray;
142
143 //Controls
144 std::vector<Control*> ControlArray;
145
146 //Triggers
147 //std::vector<Trigger*> TriggerArray;
148
149 //CameraTextures
150 std::vector<CameraTexture*> CameraTextureArray;
151
154 };
155
156private:
157 std::vector<Level*> Levels;
158 std::vector<int> ShowFloorsList; //list of floors to enable while inside the shaft/elevator
159 std::vector<int> ShowOutsideList; //list of floors that the outside should be enabled on
160 std::vector<int> ShowInterfloorsList; //list of interfloors to enable while inside the shaft/elevator
161 bool ShowFullShaft; //if true, always show full shaft instead of only a selected range
162
163 //Doors
164 DynamicMesh *DoorWrapper; //door dynamic mesh wrapper
165
166 //mesh container for shaft doors
167 DynamicMesh *ShaftDoorContainer; //shaft door dynamic mesh container
168
169 //cache objects for IsInShaft()
175
176 //dynamic mesh object
178};
179
180}
181
182#endif
std::vector< CustomObject * > CustomObjectArray
Definition shaft.h:141
std::vector< Light * > lights
Definition shaft.h:132
std::vector< Door * > DoorArray
Definition shaft.h:129
std::vector< CameraTexture * > CameraTextureArray
Definition shaft.h:150
std::vector< Control * > ControlArray
Definition shaft.h:144
std::vector< Model * > ModelArray
Definition shaft.h:135
Shaft * parent
Definition shaft.h:153
std::vector< Primitive * > PrimArray
Definition shaft.h:138
MeshObject * mesh
Definition shaft.h:126
int endfloor
Definition shaft.h:36
std::vector< Level * > Levels
Definition shaft.h:157
Vector3 lastposition
Definition shaft.h:170
bool ShowFloorsFull_Enabled
Definition shaft.h:174
Vector2 cutstart
Definition shaft.h:41
std::vector< int > ShowFloorsList
Definition shaft.h:158
DynamicMesh * dynamic_mesh
Definition shaft.h:177
bool checkfirstrun
Definition shaft.h:172
std::vector< int > elevators
Definition shaft.h:37
Real top
Definition shaft.h:40
bool GetShowFull()
Definition shaft.h:75
bool ShowOutside
Definition shaft.h:45
int ShowFloors
Definition shaft.h:44
bool EnableCheck
Definition shaft.h:47
std::vector< int > ShowInterfloorsList
Definition shaft.h:160
Vector2 cutend
Definition shaft.h:42
DynamicMesh * GetShaftDoorContainer()
Definition shaft.h:73
bool ShowInterfloors
Definition shaft.h:46
DynamicMesh * ShaftDoorContainer
Definition shaft.h:167
int ShaftNumber
Definition shaft.h:34
bool ShowFullShaft
Definition shaft.h:161
int startfloor
Definition shaft.h:35
DynamicMesh * DoorWrapper
Definition shaft.h:164
Real bottom
Definition shaft.h:39
bool lastcheckresult
Definition shaft.h:171
std::vector< int > ShowOutsideList
Definition shaft.h:159
bool InsideShaft
Definition shaft.h:38
bool InElevator
Definition shaft.h:173
bool IsEnabled
Definition shaft.h:43
Ogre::Vector3 Vector3
Definition globals.h:58
Ogre::Real Real
Definition globals.h:57
Ogre::Vector2 Vector2
Definition globals.h:59
#define SBSIMPEXP
Definition globals.h:53