Skip to content

Car Rigs

mzzvxm edited this page Dec 5, 2026 · 2 revisions

Car Rigs

A car mod can give its car moving parts, light effects (exhaust flames, glows, light strips) and leave out some of the game's own effects, with data files only. No code, no DLL, no patched executable: the mod keeps working when LARecomp is updated.

Source: src/mc_engine/modloader/features/mod_rig.cpp (the file, bones, [effects]), mod_rig_rules.h (expressions, smoothing, posing), mod_rig_visuals.h ([[value]], [[mesh]], [[sprite]]), src/gpu/vehicle_fx.h and vehicle_fx_pass.cpp (drawing).

Contents

Where the file goes

<mod folder>/<mod>/
  rigs/
    <vehicle name>.toml     one file per car
  fx/                       any folder name: the meshes and textures the rig names
    flame.obj
    flame.png

<vehicle name> is the car's name in the game's vehicle list, for example vp_nsn_skyline_99, or the name of the car your mod adds (see Car Mods). The case of the name does not matter.

One mod may hold rigs for several cars. When two mods ship a rig for the same car, only one file is used: mods are taken in the order of their folder paths and the later one replaces the earlier one. The two files are not merged.

Rigs are read once per launch. After editing a rig, or a mesh or texture it names, restart the game.

Quick start

A car whose bone spoiler_flap lifts while you brake. Save as <mod folder>/my_mod/rigs/<vehicle name>.toml:

version = 1
log = true

[[bone]]
name  = "spoiler_flap"       # a bone of your car's body skeleton
op    = "hinge"
axis  = "x"
angle = -35.0                # degrees, reached when value is 1
value = "max(brake, handbrake)"
rate  = [3.2, 2.5]           # opens in about 0.3 s, closes in 0.4 s

Start the game, get in the car and look in the log for:

[mods] my_mod: rig for <vehicle name>, 1 entries
[mods] my_mod: rig bound to <vehicle name> (N bones), 1 of 1 entries

The file

A rig is a TOML file.

Key or table Required Meaning
version = 1 yes Format version.
log no, default false true writes extra lines to the log. See Writing and debugging a rig.
[[value]] no Numbers you name and compute, for the rest of the file to use.
[[bone]] no Moves a bone of the car's body.
[[mesh]] no A textured mesh drawn as light.
[[sprite]] no A flat glow that always faces the camera.
[effects] no Game effects the car goes without.

A file needs at least one [[bone]], one [[mesh]] or [[sprite]], or one effect set to false.

A file with a mistake is reported in the log and left out whole: no part of it takes effect. An unknown key inside [[value]], [[bone]], [[mesh]], [[sprite]] or [effects] is a mistake, so a typo does not go unnoticed.

Coordinates

The car's own space, in metres:

Axis Positive direction
x right
y up
z back (the nose of the car points to negative z)

Rotations follow the right-hand rule:

Turning about A positive angle moves
x up towards the back, the back downwards
y the back towards the right, the right towards the front
z the right upwards, up towards the left

So a flap hinged at its front edge, behind the pivot, lifts with a negative angle about x.

Expressions

Wherever a field takes an expression you may write a plain number, or text:

angle     = -35.0                                  # a fixed number
value     = "max(brake, handbrake)"                # an expression
intensity = "step(0.5, throttle) * (1 + nos)"

Inputs

Name Range Meaning
throttle 0 to 1 Accelerator.
brake 0 to 1 Brake.
handbrake 0 to 1 Handbrake.
steer -1 to 1 Steering, as the car's physics holds it.
steer_left 0 to 1 The negative half of steer.
steer_right 0 to 1 The positive half of steer.
speed 0 and up Metres per second, never negative.
speed_mph 0 and up Miles per hour.
nos 0 or 1 1 while nitrous burns.
since_nos seconds Time since nitrous last started burning. Very large (1000000) before the first time.
time seconds The game's clock.
random 0 to 1 A new number every update, the same for every field of the car in that update.

A car with no physics, such as a preview, reads 0 for the driving inputs.

Operators and functions

+, -, *, /, a leading -, and parentheses.

Function Result
abs(a) Absolute value.
min(a, b), max(a, b) Smaller, larger.
clamp(x, lo, hi) x held between lo and hi.
mix(a, b, t) a + (b - a) * t.
step(edge, x) 1 where x >= edge, else 0.

There is no if: use step and mix. For example:

You want Write
on above 100 mph step(100, speed_mph)
on only while coasting 1 - step(0.05, throttle)
1 at rest, 0.5 on throttle, 0.2 on nitrous mix(mix(1, 0.5, step(0.06, throttle)), 0.2, nos)
the first 1.5 s of a nitrous burn nos * (1 - step(1.5, since_nos))
a flicker of ±10 % 0.9 + 0.2 * random
a repeating scroll time * 5.5

An expression never produces an invalid number: a division by zero or an overflow reads 0.

Named values: [[value]]

Compute something once and use it in many places. A value also keeps its own smoothing.

[[value]]
name   = "power"
value  = "max(throttle, nos)"
smooth = 5.0

[[value]]
name  = "light"
value = "power * (1 + 0.6 * nos)"     # may read the values above it
Key Required Meaning
name yes Letters, digits and _, not starting with a digit. Not the name of an input or of another value.
value yes Number or expression. May read inputs and the values declared before it.
rate no [towards, back], see below.
smooth no See below.
curve no See below.

[[bone]], [[mesh]] and [[sprite]] may read every value of the file.

Smoothing and curves

[[value]] and [[bone]] entries share these. The order is: the expression gives a target, the number moves towards it (rate or smooth), then the curve reads it.

Key Form Behaviour
none The number is the target at once.
rate [3.2, 2.5] Moves at a fixed speed in units per second: the first number while the size of the target is larger than the current one, the second on the way back. 0 means no limit.
smooth 8.0 Eases towards the target, faster the larger the number (it covers about 63 % of the way in 1 / smooth seconds). When set, rate is not used.
curve [[0, 0], [0.5, 20], [1, 90]] Straight lines between [in, out] points, 2 to 16 of them, in rising. Flat past both ends.

Smoothing follows the game's clock, so it looks the same at any frame rate. When a car appears, values start at their targets.

Use a curve when a part does not travel evenly with its input, for example a nozzle that closes quickly down to half and slowly below it.

Moving parts: [[bone]]

Each entry drives one bone of the car's body skeleton. Whatever geometry follows that bone moves with it. How a mod's model gets its bones is described in Car Mods.

Key Required Meaning
name yes The bone's name. Case does not matter.
op yes hinge, spin or scale.
axis for hinge and spin "x", "y", "z" or a direction [x, y, z], in the bone's space.
angle for hinge Degrees turned when the value is 1.
value yes Number or expression.
rate, smooth, curve no See Smoothing and curves.
pivot no, default [0, 0, 0] The point the bone turns or grows about, in the bone's space.
rest no Puts the bone at this point of the car's space, unturned, before the movement.

Operations

op The value is Result
hinge a position Turned by angle × value degrees.
spin a speed, radians per second Keeps turning. angle is not used. A negative value turns the other way.
scale a size factor Grows or shrinks about pivot (held between 0.01 and 100). axis is not used.

pivot and rest

pivot stays in place while the rest turns around it. It is measured from the bone, along the bone's axes.

rest is for a bone whose live pose the game drives for its own use, such as a gauge needle or a door, when your mod borrows it for something else. The bone is placed at that point of the car, aligned with the car's axes, and your movement starts from there. A bone you made for the purpose does not need it.

When the game draws one of its digital dashboard readouts (gear, trip, odometer, speed, clock) on a bone your rig moves, that readout is removed from the car so that it does not ride around on your part.

Several entries on one bone

They combine, in file order. Write the outer movement first and the inner one second: for a petal of a steering nozzle, first the yaw of the whole nozzle, then the petal's own hinge.

[[bone]]                      # 1. the whole nozzle swings with the steering
name  = "petal01"
op    = "hinge"
axis  = "y"
angle = 10.0
value = "steer"
smooth = 8.0
pivot = [-0.30, 0.00, 0.00]
rest  = [0.01, 0.53, 1.65]

[[bone]]                      # 2. inside that, the petal closes about its own hinge
name  = "petal01"
op    = "hinge"
axis  = [0.76, 0.64, 0.0]
angle = 20.0
value = "max(throttle, nos)"
pivot = [-0.68, 0.11, 0.00]

Put rest only on the first entry of a bone: an entry with rest starts the bone over and discards the entries before it.

Light effects: [[mesh]] and [[sprite]]

Light fixed to the car. It is added to the picture (it can only brighten), it is drawn in HDR, so bright colours feed the game's bloom, and it is hidden behind whatever is in front of it. It follows the car's body with no lag. Effects need no bones.

Texture colour is multiplied by the texture's alpha and by colour × intensity. A black texel adds nothing.

Keys shared by meshes and sprites

Key Required Meaning
texture yes PNG or DDS file, path inside the mod's folder.
colour no, default [1, 1, 1] [r, g, b]. Numbers, not expressions. Values above 1 are brighter than white and bloom.
intensity no, default 1 Expression. At 0 or below the part is not drawn. Held to at most 1000.
pivot no [x, y, z], the point scale and turn_angle work about. Numbers.
scale no, default [1, 1, 1] Three expressions. Held between -100 and 100.
offset no, default [0, 0, 0] Three expressions, metres.
turn_axis no, default "y" "x", "y", "z" or [x, y, z].
turn_angle no Expression, degrees.

A point p of the part ends up at:

pivot + turn( (p - pivot) * scale + offset )

That is: first the scale, then the offset, then the turn, all around pivot.

[[mesh]]

Key Required Meaning
file yes Wavefront .obj, path inside the mod's folder.
uv_offset no, default [0, 0] Two expressions added to the texture coordinates: scrolls the texture. Only the fraction counts.
both_sides no, default false false: a face shows only from its front. true: from both.
[[mesh]]
file       = "fx/flame.obj"
texture    = "fx/flame.png"
colour     = [2.6, 1.4, 6.5]
intensity  = "power"
pivot      = [0.30, 0.52, 1.65]
scale      = ["1 - 0.5 * power", "1 - 0.5 * power", 1]   # narrows with power
uv_offset  = [0, "time * 5.5"]                           # the flame streams

About the mesh file:

  • Positions are in the car's space and in metres: model the effect where it belongs on the car. From Blender, the default .obj export (Forward -Z, Up Y) gives these axes when the nose of the car points along Blender's +Y.
  • Texture coordinates (vt) are needed, and follow the usual .obj convention (bottom-up), as Blender writes them.
  • Normals and materials are not used. One mesh entry has one texture.
  • A face's front is the side from which its corners run counter-clockwise (Blender's outward normals). If a mesh is invisible, its faces probably point inwards: flip them, or set both_sides = true.
  • With both_sides = true a closed shape such as a tube shows its near and far walls on top of each other, about twice as bright.
  • The texture repeats.

The same file may be used by several entries. Two entries of one mesh scrolling in opposite directions ("time * 5.5" and "-time * 5.5") give a livelier flame.

[[sprite]]

A rectangle that always faces the camera. The texture does not repeat: its edges should fade to black.

Key Required Meaning
position yes [x, y, z] in the car's space. Moved by scale, offset and turn_angle like any point.
size yes [width, height] in metres.
size_scale no, default 1 Expression multiplying the size. At 0 or below the sprite is not drawn. Held to at most 100.
count no, default 1 1 to 64 copies in a row.
step no [x, y, z] from one copy to the next.
size_end no, default size [width, height] the size moves towards along the row.
intensity_end no, default 1 Share of the intensity left at the end of the row. 0 fades the row out.

Copy i of count (counting from 0) takes i / count of the way from size to size_end and from full intensity to intensity_end.

scale and turn_angle move the sprite's centre. They do not stretch or tilt the picture: use size and size_scale for that.

# a glow at the mouth of an exhaust
[[sprite]]
texture   = "fx/glow.png"
colour    = [11.0, 9.7, 11.0]
intensity = "power"
position  = [0.30, 0.52, 2.10]
size      = [0.60, 0.60]

# a wide, thin glare through the same point
[[sprite]]
texture   = "fx/glow.png"
colour    = [0.7, 0.5, 1.4]
intensity = "power"
position  = [0.30, 0.52, 2.10]
size      = [2.00, 0.18]

# a trail of fading glows behind it
[[sprite]]
texture       = "fx/glow.png"
colour        = [1.5, 0.8, 3.8]
intensity     = "power"
position      = [0.30, 0.52, 2.20]
size          = [0.90, 0.90]
count         = 16
step          = [0, 0, 0.09]
size_end      = [0.60, 0.60]
intensity_end = 0.0

Textures

  • PNG, or DDS (DXT1, DXT3, DXT5, or uncompressed 24/32-bit). At most 2048 x 2048.
  • Only the largest level is used. Soft textures of 64 to 256 pixels work well and cost little.
  • File paths are relative to the mod's folder (the one holding rigs/). Absolute paths and .. are refused.

Where effects are drawn

Effects are drawn by the Plume renderer, for the player's own car, in the driving view. They are not drawn on opponents or traffic, in mirrors or reflections, in menus or in photo mode. They do not light the road or other objects.

Leaving out the game's effects: [effects]

Everything is true (kept) unless you say false.

[effects]
tire_smoke      = false
tire_marks      = false
tire_sound      = false
nitro_particles = false
Key Set to false, the car goes without
tire_smoke Smoke and dust off the wheels.
tire_marks Rubber left on the road.
tire_sound Rolling and skidding noise of the tyres.
nitro_particles The game's own nitrous flames.

For a hover car, set the first three to false.

When the file also has [[mesh]] or [[sprite]], nitro_particles = false is taken as "my effects replace the flames": the flames go only on the player's car, and only while the renderer is actually drawing the effects. Everywhere else the game's flames stay.

Which cars a rig acts on

Part of the rig Acts on
[[bone]] Every car of that name.
tire_smoke, tire_marks, tire_sound Every car of that name.
nitro_particles Every car of that name; in a file with light effects, only the player's (see above).
[[mesh]], [[sprite]] The player's car.

A rig changes what is shown and heard. It does not change how a car drives.

Writing and debugging a rig

  1. Set log = true. Once a second the log then shows your car's inputs:

    [mods] rig <car>: throttle 1.00 brake 0.00 handbrake 0.00 steer -0.12 speed 31.4 nos 0
    
  2. Check the rig bound line: "5 of 6 entries" means one bone name was not found, and a warning names it.

  3. To find where a pivot or an effect should go, start with something large and obvious (a big angle, a bright colour, intensity = 1), place it, then tune.

  4. Each change needs a restart of the game.

  5. Set log = false before you publish the mod.

Symptom Likely cause
Nothing happens at all File name is not the vehicle's name; the file is not in <mod>/rigs/; the file was left out (look for the error in the log).
A part is drawn far from the car or twisted A borrowed bone without rest, or a pivot given in car space instead of measured from the bone.
Only one of two movements of a bone happens rest on the second entry.
A part turns the wrong way Flip the sign of angle (or of the value of a spin).
An effect never shows intensity evaluates to 0; the mesh faces point inwards; the effect is inside the car's body; you are looking at a view that does not show effects.
An effect is a solid square The texture has no black or transparent edges.
The effect is in front of the car instead of behind The sign of z: back is positive.

Log messages

Message Meaning
[mods] <mod>: rig for <car>, N entries[, without ...][, M meshes and S sprites] The file was read. N counts [[bone]] entries.
[mods] <mod>/rigs/<file>: <reason>; the file is left out The file has a mistake.
[mods] <mod>: rig bound to <car> (B bones), F of N entries The car appeared and F entries found their bone.
[mods] <mod>: rig of <car>: no bone "<name>" The car's body has no bone of that name.
[car effects] <mod>/<car>: first drawn: ... The renderer drew the light effects.
[car effects] not drawn: <reason> Why nothing was drawn, written when the reason changes. A short "its pipeline is not made yet" at the start is normal.
[mods] <mod>: <effect> left out of <car> With log = true: an [effects] key took hold.
[mods] <mod>: readout <n> taken off a moving bone With log = true: a dashboard readout was removed.

Limits

What Limit
Rig file 256 KiB
[[bone]] entries 512
[[value]], [[mesh]], [[sprite]] 64 of each
Textures per rig 16 different files, 2048 x 2048 each
Mesh file 8192 vertices and 8192 triangles
Any file a rig names 24 MiB
Sprite count 64
curve points 2 to 16
Expression 24 levels of nesting

Complete example

A car with air brakes, a turbine rotor, and a flame with a glow at one exhaust that grows with the throttle and flares on nitrous. Bone names, positions and files are placeholders: use your own.

my_mod/
  rigs/my_car.toml
  fx/flame.obj        a tube open at both ends, starting at the exhaust and running back
  fx/flame.png        soft streaks, black where nothing should show
  fx/glow.png         a round soft spot fading to black
version = 1
log = false

# ── shared numbers ──────────────────────────────────────────────

[[value]]
name   = "power"
value  = "max(throttle, nos)"
smooth = 5.0

[[value]]
name  = "light"
value = "power * (1 + 0.6 * nos)"

[[value]]
name  = "burst"                              # 1 for the first 1.5 s of a burn
value = "nos * (1 - step(1.5, since_nos))"

[[value]]
name   = "yaw"
value  = "10 * steer"                        # degrees
smooth = 8.0

# ── moving parts ────────────────────────────────────────────────

[[bone]]
name  = "airbrake_l"
op    = "hinge"
axis  = "x"
angle = -35.0
value = "max(brake, handbrake)"
rate  = [3.2, 2.5]

[[bone]]
name  = "airbrake_r"
op    = "hinge"
axis  = "x"
angle = -35.0
value = "max(brake, handbrake)"
rate  = [3.2, 2.5]

[[bone]]
name   = "rotor"
op     = "spin"
axis   = "z"
value  = "5.5 + 24 * throttle"
smooth = 8.0

# ── light ───────────────────────────────────────────────────────

[[mesh]]
file       = "fx/flame.obj"
texture    = "fx/flame.png"
colour     = [2.6, 1.4, 6.5]
intensity  = "light * (0.9 + 0.2 * random)"
pivot      = [0.30, 0.52, 1.65]
scale      = ["1 - 0.4 * power", "1 - 0.4 * power", "1 + 0.5 * burst"]
uv_offset  = [0, "time * 5.5"]
turn_angle = "yaw"

[[sprite]]
texture    = "fx/glow.png"
colour     = [8.0, 7.0, 8.0]
intensity  = "light"
position   = [0.30, 0.52, 2.10]
size       = [0.45, 0.45]
size_scale = "1 + 0.4 * burst"
pivot      = [0.30, 0.52, 1.65]
turn_angle = "yaw"

# ── the game's flames make way ──────────────────────────────────

[effects]
nitro_particles = false

Related

  • Car Mods: adding and replacing cars, bones.
  • Mod Loader: mod folder rules and load order.

Clone this wiki locally