NAME

prmbend — perform algorithmic transformations on Re-Volt PRM files

SYNOPSIS

prmbend [twist] [bend|shift] [-h height] [-o outfile] infile
twist = -b|t [twistheight]
bend = -l|r|u [radius]
shift = -e|w [slide]

BACKGROUND

One of the fundamental limitations of the Re-Volt Track Editor is that track pieces go all the way to the ground -- if you have a section of track at an elevation of, say, 8 units, the space under the track is filled by a 'platform' that the track section rests on. With the exception of the overpass track section, there is no way for one part of a track to pass over another part of the track. And with the constraint that the tracks have to cross at a 90-degree angle with both the upper and lower tracks level, that puts a serious crimp into the design of tracks.

Now, this can be fixed somewhat by the careful use of instances. For example, in my track 'Overpass', I strung together several overpass track sections, then used rvglue to cut out just the elevated track section as an instance, then pasted these PRM files back into another track as bridges over other parts of the track -- in particular, over turns, which is impossible with the Lego editor.

However, even this solution had its limitations. It was limited to the use of PRM files that could be assembled from overpass sections — straight, level bridges. While it gave more freedom to create track layouts, it still didn't have a lot of flexibility

screenshot of trackIn an attempt to solve this problem, I wrote a program that would open up a PRM file that I had made of a four-unit-long overpass bridge section, then write it out with the coordinates for the vertices of its polygons altered so that it would now be a 90° turn the same radius as the 3x3 curved-turn Lego track section. This turned out to be more successful than I'd expected. The resultant PRM file was a smoothly-curved track piece that glued precisely into position. When tested with various cars, the track was smooth and fast to drive on.

As you can see from the image to the right, the curved bridge section integrates neatly into the track, arcing smoothly over another part of the track with both straight and curved track sections.

spiral turn track sectionSeeing that the basic princible of algorithmically altering the shape of a PRM file worked so well, I decided to see how well adding elevation change would work, and modified my original program to add an elevation change of 4 units (elevation steps in the Lego editor) from one end of the curve to the other. In order to make the elevation change smooth, I applied the elevation in a sine function, so the track at both ends of the resulting PRM file is level, avoiding sharp discontinuities in the track.

Curved pipe trckAnother problem I've had with the Lego track pieces is that the pipe turn track is way too sharp, and there's no alternate-sized turns, the way there are for round turns. If a section of pipe track could be bent successfully, then it would make pipes more fun to drive.

Processing a section of pipe track and then inserting it back into a track as an instance, I discovered a problem. The bottom of the interior part of the pipe is actually below the level of the bottom of the sides of the 'block' containing the pipe -- when you put the instance down on the 'ground', the ground plane cuts off the bottom of the inside of the pipe. It was necessary to create elevated pipe track and then process that, to ensure that the modified track would be usable. The result, with two level and one climbing turn section, are pictured to the right.

glitch in conversionHowever, a glitch in the track section depiction showed up with these pieces, due to the way that the Re-Volt track editor handles elevated track sections. Each track section has its polygonal makeup; when it is placed at ground level, just those polygons are drawn. But when the track section is elevated, in order to get the outside of the track going all the way to the 'ground', the Re-Volt track editor puts the track piece on top of a four-sided platform, with each side being a single polygon. Because the track pieces themselves are made up of many polygons, the curve they make when bent looks smooth; however, with the few polygons that make up the lower sides of an elevated track piece, the lower sides are going to look faceted, not smooth, when bent — and this causes gaps between the upper and lower parts of the track section after it is bent. Unfortunately, this is an unavoidable misfeature for pipe track. However, it shouldn't preclude the use of bent pipe tracks as PRM files.

With the basic principle of PRM file bending validated, the next step was to create a general-purpose tool that could be used to create a wide variety of altered PRM files. After a small amount of programming to allow the user to pass PRM file and command information to the program, it was ready for use.

DESCRIPTION

Prmbend is a program that manipulates a Re-Volt instance file (*.PRM) to create a new PRM file; the intended use is to take instances cut out of 'Lego' tracks and reshape them into new track pieces that can be pasted into other tracks. Prmbend can bend an instance into an arc or an 'S'-curve, create an elevation change in the instance, and twist (bank) the instance. These operations fall into three groups:

Bending Operations   Elevation Operations
Function Command-line option Function Command-line option
90° left turn -l [radius] Raise track -h [height]
90° right turn -r [radius] Twisting Operations
U-turn -u [radius] Function Command-line option
Left shift -w [slide] Bank track -b [twistheight]
Right shift -e [slide] Twist track -t [twistheight]

Options

-b [twistheight]
Bank the turn around the inner edge of the turn by twistheight units (default 2 units)
-b [twistheight]
Bank a turn around the inner edge of the turn by twistheight units (default 2 units)
-t [twistheight]
Bank a turn around the centerline of the turn by twistheight units (default 2 units)
-l [radius]
Bend the instance into a 90° left turn of radius radius units (default 1 unit)
-r [radius]
Bend the instance into a 90° right turn of radius radius units (default 1 unit)
-u [radius]
Bend the instance into a 180° turn of radius radius units (default 1 unit)
-w [slide]
Bend the instance laterally so that the far end is slide units left of the near end (default 0 units)
-e [slide]
Bend the instance laterally so that the far end is slide units right of the near end (default 0 units)
-h [height]
Raise the far end of the instance height units (default 0 units)
-o outfile
Write the modified instance to the file named 'outfile'. If this option is not present, the modified instance will be saved in the file 'new_prm.prm'.

The bending operations are mutually exclusive; you can bend the PRM into a 90° turn, or a U-turn, or you can bend it into an S-curve, but combinations. Both of these can be combined with the elevation change, and the elevation change can be used by itself.

The elevation operation raises the 'far' end of the instance relative to the start of the instance. A left turn with a height change of 4 would climb while turning left; a right turn with a height change of 4 would climb while turning right.

The twisting operations create inclined track from the turns. The left and right shift operations cannot be twisted. Banked track is twisted so that the inner edge of the turn is at the same level all the way around the turn (the outside of the turn is raised). Twisted track is twisted so that the middle of the track is at the same level all the way around the turn (the inside of the turn is lowered; the outside of the turn is raised). Twisted track may not be suitable for placement at ground level, depending on the amount of twist, as the inner part of the track may intersect the ground plane.

The values for radius and shift are given in Re-Volt track units -- 'prmbend -l 3 prmfile.prm' tells prmbend to transform the file 'prmfile.prm' by bending it left into a 90° turn so that the outside edge will have a curve radius of 3 Re-Volt units. If you do this with a PRM that is a section of overpass, for example, you will have a turn the same size as the 3x3 curved turn Lego track piece.

The value for height is given in Re-Volt elevation units -- the 'steps' of elevation in the Re-Volt track editor. Each level of elevation is one-eighth of a Re-Volt track unit.

The value for twistheight is given in units that are half a Re-Volt elevation unit -- giving a bank or tilt a twistheight of '2' will raise the outside of the turn one Re-Volt elevation unit relative to the inside of the turn.

NOTE: This program modifies the instance PRM file. In order to create a 'solid' instance, it will be necessary to use another utility program, such as prm2ncp, to create collision data for the instance. If the instance is glued into a world file with rvglue, the collision data will be generated by rvglue; it is not necessary for the .NCP file to be generated before gluing the instances into the world file. However, if you intend to drive on the track before gluing the instances into it, the NCP files should be present.

NOTE: The Re-Volt coordinate system has X and Z in the plane of the ground, with Y being elevation. Prmbend assumes that the orientation of a PRM file (i.e., the direction of the track path) is along the X axis. PRM files with different orientations may cause distorted results.

NOTE: The program was created to allow PRM files that were created by cutting overpass track sections out of a world file to be bent into shapes that could be pasted back into a Re-Volt track as a single width of track. Using Prmbend on PRM files with different proportions may cause distorted results.

Version History

2/3/2002  Original version of prmbend released for download
2/7/2002  Enhancement to left/right shift algorithm to eliminate necking from simple translation method

Download

Download prmbend and sample input and output PRM files as a single zip file.

Contents of the zipfile

In addition to the prmbend executable and this documentation, the zipfile contains two directories, overpasses and modified. These contain pregenerated PRM and NCP files that can be used in Re-Volt tracks.

Component Type Explanation
First Digit Turns The radius of the turn in Re-Volt track units
Hill/Shift The length of the instance in Re-Volt track units
Instance Type  't' Turn — a 90° turn
'h' Hill — a straight hill
's' Shift — a 'diagonal shifting the track left or right
Subtype Turns 'l' for a left turn, 'r' for a right turn
Shift 'Nw' for a shift left N Re-Volt track units
'Nr' for a shift right N Re-Volt track units
Rise The number of Re-Volt elevation steps the instance rises from one end to the other. One elevation step is one-eighth the size of a Re-Volt track unit.

So an instance with the filename of '3tl4.prm' is a left-handed turn of radius 3 units (the same size as the 3x3 round turn Lego track piece) that rises 4 elevation steps as it turns left. An instance with the filename of '4s1e8.prm' is a diagonal shift track 4 units long that shifts the track right 2 units while rising 8 elevation steps.

The naming convention given here is solely for the purpose of giving short names to 36 different modified instance pieces; Re-Volt only displays the first 8 characters of the instance name in the MAKEITGOOD editor, so short names, even if a little cryptic at first glance, allow the instances to be distinguished.

With the variety of pregenerated track sections that I have supplied, you should be able to add a significant amount of variety to your tracks, and the prmbend utility itself will allow you to produce even more as needed.

prmbend, this document, and the modified instances are copyright © 2002 by Sean R. Malloy. All rights reserved. Permission is given to use and distribute the prmbend utility as long as no fee is charged for its distribution; the modified instances may be used and distributed in Re-Volt tracks as long as no fee is charged for any track containing the modified instances.