Level Bin

This information only applies to MySims Kingdom.
Check out the MySims version here.
A level is a collection of models, objects and meta data, like grid size.
Level bins have the type 0x58969018 and are found under GameData/Levels/. All values are little-endian. Every file starts with the magic LLMF and version 2.
A level is made of two kinds of models:
- Base models: the level's base geometry. Each one is a Win32 Model instance, drawn once at the origin with no transform.
- Objects: models placed with a position, rotation and scale. Each one can also swap some of its materials for others.
The file ends right after the last object. There is no padding or trailing data.
Objects
Every object starts with a model instance, a position, a rotation and a scale. The full key for the model is 0x00000000!0x{model}.0xB359C791.
The rotation is stored as Euler angles in degrees. It's applied as R = Rz * Ry * Rx (glm's quat(eulerXYZ)), and the model matrix is T * R * S.
Material overrides
Objects have a variable length. After the scale comes an override count, followed by that many material overrides. Each override is a pair of Material instances: when one of the model's meshes uses the original material, it uses replacement instead. This lets the same model appear with different materials in different places.
Most objects have no overrides, so the count is usually 0. That's why it's easy to mistake objects for a fixed 48 bytes.
Related files
These files have the same instance (group 0) as the level bin:
| File | Type | Description |
|---|---|---|
| LightSetBin | 0x50002128 | The level's lights |
| Physics | 0xD5988020 | The level's collision. Each base model also has a Physics file with that model's instance |
| BuildableRegionBin | 0xC84ACD30 | The areas the player can build in |
Pattern
import type.base;
struct Vector3 {
float x;
float y;
float z;
};
struct MaterialOverride {
type::Hex<u64> original; // material instance used by the model
type::Hex<u64> replacement; // material instance to use instead
};
struct LevelObject {
type::Hex<u64> model; // Win32 Model instance
Vector3 position;
Vector3 rotation; // Euler angles, in degrees
Vector3 scale;
u32 overrideCount;
MaterialOverride overrides[overrideCount];
};
struct LevelBinFile {
char magic[4]; // LLMF
u32 version; // 2
float startPosX;
float startPosZ;
u32 cellSizeX;
u32 cellSizeZ;
u32 numCellsX;
u32 numCellsZ;
float unknown0;
float unknown1;
u32 modelCount;
u32 objectCount;
Vector3 boundsMin;
Vector3 boundsMax;
type::Hex<u64> models[modelCount]; // base models, drawn at the origin
LevelObject objects[objectCount];
};
LevelBinFile level @ $;
Unknowns
- The two floats at
0x20and0x24. - What the start position, cell size and cell count are used for. They match the
GridInfofields of the MySims Level XML. - The bounds are often much larger than the area that actually has objects in it.