Browse by Category
   
Search  
      Glossary

Flight Simulator Knowledge Base .: Tutorials .: FS2004 Tutorials .: FS2004 Development .: Placing Default FS9 Library Objects with XML

Placing Default FS9 Library Objects with XML

This tutorial is possible through the efforts of Jeff Stanyer, who mentored me through this process via email over several weeks. He put up with a ton of bandwidth going his way asking questions that were sometimes pointless, useless, meaningless, and which often contained the answer in my description of the problem I was asking him to solve. None of this -- the tutorials, the lowered framerate impact in my sceneries, even the redesigned macros to lower the overall polygon count -- would have been possible without his vast storehouse of knowledge and his EXCEPTIONAL patience and understanding. As I posted about him in another forum, "If 'ere's a 'eaven som-'ere, e'll be th' bloke standin' roun' the rivers o' wine tellin' St Peter 'ow ta change it into BEER!!!!!!" Thanks, Jeff! notworthy.gif

1. bglcomp_SDK -- You will need this. Get it HERE and place it in a directory that you can get to easily; you will be doing drag-and-drop to compile XML coding into a .bgl file that can be used for your scenery. The SDK also comes with an Excel spreadsheet of the default FS9 objects; you will be using data from that file, so having MS-Excel available is also a "must have."

2. Using Notepad, cut and past the following lines of code into a text file (.txt) and save it to the same directory with bglcomp_SDK. Give the document a name that you will readily associate with the airport/airbase you are designing or modifying.

<?xml version="1.0"?>
<FSData
version="9.0"
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:noNamespaceSchemaLocation="bglcomp.xsd" >
<SceneryObject
lat="N43 04.6550"
lon="W070 49.4533"
alt="0"
altitudeIsAgl="TRUE"
pitch="0"
bank="0"
heading="340"
imageComplexity="NORMAL">
<LibraryObject
name="4808a0b04d43fc5620867d91fc8c6eb3"
scale="1.0"/>
</SceneryObject>
</FSData>


3. Change the lattitude, longitude, and heading in the code:

<?xml version="1.0"?>
<FSData
version="9.0"
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:noNamespaceSchemaLocation="bglcomp.xsd" >
<SceneryObject
lat="N43 04.6550"
lon="W070 49.4533"
alt="0"
altitudeIsAgl="TRUE"
pitch="0"
bank="0"
heading="340"
imageComplexity="NORMAL">
<LibraryObject
name="4808a0b04d43fc5620867d91fc8c6eb3"
scale="1.0"/>
</SceneryObject>


to show where you want the object placed. Open your airport/airbase in AFCAD and use the tip of the mouse pointer to locate the exact point where you want the CENTER of the object to be. On the bottom bar of the AFCAD display, you will see the Lat/Lon coordinates; copy them down and replace the above entries with the ones from your airport. Before closing the AFCAD, also figure out which direction you want the macro to face (the heading); replace the entry in last red-highlighted line of code (above).

4. Open the spreadsheet in the bglcomp_SDK directory and locate the object you want to place; highlight and copy the GUID of the object, then replace the sample code (below) with the new code.

<?xml version="1.0"?>
<FSData
version="9.0"
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:noNamespaceSchemaLocation="bglcomp.xsd" >
<SceneryObject
lat="N43 04.6550"
lon="W070 49.4533"
alt="0"
altitudeIsAgl="TRUE"
pitch="0"
bank="0"
heading="340"
imageComplexity="NORMAL">
<LibraryObject
name="4808a0b04d43fc5620867d91fc8c6eb3"
scale="1.0"/>
</SceneryObject>
</FSData>


5. Save your Notepad document into the bglcomp_SDK directory. Remember to give it a unique name that will let you know immediately what the file deals with.

6. Drag-and-Drop the text document over the bglcomp.exe icon. Wait a few seconds and you will see a .bgl file appear, with the same name as the text document you created. All you need to do now is copy that .bgl file into the scenery directory for your airport/airbase; the next time you start up FS9 and go to that airport/airbase, the object you placed will appear -- with default textures -- exactly where you placed it. So make SURE you copy the AFCAD coordinates correctly. Also, if for some reason the .bgl is NOT generated, it means you've inadvertently deleted a character or line of code; make SURE your document is EXACTLY what is show above, except for your coordinates, heading, and the GUID of the object you are trying to place. Every symbol (<, >, etc.) and quotation mark in the code MUST BE EXACTLY WHERE IT IS IN THE SAMPLE; if it isn't, bglcomp.exe will do nothing with the data.

NOTE 1: There is a line altitudeIsAgl="TRUE" in the above code -- this entry is always "TRUE" for any object you place on land. If you are placing an object on water, change the entry to FALSE.

NOTE 2: Right below the line where you enter the GUID of the object you are placing, you will see scale="1.0". This entry can be changed if you need the object to appear larger or smaller; make your changes in the decimal value (i.e., 1.1, 0.9, etc.) as the sizing changes proportionately. This is handy for placing multiple copies of an object where you want different sizes (like a radar dish, for instance). You could place one on an antenna next to a van, and one twice that size (or larger) on an antenna atop a building. Since you're using XML to place the object, FS9 will only draw the object once, no matter how many times it appears in the scenery. By changing the scale on subsequent call-outs, you retain that "one time draw" feature while still modifying the object for a slightly different display.

What if you have more than one object to place? No problem; simply cut-and-paste the above code as many times as you have objects to place, changing the location and GUID for each object to be placed. When you have them all listed, drag-and-drop over the bglcomp.exe icon and it will produce a single .bgl scenery file containing all of the objects you called.

How helpful was this article to you?

Related Articles

article Creating a Library of API Objects
- Requires both API and SCAFirst, you cannot create a usable LibraryObjects file of API objects...

  4-5-2006    Views: 3355   
article Placing MDL Objects from LibObj File
First things first -- there will be no tutorial describing how to make a LibraryObjects file for...

(No rating)  4-14-2006    Views: 7889   
article Placing 3rd party Macros with XML
This tutorial is possible through the efforts of Jeff Stanyer, who mentored me through this...

  12-30-2005    Views: 3862   
article Calling API Objects from LibObj File
- Requires AFCAD and SCASMTo call (place) API objects that you have placed in a LibObjs file is...

  4-5-2006    Views: 3484   

User Comments

Add Comment
No comments have been posted.




© Copyright 2003-2014 FlightSimWorld.com & its owners. All rights reserved. Terms of Use | Privacy Policy | Advertise with us | Submit News | Contact us | Twitter