A TDB Traveler[1] is responsible for traversing the route (as defined by the track database). A reasonable model for a TDB Traveler is a truck that follows a path on the route. It specifies the position and direction (orientation) of the truck. Each instance of class Train (including AI trains) has two references to instances of class TDBTraveller – FrontTDBTraveller and RearTDBTraveller – which represent the position and direction of the front and rear of the train.
When Simulator.Start calls private method InitializePlayerTrain, it (InitializePlayerTrain) reads the service and consist files and instantiates a Train object. Next, it instantiates a PATTraveller, which identifies the position of the rear of the train in the track database (TDB). A new TDBTraveller is created with this initial position, and a reference to it is stored in train.RearTDBTraveller. InitializePlayerTrain then proceeds to build the consist. When the consist is completed, InitializePlayerTrain calls train.CalculatePositionOfCars. CalculatePositionOfCars creates a new TDBTraveller named traveller which is a copy of RearTDBTraveller. It then steps traveller forward, a truck (bogie) at a time until it reaches the front of the train. Then, a reference to traveller, now at the front of the train, is assigned to FrontTDBTraveller. The rear-to-front traversal is done in three steps per car (or engine):
- traveller is moved from the rear of the car to the position of the rear truck.[2]
- traveller is moved forward to the position of the front truck.
- traveller is moved forward to the front of the car.
The positions of the traveler at each of the trucks are used to derive a transformation matrix that correctly orients the car and positions its center.
| Previous section: Open Rails Terrain | Up to: Design Overview | Next section: Track Data Structures |
[1] This misspelling is poured in concrete in the source code. While I don’t wish to proliferate the misspelling, I don’t want to change the spelling in the source code. An accommodation is required here. Whenever I specifically refer to the class TDBTraveller, I will spell it as I just did, essentially treating it as a proper noun. However, when I use the term generically, I will spell it “traveler.”
[2] Truck-to-truck spacing is approximated as 65 percent of car length because the spacing is not reported in the .wag file.