82 std::string name =
"Shaft " +
ToString(number);
110 for (
size_t i = 0; i <
Levels.size(); i++)
137 for (
size_t i = 0; i <
Levels.size(); i++)
139 if (
Levels[i]->GetFloor() == floor)
188 if (
Levels[0]->GetMeshObject()->InBoundingBox(position,
false) ==
true)
191 bool result = (
Levels[0]->GetMeshObject()->HitBeam(position, Vector3::NEGATIVE_UNIT_Y, position.y - (
bottom - 1)) >= 0);
214 Real voffset1, voffset2;
216 if (relative ==
true)
240 voffset1 = startvoffset;
242 voffset2 = endvoffset;
244 if (relative ==
true)
247 floorptr->
Cut(
Vector3(start.x, voffset1, start.y),
Vector3(end.x, voffset2, end.y),
false,
true,
false);
262 if (relative ==
true)
290 if (
IsEven(range) ==
true)
293 int additionalfloors;
295 additionalfloors = (range - 1) / 2;
297 additionalfloors = 0;
302 if (floor - additionalfloors - 1 >=
startfloor && floor - additionalfloors - 1 <=
endfloor)
305 GetLevel(floor - additionalfloors - 1)->
Enabled(
false, EnableShaftDoors);
307 if (floor + additionalfloors + 1 >=
startfloor && floor + additionalfloors + 1 <=
endfloor)
310 GetLevel(floor + additionalfloors + 1)->
Enabled(
false, EnableShaftDoors);
315 for (
int i = floor - additionalfloors; i <= floor + additionalfloors; i++)
437 if (floor < startfloor || floor >
endfloor)
450 for (
size_t i = 0; i <
elevators.size(); i++)
463 for (
size_t i = 0; i <
elevators.size(); i++)
487 for (
size_t i = 0; i <
Levels.size(); i++)
697 for (
size_t i = 0; i < ControlArray.size(); i++)
701 ControlArray[i]->parent_deleting =
true;
702 delete ControlArray[i];
719 for (
size_t i = 0; i < ModelArray.size(); i++)
723 ModelArray[i]->parent_deleting =
true;
724 delete ModelArray[i];
730 for (
size_t i = 0; i < PrimArray.size(); i++)
734 PrimArray[i]->parent_deleting =
true;
741 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
743 if (CustomObjectArray[i])
745 CustomObjectArray[i]->parent_deleting =
true;
746 delete CustomObjectArray[i];
748 CustomObjectArray[i] = 0;
752 for (
size_t i = 0; i < lights.size(); i++)
756 lights[i]->parent_deleting =
true;
763 for (
size_t i = 0; i < DoorArray.size(); i++)
767 DoorArray[i]->parent_deleting =
true;
774 for (
size_t i = 0; i < CameraTextureArray.size(); i++)
776 if (CameraTextureArray[i])
778 CameraTextureArray[i]->parent_deleting =
true;
779 delete CameraTextureArray[i];
781 CameraTextureArray[i] = 0;
789Wall*
Shaft::Level::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)
798 Wall *wall = mesh->CreateWallObject(name);
799 AddWall(wall, name, texture, thickness, x1, z1, x2, z2, height1, height2, voffset1, voffset2, tw, th);
803bool Shaft::Level::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)
809 return sbs->
AddWallMain(wall, name, texture, thickness, x1, z1, x2, z2, height1, height2, voffset1, voffset2, tw, th,
true);
812Wall*
Shaft::Level::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)
821 Wall *wall = mesh->CreateWallObject(name);
822 AddFloor(wall, name, texture, thickness, x1, z1, x2, z2, voffset1, voffset2, reverse_axis, texture_direction, tw, th, legacy_behavior);
826bool Shaft::Level::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)
836 if (altitude + voffset1 < parent->
bottom)
837 parent->bottom = altitude + voffset1;
838 if (altitude + voffset2 < parent->
bottom)
839 parent->bottom = altitude + voffset2;
840 if (altitude + voffset1 > parent->top)
841 parent->top = altitude + voffset1;
842 if (altitude + voffset2 > parent->top)
843 parent->top = altitude + voffset2;
845 return sbs->
AddFloorMain(wall, name, texture, thickness, x1, z1, x2, z2, voffset1, voffset2, reverse_axis, texture_direction, tw, th,
true, legacy_behavior);
851 if (
IsEnabled() != value && parent->EnableCheck ==
false)
855 mesh->Enabled(value);
859 for (
size_t i = 0; i < DoorArray.size(); i++)
862 DoorArray[i]->Enabled(value);
866 for (
size_t i = 0; i < ControlArray.size(); i++)
869 ControlArray[i]->Enabled(value);
880 for (
size_t i = 0; i < ModelArray.size(); i++)
883 ModelArray[i]->Enabled(value);
887 for (
size_t i = 0; i < PrimArray.size(); i++)
890 PrimArray[i]->Enabled(value);
894 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
896 if (CustomObjectArray[i])
897 CustomObjectArray[i]->Enabled(value);
901 for (
size_t i = 0; i < lights.size(); i++)
904 lights[i]->Enabled(value);
907 if (EnableShaftDoors ==
true)
909 for (
size_t i = 0; i < parent->elevators.size(); i++)
914 for (
size_t j = 1; j <= elevator->
GetCarCount(); j++)
948 for (
size_t i = 0; i < mesh->Walls.size(); i++)
957 if (relative ==
true)
958 sbs->
GetUtility()->
Cut(mesh->Walls[i],
Vector3(start.x, start.y, start.z),
Vector3(end.x, end.y, end.z), cutwalls, cutfloors, checkwallnumber, reset);
960 sbs->
GetUtility()->
Cut(mesh->Walls[i],
Vector3(start.x -
GetPosition().x, start.y, start.z -
GetPosition().z),
Vector3(end.x -
GetPosition().x, end.y, end.z -
GetPosition().z), cutwalls, cutfloors, checkwallnumber, reset);
973 for (
size_t i = 0; i < lights.size(); i++)
975 if (lights[i] == light)
977 lights.erase(lights.begin() + i);
986 for (
size_t i = 0; i < ModelArray.size(); i++)
988 if (ModelArray[i] == model)
990 ModelArray.erase(ModelArray.begin() + i);
999 for (
size_t i = 0; i < PrimArray.size(); i++)
1001 if (PrimArray[i] == prim)
1003 PrimArray.erase(PrimArray.begin() + i);
1012 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
1014 if (CustomObjectArray[i] ==
object)
1016 CustomObjectArray.erase(CustomObjectArray.begin() + i);
1025 for (
size_t i = 0; i < ControlArray.size(); i++)
1027 if (ControlArray[i] == control)
1029 ControlArray.erase(ControlArray.begin() + i);
1060 lights.emplace_back(light);
1066 for (
size_t i = 0; i < lights.size(); i++)
1068 if (lights[i]->
GetName() == name)
1074Model*
Shaft::Level::AddModel(
const std::string &name,
const std::string &filename,
bool center,
Vector3 position,
Vector3 rotation,
Real max_render_distance,
Real scale_multiplier,
bool enable_physics,
Real restitution,
Real friction,
Real mass)
1078 Model* model =
new Model(mesh, name, filename, center, position, rotation, max_render_distance, scale_multiplier, enable_physics, restitution, friction, mass);
1084 ModelArray.emplace_back(model);
1095 for (
size_t i = 0; i < ModelArray.size(); i++)
1097 if (ModelArray[i] == model)
1101 ModelArray.emplace_back(model);
1108 PrimArray.emplace_back(prim);
1119 for (
size_t i = 0; i < PrimArray.size(); i++)
1121 if (PrimArray[i] == primitive)
1125 PrimArray.emplace_back(primitive);
1132 CustomObjectArray.emplace_back(
object);
1143 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
1145 if (CustomObjectArray[i] ==
object)
1149 CustomObjectArray.emplace_back(
object);
1152Control*
Shaft::Level::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)
1156 std::vector<Action*> actionnull;
1157 Control* control =
new Control(mesh, name,
false, sound, action_names, actionnull, textures, direction, width, height,
true, selection_position);
1158 control->
Move(CenterX, voffset, CenterZ);
1159 ControlArray.emplace_back(control);
1185 for (
size_t i = 0; i < ModelArray.size(); i++)
1188 return ModelArray[i];
1200 for (
size_t i = 0; i < PrimArray.size(); i++)
1203 return PrimArray[i];
1215 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
1218 return CustomObjectArray[i];
1226 mesh->ReplaceTexture(oldtexture, newtexture);
1241Door*
Shaft::Level::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)
1257 Real x1, z1, x2, z2;
1258 if (face_direction ==
"left" || face_direction ==
"right")
1262 z1 = CenterZ - (width / 2);
1263 z2 = CenterZ + (width / 2);
1267 x1 = CenterX - (width / 2);
1268 x2 = CenterX + (width / 2);
1275 if (face_direction ==
"left" || face_direction ==
"right")
1277 Cut(1,
Vector3(x1 - 0.5, voffset, z1),
Vector3(x2 + 0.5, voffset + height, z2),
true,
false, 1);
1282 Cut(1,
Vector3(x1, voffset, z1 - 0.5),
Vector3(x2, voffset + height, z2 + 0.5),
true,
false, 1);
1289 std::string num =
ToString((
int)DoorArray.size());
1291 name =
"Door " + num;
1293 Door* door =
new Door(
this, parent->GetDoorWrapper(), name, open_sound, close_sound, rotate);
1294 door->
CreateDoor(open_state, texture, side_texture, thickness, face_direction, open_direction, open_speed, close_speed, CenterX, CenterZ, width, height, floorptr->
GetBase(
true) + voffset, tw, th, side_tw, side_th);
1295 DoorArray.emplace_back(door);
1306 std::string num =
ToString((
int)DoorArray.size());
1308 name =
"Door " + num;
1310 Door* door =
new Door(
this, parent->GetDoorWrapper(), name, open_sound, close_sound, rotate);
1311 DoorArray.emplace_back(door);
1317 for (
size_t i = 0; i < DoorArray.size(); i++)
1319 if (DoorArray[i]->
GetName() == name)
1320 return DoorArray[i];
1328 for (
size_t i = 0; i < DoorArray.size(); i++)
1330 if (DoorArray[i] == door)
1332 DoorArray.erase(DoorArray.begin() + i);
1342 CameraTextureArray.emplace_back(cameratexture);
1343 return cameratexture;
1349 for (
size_t i = 0; i < CameraTextureArray.size(); i++)
1351 if (CameraTextureArray[i] == camtex)
1353 CameraTextureArray.erase(CameraTextureArray.begin() + i);
DoorWrapper * CreateDoor(bool open_state, const std::string &texture, const std::string &side_texture, Real thickness, const std::string &face_direction, const std::string &open_direction, 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)
void Enabled(bool value, MeshObject *client=0)
void ShaftDoorsEnabled(int number, int floor, bool value)
std::vector< int > ServicedFloors
void ShaftDoorsEnabledRange(int number, int floor, int range)
ElevatorCar * GetCar(int number)
bool IsInGroup(int floor)
void Cut(const Vector3 &start, const Vector3 &end, bool cutwalls, bool cutfloors, bool fast, int checkwallnumber=0, bool prepare=false)
void EnableInterfloor(bool value)
Real GetBase(bool relative=false)
std::vector< Wall * > Walls
const std::string & GetName()
virtual bool ReportError(const std::string &message)
virtual void Report(const std::string &message)
void SetName(const std::string &name)
virtual void Move(const Vector3 &vector, Real speed=1.0)
virtual void SetPositionY(Real value)
virtual Vector3 GetPosition(bool relative=false)
SceneNode * GetSceneNode()
void SetValues(const std::string &type, const std::string &name, bool is_permanent, bool is_movable=true)
void EnableLoop(bool value)
virtual void SetPosition(const Vector3 &position)
Elevator * GetElevator(int number)
void EnableBuildings(bool value)
void RemoveShaft(Shaft *shaft)
bool AddWallMain(Wall *wallobject, const std::string &name, const std::string &texture, Real thickness, Real x1, Real z1, Real x2, Real z2, Real height_in1, Real height_in2, Real altitude1, Real altitude2, Real tw, Real th, bool autosize)
Floor * GetFloor(int number)
int ShaftOutsideDisplayRange
void EnableLandscape(bool value)
void EnableSkybox(bool value)
void EnableExternal(bool value)
void EnableFloorRange(int floor, int range, bool value, bool enablegroups, int shaftnumber=0, int stairsnumber=0)
bool AddFloorMain(Wall *wallobject, const std::string &name, const std::string &texture, Real thickness, Real x1, Real z1, Real x2, Real z2, Real altitude1, Real altitude2, bool reverse_axis, bool texture_direction, Real tw, Real th, bool autosize, bool legacy_behavior=false)
void RemoveCustomObject(CustomObject *object)
Door * GetDoor(const std::string &name)
Primitive * GetPrimitive(std::string name)
CustomObject * AddCustomObject(const std::string &name, const Vector3 &position, const Vector3 &rotation, Real max_render_distance=0, Real scale_multiplier=1)
void Enabled(bool value, bool EnableShaftDoors)
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)
CustomObject * GetCustomObject(std::string name)
void RemovePrimitive(Primitive *prim)
Model * GetModel(std::string name)
Primitive * AddPrimitive(const std::string &name)
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)
void RemoveCameraTexture(CameraTexture *camtex)
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)
Trigger * AddTrigger(const std::string &name, const std::string &sound_file, Vector3 &area_min, Vector3 &area_max, std::vector< std::string > &action_names)
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)
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)
void RemoveLight(Light *light)
Light * AddLight(const std::string &name, int type)
Level(Shaft *parent, int number)
void RemoveModel(Model *model)
void RemoveControl(Control *control)
void ReplaceTexture(const std::string &oldtexture, const std::string &newtexture)
Light * GetLight(const std::string &name)
bool Cut(bool relative, const Vector3 &start, const Vector3 &end, bool cutwalls, bool cutfloors, int checkwallnumber=0)
void RemoveDoor(Door *door)
Door * CreateDoor(std::string name, const std::string &open_sound, const std::string &close_sound, bool rotate)
MeshObject * GetMeshObject()
CameraTexture * AddCameraTexture(const std::string &name, int quality, Real fov, const Vector3 &position, bool use_rotation, const Vector3 &rotation)
void RemoveTrigger(Trigger *trigger)
Shaft(Object *parent, int number, Real CenterX, Real CenterZ, int startfloor, int endfloor)
bool IsInside(const Vector3 &position)
DynamicMesh * GetDynamicMesh()
void AddShowInterfloor(int floor)
std::vector< Level * > Levels
bool ShowFloorsFull_Enabled
void AddElevator(int number)
void RemoveElevator(int number)
std::vector< int > ShowFloorsList
void RemoveShowOutside(int floor)
void Report(const std::string &message)
DynamicMesh * dynamic_mesh
void RemoveShowInterfloor(int floor)
bool IsShowOutside(int floor)
bool IsShowInterfloor(int floor)
std::vector< int > elevators
void EnableWhole(bool value, bool EnableShaftDoors, bool force=false)
void CutFloors(bool relative, const Vector2 &start, const Vector2 &end, Real startvoffset, Real endvoffset)
void ReplaceTexture(const std::string &oldtexture, const std::string &newtexture)
DynamicMesh * GetDoorWrapper()
void RemoveShowFloor(int floor)
void SetShowFull(bool value)
std::vector< int > ShowInterfloorsList
void Check(Vector3 position, int current_floor)
bool IsShowFloor(int floor)
bool IsValidFloor(int floor)
bool ReportError(const std::string &message)
void AddShowFloor(int floor)
DynamicMesh * ShaftDoorContainer
DynamicMesh * DoorWrapper
void EnableRange(int floor, int range, bool value, bool EnableShaftDoors)
std::vector< int > ShowOutsideList
void AddShowOutside(int floor)
Level * GetLevel(int floor)
Wall * AddDoorwayWalls(MeshObject *mesh, const std::string &wallname, const std::string &texture, Real tw, Real th)
void Cut(Wall *wall, Vector3 start, Vector3 end, bool cutwalls, bool cutfloors, int checkwallnumber=0, bool reset_check=true)
std::string TruncateNumber(float value, int decimals)
void SetCase(std::string &string, bool uppercase)
std::string ToString(int number)
std::string SetCaseCopy(std::string string, bool uppercase)
#define SBS_PROFILE(name)