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 =
"RC5";
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);
187 Ogre::MeshManager::getSingleton().setBoundsPaddingFactor(0.0);
205 InstancePrompt =
ToString(InstanceNumber) +
">";
211 Rotate(0.0, rotation, 0.0);
214 SetBounds(area_min, area_max);
227 Ogre::AxisAlignedBox box (Vector3::ZERO, Vector3::ZERO);
228 mWorld =
new OgreBulletDynamics::DynamicsWorld(mSceneManager, box, Vector3::ZERO,
true);
229 mWorld->setAllowedCcdPenetration(0);
239 Mount(
"signs-sans.zip",
"signs/sans");
240 Mount(
"signs-sans_bold.zip",
"signs/sans_bold");
241 Mount(
"signs-sans_cond.zip",
"signs/sans_cond");
242 Mount(
"signs-sans_cond_bold.zip",
"signs/sans_cond_bold");
245 Buildings =
new MeshObject(
this,
"Buildings");
247 Landscape =
new MeshObject(
this,
"Landscape");
261 this->camera =
new Camera(
this);
264 MapGenerator =
new Map(
this,
"Map Generator");
274 Report(
"Deleting simulator objects...");
279 for (
size_t i = 0; i < PersonArray.size(); i++)
283 PersonArray[i]->parent_deleting =
true;
284 delete PersonArray[i];
290 for (
size_t i = 0; i < ControlArray.size(); i++)
294 ControlArray[i]->parent_deleting =
true;
295 delete ControlArray[i];
301 for (
size_t i = 0; i < TriggerArray.size(); i++)
305 TriggerArray[i]->parent_deleting =
true;
306 delete TriggerArray[i];
312 for (
size_t i = 0; i < ModelArray.size(); i++)
316 ModelArray[i]->parent_deleting =
true;
317 delete ModelArray[i];
323 for (
size_t i = 0; i < PrimArray.size(); i++)
327 PrimArray[i]->parent_deleting =
true;
334 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
336 if (CustomObjectArray[i])
338 CustomObjectArray[i]->parent_deleting =
true;
339 delete CustomObjectArray[i];
341 CustomObjectArray[i] = 0;
345 for (
size_t i = 0; i < lights.size(); i++)
349 lights[i]->parent_deleting =
true;
363 camera->parent_deleting =
true;
371 floor_manager->parent_deleting =
true;
372 delete floor_manager;
376 if (elevator_manager)
378 elevator_manager->parent_deleting =
true;
379 delete elevator_manager;
381 elevator_manager = 0;
385 shaft_manager->parent_deleting =
true;
386 delete shaft_manager;
390 if (stairwell_manager)
392 stairwell_manager->parent_deleting =
true;
393 delete stairwell_manager;
395 stairwell_manager = 0;
399 door_manager->parent_deleting =
true;
404 if (revolvingdoor_manager)
406 revolvingdoor_manager->parent_deleting =
true;
407 delete revolvingdoor_manager;
409 revolvingdoor_manager = 0;
413 vehicle_manager->parent_deleting =
true;
414 delete vehicle_manager;
418 if (controller_manager)
420 controller_manager->parent_deleting =
true;
421 delete controller_manager;
423 controller_manager = 0;
426 for (
size_t i = 0; i < sounds.size(); i++)
430 sounds[i]->parent_deleting =
true;
437 for (
size_t i = 0; i < ActionArray.size(); i++)
440 delete ActionArray[i];
447 SkyBox->parent_deleting =
true;
454 Landscape->parent_deleting =
true;
461 External->parent_deleting =
true;
468 Buildings->parent_deleting =
true;
476 soundsystem->parent_deleting =
true;
483 delete texturemanager;
489 area_trigger->parent_deleting =
true;
504 verify_results.clear();
536 texturemanager->FreeTextureBoxes();
545 for (
size_t i = 0; i < sounds.size(); i++)
549 if (sounds[i]->GetLoopState() ==
true)
555 AttachCamera(cameras);
558 if (RandomActivity ==
true)
559 EnableRandomActivity(
true);
562 if (Malfunctions ==
true)
563 EnableMalfunctions(
true);
566 for (
size_t i = 0; i < reverbs.size(); i++)
569 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 named LICENSE\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,
bool report)
697 if (x1 == x2 && z1 == z2)
698 return ReportError(
"Invalid coordinates for wall '" + name +
"'");
700 if (height_in1 == 0.0f && height_in2 == 0.0)
701 return ReportError(
"No wall height specified for wall '" + name +
"'");
705 if (std::abs(x1 - x2) > (std::abs(z1 - z2) + 0.00001))
713 if ((x1 > x2 && axis == 1) || (z1 < z2 && axis == 2))
718 std::swap(altitude1, altitude2);
719 std::swap(height_in1, height_in2);
723 Vector3 v1 (x1, altitude1 + height_in1, z1);
724 Vector3 v2 (x2, altitude2 + height_in2, z2);
725 Vector3 v3 (x2, altitude2, z2);
726 Vector3 v4 (x1, altitude1, z1);
738 if (area_trigger->IsOutside(v1x, v2x) ==
true)
741 ReportError(
"Cannot create wall outside of engine boundaries");
750 if (wall_orientation == 0)
758 if (wall_orientation == 1)
761 Real half = thickness / 2;
771 if (wall_orientation == 2)
783 if (wall_orientation == 0)
791 if (wall_orientation == 1)
794 Real half = thickness / 2;
804 if (wall_orientation == 2)
815 std::string NewName, texture2 = texture;
816 Real tw2 = tw, th2 = th;
818 bool FlipTexture = texturemanager->FlipTexture;
819 bool TextureOverride = texturemanager->TextureOverride;
821 if (FlipTexture ==
true)
822 texturemanager->ProcessTextureFlip(tw, th);
824 if (DrawMainN ==
true)
826 if (FlipTexture ==
true)
828 tw2 = texturemanager->widthscale[0];
829 th2 = texturemanager->heightscale[0];
831 if (TextureOverride ==
true)
832 texture2 = texturemanager->mainnegtex;
835 if (GetDrawWallsCount() > 1)
836 NewName.append(
":front");
837 wallobject->
AddQuad(NewName, texture2, v1, v2, v3, v4, tw2, th2, autosize);
840 if (DrawMainP ==
true)
842 if (FlipTexture ==
true)
844 tw2 = texturemanager->widthscale[1];
845 th2 = texturemanager->heightscale[1];
847 if (TextureOverride ==
true)
848 texture2 = texturemanager->mainpostex;
851 NewName.append(
":back");
852 wallobject->
AddQuad(NewName, texture2, v6, v5, v8, v7, tw2, th2, autosize);
855 if (thickness != 0.0)
857 if (DrawSideN ==
true)
859 if (FlipTexture ==
true)
861 tw2 = texturemanager->widthscale[2];
862 th2 = texturemanager->heightscale[2];
864 if (TextureOverride ==
true)
865 texture2 = texturemanager->sidenegtex;
868 NewName.append(
":left");
870 wallobject->
AddQuad(NewName, texture2, v5, v1, v4, v8, tw2, th2, autosize);
872 wallobject->
AddQuad(NewName, texture2, v2, v6, v7, v3, tw2, th2, autosize);
875 if (DrawSideP ==
true)
877 if (FlipTexture ==
true)
879 tw2 = texturemanager->widthscale[3];
880 th2 = texturemanager->heightscale[3];
882 if (TextureOverride ==
true)
883 texture2 = texturemanager->sidepostex;
886 NewName.append(
":right");
888 wallobject->
AddQuad(NewName, texture2, v2, v6, v7, v3, tw2, th2, autosize);
890 wallobject->
AddQuad(NewName, texture2, v5, v1, v4, v8, tw2, th2, autosize);
895 if (FlipTexture ==
true)
897 tw2 = texturemanager->widthscale[4];
898 th2 = texturemanager->heightscale[4];
900 if (TextureOverride ==
true)
901 texture2 = texturemanager->toptex;
904 NewName.append(
":top");
905 wallobject->
AddQuad(NewName, texture2, v5, v6, v2, v1, tw2, th2, autosize);
908 if (DrawBottom ==
true)
910 if (FlipTexture ==
true)
912 tw2 = texturemanager->widthscale[5];
913 th2 = texturemanager->heightscale[5];
915 if (TextureOverride ==
true)
916 texture2 = texturemanager->bottomtex;
919 NewName.append(
":bottom");
920 wallobject->
AddQuad(NewName, texture2, v4, v3, v7, v8, tw2, th2, autosize);
927bool 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,
bool report)
938 if (x1 == x2 || z1 == z2)
939 return ReportError(
"Invalid coordinates for floor '" + name +
"'");
945 if (std::abs(x1 - x2) > (std::abs(z1 - z2) + 0.00001))
952 if (legacy_behavior ==
false)
960 if (reverse_axis ==
true)
961 std::swap(altitude1, altitude2);
967 if (reverse_axis ==
false)
968 std::swap(altitude1, altitude2);
975 if ((x1 > x2 && axis == 1) || (z1 > z2 && axis == 2))
980 std::swap(altitude1, altitude2);
987 if (reverse_axis ==
false)
989 v1 =
Vector3(x1, altitude1, z1);
990 v2 =
Vector3(x2, altitude1, z1);
991 v3 =
Vector3(x2, altitude2, z2);
992 v4 =
Vector3(x1, altitude2, z2);
996 if (legacy_behavior ==
true)
998 v1 =
Vector3(x1, altitude1, z1);
999 v2 =
Vector3(x1, altitude1, z2);
1000 v3 =
Vector3(x2, altitude2, z2);
1001 v4 =
Vector3(x2, altitude2, z1);
1005 v1 =
Vector3(x2, altitude2, z1);
1006 v2 =
Vector3(x2, altitude2, z2);
1007 v3 =
Vector3(x1, altitude1, z2);
1008 v4 =
Vector3(x1, altitude1, z1);
1022 if (area_trigger->IsOutside(v1x, v2x) ==
true)
1025 ReportError(
"Cannot create floor outside of engine boundaries");
1031 if (floor_orientation == 0)
1039 if (floor_orientation == 1)
1042 Real half = thickness / 2;
1052 if (floor_orientation == 2)
1062 std::string NewName, texture2 = texture;
1063 Real tw2 = tw, th2 = th;
1065 bool FlipTexture = texturemanager->FlipTexture;
1066 bool TextureOverride = texturemanager->TextureOverride;
1068 if (FlipTexture ==
true)
1069 texturemanager->ProcessTextureFlip(tw, th);
1072 bool old_planarrotate = texturemanager->GetPlanarRotate();
1073 texturemanager->SetPlanarRotate(texture_direction);
1075 if (DrawMainN ==
true)
1077 if (FlipTexture ==
true)
1079 tw2 = texturemanager->widthscale[0];
1080 th2 = texturemanager->heightscale[0];
1082 if (TextureOverride ==
true)
1083 texture2 = texturemanager->mainnegtex;
1086 if (GetDrawWallsCount() > 1)
1087 NewName.append(
":front");
1088 wallobject->
AddQuad(NewName, texture2, v1, v2, v3, v4, tw2, th2, autosize);
1091 if (DrawMainP ==
true)
1093 if (FlipTexture ==
true)
1095 tw2 = texturemanager->widthscale[1];
1096 th2 = texturemanager->heightscale[1];
1098 if (TextureOverride ==
true)
1099 texture2 = texturemanager->mainpostex;
1102 NewName.append(
":back");
1103 wallobject->
AddQuad(NewName, texture2, v8, v7, v6, v5, tw2, th2, autosize);
1106 if (thickness != 0.0)
1108 if (DrawSideN ==
true)
1110 if (FlipTexture ==
true)
1112 tw2 = texturemanager->widthscale[2];
1113 th2 = texturemanager->heightscale[2];
1115 if (TextureOverride ==
true)
1116 texture2 = texturemanager->sidenegtex;
1119 NewName.append(
":left");
1120 wallobject->
AddQuad(NewName, texture2, v8, v5, v1, v4, tw2, th2, autosize);
1123 if (DrawSideP ==
true)
1125 if (FlipTexture ==
true)
1127 tw2 = texturemanager->widthscale[3];
1128 th2 = texturemanager->heightscale[3];
1130 if (TextureOverride ==
true)
1131 texture2 = texturemanager->sidepostex;
1134 NewName.append(
":right");
1135 wallobject->
AddQuad(NewName, texture2, v6, v7, v3, v2, tw2, th2, autosize);
1138 if (DrawTop ==
true)
1140 if (FlipTexture ==
true)
1142 tw2 = texturemanager->widthscale[4];
1143 th2 = texturemanager->heightscale[4];
1145 if (TextureOverride ==
true)
1146 texture2 = texturemanager->toptex;
1149 NewName.append(
":top");
1150 wallobject->
AddQuad(NewName, texture2, v5, v6, v2, v1, tw2, th2, autosize);
1153 if (DrawBottom ==
true)
1155 if (FlipTexture ==
true)
1157 tw2 = texturemanager->widthscale[5];
1158 th2 = texturemanager->heightscale[5];
1160 if (TextureOverride ==
true)
1161 texture2 = texturemanager->bottomtex;
1164 NewName.append(
":bottom");
1165 wallobject->
AddQuad(NewName, texture2, v7, v8, v4, v3, tw2, th2, autosize);
1169 texturemanager->SetPlanarRotate(old_planarrotate);
1174Wall*
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,
bool report)
1182 if (x1 == x2 && z1 == z2)
1184 ReportError(
"Invalid coordinates for wall '" + name +
"'");
1191 bool x_thickness =
false, z_thickness =
false;
1192 std::string NewName, texture2 = texture;
1207 if (sbs->GetAreaTrigger())
1209 if (sbs->GetAreaTrigger()->IsOutside(
Vector3(x1, voffset, z1),
Vector3(x2, voffset + height_in, z2)) ==
true)
1212 ReportError(
"Cannot create wall box outside of engine boundaries");
1217 bool TextureOverride = texturemanager->TextureOverride;
1224 NewName.append(
":inside");
1226 if (x_thickness ==
true)
1228 if (TextureOverride ==
true)
1229 texture2 = texturemanager->mainnegtex;
1236 Vector3(x2, voffset + height_in, z1),
1237 Vector3(x1, voffset + height_in, z1), tw, th, autosize);
1239 if (TextureOverride ==
true)
1240 texture2 = texturemanager->mainpostex;
1247 Vector3(x1, voffset + height_in, z2),
1248 Vector3(x2, voffset + height_in, z2), tw, th, autosize);
1250 if (z_thickness ==
true)
1252 if (TextureOverride ==
true)
1253 texture2 = texturemanager->sidepostex;
1260 Vector3(x2, voffset + height_in, z2),
1261 Vector3(x2, voffset + height_in, z1), tw, th, autosize);
1263 if (TextureOverride ==
true)
1264 texture2 = texturemanager->sidenegtex;
1271 Vector3(x1, voffset + height_in, z1),
1272 Vector3(x1, voffset + height_in, z2), tw, th, autosize);
1274 if (x_thickness ==
true && z_thickness ==
true)
1278 if (TextureOverride ==
true)
1279 texture2 = texturemanager->bottomtex;
1287 Vector3(x1, voffset, z1), tw, th, autosize);
1292 if (TextureOverride ==
true)
1293 texture2 = texturemanager->toptex;
1298 Vector3(x1, voffset + height_in, z1),
1299 Vector3(x2, voffset + height_in, z1),
1300 Vector3(x2, voffset + height_in, z2),
1301 Vector3(x1, voffset + height_in, z2), tw, th, autosize);
1306 if (outside ==
true)
1309 NewName.append(
":outside");
1311 if (x_thickness ==
true)
1313 if (TextureOverride ==
true)
1314 texture2 = texturemanager->mainnegtex;
1319 Vector3(x1, voffset + height_in, z1),
1320 Vector3(x2, voffset + height_in, z1),
1322 Vector3(x1, voffset, z1), tw, th, autosize);
1324 if (TextureOverride ==
true)
1325 texture2 = texturemanager->mainpostex;
1330 Vector3(x2, voffset + height_in, z2),
1331 Vector3(x1, voffset + height_in, z2),
1333 Vector3(x2, voffset, z2), tw, th, autosize);
1335 if (z_thickness ==
true)
1337 if (TextureOverride ==
true)
1338 texture2 = texturemanager->sidepostex;
1343 Vector3(x2, voffset + height_in, z1),
1344 Vector3(x2, voffset + height_in, z2),
1346 Vector3(x2, voffset, z1), tw, th, autosize);
1348 if (TextureOverride ==
true)
1349 texture2 = texturemanager->sidenegtex;
1354 Vector3(x1, voffset + height_in, z2),
1355 Vector3(x1, voffset + height_in, z1),
1357 Vector3(x1, voffset, z2), tw, th, autosize);
1359 if (x_thickness ==
true && z_thickness ==
true)
1363 if (TextureOverride ==
true)
1364 texture2 = texturemanager->bottomtex;
1372 Vector3(x1, voffset, z2), tw, th, autosize);
1376 if (TextureOverride ==
true)
1377 texture2 = texturemanager->toptex;
1382 Vector3(x1, voffset + height_in, z2),
1383 Vector3(x2, voffset + height_in, z2),
1384 Vector3(x2, voffset + height_in, z1),
1385 Vector3(x1, voffset + height_in, z1), tw, th, autosize);
1392Wall*
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,
bool report)
1396 Real x1 = CenterX - (WidthX / 2);
1397 Real x2 = CenterX + (WidthX / 2);
1398 Real z1 = CenterZ - (LengthZ / 2);
1399 Real z2 = CenterZ + (LengthZ / 2);
1401 return CreateWallBox(mesh, name, texture, x1, x2, z1, z2, height_in, voffset, tw, th, inside, outside, top, bottom, autosize, report);
1415 size_t num = varray.size();
1418 varray2.reserve(num);
1419 for (
size_t i = num - 1; i < num; --i)
1420 varray2.emplace_back(varray1[i]);
1425 Vector3 direction = utility->GetPolygonDirection(varray1);
1429 if (direction.x == 1 || direction.y == -1 || direction.z == 1)
1430 std::swap(varray1, varray2);
1432 std::string name = wallobject->
GetName();
1435 if (sbs->GetAreaTrigger())
1437 for (
size_t i = 0; i < varray1.size(); i++)
1439 if (sbs->GetAreaTrigger()->IsOutside(varray1[i]) ==
true)
1442 ReportError(
"Cannot create polygon outside of engine boundaries");
1449 if (DrawMainN ==
true)
1451 std::string NewName = name;
1452 if (DrawMainP ==
true)
1453 NewName.append(
":0");
1454 std::string final_texture = texture;
1455 if (texturemanager->TextureOverride ==
true)
1456 final_texture = texturemanager->mainnegtex;
1457 wallobject->
AddPolygon(NewName, final_texture, varray1, tw, th,
true);
1459 if (DrawMainP ==
true)
1461 std::string NewName = name;
1462 if (DrawMainN ==
true)
1463 NewName.append(
":1");
1464 std::string final_texture = texture;
1465 if (texturemanager->TextureOverride ==
true)
1466 final_texture = texturemanager->mainpostex;
1467 wallobject->
AddPolygon(NewName, final_texture, varray2, tw, th,
true);
1482 AddPolygon(wall, texture, varray, tw, th);
1493 varray3.reserve(varray.size());
1494 for (
size_t i = 0; i < varray.size(); i++)
1496 varray3.emplace_back(
Vector3(varray[i].x, altitude, varray[i].y));
1500 return AddCustomWall(mesh, name, texture, varray3, tw, th);
1503Wall*
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)
1510 varray.emplace_back(
Vector3(x1, y1, z1));
1511 varray.emplace_back(
Vector3(x2, y2, z2));
1512 varray.emplace_back(
Vector3(x3, y3, z3));
1515 return AddCustomWall(mesh, name, texture, varray, tw, th);
1521 Buildings->Enabled(value);
1522 IsBuildingsEnabled = value;
1528 Landscape->Enabled(value);
1529 IsLandscapeEnabled = value;
1537 External->Enabled(value);
1538 IsExternalEnabled = value;
1546 SkyBox->Enabled(value);
1547 IsSkyboxEnabled = value;
1550 IsSkyboxEnabled =
true;
1558 if (InstanceNumber > 0)
1561 bool result = Mount(
"sky-" + SkyName +
".zip",
"sky");
1567 texturemanager->LoadTexture(
"sky/up.jpg",
"SkyTop", -1, -1,
false,
false,
false, 0);
1568 texturemanager->LoadTexture(
"sky/down.jpg",
"SkyBottom", -1, -1,
false,
false,
false, 0);
1569 texturemanager->LoadTexture(
"sky/left.jpg",
"SkyLeft", 1, 1,
false,
false,
false, 0);
1570 texturemanager->LoadTexture(
"sky/right.jpg",
"SkyRight", 1, 1,
false,
false,
false, 0);
1571 texturemanager->LoadTexture(
"sky/front.jpg",
"SkyFront", 1, 1,
false,
false,
false, 0);
1572 texturemanager->LoadTexture(
"sky/back.jpg",
"SkyBack", 1, 1,
false,
false,
false, 0);
1578 SkyBox->create_collider =
false;
1581 Real skysize = GetConfigInt(
"Skyscraper.SBS.HorizonDistance", 30) * 5280.0;
1584 texturemanager->ResetTextureMapping(
true);
1587 texturemanager->SetTextureOverride(
"SkyFront",
"SkyBack",
"SkyLeft",
"SkyRight",
"SkyTop",
"SkyBottom");
1590 CreateWallBox(SkyBox,
"SkyBox",
"SkyFront", -skysize, skysize, -skysize, skysize, skysize, -skysize / 2, 1, 1,
true,
true,
true,
true,
false);
1593 texturemanager->ResetTextureMapping();
1600 if (GetTotalFloors() == 0)
1604 if (GetFloor(-Basements))
1606 if (altitude < GetFloor(-Basements)->Altitude)
1611 if (checklastfloor ==
true && GetFloor(lastfloor))
1613 Real lastfloor_altitude = GetFloor(lastfloor)->Altitude;
1614 Real upperfloor_altitude;
1615 if (lastfloor < Floors - 1)
1617 if (GetFloor(lastfloor + 1))
1618 upperfloor_altitude = GetFloor(lastfloor + 1)->Altitude;
1620 upperfloor_altitude = GetFloor(lastfloor)->Altitude + GetFloor(lastfloor)->FullHeight();
1623 upperfloor_altitude = GetFloor(lastfloor)->Altitude + GetFloor(lastfloor)->FullHeight();
1625 if (upperfloor_altitude > altitude && lastfloor_altitude <= altitude)
1630 if (altitude < lastfloor_altitude)
1632 for (
int i = lastfloor - 1; i >= -Basements; i--)
1634 if (!GetFloor(i + 1) || !GetFloor(i))
1636 if (GetFloor(i + 1)->Altitude > altitude && GetFloor(i)->Altitude <= altitude)
1640 else if (altitude >= upperfloor_altitude)
1642 for (
int i = lastfloor + 1; i < Floors; i++)
1646 if (GetFloor(i - 1))
1648 if (GetFloor(i - 1)->Altitude <= altitude && GetFloor(i)->Altitude > altitude)
1651 if (i == Floors - 1 && GetFloor(i)->Altitude <= altitude)
1659 for (
int i = -Basements + 1; i < Floors; i++)
1666 if (GetFloor(i - 1))
1668 if ((GetFloor(i)->Altitude > altitude) && (GetFloor(i - 1)->Altitude <= altitude))
1672 if ((i == Floors - 1) && (altitude > GetFloor(i)->Altitude))
1683 return std::abs(x1 - x2);
1685 return std::abs(z1 - z2);
1686 if ((x1 != x2) && (z2 != x2))
1687 return sqrt(pow(std::abs(x1 - x2), 2) + pow(std::abs(z1 - z2), 2));
1695 return shaft_manager->Create(number, CenterX, CenterZ, startfloor, endfloor);
1702 return stairwell_manager->Create(number, CenterX, CenterZ, startfloor, endfloor);
1709 return elevator_manager->Create(number);
1716 return floor_manager->Create(number);
1723 return vehicle_manager->
Create(number);
1730 return controller_manager->Create(number);
1736 return elevator_manager->GetCount();
1742 return vehicle_manager->GetCount();
1748 return floor_manager->GetCount();
1754 return shaft_manager->GetCount();
1760 return stairwell_manager->GetCount();
1766 return controller_manager->GetCount();
1773 return floor_manager->Get(number);
1780 return elevator_manager->Get(number);
1787 return shaft_manager->Get(number);
1794 return stairwell_manager->Get(number);
1801 return vehicle_manager->Get(number);
1808 return controller_manager->Get(number);
1821 if (direction ==
"left")
1822 wall_orientation = 0;
1823 else if (direction ==
"center")
1824 wall_orientation = 1;
1825 else if (direction ==
"right")
1826 wall_orientation = 2;
1828 return ReportError(
"SetWallOrientation: Invalid wall orientation");
1834 return wall_orientation;
1847 if (direction ==
"bottom")
1848 floor_orientation = 0;
1849 else if (direction ==
"center")
1850 floor_orientation = 1;
1851 else if (direction ==
"top")
1852 floor_orientation = 2;
1854 return ReportError(
"SetFloorOrientation: Invalid floor orientation");
1860 return floor_orientation;
1863void SBS::DrawWalls(
bool MainN,
bool MainP,
bool SideN,
bool SideP,
bool Top,
bool Bottom)
1868 DrawMainNOld = DrawMainN;
1869 DrawMainPOld = DrawMainP;
1870 DrawSideNOld = DrawSideN;
1871 DrawSidePOld = DrawSideP;
1872 DrawTopOld = DrawTop;
1873 DrawBottomOld = DrawBottom;
1881 DrawBottom = Bottom;
1889 if (ToDefaults ==
true)
1890 DrawWalls(
true,
true,
false,
false,
false,
false);
1892 DrawWalls(DrawMainNOld, DrawMainPOld, DrawSideNOld, DrawSidePOld, DrawTopOld, DrawBottomOld);
1901 if (DrawMainN ==
true)
1903 if (DrawMainP ==
true)
1905 if (DrawSideN ==
true)
1907 if (DrawSideP ==
true)
1909 if (DrawTop ==
true)
1911 if (DrawBottom ==
true)
1920 return meters * 3.2808399;
1926 return feet / 3.2808399;
1929Wall*
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)
1938 AddWallMain(wall, name, texture, thickness, x1, z1, x2, z2, height_in1, height_in2, altitude1, altitude2, tw, th,
true);
1942Wall*
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)
1951 AddFloorMain(wall, name, texture, thickness, x1, z1, x2, z2, altitude1, altitude2, reverse_axis, texture_direction, tw, th,
true, legacy_behavior);
1962 Real minx, minz, maxx, maxz;
1986 Wall *wall = Landscape->CreateWallObject(name);
1988 Report(
"Creating ground...");
1991 for (
Real i = minx; i < maxx; i += tile_x)
1995 if (i + tile_x > maxx)
1998 sizex = (
Real)tile_x;
2000 for (
Real j = minz; j < maxz; j += tile_z)
2002 if (j + tile_z > maxz)
2005 sizez = (
Real)tile_z;
2007 DrawWalls(
true,
true,
false,
false,
false,
false);
2008 AddFloorMain(wall, name, texture, 0, i, j, i + sizex, j + sizez, altitude, altitude,
false,
false, 1, 1,
false,
false,
false);
2012 Report(
"Finished ground");
2029 if (
IsEven(range) ==
true)
2033 if (!IsValidFloor(floor))
2036 int additionalfloors;
2038 additionalfloors = (range - 1) / 2;
2040 additionalfloors = 0;
2045 if (shaftnumber > 0)
2046 shaft = GetShaft(shaftnumber);
2047 if (stairsnumber > 0)
2048 stairwell = GetStairwell(stairsnumber);
2053 int floorval = floor - additionalfloors - 1;
2054 if (IsValidFloor(floorval) && GetFloor(floor)->IsInGroup(floorval) ==
false)
2055 GetFloor(floorval)->Enabled(
false);
2057 floorval = floor + additionalfloors + 1;
2058 if (IsValidFloor(floorval) && GetFloor(floor)->IsInGroup(floorval) ==
false)
2059 GetFloor(floorval)->Enabled(
false);
2063 for (
int i = floor - additionalfloors; i <= floor + additionalfloors; i++)
2065 Floor *floorobj = GetFloor(i);
2076 if (showfloor ==
true && value ==
true)
2081 if (enablegroups ==
true)
2098 if (enablegroups ==
true)
2111 if (showfloor ==
true && value ==
true)
2116 if (enablegroups ==
true)
2133 if (enablegroups ==
true)
2142 if (enablegroups ==
true)
2156 for (
size_t i = 0; i < timercallbacks.size(); i++)
2158 if (timercallbacks[i] == timer)
2163 timercallbacks.emplace_back(timer);
2173 for (
size_t i = 0; i < timercallbacks.size(); i++)
2176 if (timercallbacks[i] == timer)
2178 timercallbacks.erase(timercallbacks.begin() + i);
2191 for (
size_t i = 0; i < timercallbacks.size(); i++)
2193 if (timercallbacks[i])
2194 timercallbacks[i]->Loop();
2201 return (
int)timercallbacks.size();
2204bool SBS::Mount(
const std::string &filename,
const std::string &path)
2208 std::string newfile =
"data/" + filename;
2209 std::string file = VerifyFile(newfile);
2211 Report(
"Mounting " + file +
" as path " + path);
2214 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(file,
"Zip", path,
true);
2216 catch (Ogre::Exception &e)
2218 return ReportError(
"Error mounting file " + file +
"\n" + e.getDescription());
2228 newarea.
start = start;
2232 FloorAutoArea.emplace_back(newarea);
2241 Vector3 position = camera->GetPosition();
2242 int floor = camera->CurrentFloor;
2244 for (
size_t i = 0; i < FloorAutoArea.size(); i++)
2247 if (FloorAutoArea[i].camerafloor != floor)
2248 FloorAutoArea[i].inside =
false;
2250 if (InBox(FloorAutoArea[i].start, FloorAutoArea[i].end, position) ==
true && FloorAutoArea[i].inside ==
false)
2253 FloorAutoArea[i].inside =
true;
2254 FloorAutoArea[i].camerafloor = floor;
2255 if (floor > -Basements)
2257 GetFloor(floor - 1)->Enabled(
true);
2258 GetFloor(floor - 1)->EnableGroup(
true);
2260 GetFloor(floor)->Enabled(
true);
2261 GetFloor(floor)->EnableGroup(
true);
2262 if (floor < Floors - 1)
2264 GetFloor(floor + 1)->Enabled(
true);
2265 GetFloor(floor + 1)->EnableGroup(
true);
2268 if (InBox(FloorAutoArea[i].start, FloorAutoArea[i].end, position) ==
false && FloorAutoArea[i].inside ==
true)
2271 FloorAutoArea[i].inside =
false;
2272 FloorAutoArea[i].camerafloor = 0;
2273 if (floor > -Basements)
2275 GetFloor(floor - 1)->Enabled(
false);
2276 GetFloor(floor - 1)->EnableGroup(
false);
2278 if (floor < Floors - 1)
2280 GetFloor(floor + 1)->Enabled(
false);
2281 GetFloor(floor + 1)->EnableGroup(
false);
2283 GetFloor(floor)->Enabled(
true);
2284 GetFloor(floor)->EnableGroup(
true);
2292 return (
int)meshes.size();
2295Sound*
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)
2299 sounds.emplace_back(sound);
2309 sound->
SetConeSettings(cone_inside_angle, cone_outside_angle, cone_outside_volume);
2310 sound->
Load(filename);
2312 if (loop && IsRunning ==
true)
2322 std::string findname = name;
2324 std::vector<Sound*> soundlist;
2325 for (
size_t i = 0; i < sounds.size(); i++)
2329 std::string name2 = sounds[i]->GetName();
2331 if (findname == name2)
2332 soundlist.emplace_back(sounds[i]);
2357 Reverb *reverb =
new Reverb(
this, name, type, position, min_distance, max_distance,
false);
2358 reverbs.emplace_back(reverb);
2366 std::string findname = name;
2368 for (
size_t i = 0; i < reverbs.size(); i++)
2372 std::string name2 = reverbs[i]->GetName();
2374 if (findname == name2)
2404 return remote_value * UnitScale;
2414 return remote_value * UnitScale;
2423 newvalue.x = remote_value.x;
2424 newvalue.y = remote_value.y;
2427 newvalue.z = -remote_value.z;
2429 newvalue.z = remote_value.z;
2431 if (rescale ==
true)
2432 return newvalue * UnitScale;
2444 return local_value / UnitScale;
2454 return local_value / UnitScale;
2462 newvalue.x = local_value.x;
2463 newvalue.y = local_value.y;
2466 newvalue.z = -local_value.z;
2468 newvalue.z = local_value.z;
2470 if (rescale ==
true)
2471 return (newvalue / UnitScale);
2485 if (number >= 0 && number < (
int)ObjectArray.size())
2486 return ObjectArray[number];
2495 ObjectArray.emplace_back(
object);
2496 return (
int)ObjectArray.size() - 1;
2504 if (number < (
int)ObjectArray.size())
2506 if (ObjectArray[number])
2508 if (ObjectArray[number]->GetNumber() == number)
2510 std::vector<Object*> objects;
2511 objects.emplace_back(ObjectArray[number]);
2512 RemoveActionParent(objects);
2513 ObjectArray[number] = 0;
2526 if (GetFloor(floor))
2535 std::string output =
"SBS version: " + version +
"\n";
2536 output.append(
"Instance number: " +
ToString(InstanceNumber) +
"\n");
2537 output.append(
"Building Name: " + BuildingName +
"\n");
2538 output.append(
"Building Filename: " + BuildingFilename +
"\n");
2539 output.append(
"Building Version: " + BuildingVersion +
"\n");
2540 output.append(
"InStairwell: ");
2542 output.append(
"\n");
2543 output.append(
"InElevator: ");
2545 output.append(
"\n");
2546 output.append(
"InShaft: ");
2548 output.append(
"\n");
2549 output.append(
"CameraFloor: ");
2551 output.append(
ToString(camera->CurrentFloor));
2552 output.append(
"\n");
2553 output.append(
"ElevatorNumber: ");
2554 output.append(
ToString(ElevatorNumber));
2555 output.append(
"\n");
2556 output.append(
"CarNumber: ");
2557 output.append(
ToString(CarNumber));
2558 output.append(
"\n");
2559 output.append(
"ElevatorSync: ");
2561 output.append(
"\n");
2562 output.append(
"Running Time: ");
2564 output.append(
"\n");
2565 output.append(
"BuildingsEnabled: ");
2567 output.append(
"\n");
2568 output.append(
"ExternalEnabled: ");
2570 output.append(
"\n");
2571 output.append(
"LandscapeEnabled: ");
2573 output.append(
"\n");
2574 output.append(
"SkyboxEnabled: ");
2576 output.append(
"\n");
2577 output.append(
"Verbose: ");
2579 output.append(
"\n");
2580 output.append(
"InterfloorOnTop: ");
2582 output.append(
"\n");
2583 output.append(
"Object Count: ");
2584 output.append(
ToString(ObjectCount));
2585 output.append(
"\n");
2588 output.append(
"Camera Floor: ");
2589 output.append(
ToString(camera->CurrentFloor));
2590 output.append(
"\n");
2603 return ReportError(
"Invalid object");
2606 bool deleted =
false;
2610 return ReportError(
"Cannot delete permanent object " + number);
2612 std::string type =
object->GetType();
2615 if (type ==
"Floor")
2620 for (
int i = 0; i < shaft_manager->GetCount(); i++)
2622 Shaft *shaft = shaft_manager->GetIndex(i);
2631 for (
int i = 0; i < stairwell_manager->GetCount(); i++)
2633 Stairwell *stairwell = stairwell_manager->GetIndex(i);
2643 return ReportError(
"Only the highest floor can be deleted");
2646 return ReportError(
"Only the lowest basement can be deleted");
2650 else if (type ==
"Elevator")
2652 else if (type ==
"ButtonPanel")
2657 else if (type ==
"CallButton")
2659 else if (type ==
"DirectionalIndicator")
2661 else if (type ==
"Door")
2663 else if (type ==
"RevolvingDoor")
2665 else if (type ==
"ElevatorDoor")
2667 else if (type ==
"FloorIndicator")
2669 else if (type ==
"Shaft")
2674 for (
int i = 0; i < elevator_manager->GetCount(); i++)
2676 Elevator *elev = elevator_manager->GetIndex(i);
2686 else if (type ==
"Sound")
2688 else if (type ==
"Stairwell")
2690 else if (type ==
"Wall")
2692 else if (type ==
"Model")
2694 else if (type ==
"Control")
2696 else if (type ==
"Trigger")
2698 else if (type ==
"DoorWrapper")
2702 return ReportError(
"Deleting the main elevator door wrapper is not supported yet");
2706 else if (type ==
"Escalator")
2708 else if (type ==
"Person")
2710 else if (type ==
"ElevatorCar")
2714 return ReportError(
"Only the highest elevator car can be deleted");
2716 return ReportError(
"Cannot delete the primary elevator car");
2720 else if (type ==
"MovingWalkway")
2722 else if (type ==
"Vehicle")
2724 else if (type ==
"Light")
2726 else if (type ==
"CallStation")
2728 else if (type ==
"DispatchController")
2730 else if (type ==
"Primitive")
2732 else if (type ==
"CustomObject")
2734 else if (type ==
"Reverb")
2736 else if (type ==
"CameraTexture")
2740 if (deleted ==
true)
2743 camera->ResetCollisions();
2751 return DeleteObject(GetObject(
object));
2760 return ReportError(
"Invalid object");
2762 if (relative ==
false)
2765 position.x =
object->GetPosition().x;
2767 position.y =
object->GetPosition().y;
2769 position.z =
object->GetPosition().z;
2771 object->SetPosition(position);
2774 object->Move(position);
2785 return ReportError(
"Invalid object");
2787 if (relative ==
true)
2788 object->Rotate(rotation, speed);
2792 rotation.x =
object->GetRotation().x;
2794 rotation.y =
object->GetRotation().y;
2796 rotation.z =
object->GetRotation().z;
2797 object->SetRotation(rotation);
2807 floor_manager->Remove(floor);
2814 elevator_manager->Remove(elevator);
2821 shaft_manager->Remove(shaft);
2828 stairwell_manager->Remove(stairs);
2836 for (
size_t i = 0; i < sounds.size(); i++)
2838 if (sounds[i] == sound)
2840 sounds.erase(sounds.begin() + i);
2851 for (
size_t i = 0; i < reverbs.size(); i++)
2853 if (reverbs[i] == reverb)
2855 reverbs.erase(reverbs.begin() + i);
2864 for (
size_t i = 0; i < lights.size(); i++)
2866 if (lights[i] == light)
2868 lights.erase(lights.begin() + i);
2877 for (
size_t i = 0; i < ModelArray.size(); i++)
2879 if (ModelArray[i] == model)
2881 ModelArray.erase(ModelArray.begin() + i);
2890 for (
size_t i = 0; i < PrimArray.size(); i++)
2892 if (PrimArray[i] == prim)
2894 PrimArray.erase(PrimArray.begin() + i);
2903 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
2905 if (CustomObjectArray[i] ==
object)
2907 CustomObjectArray.erase(CustomObjectArray.begin() + i);
2916 for (
size_t i = 0; i < ControlArray.size(); i++)
2918 if (ControlArray[i] == control)
2920 ControlArray.erase(ControlArray.begin() + i);
2929 for (
size_t i = 0; i < TriggerArray.size(); i++)
2931 if (TriggerArray[i] == trigger)
2933 TriggerArray.erase(TriggerArray.begin() + i);
2943 controller_manager->Remove(controller);
2948 bool result =
false;
2949 return VerifyFile(filename, result,
false);
2966 if (skip_cache ==
false)
2968 for (
size_t i = 0; i < verify_results.size(); i++)
2970 if (verify_results[i].filename == filename)
2971 return verify_results[i].result;
2976 Ogre::Archive *filesystem = 0;
2977 Ogre::ArchiveManager::ArchiveMapIterator it = Ogre::ArchiveManager::getSingleton().getArchiveIterator();
2978 while(it.hasMoreElements())
2980 const std::string& key = it.peekNextKey();
2981 filesystem = it.getNext();
2988 std::string shortname;
2989 std::string group = GetMountPath(filename, shortname);
2991 if (group ==
"General")
2995 if (filesystem->exists(filename) ==
true)
2998 CacheFilename(filename, filename);
3004 if (!filesystem_listing)
3005 filesystem_listing = filesystem->list();
3006 listing = filesystem_listing;
3012 if (Ogre::ResourceGroupManager::getSingleton().resourceExists(group, shortname) ==
true)
3015 CacheFilename(filename, filename);
3021 listing = Ogre::ResourceGroupManager::getSingleton().listResourceNames(group);
3025 for (
size_t i = 0; i < listing->size(); i++)
3027 std::string check = listing->at(i);
3028 std::string checkoriginal =
SetCaseCopy(check,
false);
3029 std::string checkfile =
SetCaseCopy(filename,
false);
3030 if (checkoriginal == checkfile)
3033 CacheFilename(filename, check);
3041 CacheFilename(filename, filename);
3054 Ogre::Archive *filesystem = 0;
3055 Ogre::ArchiveManager::ArchiveMapIterator it = Ogre::ArchiveManager::getSingleton().getArchiveIterator();
3056 while(it.hasMoreElements())
3058 const std::string& key = it.peekNextKey();
3059 filesystem = it.getNext();
3065 std::string shortname;
3066 std::string group = GetMountPath(filename, shortname);
3068 if (group ==
"General")
3072 if (filesystem->exists(filename) ==
true)
3074 std::string path = key;
3077 return std::string(path + filename);
3090 VerifyFile(filename, result,
true);
3104 return PolygonCount;
3115 Report(
"Preparing meshes...");
3116 for (
size_t i = 0; i < meshes.size(); i++)
3118 meshes[i]->Prepare(
false);
3123 Report(
"Processing geometry...");
3124 for (
size_t i = 0; i < dynamic_meshes.size(); i++)
3126 if (sbs->Verbose && report ==
true)
3127 Report(
"DynamicMesh " +
ToString((
int)i) +
" of " +
ToString((
int)dynamic_meshes.size()));
3128 dynamic_meshes[i]->Prepare();
3131 if (renderonly ==
false)
3134 Report(
"Creating colliders...");
3135 for (
size_t i = 0; i < meshes.size(); i++)
3137 if (meshes[i]->tricollider ==
true && meshes[i]->IsPhysical() ==
false)
3138 meshes[i]->CreateCollider();
3140 meshes[i]->CreateBoxCollider();
3145 Report(
"Finished prepare");
3153 lights.emplace_back(light);
3159 meshes.emplace_back(handle);
3164 for (
size_t i = 0; i < meshes.size(); i++)
3166 if (meshes[i] == handle)
3168 meshes.erase(meshes.begin() + i);
3177 for (
size_t i = 0; i < meshes.size(); i++)
3179 if (meshes[i]->name == name)
3185Model*
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)
3188 Model* model =
new Model(
this, name, filename, center, position, rotation, max_render_distance, scale_multiplier, enable_physics, restitution, friction, mass);
3194 ModelArray.emplace_back(model);
3205 for (
size_t i = 0; i < ModelArray.size(); i++)
3207 if (ModelArray[i] == model)
3211 ModelArray.emplace_back(model);
3218 PrimArray.emplace_back(prim);
3229 for (
size_t i = 0; i < PrimArray.size(); i++)
3231 if (PrimArray[i] == primitive)
3235 PrimArray.emplace_back(primitive);
3242 CustomObjectArray.emplace_back(
object);
3253 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
3255 if (CustomObjectArray[i] ==
object)
3259 CustomObjectArray.emplace_back(
object);
3264 std::string result = configfile->getSetting(key,
"",
ToString(default_value));
3265 return ToInt(result);
3270 return configfile->getSetting(key,
"", default_value);
3275 std::string result = configfile->getSetting(key,
"",
ToString(default_value));
3281 std::string result = configfile->getSetting(key,
"",
ToString(default_value));
3289 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)
3298 unsigned long last = current_time;
3301 current_time = GetCurrentTime();
3303 last = current_time;
3305 if (current_time < last)
3306 elapsed_time = current_time + ((
unsigned long)-1 - last) + 1;
3308 elapsed_time = current_time - last;
3309 current_virtual_time += elapsed_time;
3310 frame_times.emplace_back(current_time);
3311 CalculateAverageTime();
3317 return timer->getMilliseconds();
3323 return current_virtual_time;
3329 return elapsed_time;
3335 return average_time;
3342 if (frame_times.size() <= 1)
3348 std::deque<unsigned long>::iterator it = frame_times.begin(), end = frame_times.end() - 2;
3352 if (frame_times.back() - *it > SmoothFrames)
3359 frame_times.erase(frame_times.begin(), it);
3362 average_time = (frame_times.back() - frame_times.front()) / ((
unsigned long)frame_times.size() - 1);
3370 Ogre::StringVector list = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
3372 newfilename = filename;
3374 for (
size_t i = 0; i < list.size(); i++)
3376 if (
StartsWith(filename, list[i] +
"/") ==
true)
3378 newfilename = filename.substr(list[i].size() + 1);
3390 mWorld->setShowDebugShapes(value);
3391 camera->ShowDebugShape(value);
3393 catch (Ogre::Exception &e)
3395 ReportError(
"Error enabling/disabling collider shapes\n" + e.getDescription());
3405 verify_results.emplace_back(verify);
3410 OldAmbientR = AmbientR;
3411 OldAmbientG = AmbientG;
3412 OldAmbientB = AmbientB;
3420 AmbientR = OldAmbientR;
3421 AmbientG = OldAmbientG;
3422 AmbientB = OldAmbientB;
3425Control*
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)
3428 std::vector<Action*> actionnull;
3429 Control* control =
new Control(
this, name,
false, sound, action_names, actionnull, textures, direction, width, height,
true, selection_position);
3431 ControlArray.emplace_back(control);
3438 Trigger* trigger =
new Trigger(
this, name,
false, sound_file, area_min, area_max, action_names);
3439 TriggerArray.emplace_back(trigger);
3443Action*
SBS::AddAction(
const std::string &name, std::vector<Object*> &action_parents,
const std::string &command,
const std::vector<std::string> ¶meters)
3447 Action *action =
new Action(
this, name, action_parents, command, parameters);
3448 ActionArray.emplace_back(action);
3456 Action *action =
new Action(
this, name, action_parents, command);
3457 ActionArray.emplace_back(action);
3469 size_t pos = name.find(
"Car1");
3470 if (name.substr(0, 8) ==
"Elevator" && pos != std::string::npos)
3471 name2 = name.substr(0, pos - 1) + name.substr(name.find(
":", pos));
3473 std::vector<Action*> actionlist;
3474 for (
size_t i = 0; i < ActionArray.size(); i++)
3476 std::string actionname = ActionArray[i]->GetName();
3478 if (actionname == name || actionname == name2)
3479 actionlist.emplace_back(ActionArray[i]);
3487 return (
int)ActionArray.size();
3494 bool result =
false;
3495 std::vector<Action*> actionlist = GetAction(name);
3497 for (
size_t i = 0; i < actionlist.size(); i++)
3499 Action *action = actionlist[i];
3500 for (
size_t j = 0; j < parents.size(); j++)
3513 bool result =
false;
3514 std::vector<Action*> actionlist = GetAction(name);
3516 for (
size_t i = 0; i < actionlist.size(); i++)
3518 Action *action = actionlist[i];
3519 for (
size_t j = 0; j < parents.size(); j++)
3532 bool result =
false;
3533 for (
size_t i = 0; i < ActionArray.size(); i++)
3535 Action *action = ActionArray[i];
3536 for (
size_t j = 0; j < parents.size(); j++)
3550 bool result =
false;
3551 for (
size_t i = 0; i < ActionArray.size(); i++)
3555 std::string actionname = ActionArray[i]->GetName();
3557 if (actionname == name)
3559 delete ActionArray[i];
3560 ActionArray.erase(ActionArray.begin() + i);
3576 bool result =
false;
3577 for (
size_t i = 0; i < ActionArray.size(); i++)
3579 if (ActionArray[i] == action)
3581 delete ActionArray[i];
3582 ActionArray.erase(ActionArray.begin() + i);
3587 for (
size_t j = 0; j < control_index.size(); j++)
3589 control_index[j]->RemoveAction(action);
3606 std::string tmpname =
"Floor";
3607 if (case_sensitive ==
false)
3612 if (name.find(
"floor", 0) == 0)
3617 if (name.find(
"Floor", 0) == 0)
3621 if (found ==
true && name.find(
":", 0) == std::string::npos)
3623 std::string number = name.substr(5);
3626 int floor =
ToInt(number);
3627 return sbs->GetFloor(floor);
3634 std::string tmpname =
"Elevator";
3635 if (case_sensitive ==
false)
3640 if (name.find(
"elevator", 0) == 0)
3645 if (name.find(
"Elevator", 0) == 0)
3649 if (found ==
true && name.find(
":", 0) == std::string::npos)
3651 std::string number = name.substr(8);
3654 int elevator =
ToInt(number);
3655 return sbs->GetElevator(elevator);
3662 std::string tmpname =
"Shaft";
3663 if (case_sensitive ==
false)
3668 if (name.find(
"shaft", 0) == 0)
3673 if (name.find(
"Shaft", 0) == 0)
3677 if (found ==
true && name.find(
":", 0) == std::string::npos)
3679 std::string number = name.substr(5);
3682 int shaft =
ToInt(number);
3683 return sbs->GetShaft(shaft);
3690 std::string tmpname =
"Stairwell";
3691 if (case_sensitive ==
false)
3696 if (name.find(
"stairwell", 0) == 0)
3701 if (name.find(
"Stairwell", 0) == 0)
3705 if (found ==
true && name.find(
":", 0) == std::string::npos)
3707 std::string number = name.substr(9);
3710 int stair =
ToInt(number);
3711 return sbs->GetStairwell(stair);
3716 for (
size_t i = 0; i < ObjectArray.size(); i++)
3720 std::string tmpname = ObjectArray[i]->GetName();
3722 if (case_sensitive ==
false)
3726 if (tmpname == name)
3727 return ObjectArray[i];
3729 if (ObjectArray[i]->GetParent())
3731 std::string parent_name = ObjectArray[i]->GetParent()->GetName();
3733 if (case_sensitive ==
false)
3737 if (name == parent_name +
":" + tmpname)
3738 return ObjectArray[i];
3740 if (ObjectArray[i]->GetParent()->GetParent())
3742 std::string grandparent_name = ObjectArray[i]->GetParent()->GetParent()->GetName();
3744 if (case_sensitive ==
false)
3745 SetCase(grandparent_name,
false);
3748 if (name == grandparent_name +
":" + parent_name +
":" + tmpname)
3749 return ObjectArray[i];
3764 if (case_sensitive ==
false)
3770 for (
size_t i = 0; i < ObjectArray.size(); i++)
3772 Object *
object = ObjectArray[i];
3776 if (object->
GetType() != type)
3783 std::string namecheck = parent->
GetName();
3785 if (case_sensitive ==
false)
3788 if (namecheck == parent_name)
3790 std::string tmpname =
object->GetName();
3792 if (case_sensitive ==
false)
3796 if (tmpname == name)
3810 std::vector<Object*> objects;
3811 size_t temp = expression.find(
"to", 0);
3814 size_t temp2 = expression.find(
"tor", 0);
3820 if (temp > 0 && temp != std::string::npos)
3822 if (expression.substr(0, 6) ==
"Floors")
3824 else if (expression.substr(0, 9) ==
"Elevators")
3826 else if (expression.substr(0, 6) ==
"Shafts")
3828 else if (expression.substr(0, 10) ==
"Stairwells")
3832 ReportError(
"GetObjectRange: Invalid object type");
3836 std::string str1 = expression.substr(type.size() + 1, temp - (type.size() + 1));
3837 std::string str2 = expression.substr(temp + 2, expression.length() - (temp + 2));
3840 int RangeL = 0, RangeH = 0;
3843 ReportError(
"GetObjectRange: Invalid range");
3847 for (
size_t i = 0; i < ObjectArray.size(); i++)
3851 std::string tmpname = ObjectArray[i]->GetName();
3852 for (
int j = RangeL; j <= RangeH; j++)
3855 if (type ==
"floor")
3857 if (tmpname ==
"Floor " + number)
3858 objects.emplace_back(ObjectArray[i]);
3860 if (type ==
"elevator")
3862 if (tmpname ==
"Elevator " + number)
3863 objects.emplace_back(ObjectArray[i]);
3865 if (type ==
"shaft")
3867 if (tmpname ==
"Shaft " + number)
3868 objects.emplace_back(ObjectArray[i]);
3870 if (type ==
"stairwell")
3872 if (tmpname ==
"Stairwell " + number)
3873 objects.emplace_back(ObjectArray[i]);
3882 Object *obj = GetObject(expression);
3884 objects.emplace_back(obj);
3892 if (index >= 0 && index < (
int)ActionArray.size())
3893 return ActionArray[index];
3901 std::vector<Action*> actionlist = GetAction(name);
3904 for (
size_t i = 0; i < actionlist.size(); i++)
3906 bool result2 =
false;
3910 result2 = actionlist[i]->DoAction(
this, hold);
3912 if (result2 ==
false)
3922 Action *action = GetAction(index);
3925 return action->
DoAction(
this, hold);
3935 keys.emplace_back(key);
3937 Report(
"Added key " +
ToString(keyid) +
" (" + name +
") to keyring");
3944 for (
size_t i = 0; i < keys.size(); i++)
3946 if (keys[i].
id == keyid)
3956 Report(
"\n--- Keys ---\n");
3958 for (
size_t i = 0; i < keys.size(); i++)
3960 std::string
id =
ToString(keys[i].
id);
3961 Report(
id +
" - " + keys[i].name);
3969 control_index.emplace_back(control);
3976 for (
size_t i = 0; i < control_index.size(); i++)
3978 if (control_index[i] == control)
3980 control_index.erase(control_index.begin() + i);
3990 bool header_shown =
false;
3991 for (
int i = -Basements; i < Floors; i++)
3993 Floor *floor = GetFloor(i);
3996 if (header_shown ==
false)
3999 header_shown =
true;
4012 mSceneManager->setDisplaySceneNodes(value);
4019 mSceneManager->showBoundingBoxes(value);
4026 Report(
"\n--- Visible Dynamic Meshes ---");
4027 Report(
"Name\t-\tSubmeshes\n");
4032 for (
size_t i = 0; i < dynamic_meshes.size(); i++)
4034 for (
int j = 0; j < dynamic_meshes[i]->GetMeshCount(); j++)
4036 if (camera->IsDynamicMeshVisible(dynamic_meshes[i], j) ==
true)
4038 submeshes = dynamic_meshes[i]->GetSubMeshCount(j);
4039 Report(dynamic_meshes[i]->GetMeshName(j) +
"\t-\t" +
ToString(submeshes));
4045 Report(
"Total: " +
ToString(count) +
" meshes, " +
ToString(total) +
" submeshes");
4052 return (
int)EscalatorArray.size();
4058 return (
int)MovingWalkwayArray.size();
4067 Ray ray2 (ToRemote(ToGlobal(ToLocal(ray.getOrigin()))), GetOrientation() * ray.getDirection());
4070 OgreBulletCollisions::CollisionClosestRayResultCallback callback (ray2, mWorld, max_distance);
4073 mWorld->launchRay(callback);
4076 if (callback.doesCollide() ==
false)
4080 OgreBulletCollisions::Object*
object = callback.getCollidedObject();
4086 std::string meshname;
4087 if (
dynamic_cast<OgreBulletDynamics::WheeledRigidBody*
>(
object) == 0)
4088 meshname =
object->getRootNode()->getParentSceneNode()->getName();
4090 meshname =
object->getRootNode()->getChild(0)->getName();
4093 hit_position = ToLocal(callback.getCollisionPoint());
4096 mesh = FindMeshObject(meshname);
4102 Real distance = 2000000000.;
4103 Vector3 normal = Vector3::ZERO;
4116 int people = GetConfigInt(
"Skyscraper.SBS.Person.RandomPeople", 0);
4117 people = people == 0 ? GetTotalFloors() : people;
4118 for (
int i = 0; i < people; i++)
4120 Person *person = CreatePerson(
"Random " +
ToString(i + 1), Lobby,
false);
4127 Person *person = CreatePerson(
"Random " +
ToString(people + 1), Lobby,
true);
4132 else if (value ==
false)
4134 for (
size_t i = 0; i < PersonArray.size(); i++)
4136 if (PersonArray[i]->IsRandomActivityEnabled() ==
true)
4138 Person *person = PersonArray[i];
4145 RandomActivity = value;
4152 for (
int i = 1; i <= elevator_manager->GetCount(); i++)
4154 Elevator *elevator = elevator_manager->Get(i);
4161 for (
size_t i = 0; i < EscalatorArray.size(); i++)
4163 Escalator *escalator = EscalatorArray[i];
4170 Malfunctions = value;
4177 if (type ==
"Floor")
4179 for (
int i = 0; i < floor_manager->GetCount(); i++)
4181 if (floor_manager->GetIndex(i) ==
static_cast<Floor*
>(
object))
4185 else if (type ==
"Elevator")
4187 for (
int i = 0; i < elevator_manager->GetCount(); i++)
4189 if (elevator_manager->GetIndex(i) ==
static_cast<Elevator*
>(
object))
4193 else if (type ==
"Shaft")
4195 for (
int i = 0; i < shaft_manager->GetCount(); i++)
4197 if (shaft_manager->GetIndex(i) ==
static_cast<Shaft*
>(
object))
4201 else if (type ==
"Stairwell")
4203 for (
int i = 0; i < stairwell_manager->GetCount(); i++)
4205 if (stairwell_manager->GetIndex(i) ==
static_cast<Stairwell*
>(
object))
4209 else if (type ==
"Mesh")
4211 for (
size_t i = 0; i < meshes.size(); i++)
4213 if (meshes[i] ==
static_cast<MeshObject*
>(
object))
4217 else if (type ==
"Control")
4219 for (
size_t i = 0; i < control_index.size(); i++)
4221 if (control_index[i] ==
static_cast<Control*
>(
object))
4227 for (
size_t i = 0; i < ObjectArray.size(); i++)
4229 if (ObjectArray[i] ==
object)
4239 for (
size_t i = 0; i < ActionArray.size(); i++)
4241 if (ActionArray[i] == action)
4253 int number = GetPersonCount() + 1;
4254 name =
"Person " +
ToString(number);
4256 Person *person =
new Person(
this, name, floor, service_access);
4257 PersonArray.emplace_back(person);
4265 for (
size_t i = 0; i < PersonArray.size(); i++)
4267 if (PersonArray[i] == person)
4269 PersonArray.erase(PersonArray.begin() + i);
4277 if (cameras.size() > 0)
4278 return camera->Attach(cameras, init_state);
4284 return camera->Detach();
4295 size_t index = name.find(
":(");
4296 instance =
ToInt(name.substr(0, index));
4297 name.erase(name.begin(), name.begin() + index + 1);
4300 index = name.find(
")");
4301 object_number =
ToInt(name.substr(1, index - 1));
4303 if (strip_number ==
true)
4304 name.erase(name.begin(), name.begin() + index + 1);
4311 if (number < 0 || number > (
int)PersonArray.size() - 1)
4314 return PersonArray[number];
4322 return area_trigger->IsInside();
4333 return area_trigger->IsInside(position);
4343 min = area_trigger->GetMin();
4344 max = area_trigger->GetMax();
4348 min = Vector3::ZERO;
4349 max = Vector3::ZERO;
4361 Report(
"Cutting outside boundaries...");
4362 Vector3 min = area_trigger->GetMin();
4363 Vector3 max = area_trigger->GetMax();
4365 if (landscape ==
true)
4366 Landscape->CutOutsideBounds(min, max,
true,
true);
4367 if (buildings ==
true)
4368 Buildings->CutOutsideBounds(min, max,
true,
true);
4369 if (external ==
true && External)
4370 External->CutOutsideBounds(min, max,
true,
true);
4374 for (
int i = 0; i < floor_manager->GetCount(); i++)
4375 floor_manager->GetIndex(i)->Level->CutOutsideBounds(min, max,
true,
true);
4384 if (landscape ==
true)
4385 Landscape->Cut(min, max,
true,
true);
4386 if (buildings ==
true)
4387 Buildings->Cut(min, max,
true,
true);
4388 if (external ==
true && External)
4389 External->Cut(min, max,
true,
true);
4393 for (
int i = 0; i < floor_manager->GetCount(); i++)
4394 floor_manager->GetIndex(i)->Level->Cut(min, max,
true,
true);
4401 if (InstanceNumber == 0)
4404 if (area_min != Vector3::ZERO && area_max != Vector3::ZERO && !area_trigger)
4406 std::vector<std::string> names;
4407 names.emplace_back(
"Off");
4408 area_trigger =
new Trigger(
this,
"System Boundary",
true,
"", area_min, area_max, names);
4417 EnableBuildings(
true);
4418 EnableLandscape(
true);
4419 EnableExternal(
true);
4423 floor_manager->EnableAll(
false);
4424 shaft_manager->EnableAll(
false);
4425 stairwell_manager->EnableAll(
false);
4426 elevator_manager->EnableAll(
false);
4429 for (
size_t i = 0; i < reverbs.size(); i++)
4432 reverbs[i]->Enabled(
false);
4436 camera->ResetState();
4443 return (GetOrientation().Inverse() * position) + GetPosition();
4450 return (GetOrientation() * (position - GetPosition()));
4457 return (GetOrientation() * orientation);
4464 return (GetOrientation().Inverse() * orientation);
4473 for (
size_t i = 0; i < lights.size(); i++)
4475 if (
SetCaseCopy(lights[i]->GetName(),
false) == name)
4488 for (
size_t i = 0; i < ModelArray.size(); i++)
4490 if (
SetCaseCopy(ModelArray[i]->GetName(),
false) == name)
4491 return ModelArray[i];
4503 for (
size_t i = 0; i < PrimArray.size(); i++)
4505 if (
SetCaseCopy(PrimArray[i]->GetName(),
false) == name)
4506 return PrimArray[i];
4518 for (
size_t i = 0; i < CustomObjectArray.size(); i++)
4520 if (
SetCaseCopy(CustomObjectArray[i]->GetName(),
false) == name)
4521 return CustomObjectArray[i];
4531 dynamic_meshes.emplace_back(dynmesh);
4538 for (
size_t i = 0; i < dynamic_meshes.size(); i++)
4540 if (dynamic_meshes[i] == dynmesh)
4542 dynamic_meshes.erase(dynamic_meshes.begin() + i);
4555 return (
int)PersonArray.size();
4560 return (area_trigger != 0);
4565 return floor_manager;
4570 return elevator_manager;
4575 return shaft_manager;
4580 return stairwell_manager;
4585 return door_manager;
4590 return texturemanager;
4595 return revolvingdoor_manager;
4600 return vehicle_manager;
4605 return controller_manager;
4612 camtexarray.emplace_back(camtex);
4619 for (
size_t i = 0; i < camtexarray.size(); i++)
4621 if (camtexarray[i] == camtex)
4623 camtexarray.erase(camtexarray.begin() + i);
4631 return (
int)camtexarray.size();
4636 if (number < camtexarray.size())
4637 return camtexarray[number];
4655 Report(
"--- Memory Report ---");
4658 for (
size_t i = 0; i < meshes.size(); i++)
4659 total += meshes[i]->GetSize();
4662 Report(
"Textures: " +
ToString(texturemanager->GetMemoryUsage() / 1024) +
" kb");
4665 Report(
"Meshes: " +
ToString(total / 1024) +
" kb");
4673 EscalatorArray.emplace_back(escalator);
4680 for (
size_t i = 0; i < EscalatorArray.size(); i++)
4682 if (EscalatorArray[i] == escalator)
4684 EscalatorArray.erase(EscalatorArray.begin() + i);
4692 if (index >= 0 && index < EscalatorArray.size())
4693 return EscalatorArray[index];
4700 MovingWalkwayArray.emplace_back(walkway);
4707 for (
size_t i = 0; i < MovingWalkwayArray.size(); i++)
4709 if (MovingWalkwayArray[i] == walkway)
4711 MovingWalkwayArray.erase(MovingWalkwayArray.begin() + i);
4719 if (index >= 0 && index < MovingWalkwayArray.size())
4720 return MovingWalkwayArray[index];
4728 power_state = value;
4740 return (
int)reverbs.size();
4745 if (index >= 0 && index < (
int)reverbs.size())
4746 return reverbs[index];
4759 if (GetTextureManager())
4760 return GetTextureManager()->GetMaterialCount();
4767 return area_trigger;
4774 if (HasBounds() ==
false)
4777 return area_trigger->GetBounds().getCenter();
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, bool relative=false, bool force=false)
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 AddPolygon(Wall *wallobject, const std::string &texture, PolyArray &varray, Real tw, Real th, bool report=true)
void RemoveReverb(Reverb *reverb)
Escalator * GetEscalator(int index)
Shaft * GetShaft(int number)
void UnregisterEscalator(Escalator *escalator)
Elevator * GetElevator(int number)
void DeleteMeshHandle(MeshObject *handle)
Trigger * GetAreaTrigger()
void EnableBuildings(bool value)
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)
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)
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)
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)
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)
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, bool report=true)
void EnableLandscape(bool value)
int GetTotalReverbCount()
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)
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)
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)
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, bool report=true)
bool UnregisterObject(int number)
std::vector< Object * > GetObjectRange(const std::string &expression)
void ShowColliders(bool value)
bool DeleteObject(Object *object)
Person * GetPerson(int number)
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)