This guide should help in attempts to create own crossing models. It expects you are familiar with controling the crossing program as described in User guide.
First of all, you shoul have some idea of what crossing you want to model. Have a look at some real crossing, or draw it at a mit of paper at last.
Before proceeding, decide how the vehicles will go around in the crossing. The crossing itself consists of important points, such as places where vehicle decides where it will go, where more streams of vehicles meet or cross, or where a speed or direction change is needed. These points are interconnected by one-directional lines. It is of course possible for the lines to cross without having a point in the intersection, but it may be something else than you usually want (such intersection is ignored by the program and the vehicles well ignore each other here, going there at the same time and doing all onther usually impossible things).
If you need inspiration, load an already existing model and torn on drawing of structures in the "Crossing" menu. The points and lines will appear on the crossing.
Now get your favorite image editor and create the background image for your crossing. If you think some objects will be above the vehicles (like bridges, a flying advertisment pig, you name it), draw them separatelly (don't forget to make the right parts transparent, if the thing is not exactly a rectangle). Save it all as png images (other types would probably work too, if you want to experiment).
The description file is an XML document. If you do not know, what that is, go and study it somewhere, you will really need that. So, the emty crossing with only the background image looks like this:
<?xml version='1.0'?>
<crossing xmlns='http://vorner.pretel.cz/crossing'>
<background>background_image_name.png</background>
</crossing>
You have to replace the file name with that of your background and save it to the same folder as the images. So, save it and try to load it from the Crossing program. If you did all well, you see the image there. Bingo, your first crossing. Well, almost.
If it fails with an error, you did somethig wrong. So read the error and fix that.
If you made the flying pig, you need to load it as well. So include element like this one:
<object x='13' y='126' rot='180' level='30'>pig.png</object>
This tells the program to take the picture pig.png, with its center at 13,126 pixels (it has to be integers) rotated by 180 degrees clockwise (you can omit the rotation). The level is a number telling how high the thing is. The pig is drawn above all the vehicles and objects in level 1 trough 29, while all the vehicles freom 30 upwards are above the pig (well, if you have an airplane as a vehicle...) and all the objects from 31 upwards. Objects on the same level are drawn in arbitrary order.
The level is optional, if it is missing, it is considered as 1.
So, you have the visuals (you tested it, right?) and you need to specify, where the vehicles will go. You can do it by including points and lines. A point is specifiod by its id, x and y coordinates and the level (optional). A line is specified by by its id and from and to attributes, refering to ids of the points it leads between.
<point x='1' y='1' id='first'/>
<point x='101' y='101' id='second' level='2'/>
<line id='first-to-second' from='first' to='second'/>
If you load that, you can see where the lines go by enabling of drawing structures.
You have a ghost city now. All the ways are where they shoul by, but nothig goes by them. You need to specify places where the cars appear. Pick up a point (it is prettier if the point is not visible, for example out of the crossing) and insert few elements like this into it:
<emerge type='car' amount='50'/>
The type says which type of vehicle will appear and amount how much of them. The higher the number is, the more will appear.
The types that are supported now are car and truck.
After this, you may notice the vehicles appear, go somewehere, wander around, do not obey any rules and finally go to a point where no way leads out and disappear (what did you expected them to do there?). This works in some way, but it needs a little more magic for them to act reasonably.
They are useful when specifying the behavior of vehicles.
You may change thy default speed (50) of a vehicle in any point of the crossing.
Simply place
If car enters a point and noone (meaning you) said it where to go, it chooses one of all the ways out of the point, every with the same probability.
You can tell it to choose from less of them and/or modify the probabilities.
List all the possible ways in
To change the probability, add probability attribute, with an integer.
The highter, the biggir is the chance the vehicle will choose this way.
If the probability is not specified, it is taken by 1.
The entrance to a point con be restricted to time intervals.
First thing you need to do is creating a semaphore group.
It is group of semaphores acting together.
(Usually, there is no more than one group on one crossing).
Place
Now place semaphores to all restricted points.
Semaphore looks like
This semaphore is open (vehicles can enter the point) when the group is somewhere between 0 and 100 (inclusive).
If the semaphore has more intervals, it is opened if any of them contains the actual group time (it is enough for one to match).
If there are more semaphores in one point, all must be opened for vehicle to enter.
If two (or more) vehicles meet and want to enter one point, that weth lower priority lets the one with higher go first.
This thing allows changing the priority while entering the point, like this:
If no priority is set, it is taken as 1.
If two cars with the same priority meet, one of them goes first, while the other waits, but it is not specified which one.
A condition is an element that restricts some of the modifiers only to some vehicles.
If you place somewhere a condition, you can place the modifiers (and other conditions) into it instead of the point itself.
The content of condition is taken into account only if the condition is true.
The condition is true, if the vehicle came from a specified line.
It looks like:
It can be used to define priorities, set different speeds in different dirrections, forbid some turn etc.
This condition matches one particular veticle type. Its syntax is as follows:
A line before a point where more lines meet should be long enough (et last for a car to fit in), se the car has enough space to see if enythig else is coming and enough space to stop, if it has to wait.
The emerging and disappearing points look better if they are not visible.
The levels can be used to construct bridges, tunels, and other more-level things.
<speed>130</speed> into the point, and the cars will go 130 there (and slow down to 50 on the way to the next point, if it does not the speed set).
Continuation
<cont>some-way</cont>
elements (each way one element).
The some-way is id of one line leadig out of this point.
Semaphore
<semaphores period='200' id='some-group'/>
to the top level document (not into any point).
The period is amount of time it takes the group to finish one cycle, wrap around and start again.
<semaphore group='some-group'>
<interval start='0' end='100'/>
</semaphore>Priority
<priority>3</priority>
.
However, changing all priorities to something else (but the same) is of no use, so there will be need for conditions (bellow).
Conditions
From
<from id='line-id'>
<!--The content-->
</from>Vehicle type
<vehicle type='car'>
<!--The content-->
</vehicle>Tips