• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Reading BGL files

Messages
7
Country
southafrica
Hi,

I'm trying to read BGL files in .NET, following the documentation at https://www.fsdeveloper.com/wiki/in...GL file is made,dependent on the section type.

Using P3Dv5 as a test, and for consistency I am reading the same(?) BGL file as used in the example on the wiki article. For the header, below is my 56 bytes

C:\Games\Prepar3D\Scenery\0301\scenery\cvx2815.bgl
65 0 0 0 1 0 0 0 86 8 0 0 63 91 60 2 60 88 0 0 6 0 0 0 0 FA 81 0 0 0 0 0 44 3 0 0 F4 4 0 0 26 8 0 0 6F 3E 1 0 1B 1C 0 0 86 7D B0 CE
65

The second line, is my DWORD (Int32) generated from the first 4 bytes, 0x00 to 0x03.

Is this correct, because from what I am reading, the Magic number is not 0x01, 0x02, 0x19, or 0x92?


private void ScanBGL(string thisFile)
{
Console.WriteLine(thisFile);
byte[] thisHeader = new byte[56];
using (System.IO.BinaryReader thisStream = new System.IO.BinaryReader(new System.IO.FileStream(thisFile, System.IO.FileMode.Open)))
{
thisStream.BaseStream.Seek(0x38, 0);
thisStream.Read(thisHeader, 0, 56);
}

Console.WriteLine(ByteArrayToHex(ref thisHeader));
Console.WriteLine(Hex(BitConverter.ToInt32(thisHeader, 0)));
}

private string ByteArrayToHex(ref byte[] ByteArray)
{
long l;
string strRet = "";

for (l = Information.LBound(ByteArray); l <= Information.UBound(ByteArray); l++)
strRet = strRet + Hex(ByteArray[System.Convert.ToInt32(l)]) + " ";

ByteArrayToHex = Left(strRet, Strings.Len(strRet) - 1);
}
 
Messages
7
Country
southafrica
Ok,

Granted I am reading one byte too many.

But we are talking (or I am asking), about the first 4 bytes? Surely, whether I read 55 or 56 bytes, the first 4 bytes will remain the same, as the offset in the file where they are being read from remains 0?
 
Messages
2,063
Country
us-ohio
I'm uncertain what actual language you're using... but...

Isn't this line:
thisStream.BaseStream.Seek(0x38, 0);

Actually saying to seek to position 0x38 after position 0... which would put you beyond the file header and instead put you at the first section in the BGL file??
 
Messages
7
Country
southafrica
I'm uncertain what actual language you're using... but...

Isn't this line:
thisStream.BaseStream.Seek(0x38, 0);

Actually saying to seek to position 0x38 after position 0... which would put you beyond the file header and instead put you at the first section in the BGL file??

Sorry, I feel like an idiot!! Seek(0, 0) to go to the start of the file, and I am getting 0x01, 0x02, 0x92, and 0x19 just like I am supposed too!
 
Messages
7
Country
southafrica
Getting there :)

Processing Section 1 of 11, C:\Games\Prepar3D\Scenery\0102\scenery\APX14160.bgl
Airport
Processing Section 2 of 11, C:\Games\Prepar3D\Scenery\0102\scenery\APX14160.bgl
170
Processing Section 3 of 11, C:\Games\Prepar3D\Scenery\0102\scenery\APX14160.bgl
ILSVOR
Processing Section 4 of 11, C:\Games\Prepar3D\Scenery\0102\scenery\APX14160.bgl
NDB
Processing Section 5 of 11, C:\Games\Prepar3D\Scenery\0102\scenery\APX14160.bgl
Marker
Processing Section 6 of 11, C:\Games\Prepar3D\Scenery\0102\scenery\APX14160.bgl
Waypoint
Processing Section 7 of 11, C:\Games\Prepar3D\Scenery\0102\scenery\APX14160.bgl
SceneryObject
Processing Section 8 of 11, C:\Games\Prepar3D\Scenery\0102\scenery\APX14160.bgl
VORILSICAOIndex
Processing Section 9 of 11, C:\Games\Prepar3D\Scenery\0102\scenery\APX14160.bgl
NDBICAOIndex
Processing Section 10 of 11, C:\Games\Prepar3D\Scenery\0102\scenery\APX14160.bgl
WaypointICAOIndex
Processing Section 11 of 11, C:\Games\Prepar3D\Scenery\0102\scenery\APX14160.bgl
NameList

Anyone that can be friendly and identify what Section Type 170 (0xAA) is?
 
Messages
89
Country
france
Hi Chris,

0xAA is the AirportSummary section identifier (P3DV5 and V6 only) - Was 0x2C in previous versions as well as in FSX

Hervé
 
Top