Difference between revisions of "BAI"
From Mm2kiwi
(→Structure: Added values for BAIRoadEnd.vehicleRule) |
(→Structure: Added additional info from mm2c BAI thread) |
||
Line 22: | Line 22: | ||
unsigned short nIntersections; // Number of intersections | unsigned short nIntersections; // Number of intersections | ||
unsigned short nRoads; // Number of roads | unsigned short nRoads; // Number of roads | ||
− | + | Road roads[nRoads]; // Roads | |
− | + | Intersection intersections[nIntersections]; // Intersections | |
− | + | Culling culling; // AI culling ("bubbles") | |
}; | }; | ||
− | struct | + | struct Road |
{ | { | ||
unsigned short id; | unsigned short id; | ||
Line 37: | Line 37: | ||
float unknown2; // Always == 15 | float unknown2; // Always == 15 | ||
− | + | RoadData right; // Data for right side | |
− | + | RoadData left; // Data for left side | |
float centralDistance[nSections]; // Distances for central spline | float centralDistance[nSections]; // Distances for central spline | ||
Line 47: | Line 47: | ||
Vertex wOrientation[nSections]; | Vertex wOrientation[nSections]; | ||
− | + | RoadEnd end; // End of the road | |
− | + | RoadEnd start; // Start of the road | |
}; | }; | ||
− | struct | + | struct Intersection |
{ | { | ||
unsigned short id; | unsigned short id; | ||
Line 57: | Line 57: | ||
Vertex center; // Center point of intersection | Vertex center; // Center point of intersection | ||
unsigned short nRoads; // Number of connected roads | unsigned short nRoads; // Number of connected roads | ||
− | unsigned long roads[nRoads]; // | + | unsigned long roads[nRoads]; // Clockwise ordered references to roads connected to this intersection |
}; | }; | ||
− | struct | + | struct Culling |
{ | { | ||
unsigned long nBlocks; // Number of PSDL blocks + 1 | unsigned long nBlocks; // Number of PSDL blocks + 1 | ||
Line 66: | Line 66: | ||
}; | }; | ||
− | struct | + | struct RoadData |
{ | { | ||
unsigned short nLanes; // Number of lanes | unsigned short nLanes; // Number of lanes | ||
Line 85: | Line 85: | ||
}; | }; | ||
− | struct | + | struct RoadEnd |
{ | { | ||
− | unsigned long intersectionID; // Reference to Intersection[].id | + | unsigned long intersectionID; // Reference to Intersection[].id |
− | unsigned short unknown0; | + | unsigned short unknown0; // Always 0xcdcd |
− | unsigned long vehicleRule; | + | unsigned long vehicleRule; // See below |
− | unsigned long | + | unsigned long intersectionRoadIndex; // Index in the intersections road list or 0xcdcdcdcd |
− | Vertex trafficLightOrigin; | + | Vertex trafficLightOrigin; // Origin of traffic light |
− | Vertex trafficLightAxis; | + | Vertex trafficLightAxis; // Orientation of traffic light |
}; | }; | ||
Line 102: | Line 102: | ||
} | } | ||
− | Values for '' | + | Values for ''RoadEnd.vehicleRule'': |
* 0 - Stop sign. The vehicles will stop, longest waiting vehicle drives first. | * 0 - Stop sign. The vehicles will stop, longest waiting vehicle drives first. | ||
* 1 - Traffic light. One road at a time. All roads connected to the same intersection must have this control type, if not, the vehicles will behave as if it was a stop sign and the traffic light will blink between green and yellow. Traffic lights will only show up if their coordinates are not (0, 0, 0). | * 1 - Traffic light. One road at a time. All roads connected to the same intersection must have this control type, if not, the vehicles will behave as if it was a stop sign and the traffic light will blink between green and yellow. Traffic lights will only show up if their coordinates are not (0, 0, 0). | ||
* 2 - Always stop. The vehicles stop and never proceed. | * 2 - Always stop. The vehicles stop and never proceed. | ||
* 3 - Never stop. The vehicles will drive straight through the intersection without even slowing down. | * 3 - Never stop. The vehicles will drive straight through the intersection without even slowing down. |
Revision as of 15:32, 5 March 2006
Introduction
Each city may have one BAI-file. This file defines paths for controlling ambients such as pedestrians and automated traffic.
Format description
Intersections
A BAI-file is built up in three sections. The first section defines intersections.
Roads
The next section defines all the routes between the intersections.
Culling
Lists the roads to compute ambients for depending on the given PSDL block id.
Structure
In a pseudo-C style structure, a BAI-file looks like this:
struct BAI { char[4] header = "CAI1"; unsigned short nIntersections; // Number of intersections unsigned short nRoads; // Number of roads Road roads[nRoads]; // Roads Intersection intersections[nIntersections]; // Intersections Culling culling; // AI culling ("bubbles") };
struct Road { unsigned short id; unsigned short nSections; // Number of vertex sets unsigned short unknown0; // No idea unsigned short nBlocks; // Number of block references unsigned short blocks[nBlocks]; // References to the PSDL float unknown1; // Not sure. Speed threshold? float unknown2; // Always == 15 RoadData right; // Data for right side RoadData left; // Data for left side float centralDistance[nSections]; // Distances for central spline Vertex centralLine[nSections]; // Center spline for the entire road Vertex xOrientation[nSections]; // Orientation for pedestrians(?) Vertex yOrientation[nSections]; Vertex zOrientation[nSections]; Vertex wOrientation[nSections]; RoadEnd end; // End of the road RoadEnd start; // Start of the road };
struct Intersection { unsigned short id; unsigned short block; // Reference to the PSDL, (index + 1) Vertex center; // Center point of intersection unsigned short nRoads; // Number of connected roads unsigned long roads[nRoads]; // Clockwise ordered references to roads connected to this intersection };
struct Culling { unsigned long nBlocks; // Number of PSDL blocks + 1 unsigned short **cull; // Pointers to roads };
struct RoadData { unsigned short nLanes; // Number of lanes unsigned short nTrams; // Number of tram rails (bool?) unsigned short nTrains; // Number of train rails (bool?) unsigned short unknown3; // Sidewalk? Always == 1 (bool?) unsigned short unknown4; // Road type? 0, 1, 2 or 3 float lanesDistances[nLanes][nSections]; // Distances for right lanes float distance[nSections]; // Outer edge distance float Unknown[11 + nLanes]; // Something about the lanes, gladly padded with 0xcdcdcdcd Vertex lLanesVertices[nLanes][nSections]; // Vertices for driving lane splines Vertex sidewalkCenter[nSections]; // Vertices for sidewalk central spline Vertex tramVertices[nTrams][nSections]; // Vertices for tram rail splines Vertex trainVertices[nTrains][nSections]; // Vertices for train rail splines Vertex sidewalkInner[nSections]; // Vertices for sidewalk inner spline Vertex sidewalkOuter[nSections]; // Vertices for sidewalk outer spline };
struct RoadEnd { unsigned long intersectionID; // Reference to Intersection[].id unsigned short unknown0; // Always 0xcdcd unsigned long vehicleRule; // See below unsigned long intersectionRoadIndex; // Index in the intersections road list or 0xcdcdcdcd Vertex trafficLightOrigin; // Origin of traffic light Vertex trafficLightAxis; // Orientation of traffic light };
struct Vertex { float x; float y; float z; }
Values for RoadEnd.vehicleRule:
- 0 - Stop sign. The vehicles will stop, longest waiting vehicle drives first.
- 1 - Traffic light. One road at a time. All roads connected to the same intersection must have this control type, if not, the vehicles will behave as if it was a stop sign and the traffic light will blink between green and yellow. Traffic lights will only show up if their coordinates are not (0, 0, 0).
- 2 - Always stop. The vehicles stop and never proceed.
- 3 - Never stop. The vehicles will drive straight through the intersection without even slowing down.