Skyscraper 2.0
vm.cpp
Go to the documentation of this file.
1/*
2 Skyscraper 2.0 - Nanokernel
3 Copyright (C)2003-2024 Ryan Thoryk
4 https://www.skyscrapersim.net
5 https://sourceforge.net/projects/skyscraper/
6 Contact - ryan@skyscrapersim.net
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21*/
22
23#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
24#include <sys/sysctl.h>
25#endif
26#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
27#include <windows.h>
28#endif
29#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
30#include <sys/utsname.h>
31#endif
32#include <iostream>
33#include "globals.h"
34#include "sbs.h"
35#include "vm.h"
36#include "camera.h"
37#include "scenenode.h"
38#include "soundsystem.h"
39#include "enginecontext.h"
40#include "hal.h"
41#include "sky.h"
42#include "gui.h"
43#include "profiler.h"
44#include "vmconsole.h"
45
46using namespace SBS;
47
48namespace Skyscraper {
49
50extern VMConsoleInput inputmgr; //console input manager
51
52//Virtual Manager system
53
55{
56 //initialize values
57 parent = 0;
58 active_engine = 0;
59 Shutdown = false;
60 ConcurrentLoads = false;
61 RenderOnStartup = false;
62 CheckScript = false;
63 Pause = false;
64 CutLandscape = true;
65 CutBuildings = true;
66 CutExternal = false;
67 CutFloors = false;
68 first_run = true;
69 Verbose = false;
70 showconsole = false;
71 vmconsole = 0;
72 loadstart = false;
73 unloaded = false;
74
75 macos_major = 0;
76 macos_minor = 0;
77
78 //create HAL instance
79 hal = new HAL(this);
80
81 //create sky system instance
82 skysystem = new SkySystem(this);
83
84 //create GUI instance
85#ifdef USING_WX
86 gui = new GUI(this);
87#else
88 gui = 0;
89#endif
90
91 Report("Started");
92}
93
95{
96 Report("Shutting down...");
97
98 //delete sky system instance
99 if (skysystem)
100 delete skysystem;
101 skysystem = 0;
102
103 //delete HAL instance
104 if (hal)
105 delete hal;
106 hal = 0;
107
108 //delete GUI instance
109#ifdef USING_WX
110 if (gui)
111 delete gui;
112 gui = 0;
113#endif
114
115 //delete VM console
116 if (vmconsole)
117 delete vmconsole;
118 vmconsole = 0;
119}
120
121void VM::SetParent(wxWindow *parent)
122{
123 //sets the parent WX window to be used by the system, mainly for the GUI
124
125 this->parent = parent;
126}
127
129{
130 //returns HAL instance
131
132 return hal;
133}
134
136{
137 //returns sky system instance
138
139 return skysystem;
140}
141
143{
144 return gui;
145}
146
147EngineContext* VM::CreateEngine(EngineContext *parent, const Vector3 &position, Real rotation, const Vector3 &area_min, const Vector3 &area_max)
148{
149 EngineContext* engine = new EngineContext(parent, this, hal->GetSceneManager(), hal->GetSoundSystem(), position, rotation, area_min, area_max);
150 return engine;
151}
152
154{
155 //delete a specified sim engine instance
156
157 if (!engine)
158 return false;
159
160 for (size_t i = 0; i < engines.size(); i++)
161 {
162 if (engines[i] == engine)
163 {
164 engines[i] = 0;
165 delete engine;
166 Report("Engine instance " + ToString(i) + " deleted");
167
168 int count = GetEngineCount();
169
170 if (active_engine == engine)
171 {
172 //if deleting the active engine, switch to the first valid engine
173 active_engine = 0;
174 if (count > 0)
175 {
176 int number = GetFirstValidEngine()->GetNumber();
177 SetActiveEngine(number, false, true);
178 }
179 }
180 else if (active_engine)
181 {
182 //if deleting another engine (not the active one), refresh the camera
184 }
185
186 //exit to main menu if all engines have been deleted
187 if (count == 0)
188 Shutdown = true;
189
190 return true;
191 }
192 }
193 return false;
194}
195
197{
198 //delete all sim emgine instances
199
200 Report("Deleting all engines...");
201 for (size_t i = 0; i < engines.size(); i++)
202 {
203 if (engines[i])
204 delete engines[i];
205 }
206 engines.clear();
207 active_engine = 0;
208 unloaded = true;
209}
210
212{
213 //find engine instance with an active camera
214
215 for (size_t i = 0; i < engines.size(); i++)
216 {
217 if (engines[i])
218 {
219 if (engines[i]->IsCameraActive() == true)
220 return engines[i];
221 }
222 }
223 return active_engine;
224}
225
226void VM::SetActiveEngine(int number, bool switch_engines, bool force)
227{
228 //set an engine instance to be active
229
230 EngineContext *engine = GetEngine(number);
231
232 if (!engine)
233 return;
234
235 if (active_engine == engine)
236 return;
237
238 //don't switch if the camera's already active in the specified engine
239 if (engine->IsCameraActive() == true)
240 return;
241
242 //don't switch to engine if it's loading
243 if (engine->IsLoading() == true && force == false)
244 return;
245
246 CameraState state;
247 bool state_set = false;
248
249 if (active_engine)
250 {
251 //get previous engine's camera state
252 if (switch_engines == true)
253 {
254 state = active_engine->GetCameraState();
255 state_set = true;
256 }
257
258 //detach camera from current engine
259 active_engine->DetachCamera(switch_engines);
260 }
261
262 Report("Setting engine " + ToString(number) + " as active");
263
264 //switch context to new engine instance
265 active_engine = engine;
266 active_engine->AttachCamera(hal->mCameras, !switch_engines);
267
268 //apply camera state to new engine
269 if (switch_engines == true && state_set == true)
270 active_engine->SetCameraState(state, false);
271
272 //update mouse cursor for freelook mode
273 //frontend->GetWindow()->EnableFreelook(active_engine->GetSystem()->camera->Freelook); //FIXME
274}
275
276bool VM::RunEngines(std::vector<EngineContext*> &newengines)
277{
278 //run sim engine instances, and returns the new engine(s) created (if applicable)
279 //to be started by the frontend
280
281 SBS_PROFILE_MAIN("Engines");
282
283 bool result = true;
284 bool isloading = IsEngineLoading();
285
286 if (ConcurrentLoads == true && isloading == true)
288
289 for (size_t i = 0; i < engines.size(); i++)
290 {
291 if (!engines[i])
292 continue;
293
294 //process engine run loops, and also prevent other instances from running if
295 //one or more engines are loading
296 if (ConcurrentLoads == true || isloading == false || engines[i]->IsLoading() == true || RenderOnStartup == true)
297 {
298 bool run = true;
299 if (i > 0 && ConcurrentLoads == false)
300 {
301 //if concurrent loads is off, skip running if previous engine is not finished loading
302 if (engines[i - 1])
303 {
304 if (engines[i - 1]->IsLoading() == true && engines[i - 1]->IsLoadingFinished() == false)
305 run = false;
306 }
307 }
308
309 if (engines[i]->IsLoadingFinished() == false && run == true)
310 {
311 //process engine runloop
312 engines[i]->GatherReset();
313 if (engines[i]->Run() == false)
314 result = false;
315 engines[i]->Gather();
316 }
317 }
318
319 //start engine if loading is finished
320 if (RenderOnStartup == false)
321 {
322 if (engines[i]->IsLoadingFinished() == true)
323 {
324 if (active_engine)
325 {
326 //exit if active engine is still loading
327 if (active_engine->IsLoading() == true && active_engine->IsLoadingFinished() == false)
328 continue;
329
330 //exit if active engine is finished, but other buildings are still loading
331 if (active_engine->IsLoadingFinished() == true && isloading == true)
332 continue;
333 }
334 engines[i]->NewEngine = false;
335 newengines.emplace_back(engines[i]);
336 }
337 }
338 else
339 {
340 //when RenderOnStartup is true, only add new engines to the list
341 if (engines[i]->NewEngine == true)
342 {
343 newengines.emplace_back(engines[i]);
344 engines[i]->NewEngine = false;
345 }
346 }
347 }
348 return result;
349}
350
352{
353 //return true if an engine is loading
354
355 bool result = false;
356 for (size_t i = 0; i < engines.size(); i++)
357 {
358 if (engines[i])
359 {
360 if (engines[i]->IsLoading() == true && engines[i]->IsLoadingFinished() == false)
361 result = true;
362 }
363 }
364 return result;
365}
366
368{
369 //shutdown an engine if requested
370
371 bool deleted = false;
372
373 for (size_t i = 0; i < engines.size(); i++)
374 {
375 if (engines[i])
376 {
377 //delete engine if it's shutdown state is true
378 if (engines[i]->GetShutdownState() == true)
379 {
380 Report("Shutdown requested for engine instance " + ToString(i));
381
382 if (DeleteEngine(engines[i]) == true)
383 {
385 i--;
386 deleted = true;
387 }
388 }
389 }
390 }
391
392 //clean up empty engine slots at the end of the list
393 if (deleted == true)
394 {
395 for (size_t i = engines.size() - 1; i < engines.size(); --i)
396 {
397 if (!engines[i])
398 engines.erase(engines.begin() + i);
399 else
400 break;
401 }
402 }
403}
404
406{
407 //reload building if requested
408
409 for (size_t i = 0; i < engines.size(); i++)
410 {
411 if (engines[i])
412 {
413 if (engines[i]->Reload == true)
414 {
415 //unload sky system if primary engine
416 if (i == 0)
418
419 Pause = false;
420 Report("Reloading engine instance " + ToString(i));
421
422 engines[i]->DoReload(); //handle engine reload
423
424 //create sky system if primary engine
425 if (i == 0)
427 }
428 }
429 }
430}
431
433{
434 //get an engine by instance number
435
436 if (number < 0 || number >= (int)engines.size())
437 return 0;
438
439 return engines[number];
440}
441
442int VM::GetEngineCount(bool loading_only)
443{
444 //get number of valid engines
445
446 int count = 0;
447
448 for (size_t i = 0; i < engines.size(); i++)
449 {
450 if (engines[i])
451 {
452 if (loading_only == true)
453 {
454 if (engines[i]->IsLoading() == true)
455 count++;
456 }
457 else
458 count++;
459 }
460 }
461 return count;
462}
463
465{
466 //if user is no longer inside the active engine, find a new engine to attach to
467
468 if (!active_engine)
469 return;
470
471 //exit if user is inside an engine
472 if (active_engine->IsInside() == true)
473 return;
474
476
477 //if active engine has a parent, switch to the parent if possible
478 if (parent)
479 {
480 if (parent->IsInside() == true && parent->IsCameraActive() == false)
481 {
482 SetActiveEngine(parent->GetNumber(), true);
483 return;
484 }
485 }
486
487 //otherwise search for a valid engine to attach to
488 Report("Searching for engine to attach to...");
489 for (size_t i = 0; i < engines.size(); i++)
490 {
491 if (engines[i] != active_engine && engines[i])
492 {
493 if (engines[i]->IsInside() == true && engines[i]->IsCameraActive() == false)
494 {
495 SetActiveEngine((int)i, true);
496 return;
497 }
498 }
499 }
500
501 //if user has stepped outside of all sim engines, revert the movement
502 //to place them back into the active engine
504}
505
507{
508 //returns true if the specified engine is valid (currently running)
509
510 if (!engine)
511 return false;
512
513 for (size_t i = 0; i < engines.size(); i++)
514 {
515 if (engines[i] == engine)
516 return true;
517 }
518 return false;
519}
520
522{
523 //returns true if the specified SBS instance is valid (being used by an engine context)
524
525 if (!sbs)
526 return false;
527
528 for (size_t i = 0; i < engines.size(); i++)
529 {
530 if (engines[i])
531 {
532 if (engines[i]->GetSystem() == sbs)
533 return true;
534 }
535 }
536 return false;
537}
538
540{
541 //get an available engine instance number
542
543 for (size_t i = 0; i < engines.size(); i++)
544 {
545 if (!engines[i])
546 return (int)i;
547 }
548 return (int)engines.size();
549}
550
552{
553 //register an engine, returning the assigned instance number
554
555 int number = GetFreeInstanceNumber();
556
557 if (number < (int)engines.size())
558 engines[number] = engine;
559 else
560 {
561 engine->time_stat = 0;
562 engines.emplace_back(engine);
563 }
564
565 return number;
566}
567
569{
570 //returns the first valid (running) engine context
571
572 for (size_t i = 0; i < engines.size(); i++)
573 {
574 if (engines[i])
575 return engines[i];
576 }
577 return 0;
578}
579
581{
582 //if the camera is not active in the active engine,
583 //switch the active engine to the next one that has an active camera
584
585 if (active_engine->IsCameraActive() == false)
587
588}
589
590bool VM::StartEngine(EngineContext* engine, std::vector<Ogre::Camera*> &cameras)
591{
592 //start a sim engine
593
594 Report("Initiating engine start");
595 return engine->Start(cameras);
596}
597
599{
600 //returns the active engine's SBS instance
601
602 if (active_engine)
603 return active_engine->GetSystem();
604 return 0;
605}
606
608{
609 //returns the active engine's script processor
610
611 if (active_engine)
613 return 0;
614}
615
616int VM::Run(std::vector<EngineContext*> &newengines)
617{
618 //run system
619
620 //return codes are -1 for fatal error, 0 for failure, 1 for success, 2 to unload, and 3 to load new buildings
621
622 SBS_PROFILE_MAIN("VM");
623
624 //show progress dialog if needed
625 //gui->ShowProgress();
626
627 //get time for frame statistics
628 unsigned long last = current_time;
630
631 //run sim engines
632 bool result = RunEngines(newengines);
633
634 time_stat = hal->GetCurrentTime() - last;
635
636 if (newengines.size() > 0)
637 return 3;
638
639 //delete an engine if requested
641
642 //exit if full shutdown request received
643 if (Shutdown == true)
644 {
645 Shutdown = false;
646 Report("Unloading due to shutdown request");
647 return 2;
648 }
649
650 //exit if an engine failed to run, if it's either the only engine or if ConcurrentLoads is on
651 if (result == false && (ConcurrentLoads == false || GetEngineCount() == 1))
652 return 0;
653
654 //don't continue if no available active engine
655 if (!GetActiveEngine())
656 return 0;
657
658 //make sure active engine is the one the camera is active in
659 CheckCamera();
660
661 //exit if any engine is loading, unless RenderOnStartup is true
662 if (IsEngineLoading() == true && RenderOnStartup == false)
663 return 1;
664
665 //if in CheckScript mode, exit
666 if (CheckScript == true)
667 {
668 Report("Unloading to menu...");
669 return 2;
670 }
671
672 //update Caelum
674
675 //update OpenXR
676 hal->UpdateOpenXR();
677
678 //render graphics
679 result = hal->Render();
680 if (!result)
681 return -1;
682
683 //handle a building reload
684 HandleReload();
685
686 //handle behavior when a user exits an engine area
688
689 //update first run status
690 if (first_run == true)
691 first_run = false;
692
693 return 1;
694}
695
696bool VM::Load(bool clear, const std::string &filename, EngineContext *parent, const Vector3 &position, Real rotation, const Vector3 &area_min, const Vector3 &area_max)
697{
698 //load simulator and data file
699
700 //exit if no building specified
701 if (filename == "")
702 return false;
703
704 Report("Loading engine for building file '" + filename + "'...");
705
706 //boot SBS
707 EngineContext* engine = Initialize(clear, parent, position, rotation, area_min, area_max);
708
709 //exit if init failed
710 if (!engine)
711 return false;
712
713 //have new engine instance load building
714 bool result = engine->Load(filename);
715
716 //delete engine if load failed, if more than one engine is running
717 if (result == false)
718 {
719 if (GetEngineCount() > 1)
720 DeleteEngine(engine);
721 return false;
722 }
723
724 return true;
725}
726
727EngineContext* VM::Initialize(bool clear, EngineContext *parent, const Vector3 &position, Real rotation, const Vector3 &area_min, const Vector3 &area_max)
728{
729 //bootstrap simulator
730
731 loadstart = true;
732
733 if (GetEngineCount() == 0)
734 {
735 //set sky name
736 skysystem->SkyName = hal->GetConfigString(hal->configfile, "Skyscraper.Frontend.Caelum.SkyName", "DefaultSky");
737
738 //clear scene
739 if (clear == true)
740 hal->ClearScene();
741 }
742
743 //clear screen
744 try
745 {
746 hal->GetRenderWindow()->update();
747 }
748 catch (...)
749 {
750 ReportFatalError("Error updating render window");
751 return 0;
752 }
753
754 //set parent to master engine, if not set
755 if (parent == 0 && GetEngineCount() >= 1)
757
758 //Create simulator instance
759 EngineContext* engine = CreateEngine(parent, position, rotation, area_min, area_max);
760
761 if (!GetActiveEngine())
762 active_engine = engine;
763
764 //set render on startup state
765 //SetRenderOnStartup(hal->GetConfigBool(hal->configfile, "Skyscraper.SBS.RenderOnStartup", false));
766
767 return engine;
768}
769
770void VM::Report(const std::string &message)
771{
772 hal->Report(message, "vm:");
773}
774
775bool VM::ReportError(const std::string &message)
776{
777 return hal->ReportError(message, "vm:");
778}
779
780bool VM::ReportFatalError(const std::string &message)
781{
782 return hal->ReportFatalError(message, "vm:");
783}
784
785#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
786
787// Code to get OS version on Mac
788int get_macos_version(uint32_t &major, uint32_t &minor, bool &osx)
789{
790 //returns the OS major and minor version
791 //if osx is true, os is 10.x.x releases, otherwise is 11.x or greater
792
793 char osversion[32];
794 size_t osversion_len = sizeof(osversion) - 1;
795 int osversion_name[] = { CTL_KERN, KERN_OSRELEASE };
796
797 if (sysctl(osversion_name, 2, osversion, &osversion_len, NULL, 0) == -1) {
798 printf("get_macos_version: sysctl() failed\n");
799 return 1;
800 }
801
802 if (sscanf(osversion, "%u.%u", &major, &minor) != 2) {
803 printf("get_macos_version: sscanf() failed\n");
804 return 1;
805 }
806
807 if (major >= 20) {
808 major -= 9;
809 osx = false; //macOS 11 and newer
810 } else {
811 major -= 4;
812 osx = true; //macOS 10.1.1 and newer
813 }
814
815 return 0;
816}
817
818#endif
819
821{
822 //set platform name
823
824#if OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_32
825 Bits = "32-bit";
826#endif
827#if OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_64
828 Bits = "64-bit";
829#endif
830
831#if OGRE_CPU == OGRE_CPU_X86
832 Architecture = "x86";
833#elif OGRE_CPU == OGRE_CPU_PPC
834 Architecture = "PPC";
835#elif OGRE_CPU == OGRE_CPU_ARM
836 Architecture = "ARM";
837#elif OGRE_CPU == OGRE_CPU_MIPS
838 Architecture = "MIPS";
839#elif OGRE_CPU == OGRE_CPU_UNKNOWN
840 Architecture = "Unknown";
841#endif
842
843#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
844 Platform = "Windows " + Architecture + " " + Bits;
845#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
846 #ifdef __FreeBSD__
847 Platform = "FreeBSD " + Architecture + " " + Bits;
848 #else
849 Platform = "Linux " + Architecture + " " + Bits;
850 #endif
851#elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
852 Platform = "MacOS " + Architecture + " " + Bits;
853#endif
854
855#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
856 //report MacOS version if applicable
857 uint32_t major = 0, minor = 0;
858 bool osx = true;
859 get_macos_version(major, minor, osx);
860
861 if (osx == true)
862 {
863 GetHAL()->Report("Running on MacOS 10." + ToString((int)major) + "." + ToString((int)minor), "");
864 macos_major = 10;
865 macos_minor = (int)major;
866 }
867 else
868 {
869 GetHAL()->Report("Running on MacOS " + ToString((int)major) + "." + ToString((int)minor), "");
870 macos_major = (int)major;
871 macos_minor = (int)minor;
872 }
873#endif
874
875#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
876 //get Windows version
877
878 NTSTATUS(WINAPI* RtlGetVersion)(LPOSVERSIONINFOEXW);
879 OSVERSIONINFOEXW osInfo;
880
881 *(FARPROC*)&RtlGetVersion = GetProcAddress(GetModuleHandleA("ntdll"), "RtlGetVersion");
882
883 if (NULL != RtlGetVersion)
884 {
885 osInfo.dwOSVersionInfoSize = sizeof(osInfo);
886 RtlGetVersion(&osInfo);
887 GetHAL()->Report("Running on Microsoft Windows " + ToString((int)osInfo.dwMajorVersion) + "." + ToString((int)osInfo.dwMinorVersion), "");
888 }
889#endif
890
891#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
892 struct utsname osInfo{};
893 uname(&osInfo);
894 #ifdef __FreeBSD__
895 GetHAL()->Report("Running on FreeBSD " + std::string(osInfo.release), "");
896 #else
897 GetHAL()->Report("Running on Linux " + std::string(osInfo.release), "");
898 #endif
899#endif
900}
901
902wxWindow* VM::GetParent()
903{
904 //get parent WX window, this is assigned by the frontend
905
906 return parent;
907}
908
910{
911 //update progress based on total sim engine status
912
913 int total_percent = GetEngineCount() * 100;
914 int current_percent = 0;
915
916 for (size_t i = 0; i < GetEngineCount(); i++)
917 {
918 if (GetEngine(i))
919 current_percent += GetEngine(i)->GetProgress();
920 }
921
922 int final = ((Real)current_percent / (Real)total_percent) * 100;
923
924#ifdef USING_WX
925 if (gui)
926 return gui->UpdateProgress(final);
927#endif
928 return true;
929}
930
931bool VM::ReportMissingFiles(std::vector<std::string> &missing_files)
932{
933 //report missing files
934#ifdef USING_WX
935 if (gui)
936 return gui->ReportMissingFiles(missing_files);
937#endif
938 return true;
939}
940
942{
943 //create VM console
944 vmconsole = new VMConsole(this);
945}
946
948{
949 //if enabled, process console input
950 if (vmconsole)
952
953}
954
956{
957 return vmconsole;
958}
959
961{
962 RenderOnStartup = value;
963
964 //override SBS startup render option, if specified
965 for (int i = 0; i < engines.size(); i++)
966 {
967 if (engines[i])
968 engines[i]->GetSystem()->RenderOnStartup = value;
969 }
970}
971
973{
974 return RenderOnStartup;
975}
976
977unsigned long VM::Uptime()
978{
979 //get uptime of VM in milliseconds
980
981 return hal->GetCurrentTime();
982}
983
984unsigned long VM::GetElapsedTime(int instance)
985{
986 //get elapsed time (execution time) of the specified engine instance
987
988 if (instance >= engines.size())
989 return 0;
990 return engines[instance]->time_stat;
991}
992
994{
995 //list playing sounds in all engines
996
997 for (size_t i = 0; i < engines.size(); i++)
998 {
999 ::SBS::SBS* Simcore = engines[i]->GetSystem();
1000
1001 if (Simcore)
1002 {
1003 Report("Engine " + ToString(i) + ":");
1004 Simcore->GetSoundSystem()->ShowPlayingSounds(false);
1005 if (i == engines.size() - 1)
1006 Simcore->GetSoundSystem()->ShowPlayingTotal();
1007 }
1008 }
1009}
1010
1011}
SoundSystem * GetSoundSystem()
Definition sbs.cpp:4518
void ShowPlayingSounds(bool verbose=true)
void DetachCamera(bool reset_building=false)
void SetCameraState(const ::SBS::CameraState &state, bool set_floor=true)
ScriptProcessor * GetScriptProcessor()
void AttachCamera(std::vector< Ogre::Camera * > &cameras, bool init_state=true)
bool Start(std::vector< Ogre::Camera * > &cameras)
EngineContext * GetParent()
::SBS::CameraState GetCameraState()
bool Load(std::string filename)
bool UpdateProgress(int percent)
Definition gui.cpp:272
bool ReportMissingFiles(std::vector< std::string > &missing_files)
Definition gui.cpp:339
bool ReportFatalError(const std::string &message, const std::string &prompt)
Definition hal.cpp:256
std::string GetConfigString(Ogre::ConfigFile *file, const std::string &key, const std::string &default_value)
Definition hal.cpp:292
void UpdateOpenXR()
Definition hal.cpp:191
Ogre::RenderWindow * GetRenderWindow()
Definition hal.cpp:847
unsigned long GetCurrentTime()
Definition hal.cpp:1019
Ogre::SceneManager * GetSceneManager()
Definition hal.cpp:895
void ClearScene()
Definition hal.cpp:743
std::vector< Ogre::Camera * > mCameras
Definition hal.h:90
void Report(const std::string &message, const std::string &prompt)
Definition hal.cpp:219
void RefreshViewport()
Definition hal.cpp:929
bool Render()
Definition hal.cpp:674
bool ReportError(const std::string &message, const std::string &prompt)
Definition hal.cpp:237
FMOD::System * GetSoundSystem()
Definition hal.cpp:842
Ogre::ConfigFile * configfile
Definition hal.h:97
void CreateSky(EngineContext *engine)
Definition sky.cpp:77
std::string SkyName
Definition sky.h:55
void Process(const std::string &text="", bool echo=true)
bool CutLandscape
Definition vm.h:119
EngineContext * FindActiveEngine()
Definition vm.cpp:211
bool IsValidEngine(EngineContext *engine)
Definition vm.cpp:506
void CheckCamera()
Definition vm.cpp:580
void ListPlayingSounds()
Definition vm.cpp:993
unsigned long Uptime()
Definition vm.cpp:977
bool showconsole
Definition vm.h:121
void ShowPlatform()
Definition vm.cpp:820
int GetFreeInstanceNumber()
Definition vm.cpp:539
int macos_major
Definition vm.h:134
bool CutBuildings
Definition vm.h:119
GUI * GetGUI()
Definition vm.cpp:142
HAL * GetHAL()
Definition vm.cpp:128
EngineContext * GetFirstValidEngine()
Definition vm.cpp:568
VMConsole * GetConsole()
Definition vm.cpp:955
void HandleReload()
Definition vm.cpp:405
bool StartEngine(EngineContext *engine, std::vector< Ogre::Camera * > &cameras)
Definition vm.cpp:590
bool Verbose
Definition vm.h:120
friend class VMConsole
Definition vm.h:72
::SBS::SBS * GetActiveSystem()
Definition vm.cpp:598
int macos_minor
Definition vm.h:135
GUI * gui
Definition vm.h:155
void SetActiveEngine(int number, bool switch_engines=false, bool force=false)
Definition vm.cpp:226
bool unloaded
Definition vm.h:123
void HandleEngineShutdown()
Definition vm.cpp:367
int RegisterEngine(EngineContext *engine)
Definition vm.cpp:551
int GetEngineCount(bool loading_only=false)
Definition vm.cpp:442
bool Pause
Definition vm.h:118
bool GetRenderOnStartup()
Definition vm.cpp:972
EngineContext * Initialize(bool clear, EngineContext *parent=0, const Vector3 &position=Vector3::ZERO, Real rotation=0.0, const Vector3 &area_min=Vector3::ZERO, const Vector3 &area_max=Vector3::ZERO)
Definition vm.cpp:727
HAL * hal
Definition vm.h:153
SkySystem * skysystem
Definition vm.h:154
bool first_run
Definition vm.h:160
void StartConsole()
Definition vm.cpp:941
void SwitchEngines()
Definition vm.cpp:464
bool IsValidSystem(::SBS::SBS *sbs)
Definition vm.cpp:521
bool UpdateProgress()
Definition vm.cpp:909
bool DeleteEngine(EngineContext *engine)
Definition vm.cpp:153
unsigned long GetElapsedTime(int instance)
Definition vm.cpp:984
bool Shutdown
Definition vm.h:115
EngineContext * active_engine
Definition vm.h:151
unsigned long time_stat
Definition vm.h:124
bool Load(bool clear, const std::string &filename, EngineContext *parent=0, const Vector3 &position=Vector3::ZERO, Real rotation=0.0, const Vector3 &area_min=Vector3::ZERO, const Vector3 &area_max=Vector3::ZERO)
Definition vm.cpp:696
bool ConcurrentLoads
Definition vm.h:116
bool RunEngines(std::vector< EngineContext * > &newengines)
Definition vm.cpp:276
bool ReportMissingFiles(std::vector< std::string > &missing_files)
Definition vm.cpp:931
wxWindow * GetParent()
Definition vm.cpp:902
void ProcessConsole()
Definition vm.cpp:947
int Run(std::vector< EngineContext * > &newengine)
Definition vm.cpp:616
std::string Bits
Definition vm.h:131
std::string Architecture
Definition vm.h:133
std::string Platform
Definition vm.h:132
SkySystem * GetSkySystem()
Definition vm.cpp:135
unsigned long current_time
Definition vm.h:124
void Report(const std::string &message)
Definition vm.cpp:770
void SetParent(wxWindow *parent)
Definition vm.cpp:121
bool CutExternal
Definition vm.h:119
bool CheckScript
Definition vm.h:117
ScriptProcessor * GetActiveScriptProcessor()
Definition vm.cpp:607
VMConsole * vmconsole
Definition vm.h:156
bool RenderOnStartup
Definition vm.h:161
EngineContext * GetActiveEngine()
Definition vm.h:81
bool loadstart
Definition vm.h:122
bool ReportError(const std::string &message)
Definition vm.cpp:775
bool CutFloors
Definition vm.h:119
bool ReportFatalError(const std::string &message)
Definition vm.cpp:780
EngineContext * GetEngine(int number)
Definition vm.cpp:432
EngineContext * CreateEngine(EngineContext *parent=0, const Vector3 &position=Vector3::ZERO, Real rotation=0.0, const Vector3 &area_min=Vector3::ZERO, const Vector3 &area_max=Vector3::ZERO)
Definition vm.cpp:147
wxWindow * parent
Definition vm.h:158
void SetRenderOnStartup(bool value)
Definition vm.cpp:960
std::vector< EngineContext * > engines
Definition vm.h:152
void DeleteEngines()
Definition vm.cpp:196
bool IsEngineLoading()
Definition vm.cpp:351
Ogre::Vector3 Vector3
Definition globals.h:58
Ogre::Real Real
Definition globals.h:57
std::string ToString(int number)
Definition globals.cpp:279
int get_macos_version(uint32_t &major, uint32_t &minor, bool &osx)
Definition vm.cpp:788
VMConsoleInput inputmgr
#define SBS_PROFILE_MAIN(name)
Definition profiler.h:132