OSDN Git Service

Added RunState elevator parameter
[skyscrapersim/skyscraper.git] / design.rtf
1 {\rtf1\ansi\deff1\adeflang1025
2 {\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\froman\fprq2\fcharset0 Times New Roman;}{\f2\froman\fprq2\fcharset0 Times New Roman;}{\f3\fswiss\fprq2\fcharset0 Arial;}{\f4\fswiss\fprq2\fcharset0 Bitstream Vera Sans;}}
3 {\colortbl;\red0\green0\blue0;\red128\green128\blue128;}
4 {\stylesheet{\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033\snext1 Normal;}
5 {\s2\sb240\sa120\keepn\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\rtlch\af3\afs28\lang255\ltrch\dbch\af1\langfe255\hich\f3\fs28\lang1033\loch\f3\fs28\lang1033\sbasedon1\snext3 Heading;}
6 {\s3\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033\sbasedon1\snext3 Body Text;}
7 {\s4\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033\sbasedon3\snext4 List;}
8 {\s5\sb120\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\rtlch\af1\afs24\lang255\ai\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\i\loch\f1\fs24\lang1033\i\sbasedon1\snext5 caption;}
9 {\s6\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033\sbasedon1\snext6 Index;}
10 {\s7\sb120\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\rtlch\af1\afs24\lang255\ai\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\i\loch\f1\fs24\lang1033\i\sbasedon1\snext7 caption;}
11 {\s8\sb120\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\rtlch\af1\afs24\lang255\ai\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\i\loch\f1\fs24\lang1033\i\sbasedon1\snext8 WW-caption;}
12 }
13 {\info{\creatim\yr0\mo0\dy0\hr0\min0}{\revtim\yr0\mo0\dy0\hr0\min0}{\printim\yr0\mo0\dy0\hr0\min0}{\comment StarWriter}{\vern6800}}\deftab709
14 {\*\pgdsctbl
15 {\pgdsc0\pgdscuse195\pgwsxn12240\pghsxn15840\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\pgdscnxt0 Standard;}}
16 {\*\pgdscno0}\paperh15840\paperw12240\margl1134\margr1134\margt1134\margb1134\sectd\sbknone\pgwsxn12240\pghsxn15840\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc
17 \pard\plain \ltrpar\s1\cf0\qc{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\rtlch\af1\afs28\lang255\ab\ltrch\dbch\af4\langfe255\hich\fs28\lang1033\b\loch\fs28\lang1033\b {\rtlch \ltrch\loch\f1\fs28\lang1033\i0\b The Design of Skyscraper and the Scalable Building Simulator}
18 \par \pard\plain \ltrpar\s1\cf0\qc{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 
19 \par \pard\plain \ltrpar\s1\cf0\qc{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 {\rtlch \ltrch\loch\f1\fs24\lang1033\i0\b0 by Ryan Thoryk}
20 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 
21 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 
22 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 
23 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 {\rtlch \ltrch\loch     }{\rtlch \ltrch\loch\f1\fs24\lang1033\i0\b0 This document is a basic birds-eye view of the internals of both the frontend and the backend (the Scalable Building Simulator engine) of Skyscraper.  This is intended for people who are interested in helping out with C++ development to quickly get fam
24 iliar with the system's design and how it works.}
25 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 
26 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 {\rtlch \ltrch\loch\f1\fs24\lang1033\i0\b0 Skyscraper is comprised of two parts: the frontend, and the Scalable Building Simulator (backend).  The frontend is the controller portion of the program and is responsible for setting up and managing the CrystalSpace environment, for starting and shutting
27  down the SBS simulator, making calls to SBS, handling keyboard/mouse input, and rendering.  The reason this is split is so that there can be multiple frontends sharing the same simulation library, such as the regular Skyscraper app, a graphical building d
28 esigner, etc all sharing the same SBS.dll.  Skyscraper.exe is the frontend, and does those things mentioned above, and also has a script interpreter which makes the SBS calls (the script language is known as ISL2, or Interactive Scripting Language 2).}
29 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 
30 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 
31 \par \pard\plain \ltrpar\s1\cf0\qc{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\rtlch\af1\afs24\lang255\ab\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\b\loch\f1\fs24\lang1033\b {\rtlch \ltrch\loch\f1\fs24\lang1033\i0\b A Typical Run}
32 \par \pard\plain \ltrpar\s1\cf0\qc{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 
33 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 {\rtlch \ltrch\loch\f1\fs24\lang1033\i0\b0 When the program is run, wxWidgets will pass control onto the Skyscraper class for startup (the Skyscraper::OnInit() function). Skyscraper will create the main window, initialize CrystalSpace, set up things such as sound and the buttons, and loop inside th
34 e main intro screen.  When a building is selected, Start() will be called which creates an SBS object, initializes it, runs the script interpreter for the selected file (which makes lots of SBS calls), tells SBS to create the sky, runs SBS's Start() functi
35 on (the startup initializer), and creates the debug/control panel.  Some flags are then set which tell Skyscraper that the simulator is ready to run.  When the main screen idles, wxWidgets calls that window's OnIdle() function which calls Skyscraper's Push
36 Frame() function (this is how the program loops).  PushFrame is the program's top-level loop function, and does some CrystalSpace work and calls the program's CrystalSpace event handler.  The event handler eventually does a frame dispatch which calls Setup
37 Frame(), which is Skyscraper's top-level run loop function.  This calls things such as the SBS main loop, the input handler (for keyboard/mouse input), the SBS camera loop, and CrystalSpace rendering.  So in a normal run, SBS's main loop will be called fir
38 st in there, which is SBS::MainLoop().  In this loop, other runloops are called, such as Elevator::MonitorLoop() for each elevator (the elevator loop; this handles all elevator movement, elevator door movement, shaft door movement, etc), the camera's Check
39 Shaft function (which is basically a shaft loop that handles the displaying of shafts), and the camera's CheckStairs function (which is basically the stairs loop and handles the displaying of stairs).   The mainloop also handles door callbacks, which opera
40 te the door movement (it calls Door::MoveDoor() which is the Door main loop and does the raw door movement).  After the SBS main loop is run, Skyscraper's input handler is run which gets keyboard and mouse input from wxWidgets, and calls the related SBS fu
41 nction for these.  This function also calls functions such as Camera::ClickObject which checks to see if a user clicked on an object (and performs the related functions for that, such as a button click).  After that, the SBS camera loop (Camera::Loop()) is
42  run, which handles all camera movement, collision detection, and keeping the sound listener object locked to the position and rotation of the camera.  Finally the Render() function is run, which tells CrystalSpace to render the 3D graphics onto the screen
43 .  The program will loop in this way, until the main simulator window is closed.  When it's closed, wxWidgets will call that window's OnClose() function (MainWindow::OnClose()) which turns off the debug panel timer and calls the main Skyscraper app's OnExi
44 t function.  The Skyscraper::OnExit() function stops the frame printer (automatic renderer), cleans up the sound object, deletes all windows, deletes the SBS object (which causes the simulator to clean up all it's objects), and calls CrystalSpace's Destroy
45 Application() process which cleans up the rest of the objects.}
46 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 
47 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 
48 \par \pard\plain \ltrpar\s1\cf0\qc{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\rtlch\af1\afs24\lang255\ab\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\b\loch\f1\fs24\lang1033\b {\rtlch \ltrch\loch\f1\fs24\lang1033\i0\b Some Function Descriptions}
49 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ab\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\b\loch\f1\fs24\lang1033\b {\rtlch \ltrch\loch\f1\fs24\lang1033\i0\b The Frontend:}
50 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 {\rtlch \ltrch\loch\f1\fs24\lang1033\i0\b0 Skyscraper::OnInit() - this is called by wxWidgets on program startup, and creates the main window and calls the CrystalSpace initialization function.}
51 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 {\rtlch \ltrch\loch\f1\fs24\lang1033\i0\b0 Skyscraper::OnExit() - this is called by wxWidgets when a user closes the main window, and is responsible for cleaning up objects and shutting down the app.}
52 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 {\rtlch \ltrch\loch\f1\fs24\lang1033\i0\b0 MainScreen \'96 this is a wxWidgets window class, and represents the main simulator window.}
53 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 {\rtlch \ltrch\loch\f1\fs24\lang1033\i0\b0 Skyscraper::Render() - this is the CrystalSpace rendering function}
54 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 {\rtlch \ltrch\loch\f1\fs24\lang1033\i0\b0 Skyscraper::SetupFrame() - this is considered the top-level runloop function, and calls everything else from this, such as the main menu stuff, window resize functions, the SBS main loop, the input handler, the SBS camera loop, and the rendering function. 
55  This function also has speed limiter code in order to keep the simulator running at the same speed despite changes in frame rate (the frame rate is basically how many times a second the entire app performs one loop cycle).}
56 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 {\rtlch \ltrch\loch\f1\fs24\lang1033\i0\b0 Skyscraper::HandleEvent() - this is right above SetupFrame(), and is a CrystalSpace event dispatcher; this is responsible for running both the SBS CalculateFrameRate() function and SetupFrame() within a frame event context.}
57 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 {\rtlch \ltrch\loch\f1\fs24\lang1033\i0\b0 SkyscraperEventHandler() - this is the top-level event handler, and really just calls HandleEvent.  This is outside of the Skyscraper class.}
58 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 {\rtlch \ltrch\loch\f1\fs24\lang1033\i0\b0 Skyscraper::Initialize() - this is the CrystalSpace initialization code.}
59 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 {\rtlch \ltrch\loch\f1\fs24\lang1033\i0\b0 Skyscraper::GetInput() - this is the keyboard and mouse input handler.  It uses wxWidgets for events, and calls SBS to process those events.}
60 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 {\rtlch \ltrch\loch\f1\fs24\lang1033\i0\b0 Skyscraper::PushFrame() - this is the CrystalSpace top-level loop code, and is responsible for advancing CrystalSpace's virtual clock, and for calling the event handler.  This function is called from MainScreen's OnIdle() function.}
61 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 {\rtlch \ltrch\loch\f1\fs24\lang1033\i0\b0 Skyscraper::SelectBuilding() - this is the wxWidgets code that pops up a file selection dialog for selecting a building.}
62 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 {\rtlch \ltrch\loch\f1\fs24\lang1033\i0\b0 Skyscraper::Start() - this starts the simulator.  This creates a new SBS object, calls the SBS initialization function, calls the script interpreter (which translates the script commands into SBS calls),  tells SBS to create the sky, runs the CrystalSpace 
63 engine object preparation, runs the SBS Start() function, and creates the debug control panel.}
64 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 
65 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 {\rtlch \ltrch\loch\f1\fs24\lang1033\i0\b0 The file fileio.cpp has the raw building loader code and the script interpreter.  These are part of the Skyscraper class.}
66 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 
67 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 
68 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 
69 \par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\aspalpha\ql\rtlch\af1\afs24\lang255\ltrch\dbch\af4\langfe255\hich\f1\fs24\lang1033\loch\f1\fs24\lang1033 
70 \par }