25#include <OgreSceneManager.h>
26#include <OgreFileSystem.h>
27#include <OgreConfigFile.h>
29#include "OgreStringVector.h"
33#include <OgreBulletDynamicsRigidBody.h>
34#include <OgreBulletCollisionsRay.h>
76 this->mSceneManager = mSceneManager;
79 version_state =
"RC3";
84 InstanceNumber = instance_number;
87 SetValues(
"SBS",
"SBS",
true);
89 mRoot = Ogre::Root::getSingletonPtr();
92 configfile =
new Ogre::ConfigFile();
93 configfile->load(
"skyscraper.ini");
97 BuildingDesigner =
"";
98 BuildingLocation =
"";
99 BuildingDescription =
"";
100 BuildingVersion =
"";
107 IsBuildingsEnabled =
false;
108 IsExternalEnabled =
false;
109 IsLandscapeEnabled =
false;
110 IsSkyboxEnabled =
false;
114 AutoShafts = GetConfigBool(
"Skyscraper.SBS.AutoShafts",
true);
115 AutoStairs = GetConfigBool(
"Skyscraper.SBS.AutoStairs",
true);
116 ElevatorSync =
false;
119 wall_orientation = 1;
120 floor_orientation = 2;
129 DrawSideNOld =
false;
130 DrawSidePOld =
false;
132 DrawBottomOld =
false;
134 ProcessElevators = GetConfigBool(
"Skyscraper.SBS.ProcessElevators",
true);
139 DeleteColliders =
false;
142 UnitScale = GetConfigFloat(
"Skyscraper.SBS.UnitScale", 4);
143 Verbose = GetConfigBool(
"Skyscraper.SBS.Verbose",
false);
144 InterfloorOnTop =
false;
153 current_virtual_time = 0;
156 timer =
new Ogre::Timer();
163 TexelOverride =
false;
166 SkyName = GetConfigString(
"Skyscraper.SBS.SkyName",
"noon");
167 ShaftDisplayRange = GetConfigInt(
"Skyscraper.SBS.ShaftDisplayRange", 3);
168 StairsDisplayRange = GetConfigInt(
"Skyscraper.SBS.StairsDisplayRange", 5);
169 ShaftOutsideDisplayRange = GetConfigInt(
"Skyscraper.SBS.ShaftOutsideDisplayRange", 3);
170 StairsOutsideDisplayRange = GetConfigInt(
"Skyscraper.SBS.StairsOutsideDisplayRange", 3);
171 FloorDisplayRange = GetConfigInt(
"Skyscraper.SBS.FloorDisplayRange", 3);
172 SmoothFrames = GetConfigInt(
"Skyscraper.SBS.SmoothFrames", 200);
173 RenderOnStartup = GetConfigBool(
"Skyscraper.SBS.RenderOnStartup",
false);
174 RandomActivity = GetConfigBool(
"Skyscraper.SBS.RandomActivity",
false);
175 Malfunctions = GetConfigBool(
"Skyscraper.SBS.Malfunctions",
false);
179 callstation_index = 1;
188 Ogre::MeshManager::getSingleton().setBoundsPaddingFactor(0.0);
206 InstancePrompt =
ToString(InstanceNumber) +
">";
212 Rotate(0.0, rotation, 0.0);
215 SetBounds(area_min, area_max);
228 Ogre::AxisAlignedBox box (Vector3::ZERO, Vector3::ZERO);
229 mWorld =
new OgreBulletDynamics::DynamicsWorld(mSceneManager, box, Vector3::ZERO,
true);
230 mWorld->setAllowedCcdPenetration(0);
240 Mount(
"signs-sans.zip",
"signs/sans");
241 Mount(
"signs-sans_bold.zip",
"signs/sans_bold");
242 Mount(
"signs-sans_cond.zip",
"signs/sans_cond");
243 Mount(
"signs-sans_cond_bold.zip",
"signs/sans_cond_bold");
246 Buildings =
new MeshObject(
this,
"Buildings");
248 Landscape =
new MeshObject(
this,
"Landscape");
262 this->camera =
new Camera(
this);
265 MapGenerator =
new Map(
this,
"Map Generator");
275 Report(
"Deleting simulator objects...");
280 for (
size_t i = 0; i < PersonArray.size(); i++)
284 PersonArray[i]->parent_deleting =
true;
285 delete PersonArray[i];
291 for (
size_t i = 0; i < ControlArray.size(); i++)
295 ControlArray[i]->parent_deleting =
true;
296 delete ControlArray[i];
302 for (
size_t i = 0; i < TriggerArray.size(); i++)
306 TriggerArray[i]->parent_deleting =
true;
307 delete TriggerArray[i];
313 for (
size_t i = 0; i < ModelArray.size(); i++)
317 ModelArray[i]->parent_deleting =
true;
318 delete ModelArray[i];
324 for (
size_t i = 0; i < PrimArray.size(); i++)
328 PrimArray[i]->parent_deleting =
true;
335 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
337 if (CustomObjectArray[i])
339 CustomObjectArray[i]->parent_deleting =
true;
340 delete CustomObjectArray[i];
342 CustomObjectArray[i] = 0;
346 for (
size_t i = 0; i < lights.size(); i++)
350 lights[i]->parent_deleting =
true;
364 camera->parent_deleting =
true;
372 floor_manager->parent_deleting =
true;
373 delete floor_manager;
377 if (elevator_manager)
379 elevator_manager->parent_deleting =
true;
380 delete elevator_manager;
382 elevator_manager = 0;
386 shaft_manager->parent_deleting =
true;
387 delete shaft_manager;
391 if (stairwell_manager)
393 stairwell_manager->parent_deleting =
true;
394 delete stairwell_manager;
396 stairwell_manager = 0;
400 door_manager->parent_deleting =
true;
405 if (revolvingdoor_manager)
407 revolvingdoor_manager->parent_deleting =
true;
408 delete revolvingdoor_manager;
410 revolvingdoor_manager = 0;
414 vehicle_manager->parent_deleting =
true;
415 delete vehicle_manager;
419 if (controller_manager)
421 controller_manager->parent_deleting =
true;
422 delete controller_manager;
424 controller_manager = 0;
427 for (
size_t i = 0; i < sounds.size(); i++)
431 sounds[i]->parent_deleting =
true;
438 for (
size_t i = 0; i < ActionArray.size(); i++)
441 delete ActionArray[i];
448 SkyBox->parent_deleting =
true;
455 Landscape->parent_deleting =
true;
462 External->parent_deleting =
true;
469 Buildings->parent_deleting =
true;
477 soundsystem->parent_deleting =
true;
484 delete texturemanager;
490 area_trigger->parent_deleting =
true;
505 verify_results.clear();
537 texturemanager->FreeTextureBoxes();
546 for (
size_t i = 0; i < sounds.size(); i++)
550 if (sounds[i]->GetLoopState() ==
true)
556 AttachCamera(cameras);
559 if (RandomActivity ==
true)
560 EnableRandomActivity(
true);
563 if (Malfunctions ==
true)
564 EnableMalfunctions(
true);
567 for (
size_t i = 0; i < reverbs.size(); i++)
570 reverbs[i]->Enabled(
true);
584 Report(
" Scalable Building Simulator " + version +
" " + version_state);
585 Report(
" Copyright (C)2004-2024 Ryan Thoryk");
586 Report(
" This software comes with ABSOLUTELY NO WARRANTY. This is free");
587 Report(
" software, and you are welcome to redistribute it under certain");
588 Report(
" conditions. For details, see the file gpl.txt\n");
596 if (RenderOnStartup ==
true && (loading ==
true || isready ==
false))
605 unsigned long timing;
607 if (SmoothFrames > 0)
608 timing = GetAverageTime();
610 timing = GetElapsedTime();
612 Real elapsed =
Real(timing) / 1000.0;
616 start_time = GetRunTime() / 1000.0;
617 running_time = (GetRunTime() / 1000.0) - start_time;
620 camera->MoveCharacter();
623 if (camera->EnableBullet ==
true)
629 mWorld->stepSimulation(elapsed, 0);
640 elapsed += remaining_delta;
647 while (elapsed >= delta)
650 camera->UpdateCameraFloor();
655 camera->CheckObjects();
662 remaining_delta = elapsed;
669 area_trigger->Loop();
680 fps_tottime += elapsed_time;
682 if (fps_tottime > 500)
684 FPS = (
Real (fps_frame_count) * 1000.) /
Real (fps_tottime);
690bool SBS::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)
695 if (x1 == x2 && z1 == z2)
696 return ReportError(
"Invalid coordinates for wall '" + name +
"'");
698 if (height_in1 == 0.0f && height_in2 == 0.0)
699 return ReportError(
"No wall height specified for wall '" + name +
"'");
703 if (std::abs(x1 - x2) > (std::abs(z1 - z2) + 0.00001))
711 if ((x1 > x2 && axis == 1) || (z1 < z2 && axis == 2))
716 std::swap(altitude1, altitude2);
717 std::swap(height_in1, height_in2);
721 Vector3 v1 (x1, altitude1 + height_in1, z1);
722 Vector3 v2 (x2, altitude2 + height_in2, z2);
723 Vector3 v3 (x2, altitude2, z2);
724 Vector3 v4 (x1, altitude1, z1);
736 if (area_trigger->IsOutside(v1x, v2x) ==
true)
744 if (wall_orientation == 0)
752 if (wall_orientation == 1)
755 Real half = thickness / 2;
765 if (wall_orientation == 2)
777 if (wall_orientation == 0)
785 if (wall_orientation == 1)
788 Real half = thickness / 2;
798 if (wall_orientation == 2)
809 std::string NewName, texture2 = texture;
810 Real tw2 = tw, th2 = th;
812 bool FlipTexture = texturemanager->FlipTexture;
813 bool TextureOverride = texturemanager->TextureOverride;
815 if (FlipTexture ==
true)
816 texturemanager->ProcessTextureFlip(tw, th);
818 if (DrawMainN ==
true)
820 if (FlipTexture ==
true)
822 tw2 = texturemanager->widthscale[0];
823 th2 = texturemanager->heightscale[0];
825 if (TextureOverride ==
true)
826 texture2 = texturemanager->mainnegtex;
829 if (GetDrawWallsCount() > 1)
830 NewName.append(
":front");
831 wallobject->
AddQuad(NewName, texture2, v1, v2, v3, v4, tw2, th2, autosize);
834 if (DrawMainP ==
true)
836 if (FlipTexture ==
true)
838 tw2 = texturemanager->widthscale[1];
839 th2 = texturemanager->heightscale[1];
841 if (TextureOverride ==
true)
842 texture2 = texturemanager->mainpostex;
845 NewName.append(
":back");
846 wallobject->
AddQuad(NewName, texture2, v6, v5, v8, v7, tw2, th2, autosize);
849 if (thickness != 0.0)
851 if (DrawSideN ==
true)
853 if (FlipTexture ==
true)
855 tw2 = texturemanager->widthscale[2];
856 th2 = texturemanager->heightscale[2];
858 if (TextureOverride ==
true)
859 texture2 = texturemanager->sidenegtex;
862 NewName.append(
":left");
864 wallobject->
AddQuad(NewName, texture2, v5, v1, v4, v8, tw2, th2, autosize);
866 wallobject->
AddQuad(NewName, texture2, v2, v6, v7, v3, tw2, th2, autosize);
869 if (DrawSideP ==
true)
871 if (FlipTexture ==
true)
873 tw2 = texturemanager->widthscale[3];
874 th2 = texturemanager->heightscale[3];
876 if (TextureOverride ==
true)
877 texture2 = texturemanager->sidepostex;
880 NewName.append(
":right");
882 wallobject->
AddQuad(NewName, texture2, v2, v6, v7, v3, tw2, th2, autosize);
884 wallobject->
AddQuad(NewName, texture2, v5, v1, v4, v8, tw2, th2, autosize);
889 if (FlipTexture ==
true)
891 tw2 = texturemanager->widthscale[4];
892 th2 = texturemanager->heightscale[4];
894 if (TextureOverride ==
true)
895 texture2 = texturemanager->toptex;
898 NewName.append(
":top");
899 wallobject->
AddQuad(NewName, texture2, v5, v6, v2, v1, tw2, th2, autosize);
902 if (DrawBottom ==
true)
904 if (FlipTexture ==
true)
906 tw2 = texturemanager->widthscale[5];
907 th2 = texturemanager->heightscale[5];
909 if (TextureOverride ==
true)
910 texture2 = texturemanager->bottomtex;
913 NewName.append(
":bottom");
914 wallobject->
AddQuad(NewName, texture2, v4, v3, v7, v8, tw2, th2, autosize);
921bool SBS::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)
930 if (x1 == x2 || z1 == z2)
931 return ReportError(
"Invalid coordinates for floor '" + name +
"'");
937 if (std::abs(x1 - x2) > (std::abs(z1 - z2) + 0.00001))
944 if (legacy_behavior ==
false)
952 if (reverse_axis ==
true)
953 std::swap(altitude1, altitude2);
959 if (reverse_axis ==
false)
960 std::swap(altitude1, altitude2);
967 if ((x1 > x2 && axis == 1) || (z1 > z2 && axis == 2))
972 std::swap(altitude1, altitude2);
979 if (reverse_axis ==
false)
981 v1 =
Vector3(x1, altitude1, z1);
982 v2 =
Vector3(x2, altitude1, z1);
983 v3 =
Vector3(x2, altitude2, z2);
984 v4 =
Vector3(x1, altitude2, z2);
988 if (legacy_behavior ==
true)
990 v1 =
Vector3(x1, altitude1, z1);
991 v2 =
Vector3(x1, altitude1, z2);
992 v3 =
Vector3(x2, altitude2, z2);
993 v4 =
Vector3(x2, altitude2, z1);
997 v1 =
Vector3(x2, altitude2, z1);
998 v2 =
Vector3(x2, altitude2, z2);
999 v3 =
Vector3(x1, altitude1, z2);
1000 v4 =
Vector3(x1, altitude1, z1);
1014 if (area_trigger->IsOutside(v1x, v2x) ==
true)
1019 if (floor_orientation == 0)
1027 if (floor_orientation == 1)
1030 Real half = thickness / 2;
1040 if (floor_orientation == 2)
1050 std::string NewName, texture2 = texture;
1051 Real tw2 = tw, th2 = th;
1053 bool FlipTexture = texturemanager->FlipTexture;
1054 bool TextureOverride = texturemanager->TextureOverride;
1056 if (FlipTexture ==
true)
1057 texturemanager->ProcessTextureFlip(tw, th);
1060 bool old_planarrotate = texturemanager->GetPlanarRotate();
1061 texturemanager->SetPlanarRotate(texture_direction);
1063 if (DrawMainN ==
true)
1065 if (FlipTexture ==
true)
1067 tw2 = texturemanager->widthscale[0];
1068 th2 = texturemanager->heightscale[0];
1070 if (TextureOverride ==
true)
1071 texture2 = texturemanager->mainnegtex;
1074 if (GetDrawWallsCount() > 1)
1075 NewName.append(
":front");
1076 wallobject->
AddQuad(NewName, texture2, v1, v2, v3, v4, tw2, th2, autosize);
1079 if (DrawMainP ==
true)
1081 if (FlipTexture ==
true)
1083 tw2 = texturemanager->widthscale[1];
1084 th2 = texturemanager->heightscale[1];
1086 if (TextureOverride ==
true)
1087 texture2 = texturemanager->mainpostex;
1090 NewName.append(
":back");
1091 wallobject->
AddQuad(NewName, texture2, v8, v7, v6, v5, tw2, th2, autosize);
1094 if (thickness != 0.0)
1096 if (DrawSideN ==
true)
1098 if (FlipTexture ==
true)
1100 tw2 = texturemanager->widthscale[2];
1101 th2 = texturemanager->heightscale[2];
1103 if (TextureOverride ==
true)
1104 texture2 = texturemanager->sidenegtex;
1107 NewName.append(
":left");
1108 wallobject->
AddQuad(NewName, texture2, v8, v5, v1, v4, tw2, th2, autosize);
1111 if (DrawSideP ==
true)
1113 if (FlipTexture ==
true)
1115 tw2 = texturemanager->widthscale[3];
1116 th2 = texturemanager->heightscale[3];
1118 if (TextureOverride ==
true)
1119 texture2 = texturemanager->sidepostex;
1122 NewName.append(
":right");
1123 wallobject->
AddQuad(NewName, texture2, v6, v7, v3, v2, tw2, th2, autosize);
1126 if (DrawTop ==
true)
1128 if (FlipTexture ==
true)
1130 tw2 = texturemanager->widthscale[4];
1131 th2 = texturemanager->heightscale[4];
1133 if (TextureOverride ==
true)
1134 texture2 = texturemanager->toptex;
1137 NewName.append(
":top");
1138 wallobject->
AddQuad(NewName, texture2, v5, v6, v2, v1, tw2, th2, autosize);
1141 if (DrawBottom ==
true)
1143 if (FlipTexture ==
true)
1145 tw2 = texturemanager->widthscale[5];
1146 th2 = texturemanager->heightscale[5];
1148 if (TextureOverride ==
true)
1149 texture2 = texturemanager->bottomtex;
1152 NewName.append(
":bottom");
1153 wallobject->
AddQuad(NewName, texture2, v7, v8, v4, v3, tw2, th2, autosize);
1157 texturemanager->SetPlanarRotate(old_planarrotate);
1162Wall*
SBS::CreateWallBox(
MeshObject* mesh,
const std::string &name,
const std::string &texture,
Real x1,
Real x2,
Real z1,
Real z2,
Real height_in,
Real voffset,
Real tw,
Real th,
bool inside,
bool outside,
bool top,
bool bottom,
bool autosize)
1170 if (x1 == x2 && z1 == z2)
1172 ReportError(
"Invalid coordinates for wall '" + name +
"'");
1179 bool x_thickness =
false, z_thickness =
false;
1180 std::string NewName, texture2 = texture;
1194 bool TextureOverride = texturemanager->TextureOverride;
1201 NewName.append(
":inside");
1203 if (x_thickness ==
true)
1205 if (TextureOverride ==
true)
1206 texture2 = texturemanager->mainnegtex;
1213 Vector3(x2, voffset + height_in, z1),
1214 Vector3(x1, voffset + height_in, z1), tw, th, autosize);
1216 if (TextureOverride ==
true)
1217 texture2 = texturemanager->mainpostex;
1224 Vector3(x1, voffset + height_in, z2),
1225 Vector3(x2, voffset + height_in, z2), tw, th, autosize);
1227 if (z_thickness ==
true)
1229 if (TextureOverride ==
true)
1230 texture2 = texturemanager->sidepostex;
1237 Vector3(x2, voffset + height_in, z2),
1238 Vector3(x2, voffset + height_in, z1), tw, th, autosize);
1240 if (TextureOverride ==
true)
1241 texture2 = texturemanager->sidenegtex;
1248 Vector3(x1, voffset + height_in, z1),
1249 Vector3(x1, voffset + height_in, z2), tw, th, autosize);
1251 if (x_thickness ==
true && z_thickness ==
true)
1255 if (TextureOverride ==
true)
1256 texture2 = texturemanager->bottomtex;
1264 Vector3(x1, voffset, z1), tw, th, autosize);
1269 if (TextureOverride ==
true)
1270 texture2 = texturemanager->toptex;
1275 Vector3(x1, voffset + height_in, z1),
1276 Vector3(x2, voffset + height_in, z1),
1277 Vector3(x2, voffset + height_in, z2),
1278 Vector3(x1, voffset + height_in, z2), tw, th, autosize);
1283 if (outside ==
true)
1286 NewName.append(
":outside");
1288 if (x_thickness ==
true)
1290 if (TextureOverride ==
true)
1291 texture2 = texturemanager->mainnegtex;
1296 Vector3(x1, voffset + height_in, z1),
1297 Vector3(x2, voffset + height_in, z1),
1299 Vector3(x1, voffset, z1), tw, th, autosize);
1301 if (TextureOverride ==
true)
1302 texture2 = texturemanager->mainpostex;
1307 Vector3(x2, voffset + height_in, z2),
1308 Vector3(x1, voffset + height_in, z2),
1310 Vector3(x2, voffset, z2), tw, th, autosize);
1312 if (z_thickness ==
true)
1314 if (TextureOverride ==
true)
1315 texture2 = texturemanager->sidepostex;
1320 Vector3(x2, voffset + height_in, z1),
1321 Vector3(x2, voffset + height_in, z2),
1323 Vector3(x2, voffset, z1), tw, th, autosize);
1325 if (TextureOverride ==
true)
1326 texture2 = texturemanager->sidenegtex;
1331 Vector3(x1, voffset + height_in, z2),
1332 Vector3(x1, voffset + height_in, z1),
1334 Vector3(x1, voffset, z2), tw, th, autosize);
1336 if (x_thickness ==
true && z_thickness ==
true)
1340 if (TextureOverride ==
true)
1341 texture2 = texturemanager->bottomtex;
1349 Vector3(x1, voffset, z2), tw, th, autosize);
1353 if (TextureOverride ==
true)
1354 texture2 = texturemanager->toptex;
1359 Vector3(x1, voffset + height_in, z2),
1360 Vector3(x2, voffset + height_in, z2),
1361 Vector3(x2, voffset + height_in, z1),
1362 Vector3(x1, voffset + height_in, z1), tw, th, autosize);
1369Wall*
SBS::CreateWallBox2(
MeshObject* mesh,
const std::string &name,
const std::string &texture,
Real CenterX,
Real CenterZ,
Real WidthX,
Real LengthZ,
Real height_in,
Real voffset,
Real tw,
Real th,
bool inside,
bool outside,
bool top,
bool bottom,
bool autosize)
1373 Real x1 = CenterX - (WidthX / 2);
1374 Real x2 = CenterX + (WidthX / 2);
1375 Real z1 = CenterZ - (LengthZ / 2);
1376 Real z2 = CenterZ + (LengthZ / 2);
1378 return CreateWallBox(mesh, name, texture, x1, x2, z1, z2, height_in, voffset, tw, th, inside, outside, top, bottom, autosize);
1392 size_t num = varray.size();
1395 varray2.reserve(num);
1396 for (
size_t i = num - 1; i < num; --i)
1397 varray2.emplace_back(varray1[i]);
1402 Vector3 direction = utility->GetPolygonDirection(varray1);
1406 if (direction.x == 1 || direction.y == -1 || direction.z == 1)
1407 std::swap(varray1, varray2);
1409 std::string name = wallobject->
GetName();
1412 if (DrawMainN ==
true)
1414 std::string NewName = name;
1415 if (DrawMainP ==
true)
1416 NewName.append(
":0");
1417 wallobject->
AddPolygon(NewName, texture, varray1, tw, th,
true);
1419 if (DrawMainP ==
true)
1421 std::string NewName = name;
1422 if (DrawMainN ==
true)
1423 NewName.append(
":1");
1424 wallobject->
AddPolygon(NewName, texture, varray2, tw, th,
true);
1439 AddPolygon(wall, texture, varray, tw, th);
1450 varray3.reserve(varray.size());
1451 for (
size_t i = 0; i < varray.size(); i++)
1453 varray3.emplace_back(
Vector3(varray[i].x, altitude, varray[i].y));
1457 return AddCustomWall(mesh, name, texture, varray3, tw, th);
1460Wall*
SBS::AddTriangleWall(
MeshObject* mesh,
const std::string &name,
const std::string &texture,
Real x1,
Real y1,
Real z1,
Real x2,
Real y2,
Real z2,
Real x3,
Real y3,
Real z3,
Real tw,
Real th)
1467 varray.emplace_back(
Vector3(x1, y1, z1));
1468 varray.emplace_back(
Vector3(x2, y2, z2));
1469 varray.emplace_back(
Vector3(x3, y3, z3));
1472 return AddCustomWall(mesh, name, texture, varray, tw, th);
1478 Buildings->Enabled(value);
1479 IsBuildingsEnabled = value;
1485 Landscape->Enabled(value);
1486 IsLandscapeEnabled = value;
1494 External->Enabled(value);
1495 IsExternalEnabled = value;
1503 SkyBox->Enabled(value);
1504 IsSkyboxEnabled = value;
1507 IsSkyboxEnabled =
true;
1515 if (InstanceNumber > 0)
1518 Mount(
"sky-" + SkyName +
".zip",
"sky");
1522 texturemanager->LoadTexture(
"sky/up.jpg",
"SkyTop", 1, 1,
false,
false,
false, 0);
1523 texturemanager->LoadTexture(
"sky/down.jpg",
"SkyBottom", 1, 1,
false,
false,
false, 0);
1524 texturemanager->LoadTexture(
"sky/left.jpg",
"SkyLeft", 1, 1,
false,
false,
false, 0);
1525 texturemanager->LoadTexture(
"sky/right.jpg",
"SkyRight", 1, 1,
false,
false,
false, 0);
1526 texturemanager->LoadTexture(
"sky/front.jpg",
"SkyFront", 1, 1,
false,
false,
false, 0);
1527 texturemanager->LoadTexture(
"sky/back.jpg",
"SkyBack", 1, 1,
false,
false,
false, 0);
1531 SkyBox->create_collider =
false;
1534 Real skysize = GetConfigInt(
"Skyscraper.SBS.HorizonDistance", 30) * 5280.0;
1535 texturemanager->ResetTextureMapping(
true);
1541 Vector3(-skysize, -skysize, -skysize),
1542 Vector3(skysize, -skysize, -skysize),
1543 Vector3(skysize, skysize, -skysize),
1544 Vector3(-skysize, skysize, -skysize), 1, 1,
false);
1548 Vector3(skysize, -skysize, -skysize),
1549 Vector3(skysize, -skysize, skysize),
1550 Vector3(skysize, skysize, skysize),
1551 Vector3(skysize, skysize, -skysize), 1, 1,
false);
1555 Vector3(skysize, -skysize, skysize),
1556 Vector3(-skysize, -skysize, skysize),
1557 Vector3(-skysize, skysize, skysize),
1558 Vector3(skysize, skysize, skysize), 1, 1,
false);
1562 Vector3(-skysize, -skysize, skysize),
1563 Vector3(-skysize, -skysize, -skysize),
1564 Vector3(-skysize, skysize, -skysize),
1565 Vector3(-skysize, skysize, skysize), 1, 1,
false);
1569 Vector3(-skysize, -skysize, skysize),
1570 Vector3(skysize, -skysize, skysize),
1571 Vector3(skysize, -skysize, -skysize),
1572 Vector3(-skysize, -skysize, -skysize), 1, -1,
false);
1576 Vector3(-skysize, skysize, -skysize),
1577 Vector3(skysize, skysize, -skysize),
1578 Vector3(skysize, skysize, skysize),
1579 Vector3(-skysize, skysize, skysize), -1, -1,
false);
1581 texturemanager->ResetTextureMapping();
1588 if (GetTotalFloors() == 0)
1592 if (GetFloor(-Basements))
1594 if (altitude < GetFloor(-Basements)->Altitude)
1599 if (checklastfloor ==
true && GetFloor(lastfloor))
1601 Real lastfloor_altitude = GetFloor(lastfloor)->Altitude;
1602 Real upperfloor_altitude;
1603 if (lastfloor < Floors - 1)
1604 upperfloor_altitude = GetFloor(lastfloor + 1)->Altitude;
1606 upperfloor_altitude = GetFloor(lastfloor)->Altitude + GetFloor(lastfloor)->FullHeight();
1608 if (upperfloor_altitude > altitude && lastfloor_altitude <= altitude)
1613 if (altitude < lastfloor_altitude)
1615 for (
int i = lastfloor - 1; i >= -Basements; i--)
1617 if (GetFloor(i + 1)->Altitude > altitude && GetFloor(i)->Altitude <= altitude)
1621 else if (altitude >= upperfloor_altitude)
1623 for (
int i = lastfloor + 1; i < Floors; i++)
1625 if (GetFloor(i - 1)->Altitude <= altitude && GetFloor(i)->Altitude > altitude)
1627 if (i == Floors - 1 && GetFloor(i)->Altitude <= altitude)
1635 for (
int i = -Basements + 1; i < Floors; i++)
1639 if ((GetFloor(i)->Altitude > altitude) && (GetFloor(i - 1)->Altitude <= altitude))
1642 if ((i == Floors - 1) && (altitude > GetFloor(i)->Altitude))
1653 return std::abs(x1 - x2);
1655 return std::abs(z1 - z2);
1656 if ((x1 != x2) && (z2 != x2))
1657 return sqrt(pow(std::abs(x1 - x2), 2) + pow(std::abs(z1 - z2), 2));
1665 return shaft_manager->Create(number, CenterX, CenterZ, startfloor, endfloor);
1672 return stairwell_manager->Create(number, CenterX, CenterZ, startfloor, endfloor);
1679 return elevator_manager->Create(number);
1686 return floor_manager->Create(number);
1693 return vehicle_manager->
Create(number);
1700 return controller_manager->Create(number);
1706 return elevator_manager->GetCount();
1712 return vehicle_manager->GetCount();
1718 return floor_manager->GetCount();
1724 return shaft_manager->GetCount();
1730 return stairwell_manager->GetCount();
1736 return controller_manager->GetCount();
1743 return floor_manager->Get(number);
1750 return elevator_manager->Get(number);
1757 return shaft_manager->Get(number);
1764 return stairwell_manager->Get(number);
1771 return vehicle_manager->Get(number);
1778 return controller_manager->Get(number);
1791 if (direction ==
"left")
1792 wall_orientation = 0;
1793 else if (direction ==
"center")
1794 wall_orientation = 1;
1795 else if (direction ==
"right")
1796 wall_orientation = 2;
1798 return ReportError(
"SetWallOrientation: Invalid wall orientation");
1804 return wall_orientation;
1817 if (direction ==
"bottom")
1818 floor_orientation = 0;
1819 else if (direction ==
"center")
1820 floor_orientation = 1;
1821 else if (direction ==
"top")
1822 floor_orientation = 2;
1824 return ReportError(
"SetFloorOrientation: Invalid floor orientation");
1830 return floor_orientation;
1833void SBS::DrawWalls(
bool MainN,
bool MainP,
bool SideN,
bool SideP,
bool Top,
bool Bottom)
1838 DrawMainNOld = DrawMainN;
1839 DrawMainPOld = DrawMainP;
1840 DrawSideNOld = DrawSideN;
1841 DrawSidePOld = DrawSideP;
1842 DrawTopOld = DrawTop;
1843 DrawBottomOld = DrawBottom;
1851 DrawBottom = Bottom;
1859 if (ToDefaults ==
true)
1860 DrawWalls(
true,
true,
false,
false,
false,
false);
1862 DrawWalls(DrawMainNOld, DrawMainPOld, DrawSideNOld, DrawSidePOld, DrawTopOld, DrawBottomOld);
1871 if (DrawMainN ==
true)
1873 if (DrawMainP ==
true)
1875 if (DrawSideN ==
true)
1877 if (DrawSideP ==
true)
1879 if (DrawTop ==
true)
1881 if (DrawBottom ==
true)
1890 return meters * 3.2808399;
1896 return feet / 3.2808399;
1899Wall*
SBS::AddWall(
MeshObject* mesh,
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)
1908 AddWallMain(wall, name, texture, thickness, x1, z1, x2, z2, height_in1, height_in2, altitude1, altitude2, tw, th,
true);
1912Wall*
SBS::AddFloor(
MeshObject* mesh,
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 legacy_behavior)
1921 AddFloorMain(wall, name, texture, thickness, x1, z1, x2, z2, altitude1, altitude2, reverse_axis, texture_direction, tw, th,
true, legacy_behavior);
1932 Real minx, minz, maxx, maxz;
1956 Wall *wall = Landscape->CreateWallObject(name);
1958 Report(
"Creating ground...");
1961 for (
Real i = minx; i < maxx; i += tile_x)
1965 if (i + tile_x > maxx)
1968 sizex = (
Real)tile_x;
1970 for (
Real j = minz; j < maxz; j += tile_z)
1972 if (j + tile_z > maxz)
1975 sizez = (
Real)tile_z;
1977 DrawWalls(
true,
true,
false,
false,
false,
false);
1978 AddFloorMain(wall, name, texture, 0, i, j, i + sizex, j + sizez, altitude, altitude,
false,
false, 1, 1,
false);
1982 Report(
"Finished ground");
1999 if (
IsEven(range) ==
true)
2003 if (!IsValidFloor(floor))
2006 int additionalfloors;
2008 additionalfloors = (range - 1) / 2;
2010 additionalfloors = 0;
2015 if (shaftnumber > 0)
2016 shaft = GetShaft(shaftnumber);
2017 if (stairsnumber > 0)
2018 stairwell = GetStairwell(stairsnumber);
2023 int floorval = floor - additionalfloors - 1;
2024 if (IsValidFloor(floorval) && GetFloor(floor)->IsInGroup(floorval) ==
false)
2025 GetFloor(floorval)->Enabled(
false);
2027 floorval = floor + additionalfloors + 1;
2028 if (IsValidFloor(floorval) && GetFloor(floor)->IsInGroup(floorval) ==
false)
2029 GetFloor(floorval)->Enabled(
false);
2033 for (
int i = floor - additionalfloors; i <= floor + additionalfloors; i++)
2035 Floor *floorobj = GetFloor(i);
2046 if (showfloor ==
true && value ==
true)
2051 if (enablegroups ==
true)
2068 if (enablegroups ==
true)
2081 if (showfloor ==
true && value ==
true)
2086 if (enablegroups ==
true)
2103 if (enablegroups ==
true)
2112 if (enablegroups ==
true)
2126 for (
size_t i = 0; i < timercallbacks.size(); i++)
2128 if (timercallbacks[i] == timer)
2133 timercallbacks.emplace_back(timer);
2143 for (
size_t i = 0; i < timercallbacks.size(); i++)
2146 if (timercallbacks[i] == timer)
2148 timercallbacks.erase(timercallbacks.begin() + i);
2161 for (
size_t i = 0; i < timercallbacks.size(); i++)
2163 if (timercallbacks[i])
2164 timercallbacks[i]->Loop();
2171 return (
int)timercallbacks.size();
2174bool SBS::Mount(
const std::string &filename,
const std::string &path)
2178 std::string newfile =
"data/" + filename;
2179 std::string file = VerifyFile(newfile);
2181 Report(
"Mounting " + file +
" as path " + path);
2184 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(file,
"Zip", path,
true);
2186 catch (Ogre::Exception &e)
2188 return ReportError(
"Error mounting file " + file +
"\n" + e.getDescription());
2198 newarea.
start = start;
2202 FloorAutoArea.emplace_back(newarea);
2211 Vector3 position = camera->GetPosition();
2212 int floor = camera->CurrentFloor;
2214 for (
size_t i = 0; i < FloorAutoArea.size(); i++)
2217 if (FloorAutoArea[i].camerafloor != floor)
2218 FloorAutoArea[i].inside =
false;
2220 if (InBox(FloorAutoArea[i].start, FloorAutoArea[i].end, position) ==
true && FloorAutoArea[i].inside ==
false)
2223 FloorAutoArea[i].inside =
true;
2224 FloorAutoArea[i].camerafloor = floor;
2225 if (floor > -Basements)
2227 GetFloor(floor - 1)->Enabled(
true);
2228 GetFloor(floor - 1)->EnableGroup(
true);
2230 GetFloor(floor)->Enabled(
true);
2231 GetFloor(floor)->EnableGroup(
true);
2232 if (floor < Floors - 1)
2234 GetFloor(floor + 1)->Enabled(
true);
2235 GetFloor(floor + 1)->EnableGroup(
true);
2238 if (InBox(FloorAutoArea[i].start, FloorAutoArea[i].end, position) ==
false && FloorAutoArea[i].inside ==
true)
2241 FloorAutoArea[i].inside =
false;
2242 FloorAutoArea[i].camerafloor = 0;
2243 if (floor > -Basements)
2245 GetFloor(floor - 1)->Enabled(
false);
2246 GetFloor(floor - 1)->EnableGroup(
false);
2248 if (floor < Floors - 1)
2250 GetFloor(floor + 1)->Enabled(
false);
2251 GetFloor(floor + 1)->EnableGroup(
false);
2253 GetFloor(floor)->Enabled(
true);
2254 GetFloor(floor)->EnableGroup(
true);
2262 return (
int)meshes.size();
2265Sound*
SBS::AddSound(
const std::string &name,
const std::string &filename,
const Vector3 &position,
bool loop,
Real volume,
int speed,
Real min_distance,
Real max_distance,
Real doppler_level,
Real cone_inside_angle,
Real cone_outside_angle,
Real cone_outside_volume,
const Vector3 &direction)
2269 sounds.emplace_back(sound);
2279 sound->
SetConeSettings(cone_inside_angle, cone_outside_angle, cone_outside_volume);
2280 sound->
Load(filename);
2282 if (loop && IsRunning ==
true)
2292 std::string findname = name;
2294 std::vector<Sound*> soundlist;
2295 for (
size_t i = 0; i < sounds.size(); i++)
2299 std::string name2 = sounds[i]->GetName();
2301 if (findname == name2)
2302 soundlist.emplace_back(sounds[i]);
2327 Reverb *reverb =
new Reverb(
this, name, type, position, min_distance, max_distance,
false);
2328 reverbs.emplace_back(reverb);
2336 std::string findname = name;
2338 for (
size_t i = 0; i < reverbs.size(); i++)
2342 std::string name2 = reverbs[i]->GetName();
2344 if (findname == name2)
2374 return remote_value * UnitScale;
2384 return remote_value * UnitScale;
2393 newvalue.x = remote_value.x;
2394 newvalue.y = remote_value.y;
2397 newvalue.z = -remote_value.z;
2399 newvalue.z = remote_value.z;
2401 if (rescale ==
true)
2402 return newvalue * UnitScale;
2414 return local_value / UnitScale;
2424 return local_value / UnitScale;
2432 newvalue.x = local_value.x;
2433 newvalue.y = local_value.y;
2436 newvalue.z = -local_value.z;
2438 newvalue.z = local_value.z;
2440 if (rescale ==
true)
2441 return (newvalue / UnitScale);
2455 if (number >= 0 && number < (
int)ObjectArray.size())
2456 return ObjectArray[number];
2465 ObjectArray.emplace_back(
object);
2466 return (
int)ObjectArray.size() - 1;
2474 if (number < (
int)ObjectArray.size())
2476 if (ObjectArray[number])
2478 if (ObjectArray[number]->GetNumber() == number)
2480 std::vector<Object*> objects;
2481 objects.emplace_back(ObjectArray[number]);
2482 RemoveActionParent(objects);
2483 ObjectArray[number] = 0;
2496 if (GetFloor(floor))
2505 std::string output =
"SBS version: " + version +
"\n";
2506 output.append(
"Instance number: " +
ToString(InstanceNumber) +
"\n");
2507 output.append(
"Building Name: " + BuildingName +
"\n");
2508 output.append(
"Building Filename: " + BuildingFilename +
"\n");
2509 output.append(
"Building Version: " + BuildingVersion +
"\n");
2510 output.append(
"InStairwell: ");
2512 output.append(
"\n");
2513 output.append(
"InElevator: ");
2515 output.append(
"\n");
2516 output.append(
"InShaft: ");
2518 output.append(
"\n");
2519 output.append(
"CameraFloor: ");
2521 output.append(
ToString(camera->CurrentFloor));
2522 output.append(
"\n");
2523 output.append(
"ElevatorNumber: ");
2524 output.append(
ToString(ElevatorNumber));
2525 output.append(
"\n");
2526 output.append(
"CarNumber: ");
2527 output.append(
ToString(CarNumber));
2528 output.append(
"\n");
2529 output.append(
"ElevatorSync: ");
2531 output.append(
"\n");
2532 output.append(
"Running Time: ");
2534 output.append(
"\n");
2535 output.append(
"BuildingsEnabled: ");
2537 output.append(
"\n");
2538 output.append(
"ExternalEnabled: ");
2540 output.append(
"\n");
2541 output.append(
"LandscapeEnabled: ");
2543 output.append(
"\n");
2544 output.append(
"SkyboxEnabled: ");
2546 output.append(
"\n");
2547 output.append(
"Verbose: ");
2549 output.append(
"\n");
2550 output.append(
"InterfloorOnTop: ");
2552 output.append(
"\n");
2553 output.append(
"Object Count: ");
2554 output.append(
ToString(ObjectCount));
2555 output.append(
"\n");
2558 output.append(
"Camera Floor: ");
2559 output.append(
ToString(camera->CurrentFloor));
2560 output.append(
"\n");
2573 return ReportError(
"Invalid object");
2576 bool deleted =
false;
2580 return ReportError(
"Cannot delete permanent object " + number);
2582 std::string type =
object->GetType();
2585 if (type ==
"Floor")
2590 for (
int i = 0; i < shaft_manager->GetCount(); i++)
2592 Shaft *shaft = shaft_manager->GetIndex(i);
2601 for (
int i = 0; i < stairwell_manager->GetCount(); i++)
2603 Stairwell *stairwell = stairwell_manager->GetIndex(i);
2613 return ReportError(
"Only the highest floor can be deleted");
2616 return ReportError(
"Only the lowest basement can be deleted");
2620 else if (type ==
"Elevator")
2622 else if (type ==
"ButtonPanel")
2627 else if (type ==
"CallButton")
2629 else if (type ==
"DirectionalIndicator")
2631 else if (type ==
"Door")
2633 else if (type ==
"RevolvingDoor")
2635 else if (type ==
"ElevatorDoor")
2637 else if (type ==
"FloorIndicator")
2639 else if (type ==
"Shaft")
2644 for (
int i = 0; i < elevator_manager->GetCount(); i++)
2646 Elevator *elev = elevator_manager->GetIndex(i);
2656 else if (type ==
"Sound")
2658 else if (type ==
"Stairwell")
2660 else if (type ==
"Wall")
2662 else if (type ==
"Model")
2664 else if (type ==
"Control")
2666 else if (type ==
"Trigger")
2668 else if (type ==
"DoorWrapper")
2672 return ReportError(
"Deleting the main elevator door wrapper is not supported yet");
2676 else if (type ==
"Escalator")
2678 else if (type ==
"Person")
2680 else if (type ==
"ElevatorCar")
2684 return ReportError(
"Only the highest elevator car can be deleted");
2686 return ReportError(
"Cannot delete the primary elevator car");
2690 else if (type ==
"MovingWalkway")
2692 else if (type ==
"Vehicle")
2694 else if (type ==
"Light")
2696 else if (type ==
"CallStation")
2698 else if (type ==
"DispatchController")
2700 else if (type ==
"Primitive")
2702 else if (type ==
"CustomObject")
2704 else if (type ==
"Reverb")
2706 else if (type ==
"CameraTexture")
2710 if (deleted ==
true)
2713 camera->ResetCollisions();
2721 return DeleteObject(GetObject(
object));
2730 return ReportError(
"Invalid object");
2732 if (relative ==
false)
2735 position.x =
object->GetPosition().x;
2737 position.y =
object->GetPosition().y;
2739 position.z =
object->GetPosition().z;
2741 object->SetPosition(position);
2744 object->Move(position);
2755 return ReportError(
"Invalid object");
2757 if (relative ==
true)
2758 object->Rotate(rotation, speed);
2762 rotation.x =
object->GetRotation().x;
2764 rotation.y =
object->GetRotation().y;
2766 rotation.z =
object->GetRotation().z;
2767 object->SetRotation(rotation);
2777 floor_manager->Remove(floor);
2784 elevator_manager->Remove(elevator);
2791 shaft_manager->Remove(shaft);
2798 stairwell_manager->Remove(stairs);
2806 for (
size_t i = 0; i < sounds.size(); i++)
2808 if (sounds[i] == sound)
2810 sounds.erase(sounds.begin() + i);
2821 for (
size_t i = 0; i < reverbs.size(); i++)
2823 if (reverbs[i] == reverb)
2825 reverbs.erase(reverbs.begin() + i);
2834 for (
size_t i = 0; i < lights.size(); i++)
2836 if (lights[i] == light)
2838 lights.erase(lights.begin() + i);
2847 for (
size_t i = 0; i < ModelArray.size(); i++)
2849 if (ModelArray[i] == model)
2851 ModelArray.erase(ModelArray.begin() + i);
2860 for (
size_t i = 0; i < PrimArray.size(); i++)
2862 if (PrimArray[i] == prim)
2864 PrimArray.erase(PrimArray.begin() + i);
2873 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
2875 if (CustomObjectArray[i] ==
object)
2877 CustomObjectArray.erase(CustomObjectArray.begin() + i);
2886 for (
size_t i = 0; i < ControlArray.size(); i++)
2888 if (ControlArray[i] == control)
2890 ControlArray.erase(ControlArray.begin() + i);
2899 for (
size_t i = 0; i < TriggerArray.size(); i++)
2901 if (TriggerArray[i] == trigger)
2903 TriggerArray.erase(TriggerArray.begin() + i);
2913 controller_manager->Remove(controller);
2918 bool result =
false;
2919 return VerifyFile(filename, result,
false);
2936 if (skip_cache ==
false)
2938 for (
size_t i = 0; i < verify_results.size(); i++)
2940 if (verify_results[i].filename == filename)
2941 return verify_results[i].result;
2946 Ogre::Archive *filesystem = 0;
2947 Ogre::ArchiveManager::ArchiveMapIterator it = Ogre::ArchiveManager::getSingleton().getArchiveIterator();
2948 while(it.hasMoreElements())
2950 const std::string& key = it.peekNextKey();
2951 filesystem = it.getNext();
2958 std::string shortname;
2959 std::string group = GetMountPath(filename, shortname);
2961 if (group ==
"General")
2965 if (filesystem->exists(filename) ==
true)
2968 CacheFilename(filename, filename);
2974 if (!filesystem_listing)
2975 filesystem_listing = filesystem->list();
2976 listing = filesystem_listing;
2982 if (Ogre::ResourceGroupManager::getSingleton().resourceExists(group, shortname) ==
true)
2985 CacheFilename(filename, filename);
2991 listing = Ogre::ResourceGroupManager::getSingleton().listResourceNames(group);
2995 for (
size_t i = 0; i < listing->size(); i++)
2997 std::string check = listing->at(i);
2998 std::string checkoriginal =
SetCaseCopy(check,
false);
2999 std::string checkfile =
SetCaseCopy(filename,
false);
3000 if (checkoriginal == checkfile)
3003 CacheFilename(filename, check);
3011 CacheFilename(filename, filename);
3024 Ogre::Archive *filesystem = 0;
3025 Ogre::ArchiveManager::ArchiveMapIterator it = Ogre::ArchiveManager::getSingleton().getArchiveIterator();
3026 while(it.hasMoreElements())
3028 const std::string& key = it.peekNextKey();
3029 filesystem = it.getNext();
3035 std::string shortname;
3036 std::string group = GetMountPath(filename, shortname);
3038 if (group ==
"General")
3042 if (filesystem->exists(filename) ==
true)
3044 std::string path = key;
3047 return std::string(path + filename);
3060 VerifyFile(filename, result,
true);
3074 return PolygonCount;
3085 Report(
"Preparing meshes...");
3086 for (
size_t i = 0; i < meshes.size(); i++)
3088 meshes[i]->Prepare(
false);
3093 Report(
"Processing geometry...");
3094 for (
size_t i = 0; i < dynamic_meshes.size(); i++)
3096 if (sbs->Verbose && report ==
true)
3097 Report(
"DynamicMesh " +
ToString((
int)i) +
" of " +
ToString((
int)dynamic_meshes.size()));
3098 dynamic_meshes[i]->Prepare();
3101 if (renderonly ==
false)
3104 Report(
"Creating colliders...");
3105 for (
size_t i = 0; i < meshes.size(); i++)
3107 if (meshes[i]->tricollider ==
true && meshes[i]->IsPhysical() ==
false)
3108 meshes[i]->CreateCollider();
3110 meshes[i]->CreateBoxCollider();
3115 Report(
"Finished prepare");
3123 lights.emplace_back(light);
3129 meshes.emplace_back(handle);
3134 for (
size_t i = 0; i < meshes.size(); i++)
3136 if (meshes[i] == handle)
3138 meshes.erase(meshes.begin() + i);
3147 for (
size_t i = 0; i < meshes.size(); i++)
3149 if (meshes[i]->name == name)
3155Model*
SBS::AddModel(
const std::string &name,
const std::string &filename,
bool center,
const Vector3 &position,
const Vector3 &rotation,
Real max_render_distance,
Real scale_multiplier,
bool enable_physics,
Real restitution,
Real friction,
Real mass)
3158 Model* model =
new Model(
this, name, filename, center, position, rotation, max_render_distance, scale_multiplier, enable_physics, restitution, friction, mass);
3164 ModelArray.emplace_back(model);
3175 for (
size_t i = 0; i < ModelArray.size(); i++)
3177 if (ModelArray[i] == model)
3181 ModelArray.emplace_back(model);
3188 PrimArray.emplace_back(prim);
3199 for (
size_t i = 0; i < PrimArray.size(); i++)
3201 if (PrimArray[i] == primitive)
3205 PrimArray.emplace_back(primitive);
3212 CustomObjectArray.emplace_back(
object);
3223 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
3225 if (CustomObjectArray[i] ==
object)
3229 CustomObjectArray.emplace_back(
object);
3234 std::string result = configfile->getSetting(key,
"",
ToString(default_value));
3235 return ToInt(result);
3240 return configfile->getSetting(key,
"", default_value);
3245 std::string result = configfile->getSetting(key,
"",
ToString(default_value));
3251 std::string result = configfile->getSetting(key,
"",
ToString(default_value));
3259 if (test.x > start.x && test.y > start.y && test.z > start.z && test.x < end.x && test.y < end.y && test.z < end.z)
3268 unsigned long last = current_time;
3271 current_time = GetCurrentTime();
3273 last = current_time;
3275 if (current_time < last)
3276 elapsed_time = current_time + ((
unsigned long)-1 - last) + 1;
3278 elapsed_time = current_time - last;
3279 current_virtual_time += elapsed_time;
3280 frame_times.emplace_back(current_time);
3281 CalculateAverageTime();
3287 return timer->getMilliseconds();
3293 return current_virtual_time;
3299 return elapsed_time;
3305 return average_time;
3312 if (frame_times.size() <= 1)
3318 std::deque<unsigned long>::iterator it = frame_times.begin(), end = frame_times.end() - 2;
3322 if (frame_times.back() - *it > SmoothFrames)
3329 frame_times.erase(frame_times.begin(), it);
3332 average_time = (frame_times.back() - frame_times.front()) / ((
unsigned long)frame_times.size() - 1);
3340 Ogre::StringVector list = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
3342 newfilename = filename;
3344 for (
size_t i = 0; i < list.size(); i++)
3346 if (
StartsWith(filename, list[i] +
"/") ==
true)
3348 newfilename = filename.substr(list[i].size() + 1);
3360 mWorld->setShowDebugShapes(value);
3361 camera->ShowDebugShape(value);
3363 catch (Ogre::Exception &e)
3365 ReportError(
"Error enabling/disabling collider shapes\n" + e.getDescription());
3375 verify_results.emplace_back(verify);
3380 OldAmbientR = AmbientR;
3381 OldAmbientG = AmbientG;
3382 OldAmbientB = AmbientB;
3390 AmbientR = OldAmbientR;
3391 AmbientG = OldAmbientG;
3392 AmbientB = OldAmbientB;
3395Control*
SBS::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)
3398 std::vector<Action*> actionnull;
3399 Control* control =
new Control(
this, name,
false, sound, action_names, actionnull, textures, direction, width, height,
true, selection_position);
3401 ControlArray.emplace_back(control);
3408 Trigger* trigger =
new Trigger(
this, name,
false, sound_file, area_min, area_max, action_names);
3409 TriggerArray.emplace_back(trigger);
3413Action*
SBS::AddAction(
const std::string &name, std::vector<Object*> &action_parents,
const std::string &command,
const std::vector<std::string> ¶meters)
3417 Action *action =
new Action(
this, name, action_parents, command, parameters);
3418 ActionArray.emplace_back(action);
3426 Action *action =
new Action(
this, name, action_parents, command);
3427 ActionArray.emplace_back(action);
3439 size_t pos = name.find(
"Car1");
3440 if (name.substr(0, 8) ==
"Elevator" && pos != std::string::npos)
3441 name2 = name.substr(0, pos - 1) + name.substr(name.find(
":", pos));
3443 std::vector<Action*> actionlist;
3444 for (
size_t i = 0; i < ActionArray.size(); i++)
3446 std::string actionname = ActionArray[i]->GetName();
3448 if (actionname == name || actionname == name2)
3449 actionlist.emplace_back(ActionArray[i]);
3457 return (
int)ActionArray.size();
3464 bool result =
false;
3465 std::vector<Action*> actionlist = GetAction(name);
3467 for (
size_t i = 0; i < actionlist.size(); i++)
3469 Action *action = actionlist[i];
3470 for (
size_t j = 0; j < parents.size(); j++)
3483 bool result =
false;
3484 std::vector<Action*> actionlist = GetAction(name);
3486 for (
size_t i = 0; i < actionlist.size(); i++)
3488 Action *action = actionlist[i];
3489 for (
size_t j = 0; j < parents.size(); j++)
3502 bool result =
false;
3503 for (
size_t i = 0; i < ActionArray.size(); i++)
3505 Action *action = ActionArray[i];
3506 for (
size_t j = 0; j < parents.size(); j++)
3520 bool result =
false;
3521 for (
size_t i = 0; i < ActionArray.size(); i++)
3525 std::string actionname = ActionArray[i]->GetName();
3527 if (actionname == name)
3529 delete ActionArray[i];
3530 ActionArray.erase(ActionArray.begin() + i);
3546 bool result =
false;
3547 for (
size_t i = 0; i < ActionArray.size(); i++)
3549 if (ActionArray[i] == action)
3551 delete ActionArray[i];
3552 ActionArray.erase(ActionArray.begin() + i);
3557 for (
size_t j = 0; j < control_index.size(); j++)
3559 control_index[j]->RemoveAction(action);
3576 std::string tmpname =
"Floor";
3577 if (case_sensitive ==
false)
3582 if (name.find(
"floor", 0) == 0)
3587 if (name.find(
"Floor", 0) == 0)
3591 if (found ==
true && name.find(
":", 0) == std::string::npos)
3593 std::string number = name.substr(5);
3596 int floor =
ToInt(number);
3597 return sbs->GetFloor(floor);
3604 std::string tmpname =
"Elevator";
3605 if (case_sensitive ==
false)
3610 if (name.find(
"elevator", 0) == 0)
3615 if (name.find(
"Elevator", 0) == 0)
3619 if (found ==
true && name.find(
":", 0) == std::string::npos)
3621 std::string number = name.substr(8);
3624 int elevator =
ToInt(number);
3625 return sbs->GetElevator(elevator);
3632 std::string tmpname =
"Shaft";
3633 if (case_sensitive ==
false)
3638 if (name.find(
"shaft", 0) == 0)
3643 if (name.find(
"Shaft", 0) == 0)
3647 if (found ==
true && name.find(
":", 0) == std::string::npos)
3649 std::string number = name.substr(5);
3652 int shaft =
ToInt(number);
3653 return sbs->GetShaft(shaft);
3660 std::string tmpname =
"Stairwell";
3661 if (case_sensitive ==
false)
3666 if (name.find(
"stairwell", 0) == 0)
3671 if (name.find(
"Stairwell", 0) == 0)
3675 if (found ==
true && name.find(
":", 0) == std::string::npos)
3677 std::string number = name.substr(9);
3680 int stair =
ToInt(number);
3681 return sbs->GetStairwell(stair);
3686 for (
size_t i = 0; i < ObjectArray.size(); i++)
3690 std::string tmpname = ObjectArray[i]->GetName();
3692 if (case_sensitive ==
false)
3696 if (tmpname == name)
3697 return ObjectArray[i];
3699 if (ObjectArray[i]->GetParent())
3701 std::string parent_name = ObjectArray[i]->GetParent()->GetName();
3703 if (case_sensitive ==
false)
3707 if (name == parent_name +
":" + tmpname)
3708 return ObjectArray[i];
3710 if (ObjectArray[i]->GetParent()->GetParent())
3712 std::string grandparent_name = ObjectArray[i]->GetParent()->GetParent()->GetName();
3714 if (case_sensitive ==
false)
3715 SetCase(grandparent_name,
false);
3718 if (name == grandparent_name +
":" + parent_name +
":" + tmpname)
3719 return ObjectArray[i];
3734 if (case_sensitive ==
false)
3740 for (
size_t i = 0; i < ObjectArray.size(); i++)
3742 Object *
object = ObjectArray[i];
3746 if (object->
GetType() != type)
3753 std::string namecheck = parent->
GetName();
3755 if (case_sensitive ==
false)
3758 if (namecheck == parent_name)
3760 std::string tmpname =
object->GetName();
3762 if (case_sensitive ==
false)
3766 if (tmpname == name)
3780 std::vector<Object*> objects;
3781 size_t temp = expression.find(
"to", 0);
3784 size_t temp2 = expression.find(
"tor", 0);
3790 if (temp > 0 && temp != std::string::npos)
3792 if (expression.substr(0, 6) ==
"Floors")
3794 else if (expression.substr(0, 9) ==
"Elevators")
3796 else if (expression.substr(0, 6) ==
"Shafts")
3798 else if (expression.substr(0, 10) ==
"Stairwells")
3802 ReportError(
"GetObjectRange: Invalid object type");
3806 std::string str1 = expression.substr(type.size() + 1, temp - (type.size() + 1));
3807 std::string str2 = expression.substr(temp + 2, expression.length() - (temp + 2));
3810 int RangeL = 0, RangeH = 0;
3813 ReportError(
"GetObjectRange: Invalid range");
3817 for (
size_t i = 0; i < ObjectArray.size(); i++)
3821 std::string tmpname = ObjectArray[i]->GetName();
3822 for (
int j = RangeL; j <= RangeH; j++)
3825 if (type ==
"floor")
3827 if (tmpname ==
"Floor " + number)
3828 objects.emplace_back(ObjectArray[i]);
3830 if (type ==
"elevator")
3832 if (tmpname ==
"Elevator " + number)
3833 objects.emplace_back(ObjectArray[i]);
3835 if (type ==
"shaft")
3837 if (tmpname ==
"Shaft " + number)
3838 objects.emplace_back(ObjectArray[i]);
3840 if (type ==
"stairwell")
3842 if (tmpname ==
"Stairwell " + number)
3843 objects.emplace_back(ObjectArray[i]);
3852 Object *obj = GetObject(expression);
3854 objects.emplace_back(obj);
3862 if (index >= 0 && index < (
int)ActionArray.size())
3863 return ActionArray[index];
3871 std::vector<Action*> actionlist = GetAction(name);
3874 for (
size_t i = 0; i < actionlist.size(); i++)
3876 bool result2 =
false;
3880 result2 = actionlist[i]->DoAction(
this, hold);
3882 if (result2 ==
false)
3892 Action *action = GetAction(index);
3895 return action->
DoAction(
this, hold);
3905 keys.emplace_back(key);
3907 Report(
"Added key " +
ToString(keyid) +
" (" + name +
") to keyring");
3914 for (
size_t i = 0; i < keys.size(); i++)
3916 if (keys[i].
id == keyid)
3926 Report(
"\n--- Keys ---\n");
3928 for (
size_t i = 0; i < keys.size(); i++)
3930 std::string
id =
ToString(keys[i].
id);
3931 Report(
id +
" - " + keys[i].name);
3939 control_index.emplace_back(control);
3946 for (
size_t i = 0; i < control_index.size(); i++)
3948 if (control_index[i] == control)
3950 control_index.erase(control_index.begin() + i);
3960 bool header_shown =
false;
3961 for (
int i = -Basements; i < Floors; i++)
3963 Floor *floor = GetFloor(i);
3966 if (header_shown ==
false)
3969 header_shown =
true;
3982 mSceneManager->setDisplaySceneNodes(value);
3989 mSceneManager->showBoundingBoxes(value);
3996 Report(
"\n--- Visible Dynamic Meshes ---");
3997 Report(
"Name\t-\tSubmeshes\n");
4002 for (
size_t i = 0; i < dynamic_meshes.size(); i++)
4004 for (
int j = 0; j < dynamic_meshes[i]->GetMeshCount(); j++)
4006 if (camera->IsDynamicMeshVisible(dynamic_meshes[i], j) ==
true)
4008 submeshes = dynamic_meshes[i]->GetSubMeshCount(j);
4009 Report(dynamic_meshes[i]->GetMeshName(j) +
"\t-\t" +
ToString(submeshes));
4015 Report(
"Total: " +
ToString(count) +
" meshes, " +
ToString(total) +
" submeshes");
4022 return (
int)EscalatorArray.size();
4028 return (
int)MovingWalkwayArray.size();
4037 Ray ray2 (ToRemote(ToGlobal(ToLocal(ray.getOrigin()))), GetOrientation() * ray.getDirection());
4040 OgreBulletCollisions::CollisionClosestRayResultCallback callback (ray2, mWorld, max_distance);
4043 mWorld->launchRay(callback);
4046 if (callback.doesCollide() ==
false)
4050 OgreBulletCollisions::Object*
object = callback.getCollidedObject();
4056 std::string meshname;
4057 if (
dynamic_cast<OgreBulletDynamics::WheeledRigidBody*
>(
object) == 0)
4058 meshname =
object->getRootNode()->getParentSceneNode()->getName();
4060 meshname =
object->getRootNode()->getChild(0)->getName();
4063 hit_position = ToLocal(callback.getCollisionPoint());
4066 mesh = FindMeshObject(meshname);
4072 Real distance = 2000000000.;
4073 Vector3 normal = Vector3::ZERO;
4086 int people = GetConfigInt(
"Skyscraper.SBS.Person.RandomPeople", 0);
4087 people = people == 0 ? GetTotalFloors() : people;
4088 for (
int i = 0; i < people; i++)
4090 Person *person = CreatePerson(
"Random " +
ToString(i + 1), Lobby,
false);
4097 Person *person = CreatePerson(
"Random " +
ToString(people + 1), Lobby,
true);
4102 else if (value ==
false)
4104 for (
size_t i = 0; i < PersonArray.size(); i++)
4106 if (PersonArray[i]->IsRandomActivityEnabled() ==
true)
4108 Person *person = PersonArray[i];
4115 RandomActivity = value;
4122 for (
int i = 1; i <= elevator_manager->GetCount(); i++)
4124 Elevator *elevator = elevator_manager->Get(i);
4131 for (
size_t i = 0; i < EscalatorArray.size(); i++)
4133 Escalator *escalator = EscalatorArray[i];
4140 Malfunctions = value;
4147 if (type ==
"Floor")
4149 for (
int i = 0; i < floor_manager->GetCount(); i++)
4151 if (floor_manager->GetIndex(i) ==
static_cast<Floor*
>(
object))
4155 else if (type ==
"Elevator")
4157 for (
int i = 0; i < elevator_manager->GetCount(); i++)
4159 if (elevator_manager->GetIndex(i) ==
static_cast<Elevator*
>(
object))
4163 else if (type ==
"Shaft")
4165 for (
int i = 0; i < shaft_manager->GetCount(); i++)
4167 if (shaft_manager->GetIndex(i) ==
static_cast<Shaft*
>(
object))
4171 else if (type ==
"Stairwell")
4173 for (
int i = 0; i < stairwell_manager->GetCount(); i++)
4175 if (stairwell_manager->GetIndex(i) ==
static_cast<Stairwell*
>(
object))
4179 else if (type ==
"Mesh")
4181 for (
size_t i = 0; i < meshes.size(); i++)
4183 if (meshes[i] ==
static_cast<MeshObject*
>(
object))
4187 else if (type ==
"Control")
4189 for (
size_t i = 0; i < control_index.size(); i++)
4191 if (control_index[i] ==
static_cast<Control*
>(
object))
4197 for (
size_t i = 0; i < ObjectArray.size(); i++)
4199 if (ObjectArray[i] ==
object)
4209 for (
size_t i = 0; i < ActionArray.size(); i++)
4211 if (ActionArray[i] == action)
4223 int number = GetPersonCount() + 1;
4224 name =
"Person " +
ToString(number);
4226 Person *person =
new Person(
this, name, floor, service_access);
4227 PersonArray.emplace_back(person);
4235 for (
size_t i = 0; i < PersonArray.size(); i++)
4237 if (PersonArray[i] == person)
4239 PersonArray.erase(PersonArray.begin() + i);
4247 if (cameras.size() > 0)
4248 return camera->Attach(cameras, init_state);
4254 return camera->Detach();
4265 size_t index = name.find(
":(");
4266 instance =
ToInt(name.substr(0, index));
4267 name.erase(name.begin(), name.begin() + index + 1);
4270 index = name.find(
")");
4271 object_number =
ToInt(name.substr(1, index - 1));
4273 if (strip_number ==
true)
4274 name.erase(name.begin(), name.begin() + index + 1);
4281 if (number < 0 || number > (
int)PersonArray.size() - 1)
4284 return PersonArray[number];
4292 return area_trigger->IsInside();
4303 return area_trigger->IsInside(position);
4313 min = area_trigger->GetMin();
4314 max = area_trigger->GetMax();
4318 min = Vector3::ZERO;
4319 max = Vector3::ZERO;
4331 Report(
"Cutting outside boundaries...");
4332 Vector3 min = area_trigger->GetMin();
4333 Vector3 max = area_trigger->GetMax();
4335 if (landscape ==
true)
4336 Landscape->CutOutsideBounds(min, max,
true,
true);
4337 if (buildings ==
true)
4338 Buildings->CutOutsideBounds(min, max,
true,
true);
4339 if (external ==
true && External)
4340 External->CutOutsideBounds(min, max,
true,
true);
4344 for (
int i = 0; i < floor_manager->GetCount(); i++)
4345 floor_manager->GetIndex(i)->Level->CutOutsideBounds(min, max,
true,
true);
4354 if (landscape ==
true)
4355 Landscape->Cut(min, max,
true,
true);
4356 if (buildings ==
true)
4357 Buildings->Cut(min, max,
true,
true);
4358 if (external ==
true && External)
4359 External->Cut(min, max,
true,
true);
4363 for (
int i = 0; i < floor_manager->GetCount(); i++)
4364 floor_manager->GetIndex(i)->Level->Cut(min, max,
true,
true);
4371 if (InstanceNumber == 0)
4374 if (area_min != Vector3::ZERO && area_max != Vector3::ZERO && !area_trigger)
4376 std::vector<std::string> names;
4377 names.emplace_back(
"Off");
4378 area_trigger =
new Trigger(
this,
"System Boundary",
true,
"", area_min, area_max, names);
4387 EnableBuildings(
true);
4388 EnableLandscape(
true);
4389 EnableExternal(
true);
4393 floor_manager->EnableAll(
false);
4394 shaft_manager->EnableAll(
false);
4395 stairwell_manager->EnableAll(
false);
4396 elevator_manager->EnableAll(
false);
4399 for (
size_t i = 0; i < reverbs.size(); i++)
4402 reverbs[i]->Enabled(
false);
4406 camera->ResetState();
4413 return (GetOrientation().Inverse() * position) + GetPosition();
4420 return (GetOrientation() * (position - GetPosition()));
4427 return (GetOrientation() * orientation);
4434 return (GetOrientation().Inverse() * orientation);
4443 for (
size_t i = 0; i < lights.size(); i++)
4445 if (
SetCaseCopy(lights[i]->GetName(),
false) == name)
4458 for (
size_t i = 0; i < ModelArray.size(); i++)
4460 if (
SetCaseCopy(ModelArray[i]->GetName(),
false) == name)
4461 return ModelArray[i];
4473 for (
size_t i = 0; i < PrimArray.size(); i++)
4475 if (
SetCaseCopy(PrimArray[i]->GetName(),
false) == name)
4476 return PrimArray[i];
4488 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
4490 if (
SetCaseCopy(CustomObjectArray[i]->GetName(),
false) == name)
4491 return CustomObjectArray[i];
4501 dynamic_meshes.emplace_back(dynmesh);
4508 for (
size_t i = 0; i < dynamic_meshes.size(); i++)
4510 if (dynamic_meshes[i] == dynmesh)
4512 dynamic_meshes.erase(dynamic_meshes.begin() + i);
4525 return (
int)PersonArray.size();
4530 return (area_trigger != 0);
4535 return floor_manager;
4540 return elevator_manager;
4545 return shaft_manager;
4550 return stairwell_manager;
4555 return door_manager;
4560 return texturemanager;
4565 return revolvingdoor_manager;
4570 return vehicle_manager;
4575 return controller_manager;
4582 camtexarray.emplace_back(camtex);
4589 for (
size_t i = 0; i < camtexarray.size(); i++)
4591 if (camtexarray[i] == camtex)
4593 camtexarray.erase(camtexarray.begin() + i);
4601 return (
int)camtexarray.size();
4606 if (number < camtexarray.size())
4607 return camtexarray[number];
4625 Report(
"--- Memory Report ---");
4628 for (
size_t i = 0; i < meshes.size(); i++)
4629 total += meshes[i]->GetSize();
4632 Report(
"Textures: " +
ToString(texturemanager->GetMemoryUsage() / 1024) +
" kb");
4635 Report(
"Meshes: " +
ToString(total / 1024) +
" kb");
4643 EscalatorArray.emplace_back(escalator);
4650 for (
size_t i = 0; i < EscalatorArray.size(); i++)
4652 if (EscalatorArray[i] == escalator)
4654 EscalatorArray.erase(EscalatorArray.begin() + i);
4662 if (index >= 0 && index < EscalatorArray.size())
4663 return EscalatorArray[index];
4670 MovingWalkwayArray.emplace_back(walkway);
4677 for (
size_t i = 0; i < MovingWalkwayArray.size(); i++)
4679 if (MovingWalkwayArray[i] == walkway)
4681 MovingWalkwayArray.erase(MovingWalkwayArray.begin() + i);
4689 if (index >= 0 && index < MovingWalkwayArray.size())
4690 return MovingWalkwayArray[index];
4698 power_state = value;
4710 return (
int)reverbs.size();
4715 if (index >= 0 && index < (
int)reverbs.size())
4716 return reverbs[index];
bool AddParent(Object *parent)
bool RemoveParent(Object *parent)
bool DoAction(Object *caller, bool &hold)
void EnableMalfunctions(bool value)
void EnableMalfunctions(bool value)
void ShowInfo(bool detailed=true, bool display_header=true)
void EnableGroup(bool value)
Wall * CreateWallObject(const std::string &name)
const std::string & GetName()
virtual Vector3 GetPosition(bool relative=false)
virtual void Enabled(bool value)
const std::string & GetType()
virtual void SetPosition(const Vector3 &position)
void EnableRandomActivity(bool value)
Wall * FindWallIntersect(const Vector3 &start, const Vector3 &end, Vector3 &isect, Real &distance, Vector3 &normal, Wall *wall=0)
static void Stop_Profile(void)
static void Start_Profile(const char *name)
std::string ProcessFullName(std::string name, int &instance, int &object_number, bool strip_number=false)
Action * AddAction(const std::string &name, std::vector< Object * > &action_parents, const std::string &command, const std::vector< std::string > ¶meters)
void RemoveReverb(Reverb *reverb)
Escalator * GetEscalator(int index)
Shaft * GetShaft(int number)
void UnregisterEscalator(Escalator *escalator)
Elevator * GetElevator(int number)
void DeleteMeshHandle(MeshObject *handle)
void EnableBuildings(bool value)
FloorManager * GetFloorManager()
bool HitBeam(const Ray &ray, Real max_distance, MeshObject *&mesh, Wall *&wall, Vector3 &hit_position)
Reverb * AddReverb(const std::string &name, const std::string &type, const Vector3 &position, Real min_distance, Real max_distance)
VehicleManager * GetVehicleManager()
void EnableMap(bool value)
void UnregisterCameraTexture(CameraTexture *camtex)
int GetFloorOrientation()
std::string GetConfigString(const std::string &key, const std::string &default_value)
void RemoveElevator(Elevator *elevator)
void RemoveControl(Control *control)
void AddMeshHandle(MeshObject *handle)
Vector3 ToGlobal(const Vector3 &position)
MeshObject * FindMeshObject(const std::string &name)
void RegisterDynamicMesh(DynamicMesh *dynmesh)
Light * GetLight(std::string name)
void RegisterMovingWalkway(MovingWalkway *walkway)
void RemoveSound(Sound *sound)
void RemoveShaft(Shaft *shaft)
bool AttachCamera(std::vector< Ogre::Camera * > &cameras, bool init_state=true)
CameraTexture * GetCameraTexture(int number)
Real GetConfigFloat(const std::string &key, Real default_value)
unsigned long GetAverageTime()
void IncrementReverbCount()
StairwellManager * GetStairwellManager()
bool Mount(const std::string &filename, const std::string &path)
Shaft * CreateShaft(int number, Real CenterX, Real CenterZ, int startfloor, int endfloor)
DoorManager * GetDoorManager()
bool RemoveActionParent(const std::string &name, std::vector< Object * > &parents)
void IncrementSoundCount()
std::string GetFilesystemPath(std::string filename)
int GetTimerCallbackCount()
DispatchController * GetController(int number)
void CutOutsideBoundaries(bool landscape=true, bool buildings=true, bool external=false, bool floors=false)
Sound * AddSound(const std::string &name, const std::string &filename, const Vector3 &position, bool loop=true, Real volume=1.0, int speed=100, Real min_distance=1.0, Real max_distance=-1.0, Real doppler_level=0.0, Real cone_inside_angle=360, Real cone_outside_angle=360, Real cone_outside_volume=1.0, const Vector3 &direction=Vector3(0, 0, 0))
CustomObject * GetCustomObject(std::string name)
void AddFloorAutoArea(Vector3 start, Vector3 end)
void RegisterCameraTexture(CameraTexture *camtex)
std::string GetMountPath(std::string filename, std::string &newfilename)
bool FileExists(const std::string &filename)
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 RemovePerson(Person *person)
void RemoveLight(Light *light)
void RegisterEscalator(Escalator *escalator)
void RemoveStairwell(Stairwell *stairs)
Wall * AddFloor(MeshObject *mesh, 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 legacy_behavior=false)
unsigned long GetElapsedTime()
DispatchController * NewController(int number)
bool IsObjectValid(Object *object, std::string type="")
void DecrementReverbCount()
Real MetersToFeet(Real meters)
void ResetWalls(bool ToDefaults=false)
void CacheFilename(const std::string &filename, const std::string &result)
void EnableMalfunctions(bool value)
void ShowBoundingBoxes(bool value)
bool IsValidFloor(int floor)
Model * GetModel(std::string name)
Floor * GetFloor(int number)
SBS(Ogre::SceneManager *mSceneManager, FMOD::System *fmodsystem, int instance_number, const Vector3 &position=Vector3::ZERO, Real rotation=0.0f, const Vector3 &area_min=Vector3::ZERO, const Vector3 &area_max=Vector3::ZERO)
Vehicle * NewVehicle(int number)
MovingWalkway * GetMovingWalkway(int index)
bool RunAction(const std::string &name)
Stairwell * GetStairwell(int number)
TextureManager * GetTextureManager()
bool MoveObject(Object *object, Vector3 position, bool relative, bool X, bool Y, bool Z)
void RemoveFloor(Floor *floor)
void RemoveModel(Model *model)
void ShowSceneNodes(bool value)
Wall * AddCustomFloor(MeshObject *mesh, const std::string &name, const std::string &texture, std::vector< Vector2 > &varray, Real altitude, Real tw, Real th)
Vehicle * GetVehicle(int number)
void EnableLandscape(bool value)
int GetTotalReverbCount()
Wall * CreateWallBox2(MeshObject *mesh, const std::string &name, const std::string &texture, Real CenterX, Real CenterZ, Real WidthX, Real LengthZ, Real height_in, Real voffset, Real tw, Real th, bool inside=true, bool outside=true, bool top=true, bool bottom=true, bool autosize=true)
Primitive * AddPrimitive(const std::string &name)
bool RegisterTimerCallback(TimerObject *timer)
void AddKey(int keyid, const std::string &name)
void EnableSkybox(bool value)
bool IsActionValid(Action *action)
Object * GetObjectOfParent(std::string parent_name, std::string name, const std::string &type, bool case_sensitive=true)
int GetFloorNumber(Real altitude, int lastfloor=0, bool checklastfloor=false)
Real GetDistance(Real x1, Real x2, Real z1, Real z2)
void CalculateFrameRate()
Wall * AddCustomWall(MeshObject *mesh, const std::string &name, const std::string &texture, PolyArray &varray, Real tw, Real th)
Model * AddModel(const std::string &name, const std::string &filename, bool center, const Vector3 &position, const 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 RemoveTrigger(Trigger *trigger)
void SetBounds(const Vector3 &area_min, const Vector3 &area_max)
void EnableRandomActivity(bool value)
unsigned long GetCurrentTime()
Primitive * GetPrimitive(std::string name)
int GetCameraTextureCount()
Wall * AddTriangleWall(MeshObject *mesh, const std::string &name, const std::string &texture, Real x1, Real y1, Real z1, Real x2, Real y2, Real z2, Real x3, Real y3, Real z3, Real tw, Real th)
Real FeetToMeters(Real feet)
void SetPower(bool value)
Real ToLocal(Real remote_value)
bool AddActionParent(const std::string &name, std::vector< Object * > &parents)
bool GetConfigBool(const std::string &key, bool default_value)
Wall * AddWall(MeshObject *mesh, 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)
void RegisterControl(Control *control)
int RegisterObject(Object *object)
Person * CreatePerson(std::string name="", int floor=0, bool service_access=false)
Floor * NewFloor(int number)
int GetConfigInt(const std::string &key, int default_value)
void EnableExternal(bool value)
void EnableFloorRange(int floor, int range, bool value, bool enablegroups, int shaftnumber=0, int stairsnumber=0)
std::vector< Sound * > GetSound(const std::string &name)
Vector3 FromGlobal(const Vector3 &position)
Trigger * AddTrigger(const std::string &name, const std::string &sound_file, const Vector3 &area_min, const Vector3 &area_max, std::vector< std::string > &action_names)
GeometryController * GetGeometry()
CustomObject * AddCustomObject(const std::string &name, const Vector3 &position, const Vector3 &rotation, Real max_render_distance=0, Real scale_multiplier=1)
void CutInsideBoundaries(const Vector3 &min, const Vector3 &max, bool landscape=true, bool buildings=true, bool external=false, bool floors=false)
std::vector< Action * > GetAction(std::string name)
int GetMovingWalkwayCount()
Reverb * GetReverb(const std::string &name)
Real ToRemote(Real local_value)
bool Start(std::vector< Ogre::Camera * > &cameras)
void CalculateAverageTime()
void Prepare(bool report=true, bool renderonly=false)
unsigned long GetRunTime()
void RemoveController(DispatchController *controller)
bool SetWallOrientation(std::string direction)
ControllerManager * GetControllerManager()
bool SetFloorOrientation(std::string direction)
void UnregisterControl(Control *control)
bool UnregisterTimerCallback(TimerObject *timer)
void SetLighting(Real red=1.0, Real green=1.0, Real blue=1.0)
void AddPolygon(Wall *wallobject, const std::string &texture, PolyArray &varray, Real tw, Real th)
ElevatorManager * GetElevatorManager()
void UnregisterDynamicMesh(DynamicMesh *dynmesh)
bool RotateObject(Object *object, Vector3 rotation, Real speed, bool relative, bool X, bool Y, bool Z)
bool RemoveAction(std::string name)
void DrawWalls(bool MainN, bool MainP, bool SideN, bool SideP, bool Top, bool Bottom)
SoundSystem * GetSoundSystem()
void DecrementSoundCount()
Wall * AddGround(const std::string &name, const std::string &texture, Real x1, Real z1, Real x2, Real z2, Real altitude, int tile_x, int tile_z)
void UnregisterMovingWalkway(MovingWalkway *walkway)
Object * GetObject(int number)
ShaftManager * GetShaftManager()
bool InBox(const Vector3 &start, const Vector3 &end, const Vector3 &test)
Wall * CreateWallBox(MeshObject *mesh, const std::string &name, const std::string &texture, Real x1, Real x2, Real z1, Real z2, Real height_in, Real voffset, Real tw, Real th, bool inside=true, bool outside=true, bool top=true, bool bottom=true, bool autosize=true)
void RemoveCustomObject(CustomObject *object)
bool GetBounds(Vector3 &min, Vector3 &max)
Stairwell * CreateStairwell(int number, Real CenterX, Real CenterZ, int startfloor, int endfloor)
void RemovePrimitive(Primitive *prim)
Light * AddLight(const std::string &name, int type)
bool UnregisterObject(int number)
std::vector< Object * > GetObjectRange(const std::string &expression)
void ShowColliders(bool value)
bool DeleteObject(Object *object)
Person * GetPerson(int number)
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)
Elevator * NewElevator(int number)
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)
std::string VerifyFile(const std::string &filename)
RevolvingDoorManager * GetRevolvingDoorManager()
bool IsShowFloor(int floor)
bool IsValidFloor(int floor)
bool Load(const std::string &filename, bool force=false)
bool Play(bool reset=true)
void SetSpeed(int percent)
void SetDopplerLevel(Real level)
void SetLoopState(bool value)
void SetConeSettings(Real inside_angle=360.0, Real outside_angle=360.0, Real outside_volume=1.0)
void SetVolume(Real value)
void SetDirection(const Vector3 &direction)
void SetDistances(Real min, Real max)
bool IsValidFloor(int floor)
bool IsShowFloor(int floor)
bool Create(const Vector3 &position)
Polygon * AddQuad(const std::string &name, const std::string &texture, const Vector3 &v1, const Vector3 &v2, const Vector3 &v3, const Vector3 &v4, Real tw, Real th, bool autosize)
Polygon * AddPolygon(const std::string &name, const std::string &texture, PolyArray &vertices, Real tw, Real th, bool autosize)
Ogre::Quaternion Quaternion
std::vector< String > StringVector
SharedPtr< StringVector > StringVectorPtr
bool SBSIMPEXP enable_profiling
std::vector< Vector3 > PolyArray
std::string TruncateNumber(float value, int decimals)
bool SBSIMPEXP enable_advanced_profiling
void ReplaceAll(std::string &string, const std::string &original, const std::string &replacement)
int ToInt(const std::string &string)
void SetCase(std::string &string, bool uppercase)
std::string ToString(int number)
std::string SetCaseCopy(std::string string, bool uppercase)
Real ToFloat(const std::string &string)
bool IsNumeric(char character)
bool StartsWith(const std::string &string, const std::string &check_string, bool ignore_case)
std::string BoolToString(bool item)
void TrimString(std::string &string)
bool ToBool(std::string string)
#define SBS_PROFILE(name)
#define SBS_PROFILE_MAIN(name)