Primitive Types - DustStormPettigrew/LibLR1 GitHub Wiki

Primitive Types

LibLR1 defines several composite types in LibLR1.Utils that are used across all formats.

LRVector3

3D coordinate. Three consecutive Float tokens.

Field Type Token
X float 0x03
Y float 0x03
Z float 0x03

LRVector2

2D coordinate (UV, position). Two consecutive Float tokens.

Field Type Token
X float 0x03
Y float 0x03

LRQuaternion

Rotation quaternion. Four consecutive Float tokens. Default: (0, 0, 0, 1).

Field Type Token
X float 0x03
Y float 0x03
Z float 0x03
W float 0x03

LRColor

RGBA color. Four values read via ReadIntegralWithHeader() (may be Byte, SByte, Int32, etc.), cast to byte (0–255).

Field Type Range
R byte 0–255
G byte 0–255
B byte 0–255
A byte 0–255

Some formats use ReadNoAlpha() which reads only RGB (3 values, no alpha channel). This is used for light colors in WDB and CDB.

LRRect

Integer rectangle. Four Int32 tokens.

Field Type
X int
Y int
Width int
Height int

Fract16Bit

16-bit fixed-point fractional type. Stored as a Short (token 0x0D), converted to float by dividing by 256.

float = raw_short / 256.0
raw_short = (short)(float * 256)

Used in RRB and GHB path nodes for compact delta positions. Range: approximately ±128.0 with 1/256 precision.

Fract8Bit

8-bit fixed-point fractional type. Stored as an SByte (token 0x0B), converted to float by dividing by 16.

float = raw_sbyte / 16.0
raw_sbyte = (sbyte)(float * 16)

Used in RRB path nodes for compact delta Z, rotation quaternion components, and other small-range values. Range: approximately ±8.0 with 1/16 precision.