Skip to content

Instantly share code, notes, and snippets.

@SalatielSauer
Created June 4, 2023 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SalatielSauer/99f99cab8bd7f585f3d7e9a18f8f1c06 to your computer and use it in GitHub Desktop.
Save SalatielSauer/99f99cab8bd7f585f3d7e9a18f8f1c06 to your computer and use it in GitHub Desktop.
Incomplete data structure of Cube 2 Sauerbraten OBR (prefabs) files.

OBR File Format Incomplete Structure

OBR is a file format that holds presets of Sauerbraten map geometries.

This is an incomplete overview and may contain misinterpretations, feel free to correct or add more information. :)

Example of an uncompressed .obr file:

4f45 4252 0000 0000 f001 0000 1002 0000 0002 0000 // header
0100 0000 0100 0000 0100 0000 1000 0000 0000 0000 // selection setup
0000 8083 8043 5050 8080 8080 8080 0100 0100 0200 0300 0400 0500 // first "cube"

OBR Header (20 bytes)

4f45 4252 // magic (OEBR)
0000 0000 // ?
5001 0000 // ?
f001 0000 // ?
2002 0000 // ?

Selection Setup (20 bytes)

0400 0000 // +x
0800 0000 // +y
0300 0000 // +z
1000 0000 // ?
0000 0000 // direction

Direction options are as follows:

  • 0 = front-bottom-left
  • 1 = back-bottom-right
  • 2 = left-bottom-right
  • 3 = right-bottom-left
  • 4 = down-top-left
  • 5 = up-bottom-left

Note: x, y, z are not the coordinates of the cube, but the size of the selection. The "direction" is the origin of the cube within the selection. The initial coordinate is based on the existing selection when the player pastes the prefab.

Single Manipulated Cube (1/4 of a Circle) (26 bytes)

0000 8083 8083 5050 8080 8080 8080 0100 0100 0200 0300 0400 0500 

Each of the 52-digit pairs after the selection setup is a cube:

  • The first column is something related to the materials.
  • Columns 2 to 7 represent the faces (4 vertices per face) and their push level.
  • The rest of the columns are the indices of registered textures for each face.

The default value of each even vertex is 0, which means that the vertex has not been manipulated. For odd vertices, this applies to the value 8.

Geometry Data Structure

Note: ingame the "front" face is identified by the outline of a small red cube at the front-bottom-left vertex.

Vertices of a Default Unmanipulated Cube and Their Names (in exact order)

  • back-bottom-right(8) front-bottom-left(0) back-bottom-left(8) front-bottom-right(0)
  • back-top-right(8) front-top-left(0) back-top-left(8) front-top-right(0)
  • right-bottom-left(8) left-bottom-right(0) right-top-left(8) left-top-right(0)
  • right-bottom-right(8) left-bottom-left(0) right-top-right(8) left-top-left(0)
  • up-bottom-left(8) down-top-left(0) up-top-left(8) down-bottom-left(0)
  • up-bottom-right(8) down-top-right(0) up-top-right(8) down-bottom-right(0)

Tip: you can use gzip to compress and decompress obr/ogz/dmo files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment