Skyscraper 2.0
stairs.h
Go to the documentation of this file.
1/*
2 Scalable Building Simulator - Stairwell 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_STAIRS_H
25#define _SBS_STAIRS_H
26
27namespace SBS {
28
30{
31public:
32 class Level;
33
34 int StairsNum; //number
35 int startfloor; //starting floor
36 int endfloor; //ending floor
37 Vector2 cutstart; //cut starting vector
38 Vector2 cutend; //cut ending vector
39 bool Inside; //true if user/camera is in the stairwell
40 bool IsEnabled; //true if the entire stairwell has been enabled
41 bool ShowFloors; //true if floors should be shown while inside the stairwell; floor list in ShowFloorsList
42 int ShowFullStairs; //if 1, always show full stairwell while inside instead of only a selected range, and always show whole stairwell if 2
43
44 Stairwell(Object *parent, int number, Real CenterX, Real CenterZ, int startfloor, int endfloor);
45 ~Stairwell();
46 void EnableWhole(bool value, bool force = false);
47 bool IsInside(const Vector3 &position);
48 void CutFloors(bool relative, const Vector2 &start, const Vector2 &end, Real startvoffset, Real endvoffset);
49 void EnableRange(int floor, int range, bool value);
50 void Report(const std::string &message);
51 bool ReportError(const std::string &message);
52 void ReplaceTexture(const std::string &oldtexture, const std::string &newtexture);
53 void OnInit();
54 void AddShowFloor(int floor);
55 void RemoveShowFloor(int floor);
56 bool IsShowFloor(int floor);
57 void Check(Vector3 position, int current_floor, int previous_floor);
58 void Loop();
59 void SetShowFull(int value);
60 Level* GetLevel(int floor);
61 bool IsValidFloor(int floor);
62 DynamicMesh* GetDynamicMesh();
63
64 class SBSIMPEXP Level : public Object
65 {
66 public:
67 Level(Stairwell *parent, int number);
68 ~Level();
69 Wall* AddStairs(const std::string &name, const std::string &riser_texture, const std::string &tread_texture, const std::string &direction, Real CenterX, Real CenterZ, Real width, Real risersize, Real treadsize, int num_stairs, Real voffset, Real tw, Real th);
70 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);
71 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);
72 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);
73 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);
74 void Enabled(bool value);
75 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);
76 Door* CreateDoor(std::string name, const std::string &open_sound, const std::string &close_sound, bool rotate);
77 Door* GetDoor(const std::string &name);
78 bool Cut(bool relative, const Vector3 &start, const Vector3 &end, bool cutwalls, bool cutfloors, int checkwallnumber = 0);
79 bool IsEnabled();
80 void RemoveDoor(Door *door);
81 void RemoveLight(Light *light);
82 void RemoveModel(Model *model);
83 void RemovePrimitive(Primitive *prim);
84 void RemoveCustomObject(CustomObject *object);
85 void RemoveControl(Control *control);
86 void RemoveTrigger(Trigger *trigger);
87 Light* AddLight(const std::string &name, int type);
88 Light* GetLight(const std::string &name);
89 MeshObject* GetMeshObject();
90 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);
91 void AddModel(Model *model);
92 Primitive* AddPrimitive(const std::string &name);
93 void AddPrimitive(Primitive *primitive);
94 CustomObject* AddCustomObject(const std::string &name, const Vector3 &position, const Vector3 &rotation, Real max_render_distance = 0, Real scale_multiplier = 1);
95 void AddCustomObject(CustomObject *object);
96 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);
97 Trigger* AddTrigger(const std::string &name, const std::string &sound_file, Vector3 &area_min, Vector3 &area_max, std::vector<std::string> &action_names);
98 Model* GetModel(std::string name);
99 Primitive* GetPrimitive(std::string name);
100 CustomObject* GetCustomObject(std::string name);
101 void ReplaceTexture(const std::string &oldtexture, const std::string &newtexture);
102 int GetFloor();
103 void Loop();
104 CameraTexture* AddCameraTexture(const std::string &name, int quality, Real fov, const Vector3 &position, bool use_rotation, const Vector3 &rotation);
105 void RemoveCameraTexture(CameraTexture* camtex);
106
108
109 private:
110 MeshObject* mesh; //level mesh
111
112 //Doors
113 std::vector<Door*> DoorArray;
114
115 //Lights
116 std::vector<Light*> lights;
117
118 //Models
119 std::vector<Model*> ModelArray;
120
121 //Primitives
122 std::vector<Primitive*> PrimArray;
123
124 //custom objects
125 std::vector<CustomObject*> CustomObjectArray;
126
127 //Controls
128 std::vector<Control*> ControlArray;
129
130 //Triggers
131 //std::vector<Trigger*> TriggerArray
132
133 //CameraTextures
134 std::vector<CameraTexture*> CameraTextureArray;
135
138 };
139
140private:
141 std::vector<Level*> Levels;
142 std::vector<int> ShowFloorsList; //list of floors to enable while inside the stairwell
143
146
147 //Doors
148 DynamicMesh *DoorWrapper; //door dynamic mesh wrapper
149
150 //dynamic mesh object
152
153 //cache objects for IsInStairwell()
157};
158
159}
160
161#endif
std::vector< Door * > DoorArray
Definition stairs.h:113
MeshObject * mesh
Definition stairs.h:110
std::vector< Light * > lights
Definition stairs.h:116
Stairwell * parent
Definition stairs.h:137
std::vector< Primitive * > PrimArray
Definition stairs.h:122
std::vector< Control * > ControlArray
Definition stairs.h:128
std::vector< CameraTexture * > CameraTextureArray
Definition stairs.h:134
std::vector< Model * > ModelArray
Definition stairs.h:119
std::vector< CustomObject * > CustomObjectArray
Definition stairs.h:125
bool lastcheckresult
Definition stairs.h:155
DynamicMesh * DoorWrapper
Definition stairs.h:148
bool ShowFloors
Definition stairs.h:41
int ShowFullStairs
Definition stairs.h:42
int StairsNum
Definition stairs.h:34
bool IsEnabled
Definition stairs.h:40
int startfloor
Definition stairs.h:35
bool lastfloorset
Definition stairs.h:145
std::vector< int > ShowFloorsList
Definition stairs.h:142
bool checkfirstrun
Definition stairs.h:156
Vector3 lastposition
Definition stairs.h:154
DynamicMesh * dynamic_mesh
Definition stairs.h:151
std::vector< Level * > Levels
Definition stairs.h:141
Vector2 cutend
Definition stairs.h:38
Vector2 cutstart
Definition stairs.h:37
bool Inside
Definition stairs.h:39
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