openOMSI GitHub Discord
Content formats

Docs / Reference / Content formats

Models (.cfg and .o3d)

10 min readEdit this pagedocs/FORMATS.md

On this page
  1. model.cfg keywords
  2. Visibility and LOD
  3. Animations ([newanim])
  4. Materials
  5. Smoke particles
  6. Lights
  7. Script textures
  8. .o3d (binary mesh)
  9. DirectX .x meshes
  10. Other model formats (openOMSI)

A model.cfg lists a vehicle's or object's meshes and their materials, animations and lights. The meshes are .o3d files (or .x, glTF, FBX, OBJ) in the same folder.

[LOD]
0.02

[mesh]
body.o3d

[matl]
body.bmp
0

[matl_envmap]
envmap.bmp
0.5

[mesh]
door.o3d

[newanim]
origin_from_mesh
anim_rot
door_0
90

model.cfg keywords#

Group Keywords
Detail [LOD], [VFDmaxmin], [detail_factor], [tex_detail_factor], [noDistanceCheck]
Meshes [mesh], [mesh_ident], [viewpoint], [shadow], [isshadow], [mouseevent], [visible], [item], [setvar]
Skinning [setbone], [smoothskin], [animparent]
Animation [newanim] + origin_trans, origin_rot_x/y/z, origin_from_mesh, anim_rot, anim_trans, offset, delay, maxspeed
Materials [matl], [matl_change], [matl_item], [matl_alpha], [matl_noZwrite], [matl_noZcheck], [matl_Zbias], [matl_allcolor], [matl_freetex], [matl_lightmap], [matl_nightmap], [matl_bumpmap], [matl_envmap], [matl_envmap_mask], [matl_envmaprealtime], [matl_transmap], [matl_raindropmap], [matl_texadress_mirror/clamp/border/mirroronce], [texcoordtransX/Y], [alphascale], [texchanges]
Textures by script [CTC], [CTCTexture], [scripttexture], [useScriptTexture], [texttexture], [texttexture_enh], [useTextTexture]
Lights [illumination], [illumination_interior], [light], [light_enh], [light_enh_2], [spotlight], [interiorlight]
Particles [smoke], [particle_emitter], PS_attachTo
Ground [terrainhole]

openOMSI adds [visible_range] (and ! / || in [visible]), [spotlight_2], [spotlight_cookie], [matl_glow], [led_glow_effect], [htmltexture]/[useHtmlTexture], [navigatortexture]/[useNavigatorTexture] and more than four lamps in [illumination_interior]. See Modding overview, HTML textures and Navigator textures.

Visibility and LOD#

OMSI decides per object (scenery object, vehicle), never per mesh. It uses the model's radius R, [detail_factor] D (default 1) and [noDistanceCheck]. With d the distance to the camera and z the depth along the view:

  • The object is dropped when d > R + maxObjDist or (z − R) / maxObjDist > 1. Both checks are skipped with [noDistanceCheck].
  • It is also dropped when size / D < minObjSize, where size = 2R / (d · fov · π/180): the object's diameter over its distance as a share of the vertical field of view.
  • The values come from options.cfg: [performance_maxObjDist] (750 in the shipped file), [performance_minObjSize] (0.013) and [performance_minObjSizeRefl] (0.046) for reflections.
  • A detail factor above 1 makes an object vanish sooner (clutter); below 1 keeps it longer.

[LOD] x appends x to the model's list; the meshes after it belong to that level. With the same size (not divided by D), OMSI takes the first level in file order whose x ≤ size, else the last level. A model with one [LOD] is drawn at any size. A mesh written before the first [LOD] joins the first level.

Lights count whatever level their mesh belongs to: 40 stock models declare theirs after the far [LOD] 0 mesh.

Animations ([newanim])#

[newanim]
origin_rot_y
-90
anim_rot
door_0
90
  • anim_rot turns about the x axis of the origin frame; anim_trans slides along it. Doors turn that axis up with origin_rot_y -90, wheels spin about it directly.
  • origin_from_mesh takes the pivot matrix stored in the .o3d: its first row is the axis, its fourth row the origin.
  • Several blocks on one mesh compose in file order: the first transforms the mesh first, and later ones act on the result. The SD200's door leaves are the test case (−170° about the fold, then +80.5° about the post).
  • OMSI evaluates rotations in its left-handed Direct3D frame. In a right-handed frame (x right, y forward, z up) every angle changes sign.

Materials#

[matl] texture index starts a material slot. Commands after it change that slot.

[matl_change] texture index variable + one [matl_item] makes a variant switched by a variable:

  • The variable is rounded to the nearest whole number. Item n shows for 1 ≤ n ≤ the number of items, the plain material otherwise. A variable no script declares is registered at 0.
  • Commands between [matl_change] and its first [matl_item] change the plain material.
  • Each [matl_item] starts as a copy of the plain material at that point and may replace its alpha mode, transmap, light map and so on.
  • [matl_transmap] + [matl_alpha] 2 items are washer water or condensation that exist only while the variable is on.
  • [matl_allcolor] items (diffuse rgba, ambient rgb, specular rgb, emissive rgb, power) tint the variant and add texture × emissive self-illumination.

[matl_nightmap] is a self-illumination texture.

  • In a [matl_item] it glows at full strength while the variable is on, by day as well (warning lamps, dashboard screens).
  • On a vehicle's plain [matl] it fades in with the night, as a scenery object's does. A dashboard lamp whose mesh is switched by [visible], or a slot fed by the script's text or texture, glows whenever it is drawn, by day as well (#497); a static instrument panel stays dark by day (#3195).
  • On a scenery object it fades in with the night. Street lights use NightlightA, bus panels elec_busbar_main.

[matl_lightmap] is a light mask multiplied with the diffuse texture, scaled by its variable (the SD202's D86_02_L1.bmp masks the lit atlas regions).

[matl_envmap] tex factor: reflectivity = diffuse alpha × factor, the factor saturating at

  1. SD202 bodies write 10 with paint alpha 0.12-0.19 (a gloss); windows have alpha 0.5 and factor 1. A texture without alpha (a DXT1 livery) does not reflect. The sphere map has the sky at the bottom and is read as Direct3D's sphere mapping does.

[matl_transmap] uses its texture's alpha as the slot's alpha. A picture without an alpha channel is opaque. [matl_transmap] \S:n uses script texture n.

[matl_freetex] <texture> <string variable> uses a file name the script builds at run time. The SD200's roller sets Rollband_Tex_V from the depot and terminus strings, so Linienlisten\<yard>_RLB.jpg resolves.

[texcoordtransX/Y] <variable> scrolls one material slot's texture, not the whole mesh.

openOMSI extensions (OMSI skips them as unknown lines):

  • [matl_glow] <texture> <value> makes the slot its own light. The texture is a greyscale mask (white full, black none); the light is the material's own colour. value is a brightness on the scale of the Led glow setting (6 matches its default). Enhanced draws it in HDR; Vanilla and Vanilla+ add it as a light map, full from 6 up.

    It uses the light map's slot, so a slot with a [matl_lightmap] keeps that and has no glow. The last [matl_glow] of a slot counts.

  • [led_glow_effect] <value> (0..1) is how much of the Led glow setting the slot's dots burn with. 0 means the slot is no LED panel. Without it, Enhanced guesses: a \S:n script mask under an all-white light map is taken for an LED panel.
  • [matl_basecolor] (three lines, sRGB 0..1), [matl_metallic], [matl_roughness], [matl_normal_strength] and [matl_occlusion_strength] (one line each) are PBR factors: the value itself without a map, the map's value scaled with one. Only Enhanced draws them, except the base colour, which every mode takes. See PBR materials.
  • [matl_emissive] (r, g, b, strength, optional variable), [matl_emissive_nits], [matl_emissive_kelvin] (temperature, optional variable or filament), [matl_emissive_texture] and [matl_emissive_fade] (seconds up, optional seconds down) make the slot its own light in HDR, which the scripts can switch, dim and tint.

    Enhanced draws it in HDR; Vanilla and Vanilla+ add it as a light map, held at white. See Emissive materials.

Smoke particles#

[smoke] has nineteen lines, numbers or variable names:

Lines Meaning
1-3 Position
4-6 Direction
7-8 Speed and its spread
9 Frequency (per second)
10 Lifetime (s)
11 Brake factor (per 1/20 s, at any frame rate)
12 Gravity (9.81 × gravity × dt off the vertical speed; negative lifts)
13-14 Start size, growth per second
15 Initial alpha (the final alpha is 0, so a puff fades out)
16 Skipped
17-19 Red, green, blue

A puff is a square facing the screen, turned by a random angle, blended with rauch.tga's alpha. OMSI lets puffs fall through the road, so the road cuts them off in a straight line.

Lights#

  • [light_enh]: position, rgb 0-255, size (m), fading variable (name or constant), brightness factor, z offset, effect bits, fade time, optional texture. It is read into the same lamp as a [light_enh_2] (omnidirectional, turned to the viewer).
  • [light_enh_2]: position, direction, up, omni, rotating, rgb, size, cone inner/outer, variable, factor, z offset, parameters, cone, time constant, bitmap.
  • [spotlight] (vehicle): position, direction, rgb, range, inner, outer. The active one is chosen by Spot_Select (negative = none).
  • [interiorlight] variable range r g b x y z.
  • [maplight] x y z r g b radius (scenery): a point light at night, full within radius, inverse-square beyond, out of range at six times it. The colour is the brightness: a petrol station's sign declares 0.1 red over 20 m.

openOMSI's [spotlight_2] and [spotlight_cookie] (a lamp whose beam is a picture) are in Modding overview. In Enhanced with shadows on, the lamps on the front of the player's vehicle that light the road share one shadow map, so what stands in their light throws a shadow ahead.

Script textures#

[scripttexture] w h declares an RGBA image per index. [useScriptTexture] n puts it on a material; [matl_transmap] \S:n uses its alpha.

Scripts draw with (M.V.ST...) callbacks, arguments pushed in order (index first):

Callback What it does
STNewTex(i), STLock(i), STUnlock(i) Start, lock, upload
STFilter(i) Filter the texture
STSetColor(i, a, r, g, b) Drawing colour
STDrawPixel(i, x, y), STDrawRect(i, x1, y1, x2, y2) Draw
STTextOut(i, x, y, font, mode, spacing, "text") Text (below)
STReadPixel(i, x, y) + STGetR/G/B/A(0) Read a pixel
STLoadTex("path", i) Load a picture; pushes nothing
STCopyColor(a, b) Copy
GetFontIndex("name") Register an .oft font; -1 if it does not exist
TextLength(font, "text") Drawn width (glyph advance plus the font gap)
NrSpecRandom(seed) Stable pseudo-random number in [0, 1)
  • STTextOut mode bit 0: colour from the font's colour bitmap, else the STSetColor colour; alpha from the font's mask. mode & 3 == 2 writes only covered pixels.
  • STLoadTex paths are relative to the object's Texture folder, then the global Texture.
  • Fonts are found by [newfont] name in every content root's Fonts. openOMSI draws a missing weight with another of the same family and size ("churafont++ Numeric 26x11 Bold" → "churafont++ Numeric 26x11").
  • A work texture keeps its picture in the colour channels with alpha 0; LED textures keep it in alpha only, one texture per LED colour.
  • In colour mode a glyph pixel takes the colour bitmap's pixel at the same row and column, often a small one-colour swatch. OMSI stops drawing text at a row past the colour bitmap's height; openOMSI repeats the colour bitmap instead.

.o3d (binary mesh)#

84 19            magic
ver              u8   (1, 3, 4, 5, 7 seen)
[flags]          u8   (ver >= 3)  bit 0: 32-bit triangle indices
[key]            u32  (ver >= 4)  usually 0
sections, tagged by one byte, until the end of the file:
  0x17 vertices  count (u16, or u32 if ver >= 3) × {x y z nx ny nz u v} f32
  0x49 triangles count (u16/u32) × {i0 i1 i2 (u16 or u32), material u16}
  0x26 materials count u16 × {diffuse rgba, specular rgb, emissive rgb, power} f32 × 11, name (u8 length + bytes)
  0x79 matrix    16 × f32 (row-major, row 3 = translation)
  0x54 bones     count u16 × {name (u8 length), weight count u16 × {vertex index (u16/u32), weight f32}}
  • Stock content always has the order 17 49 26 79 [54] (checked on all 4026 stock files).
  • Any other byte where a tag is expected is skipped, one byte at a time. Mods rely on it: the MB Sprinter 412D XLWB pack has junk bytes inside the matrix.
  • Axes: X right, Y up, Z forward (Direct3D). Vertices are in the parent frame. The 0x79 matrix is the mesh's pivot frame for origin_from_mesh, not applied when drawing. The engine swaps Y and Z to get its world frame (X east, Y north, Z up).

Scrambled vertices (version ≥ 4). The key (0xFFFFFFFF = none) selects the original loader's vertex scrambling, which openOMSI reproduces:

state = (key + version - 4 + (flags&2 ? 0x17D : 0)) mod 0xFDE8     (u16)
n     = vertex_count mod 0xFDE8;  b = 0
for each vertex (raw x y z nx ny nz u v):
    if key == 0: state = flags&2 ? 0x130 : 0
    state = (state*n + n*b) mod 8000
    b     = trunc(|frac(x)·frac(y)·frac(z)|·600) mod 256          (from the raw position)
    if state < 1000: swap(x,y) elif state < 3000: swap(x,z) elif state > 7000: swap(y,z)
    if state % 4 == 0: nx = -nx;  if state % 6 == 0: ny = -ny;  if state % 7 == 0: nz = -nz
    if state < 600: swap(ny,nz) elif state > 4500: swap(nx,ny) elif state > 6500: swap(nx,nz)
    if state % 5 == 0: u -= (state%100)² / 10000
    if state % 3 == 0: v -= (state%50)²  / 2500

Triangles, materials, matrix and bones are stored plainly. OMSI also refuses keys that are not in its registration list; openOMSI does not check that.

DirectX .x meshes#

Text .x files (xof 0303txt) are flattened as D3DXLoadMeshFromX does:

  • Every Frame's FrameTransformMatrix applies to the meshes inside it, parent after child. The 16 numbers are row-major for row vectors (translation in elements 12-14).
  • Normals are transformed by the inverse transpose (for unevenly scaled frames).
  • A data object may carry a name (FrameTransformMatrix relative {), as the 3ds Max exporter writes it.
  • DeclData inside a Mesh carries per-vertex data as a Direct3D 9 vertex declaration. Its first NORMAL and TEXCOORD replace MeshNormals / MeshTextureCoords; packed types widen to floats. Without it such meshes (the PAD-Labs houses, the Köln trees) come out in one colour.

Binary .x (xof 0303bin 0032, or 0064 for double floats) holds the same objects as little-endian tokens and loads like the text files. The compressed tzip/bzip variants are refused.

Other model formats (openOMSI)#

A [mesh] may also name a glTF 2.0 (.gltf with its .bin, or .glb), FBX (binary or ASCII) or Wavefront OBJ (with its .mtl) file.

These are right-handed with y up; openOMSI turns z round, so a model built in Blender with the front along +y comes in facing the way it faced in the modeller. glTF and FBX bring their colour textures (as files or packed), skins and morph targets; OBJ brings Kd, d/Tr and map_Kd.

Something wrong or missing? Fix it on GitHub or open an issue.

↑↓ to move↵ to open