69 name =
"Stairwell " +
ToString(number);
91 for (
size_t i = 0; i <
Levels.size(); i++)
114 for (
size_t i = 0; i <
Levels.size(); i++)
116 if (
Levels[i]->GetFloor() == floor)
193 if (position.y > bottom && position.y < top)
231 Real voffset1, voffset2;
248 voffset1 = startvoffset;
250 voffset2 = endvoffset;
252 if (relative ==
true)
255 floorptr->
Cut(
Vector3(start.x, voffset1, start.y),
Vector3(end.x, voffset2, end.y),
false,
true,
false);
270 if (relative ==
true)
294 if (
IsEven(range) ==
true)
297 int additionalfloors;
299 additionalfloors = (range - 1) / 2;
301 additionalfloors = 0;
306 if (floor - additionalfloors - 1 >=
startfloor && floor - additionalfloors - 1 <=
endfloor)
311 if (floor + additionalfloors + 1 >=
startfloor && floor + additionalfloors + 1 <=
endfloor)
319 for (
int i = floor - additionalfloors; i <= floor + additionalfloors; i++)
330 if (floor < startfloor || floor >
endfloor)
353 for (
size_t i = 0; i <
Levels.size(); i++)
427 if (current_floor != previous_floor)
529 for (
size_t i = 0; i < ControlArray.size(); i++)
533 ControlArray[i]->parent_deleting =
true;
534 delete ControlArray[i];
551 for (
size_t i = 0; i < ModelArray.size(); i++)
555 ModelArray[i]->parent_deleting =
true;
556 delete ModelArray[i];
562 for (
size_t i = 0; i < PrimArray.size(); i++)
566 PrimArray[i]->parent_deleting =
true;
573 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
575 if (CustomObjectArray[i])
577 CustomObjectArray[i]->parent_deleting =
true;
578 delete CustomObjectArray[i];
580 CustomObjectArray[i] = 0;
584 for (
size_t i = 0; i < lights.size(); i++)
588 lights[i]->parent_deleting =
true;
595 for (
size_t i = 0; i < DoorArray.size(); i++)
599 DoorArray[i]->parent_deleting =
true;
606 for (
size_t i = 0; i < CameraTextureArray.size(); i++)
608 if (CameraTextureArray[i])
610 CameraTextureArray[i]->parent_deleting =
true;
611 delete CameraTextureArray[i];
613 CameraTextureArray[i] = 0;
621Wall*
Stairwell::Level::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)
634 Wall *wall = mesh->CreateWallObject(name);
636 std::string
Name = name;
638 std::string Direction = direction;
642 if (Direction ==
"right" || Direction ==
"back")
644 if (Direction ==
"left" || Direction ==
"front")
647 for (
int i = 1; i <= num_stairs; i++)
654 if (i < num_stairs - 1)
655 thickness = treadsize * 2;
656 if (i == num_stairs - 1)
657 thickness = treadsize;
661 if (Direction ==
"right")
663 pos = CenterX + ((treadsize * (num_stairs - 1)) / 2) - (treadsize * i);
664 buffer = base +
"-riser";
669 AddWall(wall, buffer, riser_texture, thickness, pos + treadsize, -(width / 2) + CenterZ, pos + treadsize, (width / 2) + CenterZ, risersize, risersize, voffset + (risersize * (i - 1)), voffset + (risersize * (i - 1)), tw, th);
670 buffer = base +
"-tread";
673 sbs->
DrawWalls(
false,
true,
false,
false,
false,
false);
674 AddFloor(wall, buffer, tread_texture, 0, pos, -(width / 2) + CenterZ, pos + treadsize, (width / 2) + CenterZ, voffset + (risersize * i), voffset + (risersize * i),
false,
false, tw, th);
677 if (Direction ==
"left")
679 pos = CenterX - ((treadsize * (num_stairs - 1)) / 2) + (treadsize * i);
680 buffer = base +
"-riser";
685 AddWall(wall, buffer, riser_texture, thickness, pos - treadsize, (width / 2) + CenterZ, pos - treadsize, -(width / 2) + CenterZ, risersize, risersize, voffset + (risersize * (i - 1)), voffset + (risersize * (i - 1)), tw, th);
686 buffer = base +
"-tread";
689 sbs->
DrawWalls(
false,
true,
false,
false,
false,
false);
690 AddFloor(wall, buffer, tread_texture, 0, pos - treadsize, -(width / 2) + CenterZ, pos, (width / 2) + CenterZ, voffset + (risersize * i), voffset + (risersize * i),
false,
false, tw, th);
693 if (Direction ==
"back")
695 pos = CenterZ + ((treadsize * (num_stairs - 1)) / 2) - (treadsize * i);
696 buffer = base +
"-riser";
701 AddWall(wall, buffer, riser_texture, thickness, (width / 2) + CenterX, pos + treadsize, -(width / 2) + CenterX, pos + treadsize, risersize, risersize, voffset + (risersize * (i - 1)), voffset + (risersize * (i - 1)), tw, th);
702 buffer = base +
"-tread";
705 sbs->
DrawWalls(
false,
true,
false,
false,
false,
false);
706 AddFloor(wall, buffer, tread_texture, 0, -(width / 2) + CenterX, pos, (width / 2) + CenterX, pos + treadsize, voffset + (risersize * i), voffset + (risersize * i),
false,
false, tw, th);
709 if (Direction ==
"front")
711 pos = CenterZ - ((treadsize * (num_stairs - 1)) / 2) + (treadsize * i);
712 buffer = base +
"-riser";
717 AddWall(wall, buffer, riser_texture, thickness, -(width / 2) + CenterX, pos - treadsize, (width / 2) + CenterX, pos - treadsize, risersize, risersize, voffset + (risersize * (i - 1)), voffset + (risersize * (i - 1)), tw, th);
718 buffer = base +
"-tread";
721 sbs->
DrawWalls(
false,
true,
false,
false,
false,
false);
722 AddFloor(wall, buffer, tread_texture, 0, -(width / 2) + CenterX, pos - treadsize, (width / 2) + CenterX, pos, voffset + (risersize * i), voffset + (risersize * i),
false,
false, tw, th);
732Wall*
Stairwell::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)
741 Wall *wall = mesh->CreateWallObject(name);
742 AddWall(wall, name, texture, thickness, x1, z1, x2, z2, height1, height2, voffset1, voffset2, tw, th);
746bool Stairwell::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)
752 return sbs->
AddWallMain(wall, name, texture, thickness, x1, z1, x2, z2, height1, height2, voffset1, voffset2, tw, th,
true);
755Wall*
Stairwell::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)
764 Wall *wall = mesh->CreateWallObject(name);
765 AddFloor(wall, name, texture, thickness, x1, z1, x2, z2, voffset1, voffset2, reverse_axis, texture_direction, tw, th, legacy_behavior);
769bool Stairwell::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)
775 return sbs->
AddFloorMain(wall, name, texture, thickness, x1, z1, x2, z2, voffset1, voffset2, reverse_axis, texture_direction, tw, th,
true, legacy_behavior);
785 mesh->Enabled(value);
789 for (
size_t i = 0; i < DoorArray.size(); i++)
792 DoorArray[i]->Enabled(value);
796 for (
size_t i = 0; i < ControlArray.size(); i++)
799 ControlArray[i]->Enabled(value);
810 for (
size_t i = 0; i < ModelArray.size(); i++)
813 ModelArray[i]->Enabled(value);
817 for (
size_t i = 0; i < PrimArray.size(); i++)
820 PrimArray[i]->Enabled(value);
824 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
826 if (CustomObjectArray[i])
827 CustomObjectArray[i]->Enabled(value);
831 for (
size_t i = 0; i < lights.size(); i++)
834 lights[i]->Enabled(value);
839Door*
Stairwell::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)
856 if (face_direction ==
"left" || face_direction ==
"right")
860 z1 = CenterZ - (width / 2);
861 z2 = CenterZ + (width / 2);
865 x1 = CenterX - (width / 2);
866 x2 = CenterX + (width / 2);
873 if (face_direction ==
"left" || face_direction ==
"right")
875 Cut(1,
Vector3(x1 - 0.5, voffset, z1),
Vector3(x2 + 0.5, voffset + height, z2),
true,
false, 1);
880 Cut(1,
Vector3(x1, voffset, z1 - 0.5),
Vector3(x2, voffset + height, z2 + 0.5),
true,
false, 1);
887 std::string num =
ToString((
int)DoorArray.size());
889 name =
"Door " + num;
891 Door* door =
new Door(
this, parent->DoorWrapper, name, open_sound, close_sound, rotate);
892 door->
CreateDoor(open_state, texture, side_texture, thickness, face_direction, open_direction, open_speed, close_speed, CenterX, CenterZ, width, height, voffset, tw, th, side_tw, side_th);
893 DoorArray.emplace_back(door);
904 std::string num =
ToString((
int)DoorArray.size());
906 name =
"Door " + num;
908 Door* door =
new Door(
this, parent->DoorWrapper, name, open_sound, close_sound, rotate);
909 DoorArray.emplace_back(door);
915 for (
size_t i = 0; i < DoorArray.size(); i++)
917 if (DoorArray[i]->
GetName() == name)
941 for (
size_t i = 0; i < mesh->Walls.size(); i++)
950 if (relative ==
true)
951 sbs->
GetUtility()->
Cut(mesh->Walls[i],
Vector3(start.x, start.y, start.z),
Vector3(end.x, end.y, end.z), cutwalls, cutfloors, checkwallnumber, reset);
953 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);
967 for (
size_t i = 0; i < DoorArray.size(); i++)
969 if (DoorArray[i] == door)
971 DoorArray.erase(DoorArray.begin() + i);
980 for (
size_t i = 0; i < lights.size(); i++)
982 if (lights[i] == light)
984 lights.erase(lights.begin() + i);
993 for (
size_t i = 0; i < ModelArray.size(); i++)
995 if (ModelArray[i] == model)
997 ModelArray.erase(ModelArray.begin() + i);
1006 for (
size_t i = 0; i < PrimArray.size(); i++)
1008 if (PrimArray[i] == prim)
1010 PrimArray.erase(PrimArray.begin() + i);
1019 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
1021 if (CustomObjectArray[i] ==
object)
1023 CustomObjectArray.erase(CustomObjectArray.begin() + i);
1032 for (
size_t i = 0; i < ControlArray.size(); i++)
1034 if (ControlArray[i] == control)
1036 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)
1081Model*
Stairwell::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)
1085 Model* model =
new Model(mesh, name, filename, center, position, rotation, max_render_distance, scale_multiplier, enable_physics, restitution, friction, mass);
1091 ModelArray.emplace_back(model);
1102 for (
size_t i = 0; i < ModelArray.size(); i++)
1104 if (ModelArray[i] == model)
1108 ModelArray.emplace_back(model);
1115 PrimArray.emplace_back(prim);
1126 for (
size_t i = 0; i < PrimArray.size(); i++)
1128 if (PrimArray[i] == primitive)
1132 PrimArray.emplace_back(primitive);
1139 CustomObjectArray.emplace_back(
object);
1150 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
1152 if (CustomObjectArray[i] ==
object)
1156 CustomObjectArray.emplace_back(
object);
1160Control*
Stairwell::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)
1164 std::vector<Action*> actionnull;
1165 Control* control =
new Control(mesh, name,
false, sound, action_names, actionnull, textures, direction, width, height,
true, selection_position);
1166 control->
Move(CenterX, voffset, CenterZ);
1167 ControlArray.emplace_back(control);
1193 for (
size_t i = 0; i < ModelArray.size(); i++)
1196 return ModelArray[i];
1208 for (
size_t i = 0; i < PrimArray.size(); i++)
1211 return PrimArray[i];
1223 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
1226 return CustomObjectArray[i];
1234 mesh->ReplaceTexture(oldtexture, newtexture);
1253 CameraTextureArray.emplace_back(cameratexture);
1254 return cameratexture;
1260 for (
size_t i = 0; i < CameraTextureArray.size(); i++)
1262 if (CameraTextureArray[i] == camtex)
1264 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)
bool IsInGroup(int floor)
void Cut(const Vector3 &start, const Vector3 &end, bool cutwalls, bool cutfloors, bool fast, int checkwallnumber=0, bool prepare=false)
Real GetBase(bool relative=false)
void EnableGroup(bool value)
std::vector< Wall * > Walls
Real HitBeam(const Vector3 &origin, const Vector3 &direction, Real max_distance)
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)
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)
void RemoveStairwell(Stairwell *stairs)
int StairsOutsideDisplayRange
void ResetWalls(bool ToDefaults=false)
Floor * GetFloor(int number)
TextureManager * GetTextureManager()
int GetFloorNumber(Real altitude, int lastfloor=0, bool checklastfloor=false)
bool SetWallOrientation(std::string direction)
void DrawWalls(bool MainN, bool MainP, bool SideN, bool SideP, bool Top, bool Bottom)
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)
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)
Primitive * GetPrimitive(std::string name)
MeshObject * GetMeshObject()
CustomObject * GetCustomObject(std::string name)
Model * GetModel(std::string name)
void RemoveLight(Light *light)
Primitive * AddPrimitive(const std::string &name)
Light * GetLight(const std::string &name)
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)
void RemoveCustomObject(CustomObject *object)
Level(Stairwell *parent, int number)
void RemoveModel(Model *model)
void RemoveDoor(Door *door)
void RemovePrimitive(Primitive *prim)
void ReplaceTexture(const std::string &oldtexture, const std::string &newtexture)
void RemoveCameraTexture(CameraTexture *camtex)
bool Cut(bool relative, const Vector3 &start, const Vector3 &end, bool cutwalls, bool cutfloors, int checkwallnumber=0)
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)
CameraTexture * AddCameraTexture(const std::string &name, int quality, Real fov, const Vector3 &position, bool use_rotation, const Vector3 &rotation)
void RemoveTrigger(Trigger *trigger)
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)
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)
CustomObject * AddCustomObject(const std::string &name, const Vector3 &position, const Vector3 &rotation, Real max_render_distance=0, Real scale_multiplier=1)
Light * AddLight(const std::string &name, int type)
Trigger * AddTrigger(const std::string &name, const std::string &sound_file, Vector3 &area_min, Vector3 &area_max, std::vector< std::string > &action_names)
Door * CreateDoor(std::string name, const std::string &open_sound, const std::string &close_sound, bool rotate)
Door * GetDoor(const std::string &name)
void RemoveControl(Control *control)
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)
DynamicMesh * DoorWrapper
void CutFloors(bool relative, const Vector2 &start, const Vector2 &end, Real startvoffset, Real endvoffset)
void AddShowFloor(int floor)
bool ReportError(const std::string &message)
void RemoveShowFloor(int floor)
void Report(const std::string &message)
void EnableRange(int floor, int range, bool value)
bool IsValidFloor(int floor)
DynamicMesh * GetDynamicMesh()
bool IsShowFloor(int floor)
void Check(Vector3 position, int current_floor, int previous_floor)
std::vector< int > ShowFloorsList
Stairwell(Object *parent, int number, Real CenterX, Real CenterZ, int startfloor, int endfloor)
bool IsInside(const Vector3 &position)
void ReplaceTexture(const std::string &oldtexture, const std::string &newtexture)
DynamicMesh * dynamic_mesh
std::vector< Level * > Levels
void EnableWhole(bool value, bool force=false)
void SetShowFull(int value)
Level * GetLevel(int floor)
void ResetTextureMapping(bool todefaults=false)
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)
void TrimString(std::string &string)
#define SBS_PROFILE(name)