[Join] or [Login] to make identifiable contributions

XML Tracks and pieces

What is needed of our structured format?

For various reasons we're doing this in XML - since it satisfies the first two points above, and it might get us out of writing a complicated editor before we've got a playable game. It beats some hokey home-rolled text format or a nasty binary-mush of language-specific data structures. (Pedants might insist it is still a hokey home-rolled text format, but at least it is well-formed, and therefore less hokey).

None of this is settled yet - your comments are most welcome.

Let's split things in two, we can have piece libraries, describing the shape and connectivity of different pieces, and track layouts which describe tracks as sequences of connected pieces.

Piece Libraries

We might have something like (eliding the XML-gubbins at the top). We'll be referencing pieces from within track definitions by URIs with fragment identifiers (hence the id attribute on <piece>).

A sample pieces file (pieces.xml):

<?xml version="1.0"?>

<!-- 
Need to handle units somehow, so all lengths here are in track-widths
- 154 millimetres. We allow for only very basic arithmetic operations
(single operator, / or *).

The radius is the radius of curvature of the centre of the track.  

May be better to switch to millimetre specs in general, in order to
easily reflect real-world widgets without the ratios.  
-->

<pieces>
<piece id="start" length="350/154" title="Starting straight" startingblock="startingblock">
<connector start="0.25" end="0.75" />
<connector start="0.25" end="0.75" />
</piece>
<piece id="straight" length="350/154" title="Straight">
<connector start="0.25" end="0.75" />
<connector start="0.25" end="0.75" />
</piece>
<piece id="tochicane" length="350/154" title="Chicane begin">
<connector start="0.25" end="0.75" />
<connector start="0.40" end="0.60" />
</piece>
<piece id="chicanestraight" length="350/154" title="Chicane straight">
<connector start="0.40" end="0.60" />
<connector start="0.40" end="0.60" />
</piece>
<piece id="halfstraight" length="175/154" title="Half straight">
<connector start="0.25" end="0.75" />
<connector start="0.25" end="0.75" />
</piece>
<piece id="quarterstraight" length="87/154" title="Quarter straight">
<connector start="0.25" end="0.75" />
<connector start="0.25" end="0.75" />
</piece>
<piece id="shortstraight" length="78/154" title="Short straight">
<connector start="0.25" end="0.75" />
<connector start="0.25" end="0.75" />
</piece>
<piece id="xover" length="350/154" title="Crossover">
<connector start="0.25" end="0.75" />
<connector start="0.75" end="0.25" />
</piece>
<piece id="R1curve90" title="90 degree R1 curve" radius="0.9" angle="90">
<connector start="0.25" end="0.75" />
<connector start="0.25" end="0.75" />
</piece>
<piece id="R1curve45" title="45 degree R1 curve" radius="0.9" angle="45">
<connector start="0.25" end="0.75" />
<connector start="0.25" end="0.75" />
</piece>
<piece id="R2curve45" title="45 degree R2 curve" radius="1.9" angle="45">
<connector start="0.25" end="0.75" />
<connector start="0.25" end="0.75" />
</piece>
<piece id="R3curve45" title="45 degree R3 curve" radius="2.9" angle="45">
<connector start="0.25" end="0.75" />
<connector start="0.25" end="0.75" />
</piece>
<piece id="R4curve45" title="45 degree R4 curve" radius="3.9" angle="45">
<connector start="0.25" end="0.75" />
<connector start="0.25" end="0.75" />
</piece>
<piece id="R1curve22.5" title="22.5 degree R1 curve" radius="0.9" angle="22.5">
<connector start="0.25" end="0.75" />
<connector start="0.25" end="0.75" />
</piece>
<piece id="R2curve22.5" title="22.5 degree R2 curve" radius="1.9" angle="22.5">
<connector start="0.25" end="0.75" />
<connector start="0.25" end="0.75" />
</piece>
<piece id="R3curve22.5" title="22.5 degree R3 curve" radius="2.9" angle="22.5">
<connector start="0.25" end="0.75" />
<connector start="0.25" end="0.75" />
</piece>
<piece id="R4curve22.5" title="22.5 degree R4 curve" radius="3.9" angle="22.5">
<connector start="0.25" end="0.75" />
<connector start="0.25" end="0.75" />
</piece>
<piece id="R2curve90" title="90 degree R2 curve" radius="1.9" angle="90">
<connector start="0.25" end="0.75" />
<connector start="0.25" end="0.75" />
</piece>
<piece id="R2chicanecurve90" title="90 degree R2 chicane curve" radius="1.9" angle="90">
<connector start="0.40" end="0.60" />
<connector start="0.40" end="0.60" />
</piece>
<piece id="R2bankedcurve60" title="60 degree R2 banked curve" radius="1.9" angle="45">
<connector start="0.25" end="0.75" tilt="48" />
<connector start="0.25" end="0.75" tilt="48" />
</piece>
<piece id="debankingstraight" title="Flat to banked curve straight" length="4">
<connector start="0.25" end="0.75" />
<connector start="0.25" end="0.75" tilt="48" />
</piece>
<piece id="debankingstraight" title="Banked curve to flat straight" length="4">
<connector start="0.25" end="0.75" tilt="48" />
<connector start="0.25" end="0.75" />
</piece>
</pieces>

The <connector> start/end values indicate where along the edge the first and last grooves cut the edge, ranging from 0 to 1. Where the order switches the grooves crossover. This is intended to allow expansion to n-groove pieces from the same definition simply by altering the width of the piece to fit enough cars in and spacing the grooves evenly from start to end. The length attribute is considered to be a multiple of the width of the track, although I'm not sure if that is appropriate yet. I imagine measuring it down the centre of the piece. angle is about orientation top-down, tilt is the angle to the horizontal - both in degrees, and presumed zero if absent. Proper ranges and so forth to follow, along with seriously annotated diagrams.

14-March: Added radius after discussions at TWYD#4. Allows for tighter or looser curves. Not sure if it is strictly redundant, since we had angle and length already, may be nice to state it more explicitly though. May remove the notion of more than two connectors on a piece, and allow free-form of melded pieces allowing all manner of different crossover pieces, just by crossing the track at the same height. Hmmm, not sure yet. Will sort it out with gef this weekend.

I need to type more stuff in so people can decide if this is a suitable format.

Track

Takes pieces, needs to add some height information (here rather than inherent in the pieces - seems reasonable) to do flyovers and such like. Other than that this ought to be much simpler than the Piece Libraries.

Update: stripped out the id and connector stuff that was frankly superfluous (cheers, gef).

A sample track file (simple.xml):

<?xml version="1.0"?>
<!-- sort syntax out on this, vs. parser complaining
 DOCTYPE trix_track_01 SYSTEM "http://logicwand.com/games/trix/tracks/track01.dtd" -->
<track id="simple">
<title>Simple Track</title>
<description>
Simple oval track
</description>
<piecelib src="pieces.xml" />
<preview src="previews/simple" />
<piece src="start" />
<piece src="R2curve90" />
<piece src="R2curve90" />
<piece src="straight" />
<piece src="R2curve90" />
<piece src="R2curve90" />
</track>

DTDs to follow once we've solidified the formats. Rough, generated (and almost certainly out-of-date) DTDs are here for Piece Libraries and Tracks.

2 Comments

Add a new comment.

Gef Howie[gef] on 27th March 2002

Do we need to specify each connection?

Isn't it sufficient to list the pieces in order? I can't think of any way /not/ to make all those connections you specify in the track. I think we just need a lanes=2 spec somewhere.

Ashok Argent-Katwala[ash] on 5th July 2002

I've blown out the connections, so we now have a reasonable format for flat tracks, which is good enough for the initial version.

In particular there isn't a guarantee of connectedness at the moment, and the server will happily carry you from the last piece specified back onto the first, irrespective of the shape of the track. To be honest this isn't a huge concern, but it's worth stating.