BMTR format (binarized RTM)

The armaio.rtm module provides utilites for reading the binarized RTM animation format. The implementations are based on the Community Wiki binarized RTM page and further research.

For “binarized” RTM files, the module only supports reading. Writing is only supported through conversion to the “plain” representation.

Warning

While both the “plain” and “binarized” RTM formats use the .rtm extension, the actual file format is completely different, and not interchangeable.

In contrast to “plain” files, the BMTR format uses optional compression in some data blocks, and the transformation data itself is stored as relative quaternion-vector pairs, instead of absolute matrices.

Examples

Reading

from armaio.rtm import BmtrFile

bmtr = BmtrFile.read_file("animation_binarized.rtm")
print(bmtr.motion)

Converting

from armaio.rtm import RtmFile, BmtrFile, BoneStructure

bmtr = BmtrFile.read_file("animation_binarized.rtm")
skeleton: BoneStructure = {
    "pelvis": {
        "torso": {
            "leftarm": {},
            "rightarm": {}
        }
    }
}

rtm = RtmFile.from_binarized(bmtr, skeleton)
print(rtm.motion)

Exceptions

class armaio.rtm.BmtrError

Exception raised upon BMTR reading errors.

Classes

class armaio.rtm.BmtrFrame(phase: float, bones: tuple[str, ...])

Animation frame at a given phase, containing the transformation data for all bones.

Parameters:
  • phase (float) – Animation phase

  • bones (tuple[str, ...]) – Bones animated in the frame

Raises:

BmtrError – Duplicate bones

classmethod read(stream: IO[bytes], phase: float, bones: tuple[str, ...]) Self

Reads an animation frame from a binary stream.

Parameters:
  • stream (IO[bytes]) – Source binary stream

  • phase (float) – Animation phase

  • bones (tuple[str, ...]) – List of expected bones

Returns:

Animation frame

Return type:

Self

property phase: float
Returns:

Animation phase

Return type:

float

property transforms: MappingProxyType
Returns:

Bone transformations

Return type:

MappingProxyType[str, tuple[RtmQuaternion, RtmVector] | None]

class armaio.rtm.BmtrFile

Animation data read from a binarized RTM file.

classmethod read(stream: IO[bytes]) Self

Reads binarized animation data from a binary stream.

Parameters:

stream (IO[bytes]) – Source binary stream

Raises:

BmtrError – Stream is not valid animation data

Returns:

Animation data

Return type:

Self

classmethod read_file(filepath: str) Self

Reads animation data from a binarized RTM file at a given path.

Parameters:

filepath (str) – Path to RTM file

Returns:

Animation data

Return type:

Self

property bones: tuple[str, ...]
Returns:

Bones in the animation

Return type:

tuple[str, …]

property frames: tuple[BmtrFrame, ...]
Returns:

Animation frames

Return type:

tuple[RtmFrame, …]

property motion: RtmVector
Returns:

Motion vector

Return type:

RtmVector

property properties: tuple[RtmProperty, ...]
Returns:

Phase-linked animation properties

Return type:

tuple[tuple[float, str, str], …]

property source: str | None
Returns:

Path to source file (None if not read from file)

Return type:

str | None

property version: int
Returns:

Format version

Return type:

int