Skip to main content

Python reader/writer for Live2D Cubism .moc3 binary files

Project description

py-moc3

Python reader/writer for Live2D Cubism .moc3 binary files. Zero dependencies — just Python stdlib.

Install

pip install py-moc3

Quick Start

from moc3 import Moc3

# Read
moc = Moc3.from_file("model.moc3")
print(moc.summary())
print(moc.parameter_ids)
print(moc.art_mesh_ids)

# Modify
moc["art_mesh.texture_indices"][0] = 1
moc["parameter.max_values"][0] = 60.0

# Write
moc.to_file("model_modified.moc3")

CLI

# Show model info
moc3 info model.moc3

# List parameters with ranges
moc3 params model.moc3
moc3 params model.moc3 --json

# List art meshes
moc3 meshes model.moc3

# Verify read-write round-trip (byte-identical check)
moc3 verify model.moc3

Section Access

All data is stored in named sections using struct-of-arrays layout. Access any section by name:

moc = Moc3.from_file("model.moc3")

# IDs
moc["part.ids"]           # list[str]
moc["deformer.ids"]       # list[str]
moc["art_mesh.ids"]       # list[str]
moc["parameter.ids"]      # list[str]

# Art mesh properties
moc["art_mesh.texture_indices"]   # list[int] — which texture sheet
moc["art_mesh.vertex_counts"]    # list[int]
moc["art_mesh.visibles"]         # list[bool]

# Parameter ranges
moc["parameter.min_values"]      # list[float]
moc["parameter.max_values"]      # list[float]
moc["parameter.default_values"]  # list[float]

# UV coordinates (flat x,y pairs)
moc["uv.xys"]                    # list[float]

# Triangle indices
moc["position_index.indices"]    # list[int]

# Canvas info
moc.canvas.canvas_width          # float
moc.canvas.canvas_height         # float
moc.canvas.pixels_per_unit       # float

See SECTION_LAYOUT in the source for the complete list of ~100 available sections.

Format Support

Version Read Write Notes
V3.00 (1) Yes Yes Base format
V3.03 (2) Yes Yes + quad transforms
V4.00 (3) Yes Yes
V4.02 (4) Yes Yes
V5.00 (5) Yes Yes

Round-trip tested: read → write produces byte-identical output.

How It Works

The .moc3 format is a flat binary with:

  1. Header (64 bytes): magic "MOC3", format version, endian flag
  2. Section Offset Table (640 bytes): 160 × uint32 offsets pointing into the body
  3. Body (from byte 1984): ~100 typed arrays, each 64-byte aligned

Each array stores one property for all items of a type (struct-of-arrays). For example, art_mesh.texture_indices stores the texture index for every art mesh, contiguously.

Ported from moc3-reader-re (Java decompilation of the Cubism SDK exporter).

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_moc3-0.1.0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_moc3-0.1.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file py_moc3-0.1.0.tar.gz.

File metadata

  • Download URL: py_moc3-0.1.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for py_moc3-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1d4cf2bf990eb520abebd79aaa9567b6c971380fd9372f6330629db08ee85cc6
MD5 c9331538871021ca69996bf30535daa1
BLAKE2b-256 0e240ab2b1aee468d3525a0669448d6b9e04866aa80ca3d63b3514813a254a8b

See more details on using hashes here.

File details

Details for the file py_moc3-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: py_moc3-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for py_moc3-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a955c2c0d62b998de2289a3efac2f0a7c02dffe8489fa0f9bcd03470967f70e2
MD5 a5f0b719943cfa41a25730fa63929deb
BLAKE2b-256 3dab270586cd8428d98887d780253793fe6d893fea28d837bcd0d7eadcdf4ebb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page