This utility extracts editable displacement and texture images from compiled
Motocross Madness 1 National and TrackEdit/SX .trn terrain files. It also
calculates a compatible Tga2Asc MAXHEIGHT for the selected output gray range.
Quick start
- Drop one National or SX
.trnfile onto the extractor. - Optionally drop its same-name
.scnat the same time. - Review the center and perimeter previews.
- Leave Darkest Gray at
0and Max Gray at255for a full-range starting point. - Use the displayed Calculated Tga2Asc MAXHEIGHT when converting the extracted displacement TGA to ASC.
- Download individual files or use Download All (.zip).
Every newly loaded TRN resets the gray range to 0–255.
Adjustments apply only to the currently loaded track.
Controls
| Control | Purpose |
|---|---|
| Displacement base elevation | Reconstruction offset used when converting compiled elevations to grayscale. It is automatically calculated when a track loads or the gray endpoints change. Manually changing it shifts the grayscale and can move values outside the selected endpoint targets. |
| Darkest editable gray | Gray assigned to the lowest elevation in the shared extraction range. Defaults to 0. |
| Max gray | Gray assigned to the highest elevation in the shared extraction range. Defaults to 255. |
| Calculated Tga2Asc MAXHEIGHT | Read-only value calculated from the compiled TRN elevation span and selected gray endpoints. |
Output files
| File | Contents |
|---|---|
-displacement.tga | 257×257 center displacement, 24-bit grayscale RGB. |
-texture.tga | Reconstructed center terrain texture, 24-bit RGB: 1024×1024 for National or 2016×2016 for SX. |
-perimeter-displacement.tga | 129×129 representative repeated perimeter displacement, when identified. |
-perimeter-tile.tga | Palette-decoded perimeter texture tile, when present. |
-extraction-info.txt | Source details, calculated values, orientation, wrapping, and rebuild notes. |
-extracted.zip | All available outputs in one stored ZIP archive. |
Displacement TGAs use identical blue, green, and red channel values:
B = G = R. They are written with TGA descriptor
0x00, using classic bottom-left row storage.
National and SX textures
The extractor identifies the terrain variant from the TRN terrain-kind field. National and TrackEdit/SX files use the same indexed texture format, but store and arrange their center textures differently.
| Variant | Stored layout | Extracted texture |
|---|---|---|
| National | Sixteen 256×256 indexed tiles arranged as a fixed 4×4 grid. | 1024×1024 |
| TrackEdit/SX | 128×128 indexed tiles referenced by the terrain quadtree, including a one-pixel border and per-leaf transformations. | 2016×2016 |
For SX, the extractor removes each stored tile’s one-pixel border, applies its quadtree transformation, and assembles the resulting 126×126 interiors into a 16×16 terrain texture. The extraction-info file records the detected terrain variant and final texture dimensions.
TRN elevation values
Supported TRN heights are stored as 16-bit fixed-point values with eight fractional bits. The extractor presents the useful elevation value rather than the encoded integer.
Stored elevation:
elevation_units = raw_height / 256
Examples:
| Encoded value | Elevation value |
|---|---|
3840 (0x0F00) | 15.0 |
8760 | 34.21875 |
The common compiled edge elevation 15.0 is an elevation value,
not gray 15 and not raw integer 15.
GridResolutionInFeet and physical scale
The TRN contains the scale used by MakeTerr. The stored floating-point field
is multiplied by 256 to recover GridResolutionInFeet.
GridResolutionInFeet = trn_scale_field × 256
| TRN field | Grid resolution | 257-point center width |
|---|---|---|
0.01171875 | 3.0 ft | 256 × 3 = 768 ft |
0.015625 | 4.0 ft | 1024 ft |
0.01953125 | 5.0 ft | 1280 ft |
In this authoring workflow, Tga2Asc elevation values are terrain elevation
units. MakeTerr applies the terrain grid scale. A Tga2Asc value of
25 on a 3.0 terrain represents
25 × 3 = 75 ft at white.
Gray-range normalization
A compiled TRN no longer contains the original editable TGA gray endpoints. The extractor therefore creates a new linear mapping.
- The lowest shared extracted elevation maps to Darkest Gray.
- The highest shared extracted elevation maps to Max Gray.
- All values between them are mapped linearly.
- Center and non-flat perimeter values normally share the same mapping.
Using 0–255 uses all available grayscale levels. A narrower
range leaves editing headroom but requires a larger Tga2Asc MAXHEIGHT.
Calculated Tga2Asc MAXHEIGHT
Compiled elevation span:
span = (raw_max − raw_min) / 256
MAXHEIGHT for selected gray endpoints:
MAXHEIGHT = span × 255 / (max_gray − darkest_gray)
With a full 0–255 range, MAXHEIGHT equals the compiled
elevation span. If the output uses only part of the grayscale range,
MAXHEIGHT increases so the selected endpoints still represent the same
elevation difference.
Base and VerticalMultiplier
In a MakeTerr .ter source file, Base identifies
the flat edge elevation of the referenced ASC terrain. MakeTerr uses it to
align that terrain with the surrounding compiled terrain.
VerticalMultiplier controls the strength of a terrain chunk.
A National center chunk normally uses 1.0. Surrounding copies
may use smaller or negative values.
These source parameters are baked into the compiled TRN geometry and are
not recoverable as their original text values. The extractor’s Base field
is a calculated reconstruction offset, not necessarily the original
.ter Base.
Extractor reconstruction mapping:
elevation = reconstruction_base + ((raw_height − 3840) / 256) gray = round(elevation × 255 / MAXHEIGHT)
Perimeter displacement
National terrain, and any compatible SX terrain containing the same repeated structure, may contain a representative 129×129 perimeter displacement that is reused around the center terrain. The extractor identifies the repeated source and exports one representative tile.
- A non-flat perimeter uses the shared center/perimeter elevation mapping.
- A completely flat perimeter is filled with the dominant gray along the extracted center terrain edge.
- This makes a flat perimeter visually match the center edge at any selected gray range.
For example, a flat perimeter is gray 0 when the center edge
is gray 0, and gray 56 when the center edge is
gray 56.
Orientation and patch-edge wrapping
TRN patch order does not match the way the displacement appears in an image editor. The extractor applies the verified vertical flip to both center and non-flat perimeter displacement maps.
The extractor also derives cyclic X/Y patch wrapping from the TRN quadtree center block. The extraction-info file records the fixed orientation and calculated wrap values.
Worked examples
FireRoad
| Grid resolution | 3.0 |
|---|---|
| Compiled elevation minimum | 15.0 |
| Compiled elevation maximum | 34.21875 |
| Compiled elevation span | 19.21875 |
| Calculated MAXHEIGHT at 0–255 | 19.2188 |
| Calculated MAXHEIGHT at 56–254 | 24.7514 |
FireRoad’s surviving 257×257 source TGA uses gray 56–254.
That known range explains why an equivalent reconstructed MAXHEIGHT is
close to 25. The TRN alone would reveal the
19.21875 span but not the original starting gray.
JoyOfSX
| Grid resolution | 3.0 |
|---|---|
| Compiled center minimum | 15.0 |
| Compiled center maximum | 22.4453125 |
| Compiled center span | 7.4453125 |
| Calculated MAXHEIGHT at 0–255 | 7.4453 |
| Flat perimeter elevation | 16.34375 |
| Flat perimeter output at 0–255 | Gray 0, matching the center edge. |
Suggested rebuild workflow
- Load the TRN and leave the gray range at
0–255initially. - Download the center displacement TGA.
- Convert it with Tga2Asc using scale
1.0and the displayed calculated MAXHEIGHT. - Use the TRN-derived
GridResolutionInFeetin the new.ter. - Use the extractor’s reconstruction Base as the starting Base for the extracted center ASC.
- Edit the displacement only after confirming the unedited round trip builds correctly.
- Keep the center and perimeter boundaries compatible before compiling with MakeTerr.
If you change the gray endpoints, reconvert with the newly calculated MAXHEIGHT. Do not continue using the value calculated for an earlier range.
What cannot be recovered reliably
- The original Tga2Asc MAXHEIGHT without the original TGA gray range or equivalent source evidence.
- The original center
.ter Base. - Original
VerticalMultipliervalues. - The deleted intermediate ASC file.
- Unused grayscale headroom below the original minimum or above the original maximum.
- Authoring intent, such as whether a POV-Ray vertical scale was used only for lighting or shadows.
The TRN does preserve compiled elevations, terrain scale, textures, and geometry sufficiently to produce an equivalent editable extraction.
Troubleshooting
The displacement looks upside down
The extractor applies the verified vertical flip automatically. The extraction-info file records the output orientation and calculated patch wrapping.
The extracted image is too dark
Raise Darkest Gray. The extractor will recalculate Base and MAXHEIGHT to preserve the elevation span.
The extracted image clips at white
Confirm Max Gray is greater than Darkest Gray and use the displayed calculated MAXHEIGHT when running Tga2Asc.
The perimeter is one solid color
The compiled perimeter may be genuinely flat. A flat perimeter is intentionally colored to match the center edge.
The reported histogram count is three times the pixel count
Some editors count the identical R, G, and B channels separately. A 24-bit grayscale TGA pixel has three equal channel samples. Divide such a channel count by three to get the number of pixels.
The matching SCN was not selected
The SCN is optional and is used only to display the track name. It does not change terrain extraction.
The extractor rejects a TRN
The file must be a supported MCM1 National or TrackEdit/SX TRN with a valid
TRN\0 signature, indexed texture format, and recognized terrain
kind. Stunt Quarry, Baja, damaged, or differently structured terrain may
require a different extractor.
Help guide for MCM1 TRN Extractor version 2.0.