Saturday, May 26, 2007

FlightGear ship traffic-- A Dummy to Dummy Guide

Ok, this is probably one of the most useless things you would want to do with FlightGear, but it is kind of fun. A full guide to AI Systems can be found here on the FlightGear Wiki. Here, I will show you exactly what I did to easily add some ships to my local scenery. Using this method you will have boats that travel in slow circles according to their rudder settings, without the need to explicitly define routes.

The first thing to do is to copy the ship_demo.xml file found in your FlightGear\data\AI directory, and rename it. In my case I called it RIship_demo.xml, because I was creating boat traffic for the Naragansett Bay in Rhode Island.

Edit the file in any text editor, such as Wordpad. Below is how I edited the file. (My apologies for giving this with screen shots instead of cut-and-pastable text, but I don't know a simple way to put xml code into this blog without the browser trying to interpret it as code.) My edits are red. Mainly, I just changed the latitude and longitude for the ship. Then I copied it twice, and modified each copy for location and speed. Finally, in the third entry I changed the vessel to the freighter. This required one more modification, which I will explain below. To find the latitude and longitude values, you can go here. Move the map to your desired location, and you will see the lat. and long. in the upper right corner.



But before we set up the freighter, I will show you how to add this traffic file to your preferences. This step is essential or we will not see the ships. Edit the preferences.xml file in your FlightGear\data directory. Search for the text 'scenario' and add a line for your new file, as shown below (use your file name, however). My edits are in red. Also, make sure the boolean value shown in red is set to true.



I noticed there was a freighter in the same directory as the sailboat model. However, it did not have a corresponding xml file. Acting on a guess, I copied the sailboat.xml, edited as shown below, and saved it as freighter.xml. It worked!



Once you've modified and saved these files, load up a flight in the appropriate area, and go look for your boats!

2 comments:

Sagar said...

You might try replacing < with &lt; and > with &gt;. So, for example, <b> would be &lt;b&gt;. Ugly, I know, but a search and replace should make it pretty painless.

If you're wondering what the heck that junk is, you should check out the Wikipedia article on HTML entities.

Runnerdad said...

Sagar,
I tried the [ampersand]lt and [ampersand]gt thing, but it didn't work on blogger, at least not on the preview. I notice it works in the comments, tho!
< see I can do it now ! >