AGN (FSX)
This document describes the FSX format for autogen (AGN) files.
Sections
The AGN file uses the RIFF format (like MDL files), this means that the file consists of different sections. Each section starts with a four character label, followed by the length of the section in bytes (this length without the header itself).
The main RIFF section itself has one additional parameter, this is a four character string that indicates the type of RIFF AGN file. For an FSX AGN file the value should always be AGNX.
The following subsection show more details about the content of these different sections.
VERS
Contains versions information about the AGN file.
int32 version (normally 1091777331)
GBDD
Contains information about autogen generic buildings
int32 percentage of 1 and 2 floor buildings (normally 10) int32 percentage of 3 to 5 floor buildings (normally 10) int32 percentage of 6 to 8 floor buildings (normally 10) int32 percentage of 9 to 12 floor buildings (normally 10)
Valid values for percentage are from 0x00 (0%) to 0x14 (100%).
GBTE
This section contains the name of the texture to use for the generic buidlings. The texture name is stored without extension and the length seems to be a multiple of 4.
RHTE
This section contains the name of the texture to use for the row houses. The texture name is stored without extension and the length seems to be a multiple of 4.
GBLD
Contains building information. This section contains one or more GBLR sections.
GBLR
Contains information about Generic Buildings.
GUID roof type (will use default roofs, if 0)
For each Generic Building:
float X position of first point float Y position of first point float X direction to the second point float Y direction to the second point float X offset of third point float Y offset of third point
The x and y coordinates are given as offset from the middle of the LOD13 square (range -0.5 till 0.5).
PREG
Contains vegatation information. This section contains one or more PRDE sections.
PRDE
For vegatation polygon. Contains:
GUID vegatation type
For each polygon:
int number of vertices
For each vertex:
single x single y
The x and y coordinates are given as offset from the top left of the LOD13 square (range 0 till 1). The first and last vertex of the polygon have to be the same (so the polygon has to be closed).
VGRG
Contains information about FSX style rectangular vegetation regions. This section contains one or more VGRE sections. The type of vegetation is defined by a GUID.
VGRE
GUID vegetation type
For each rectangle:
float X position of first point float Y position of first point float X offset to second point float Y offset to second point
The x and y coordinates are given as offset from the middle of the LOD13 square (range -0.5 till 0.5).
VGRD
Contains information about the FS2004 vegetation definition.
int vegetation class 1 int vegetation class 2 int percentage vegetation class 1 (0-100) int maximum density float minimum height class 1 float maximum height class 1 float minimum height class 2 float maximum height class 2
VGRO
Contains information about FS2004 style rectangular vegetation regions. The type of vegetation is defined in the VGRD section.
For each rectangle:
float X position of first point float Y position of first point float X offset to second point float Y offset to second point
The x and y coordinates are given as offset from the middle of the LOD13 square (range -0.5 till 0.5).
ROWH
Contains information about row houses. The amount of houses is the length of the section divided by 24.
For each row house:
float X position of first point float Y position of first point float X direction to second point float Y direction to second point float X offset to third point float Y offset to third point
The x and y coordinates are given as offset from the middle of the LOD13 square (range -0.5 till 0.5).
AGN2
Contains information about library objects. Contains one or more A2GE sections.
A2GE
Contains information about library objects.
GUID library object guid
For each library object:
float X position of first point float Y position of first point float X direction to second point float Y direction to second point
Optional:
float X offset to third point float Y offset to third point
The x and y coordinates are given as offset from the middle of the LOD13 square (range -0.5 till 0.5). The coordinates describe the bounding box, the actual library object is placed in the center of it.
PBLD
Contains information about polygon buildings. Contains one or more PBDE sections.
PBDE
GUID building type
For each building:
int32 1 (seems always to be 1) float extrusion width int32 number of footprint vertices
For each vertex:
single x single y
The x and y coordinates are given as offset from the top left of the LOD13 square (range 0 till 1).
LOD 13 Geographical Location
The geographical location of the LOD13 square associated with the AGN file is encoded in the file name.
The file name is in the format : xxxxxan.agn, where the xxxxx part, with a length of 15, is made of the following digits: 0,1,2 and 3
Encoding the LOD13 geographical location in the file name
Let's say that the upperleft position of the LOD13 square is:
Latitude: N45.51
Longitude: W73.38
This corresponds to the QMID square U=7278, V=4049, Level =15 (Remember that QMID Level = LOD Level + 2)
We then convert the U and V values in binary format:
U = 7278 = 1110001101110 V = 4049 = 111111010001
However, for the V value, we replace the '1' with '2'
So V = 4049 = 222222020002
Finally we add U + V with their respective binary format
U: 1110001101110 + V: 222222020002 = 1332223121112
If needed, we left-pad the result with zeroes to have a length of 15
001332223121112
So the resulting AGN file will be : 001332223121112an.agn.
The reason the length is 15 is because the maximun U value for LOD13 is 24575 which has a binary value of 101111111111111 (15 characters)
Decoding the LOD13 geographical location from the file name
Let's say the file name is 001332223121112an.agn
We extract the numerical part to compute the U and V values (QMID Level is always 15)
To get the U value, we replace the '3' with '1' and '2' with '0'
To get the V value, we replace the '1' with '0' and the '3' and '2' with '1'
001332223121112 U: 001110001101110b = 7278d V: 000111111010001b = 4049d
So the agn file corresponds to the QMID square (u=7278, v =4049, l=15)
Once we have the u and v values, the upperleft coordinates of the square are:
LongitudeDeg = u * 0.0146484375 - 180 LatitudeDeg = 90 - v * 0.010986328125