70 name =
"Stairwell " +
ToString(number);
92 for (
size_t i = 0; i <
Levels.size(); i++)
115 for (
size_t i = 0; i <
Levels.size(); i++)
117 if (
Levels[i]->GetFloor() == floor)
194 if (position.y > bottom && position.y < top)
232 Real voffset1, voffset2;
249 voffset1 = startvoffset;
251 voffset2 = endvoffset;
253 if (relative ==
true)
256 floorptr->
Cut(
Vector3(start.x, voffset1, start.y),
Vector3(end.x, voffset2, end.y),
false,
true,
false);
271 if (relative ==
true)
295 if (
IsEven(range) ==
true)
298 int additionalfloors;
300 additionalfloors = (range - 1) / 2;
302 additionalfloors = 0;
307 if (floor - additionalfloors - 1 >=
startfloor && floor - additionalfloors - 1 <=
endfloor)
312 if (floor + additionalfloors + 1 >=
startfloor && floor + additionalfloors + 1 <=
endfloor)
320 for (
int i = floor - additionalfloors; i <= floor + additionalfloors; i++)
331 if (floor < startfloor || floor >
endfloor)
354 for (
size_t i = 0; i <
Levels.size(); i++)
428 if (current_floor != previous_floor)
530 for (
size_t i = 0; i < ControlArray.size(); i++)
534 ControlArray[i]->parent_deleting =
true;
535 delete ControlArray[i];
541 for (
size_t i = 0; i < TriggerArray.size(); i++)
545 TriggerArray[i]->parent_deleting =
true;
546 delete TriggerArray[i];
552 for (
size_t i = 0; i < ModelArray.size(); i++)
556 ModelArray[i]->parent_deleting =
true;
557 delete ModelArray[i];
563 for (
size_t i = 0; i < PrimArray.size(); i++)
567 PrimArray[i]->parent_deleting =
true;
574 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
576 if (CustomObjectArray[i])
578 CustomObjectArray[i]->parent_deleting =
true;
579 delete CustomObjectArray[i];
581 CustomObjectArray[i] = 0;
585 for (
size_t i = 0; i < lights.size(); i++)
589 lights[i]->parent_deleting =
true;
596 for (
size_t i = 0; i < DoorArray.size(); i++)
600 DoorArray[i]->parent_deleting =
true;
607 for (
size_t i = 0; i < CameraTextureArray.size(); i++)
609 if (CameraTextureArray[i])
611 CameraTextureArray[i]->parent_deleting =
true;
612 delete CameraTextureArray[i];
614 CameraTextureArray[i] = 0;
622Wall*
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)
635 Wall *wall = mesh->CreateWallObject(name);
637 std::string
Name = name;
639 std::string Direction = direction;
643 if (Direction ==
"right" || Direction ==
"back")
645 if (Direction ==
"left" || Direction ==
"front")
648 for (
int i = 1; i <= num_stairs; i++)
655 if (i < num_stairs - 1)
656 thickness = treadsize * 2;
657 if (i == num_stairs - 1)
658 thickness = treadsize;
662 if (Direction ==
"right")
664 pos = CenterX + ((treadsize * (num_stairs - 1)) / 2) - (treadsize * i);
665 buffer = base +
"-riser";
670 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);
671 buffer = base +
"-tread";
674 sbs->
DrawWalls(
false,
true,
false,
false,
false,
false);
675 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);
678 if (Direction ==
"left")
680 pos = CenterX - ((treadsize * (num_stairs - 1)) / 2) + (treadsize * i);
681 buffer = base +
"-riser";
686 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);
687 buffer = base +
"-tread";
690 sbs->
DrawWalls(
false,
true,
false,
false,
false,
false);
691 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);
694 if (Direction ==
"back")
696 pos = CenterZ + ((treadsize * (num_stairs - 1)) / 2) - (treadsize * i);
697 buffer = base +
"-riser";
702 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);
703 buffer = base +
"-tread";
706 sbs->
DrawWalls(
false,
true,
false,
false,
false,
false);
707 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);
710 if (Direction ==
"front")
712 pos = CenterZ - ((treadsize * (num_stairs - 1)) / 2) + (treadsize * i);
713 buffer = base +
"-riser";
718 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);
719 buffer = base +
"-tread";
722 sbs->
DrawWalls(
false,
true,
false,
false,
false,
false);
723 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);
733Wall*
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)
742 Wall *wall = mesh->CreateWallObject(name);
743 AddWall(wall, name, texture, thickness, x1, z1, x2, z2, height1, height2, voffset1, voffset2, tw, th);
747bool 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)
753 return sbs->
AddWallMain(wall, name, texture, thickness, x1, z1, x2, z2, height1, height2, voffset1, voffset2, tw, th,
true);
756Wall*
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)
765 Wall *wall = mesh->CreateWallObject(name);
766 AddFloor(wall, name, texture, thickness, x1, z1, x2, z2, voffset1, voffset2, reverse_axis, texture_direction, tw, th, legacy_behavior);
770bool 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)
776 return sbs->
AddFloorMain(wall, name, texture, thickness, x1, z1, x2, z2, voffset1, voffset2, reverse_axis, texture_direction, tw, th,
true, legacy_behavior);
786 mesh->Enabled(value);
790 for (
size_t i = 0; i < DoorArray.size(); i++)
793 DoorArray[i]->Enabled(value);
797 for (
size_t i = 0; i < ControlArray.size(); i++)
800 ControlArray[i]->Enabled(value);
804 for (
size_t i = 0; i < TriggerArray.size(); i++)
807 TriggerArray[i]->Enabled(value);
811 for (
size_t i = 0; i < ModelArray.size(); i++)
814 ModelArray[i]->Enabled(value);
818 for (
size_t i = 0; i < PrimArray.size(); i++)
821 PrimArray[i]->Enabled(value);
825 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
827 if (CustomObjectArray[i])
828 CustomObjectArray[i]->Enabled(value);
832 for (
size_t i = 0; i < lights.size(); i++)
835 lights[i]->Enabled(value);
840Door*
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)
857 if (face_direction ==
"left" || face_direction ==
"right")
861 z1 = CenterZ - (width / 2);
862 z2 = CenterZ + (width / 2);
866 x1 = CenterX - (width / 2);
867 x2 = CenterX + (width / 2);
874 if (face_direction ==
"left" || face_direction ==
"right")
876 Cut(1,
Vector3(x1 - 0.5, voffset, z1),
Vector3(x2 + 0.5, voffset + height, z2),
true,
false, 1);
881 Cut(1,
Vector3(x1, voffset, z1 - 0.5),
Vector3(x2, voffset + height, z2 + 0.5),
true,
false, 1);
888 std::string num =
ToString((
int)DoorArray.size());
890 name =
"Door " + num;
892 Door* door =
new Door(
this, parent->DoorWrapper, name, open_sound, close_sound, rotate);
893 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);
894 DoorArray.emplace_back(door);
905 std::string num =
ToString((
int)DoorArray.size());
907 name =
"Door " + num;
909 Door* door =
new Door(
this, parent->DoorWrapper, name, open_sound, close_sound, rotate);
910 DoorArray.emplace_back(door);
916 for (
size_t i = 0; i < DoorArray.size(); i++)
918 if (DoorArray[i]->
GetName() == name)
942 for (
size_t i = 0; i < mesh->Walls.size(); i++)
951 if (relative ==
true)
952 sbs->
GetUtility()->
Cut(mesh->Walls[i],
Vector3(start.x, start.y, start.z),
Vector3(end.x, end.y, end.z), cutwalls, cutfloors, checkwallnumber, reset);
954 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);
968 for (
size_t i = 0; i < DoorArray.size(); i++)
970 if (DoorArray[i] == door)
972 DoorArray.erase(DoorArray.begin() + i);
981 for (
size_t i = 0; i < lights.size(); i++)
983 if (lights[i] == light)
985 lights.erase(lights.begin() + i);
994 for (
size_t i = 0; i < ModelArray.size(); i++)
996 if (ModelArray[i] == model)
998 ModelArray.erase(ModelArray.begin() + i);
1007 for (
size_t i = 0; i < PrimArray.size(); i++)
1009 if (PrimArray[i] == prim)
1011 PrimArray.erase(PrimArray.begin() + i);
1020 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
1022 if (CustomObjectArray[i] ==
object)
1024 CustomObjectArray.erase(CustomObjectArray.begin() + i);
1033 for (
size_t i = 0; i < ControlArray.size(); i++)
1035 if (ControlArray[i] == control)
1037 ControlArray.erase(ControlArray.begin() + i);
1046 for (
size_t i = 0; i < TriggerArray.size(); i++)
1048 if (TriggerArray[i] == trigger)
1050 TriggerArray.erase(TriggerArray.begin() + i);
1061 lights.emplace_back(light);
1067 for (
size_t i = 0; i < lights.size(); i++)
1069 if (lights[i]->
GetName() == name)
1082Model*
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)
1086 Model* model =
new Model(
this, name, filename, center, position, rotation, max_render_distance, scale_multiplier, enable_physics, restitution, friction, mass);
1092 ModelArray.emplace_back(model);
1103 for (
size_t i = 0; i < ModelArray.size(); i++)
1105 if (ModelArray[i] == model)
1109 ModelArray.emplace_back(model);
1116 PrimArray.emplace_back(prim);
1127 for (
size_t i = 0; i < PrimArray.size(); i++)
1129 if (PrimArray[i] == primitive)
1133 PrimArray.emplace_back(primitive);
1140 CustomObjectArray.emplace_back(
object);
1151 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
1153 if (CustomObjectArray[i] ==
object)
1157 CustomObjectArray.emplace_back(
object);
1161Control*
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)
1165 std::vector<Action*> actionnull;
1166 Control* control =
new Control(
this, name,
false, sound, action_names, actionnull, textures, direction, width, height,
true, selection_position);
1167 control->
Move(CenterX, voffset, CenterZ);
1168 ControlArray.emplace_back(control);
1176 Trigger* trigger =
new Trigger(
this, name,
false, sound_file, area_min, area_max, action_names);
1177 TriggerArray.emplace_back(trigger);
1187 for (
size_t i = 0; i < ModelArray.size(); i++)
1190 return ModelArray[i];
1202 for (
size_t i = 0; i < PrimArray.size(); i++)
1205 return PrimArray[i];
1217 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
1220 return CustomObjectArray[i];
1228 mesh->ReplaceTexture(oldtexture, newtexture);
1247 CameraTextureArray.emplace_back(cameratexture);
1248 return cameratexture;
1254 for (
size_t i = 0; i < CameraTextureArray.size(); i++)
1256 if (CameraTextureArray[i] == camtex)
1258 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 Vector3 GetPosition(bool relative=false)
SceneNode * GetSceneNode()
void SetValues(const std::string &type, const std::string &name, bool is_permanent, bool is_movable=true)
virtual void Move(const Vector3 &vector, Real speed=1.0, bool force=false)
void EnableLoop(bool value)
virtual void SetPosition(const Vector3 &position, bool relative=false, bool force=false)
virtual void SetPositionY(Real value, bool force=false)
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, bool report=true)
void RemoveStairwell(Stairwell *stairs)
int StairsOutsideDisplayRange
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, bool report=true)
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)
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)