AIW files for bridges/crossovers

Introduction

If your BTB track crosses over itself like this:
crossover1.gif

You will get problems with the AIW file (which stores info about the centreline and racing line, plus a few other things).

Here you can see triangles representing the centreline waypoints, with squares showing the racing line, which is a simple offset from the centreline. At the overlap, the waypoints are positioned on the higher part instead of the lower part:
crossover2.gif
(note this AIW file was loaded into 3DSimEd, which can load AIW files but does not support editing them)

Fixing the problem

Option 1: the official AIW editior

By far the best way to create an AIW file is to use the official rFactor AIW editor (Example video tutorial), but there are two possible problems with that approach:

  1. If you have rFactor installed via Steam, the AIW editor won't work.
  2. If you're editing for one of the other gMotor2 games, such as Race07, GTR Evolution etc, there may not be an in-game editor.

Option 2: Two versions of your track and the unofficial AIW editor! (and notepad)

Although the AIW file points can be edited manually, or using the AIW editor mentioned below, by far the best approach is to get BTB to do as much as possible so there's less manual tweaking to do at the end.

BTB track preparation

Warning: Make plenty of backups of your BTB project and your track export folders.

In BTB create two surfaces/cross sections on the upper part of the overlap, ensuring fully cover the lower part:
crossover3.gif

For both of them, select 'Set Material'. You'll see in the 3D view that the short section is highlighted in red when you click on it.
In the 3D view hold and right click and select 'remove material' and remove all materials used by this cross section:
crossover4.gif
(you can also use the cross section window)

You should repeat the process for all materials in this cross section to ensure there's nothing left of the upper part of the track:
crossover5.gif

Export the track but choose different Venue and Track names (this prevents things getting mixed up). e.g.
crossover6.gif

For both surfaces deselect 'Set Material' to restore the track to its original state. The surfaces themselves can remain in place in case you change the track layout and need a new AIW.

Do another export, including the AIW file and remember to change the Venue and Track names back to their previous values. This ensures there will be as close a match as possible between the AIW files for both versions of the track. Also remember that BTB saves the most recently used export folder (venue/track names) when you save a project:

crossover7.gif

AIW editing

Finding the points visually

The temp AIW file (the one called …AIWFix) will contain some waypoints that need to be copied to the main AIW file to override the incorrect heights. It's possible, but needlessly hard, to work it out using only a text editor.

It's much easier to use guitarmann's AIW editor, which can be downloaded from here: http://www.mediafire.com/?5bdkeud5q5zim

There are several versions in the above location. This tutorial assumes version 4.22 is being used.

Extract the files somewhere. It doesn't appear to matter where, but a subfolder if the game won't hurt. With it being an old program there may be directory access issues if it tries to save to somewhere in Program Files (x86).

Edit the file "rF_AIW_CAM.conf" with a text editor and enter the location of your "Gamedata\locations" directory, using the default value as an example. Also set the window size to a suitable value.

Run the program and you'll see something like this:
crossover8.gif
(note the file load button on the right)

Open the AIW file for the main version of your track.

If you press 'h' the program displays a help window which tells you the keyboard shortcuts. The ones relevant to this tutorial will be mentioned here.

If you have track edges turned on you'll notice the program changes their colour to show the height. Toggled with the E button:
crossover_9.gif

Use keypad + or minus to zoom in and out. It's not clear if laptops without keypads can emulate those keypresses physically, but you can run Windows' 'osk' keyboard and turn on the keypad from there if necessary.

Cursor keys or keypad arrows to move the view.

You can select a waypoint by clicking on it, and use x and c to go back/forward along the path.

Zoom in on the crossover and you'll see an abrupt change in colour, which shows you where the height suddenly goes wrong:
crossover_10.gif

Those points need to be replaced, but so do the two points before and after this set. One of the waypoint parameters is a vector pointing in the direction of the next one in the path. Including the yellow highlighted points will ensure the AI navigation is as smooth as possible:
crossover_11.gifWith the first of the required points selected, look at the values at the top of the window:
crossover_12.gif

The Waypoint # is the ID, but that's not actually stored in the AIW file (the game probably stores it internally when the track is loaded). To find the waypoint in the AIW file, you have to use WP_Ptrs parameter instead. The first value is the ID of the previous waypoint, so make a note of this. The second value is the ID of the next waypoint.

Do the same for the final required waypoint:
crossover_13.gif
(waypoint 504, Ptrs: 503, 505…)

With the first and last waypoints known, it's now time to search for them in the main AIW file.

Finding the points in the AIW files

Main AIW file

Open your main AIW file in a text editor (and make a backup). I recommend something like notepad++ which can open multiple tabs and highlight repeating words (this will be handy for this process).

Go to the [waypoint] section. You'll see some initial values and then a repeating pattern for each waypoint, starting with wp_pos and ending with WP_PTRS. To find the first waypoint you have to search for "(498", and you'll find this:
crossover_14.gif
(always remember that WP_PTRS is the last parameter for each waypoint).Put a new line above wp_pos so you can easily see it, then search for the last waypoint, by searching for "(503", and put a line break below it:
crossover_15.gif
Temp AIW file

This is the one where the bridge has been deleted, so the lower points will have the correct heights.

These may not have the same waypoint ID (or WP_PTRS values), so you have to search for the coordinates and then change the WP_PTRS values to match the original file.

The first point starts with "wp_pos=(134.0467,20.00098,-77.46556)" so search for that in the temp file:

crossover_16.gif

The final point starts with "wp_pos=(122.8192,20.00195,-55.11424)", so also search for that in the temp file:

crossover_17.gif
Compare the WP_PTRS values of the waypoints from both AIW files:
crossover_18.gif
In this example you can see that the WP_PTRS values for the required waypoints in the temp file need to be reduced by 2. Once you've done that you can replace the waypoints in the main AIW file.

The line breaks suggested earlier make it much easier to find the correct places for copying and pasting but you should remove them before saving the original main file.

AIW editor again

Reload the main AIW file in the editor and you should see, either by looking at the track edge colours or the heights of the waypoints, that the lower part of the track is nearly fixed:
crossover_19.gif

The heights are fine but you may see that the green line, the racing line/grrove, also needs fixing for both the top and bottom parts of the track. You can select each waypoint and type a value in 'WP_Path' on the left of the window, but there's another way which is probably better.

Select a point a few places before the error, then press 's' to enter spline mode, which allows the racing line to be created smoothly over a set of waypoints. You'll see a dotted yellow line showing you what the program will create:
crossover_20.gif

You can move the start of the curve by pressing x or c
You can move the end of the curve by holding shift and then pressing x or c
The two control points can adjust the shape too.
The first control point can be moved with page up or page down
The second control point can be moved by holding shift along with page up or page down.

When you're happy with the shape, click on the 'create curve' button:
crossover_21.gif

In this example the top of the crossover also has a problem with the racing line, so use the above method to fix it.

You can also use this method to tweak the racing line at other corners (sometimes it's hard to get BTB to generate the line you want).

When finished, go to File and Save. By default the program sets a randomised filename, presumably to prevent you accidentally losing the original file. You can type the filename in the box but it's recommended you just rename the randomised filename and use the opportunity to make a backup of the previously created file.

Go in game and test it out. Make sure it looks correct and make sure the AI drive around properly. If there are any glitches, such as the AI slowing down or crashing, go back to the spline mode and tweak the curve again.

Further editing

If you make any changes to your track layout in BTB you'll have to do the above process again. Once you're used to the key commands it gets easier.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License