pypmxvmd 2.7.2__tar.gz → 2.8.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. pypmxvmd-2.8.2/MANIFEST.in +3 -0
  2. pypmxvmd-2.8.2/PKG-INFO +499 -0
  3. pypmxvmd-2.8.2/README.md +476 -0
  4. pypmxvmd-2.8.2/docs/API.md +1681 -0
  5. pypmxvmd-2.8.2/docs/API_CN.md +1846 -0
  6. pypmxvmd-2.8.2/docs/index.md +18 -0
  7. pypmxvmd-2.8.2/pypmxvmd/__init__.py +1147 -0
  8. pypmxvmd-2.8.2/pypmxvmd/common/__init__.py +11 -0
  9. pypmxvmd-2.8.2/pypmxvmd/common/expressions/__init__.py +1 -0
  10. pypmxvmd-2.8.2/pypmxvmd/common/expressions/expression_profile.py +370 -0
  11. pypmxvmd-2.8.2/pypmxvmd/common/expressions/expression_profile_io.py +190 -0
  12. pypmxvmd-2.8.2/pypmxvmd/common/expressions/expression_resolution.py +426 -0
  13. pypmxvmd-2.8.2/pypmxvmd/common/expressions/pmx_expression_profile.py +135 -0
  14. pypmxvmd-2.8.2/pypmxvmd/common/expressions/tda_expression_profile.py +138 -0
  15. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/io/__init__.py +16 -16
  16. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/io/_fast_binary.c +6666 -4555
  17. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/io/_fast_binary.pyi +32 -32
  18. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/io/_fast_binary.pyx +43 -6
  19. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/io/binary_io.py +465 -451
  20. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/io/file_utils.py +313 -293
  21. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/io/text_io.py +316 -299
  22. pypmxvmd-2.8.2/pypmxvmd/common/io/vmd_codec.py +132 -0
  23. pypmxvmd-2.8.2/pypmxvmd/common/io/vmd_layout.py +195 -0
  24. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/models/__init__.py +18 -18
  25. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/models/base.py +172 -168
  26. pypmxvmd-2.8.2/pypmxvmd/common/models/pmx.py +2019 -0
  27. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/models/vmd.py +387 -350
  28. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/models/vpd.py +114 -111
  29. pypmxvmd-2.8.2/pypmxvmd/common/morph/__init__.py +1 -0
  30. pypmxvmd-2.8.2/pypmxvmd/common/morph/expression_controller.py +55 -0
  31. pypmxvmd-2.8.2/pypmxvmd/common/morph/eye_controller.py +236 -0
  32. pypmxvmd-2.8.2/pypmxvmd/common/morph/morph_control_plan.py +143 -0
  33. pypmxvmd-2.8.2/pypmxvmd/common/morph/morph_control_planner.py +247 -0
  34. pypmxvmd-2.8.2/pypmxvmd/common/morph/morph_controller.py +253 -0
  35. pypmxvmd-2.8.2/pypmxvmd/common/morph/morph_rig_profile.py +233 -0
  36. pypmxvmd-2.8.2/pypmxvmd/common/morph/mouth_controller.py +55 -0
  37. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/parsers/__init__.py +16 -16
  38. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/parsers/_fast_pmx.c +6079 -4127
  39. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/parsers/_fast_pmx.pyi +5 -6
  40. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/parsers/_fast_pmx.pyx +35 -9
  41. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/parsers/_fast_vmd.c +6580 -4226
  42. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/parsers/_fast_vmd.pyi +5 -6
  43. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/parsers/_fast_vmd.pyx +24 -13
  44. pypmxvmd-2.8.2/pypmxvmd/common/parsers/pmx_parser.py +2716 -0
  45. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/parsers/pmx_parser_nuthouse.py +1607 -1320
  46. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/parsers/vmd_parser.py +1852 -1569
  47. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/parsers/vmd_parser_nuthouse.py +1426 -1092
  48. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd/common/parsers/vpd_parser.py +627 -589
  49. pypmxvmd-2.8.2/pypmxvmd/common/pmx/__init__.py +496 -0
  50. pypmxvmd-2.8.2/pypmxvmd/common/pmx/cursor.py +415 -0
  51. pypmxvmd-2.8.2/pypmxvmd/common/pmx/document.py +903 -0
  52. pypmxvmd-2.8.2/pypmxvmd/common/pmx/editing.py +2749 -0
  53. pypmxvmd-2.8.2/pypmxvmd/common/pmx/errors.py +165 -0
  54. pypmxvmd-2.8.2/pypmxvmd/common/pmx/legacy_patch.py +628 -0
  55. pypmxvmd-2.8.2/pypmxvmd/common/pmx/limits.py +33 -0
  56. pypmxvmd-2.8.2/pypmxvmd/common/pmx/material_compatibility.py +532 -0
  57. pypmxvmd-2.8.2/pypmxvmd/common/pmx/motion_diagnostics.py +1001 -0
  58. pypmxvmd-2.8.2/pypmxvmd/common/pmx/motion_repair.py +2189 -0
  59. pypmxvmd-2.8.2/pypmxvmd/common/pmx/outfit.py +8243 -0
  60. pypmxvmd-2.8.2/pypmxvmd/common/pmx/report.py +114 -0
  61. pypmxvmd-2.8.2/pypmxvmd/common/pmx/transaction.py +3479 -0
  62. pypmxvmd-2.8.2/pypmxvmd/common/pmx/types.py +127 -0
  63. pypmxvmd-2.8.2/pypmxvmd/common/pmx/validator.py +1143 -0
  64. pypmxvmd-2.8.2/pypmxvmd/common/pmx/writer.py +478 -0
  65. pypmxvmd-2.8.2/pypmxvmd/common/vmd/__init__.py +1 -0
  66. pypmxvmd-2.8.2/pypmxvmd/common/vmd/vmd_bone_editor.py +134 -0
  67. pypmxvmd-2.8.2/pypmxvmd/common/vmd/vmd_document.py +223 -0
  68. pypmxvmd-2.8.2/pypmxvmd/common/vmd/vmd_edit_plan.py +198 -0
  69. pypmxvmd-2.8.2/pypmxvmd/common/vmd/vmd_edit_transaction.py +519 -0
  70. pypmxvmd-2.8.2/pypmxvmd/common/vmd/vmd_frame_codec.py +286 -0
  71. pypmxvmd-2.8.2/pypmxvmd/common/vmd/vmd_record_index.py +77 -0
  72. pypmxvmd-2.8.2/pypmxvmd/common/vmd/vmd_rotation.py +94 -0
  73. pypmxvmd-2.8.2/pypmxvmd/common/vmd/vmd_sampler.py +341 -0
  74. pypmxvmd-2.8.2/pypmxvmd/common/vmd/vmd_track_operations.py +436 -0
  75. pypmxvmd-2.8.2/pypmxvmd/py.typed +0 -0
  76. pypmxvmd-2.8.2/pypmxvmd.egg-info/PKG-INFO +499 -0
  77. pypmxvmd-2.8.2/pypmxvmd.egg-info/SOURCES.txt +139 -0
  78. pypmxvmd-2.8.2/pypmxvmd.egg-info/not-zip-safe +1 -0
  79. pypmxvmd-2.8.2/pypmxvmd.egg-info/requires.txt +4 -0
  80. pypmxvmd-2.8.2/pyproject.toml +145 -0
  81. pypmxvmd-2.8.2/setup.py +54 -0
  82. pypmxvmd-2.8.2/tests/test_api_compatibility.py +178 -0
  83. pypmxvmd-2.8.2/tests/test_api_integration.py +94 -0
  84. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/tests/test_complete_coverage.py +1288 -1276
  85. pypmxvmd-2.8.2/tests/test_corpus_parsers.py +73 -0
  86. pypmxvmd-2.8.2/tests/test_cython_parsers.py +203 -0
  87. pypmxvmd-2.8.2/tests/test_expression_profiles.py +212 -0
  88. pypmxvmd-2.8.2/tests/test_expression_resolution.py +230 -0
  89. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/tests/test_io_utils.py +150 -141
  90. pypmxvmd-2.8.2/tests/test_morph_controller.py +252 -0
  91. pypmxvmd-2.8.2/tests/test_parser_optimization.py +114 -0
  92. pypmxvmd-2.8.2/tests/test_pmx_0047_ik_contract.py +295 -0
  93. pypmxvmd-2.8.2/tests/test_pmx_21.py +357 -0
  94. pypmxvmd-2.8.2/tests/test_pmx_binary_layout.py +113 -0
  95. pypmxvmd-2.8.2/tests/test_pmx_bone_editing.py +342 -0
  96. pypmxvmd-2.8.2/tests/test_pmx_bone_morph_items.py +159 -0
  97. pypmxvmd-2.8.2/tests/test_pmx_bone_reader.py +298 -0
  98. pypmxvmd-2.8.2/tests/test_pmx_comprehensive.py +56 -0
  99. pypmxvmd-2.8.2/tests/test_pmx_cursor.py +163 -0
  100. pypmxvmd-2.8.2/tests/test_pmx_document.py +162 -0
  101. pypmxvmd-2.8.2/tests/test_pmx_high_level_editing.py +334 -0
  102. pypmxvmd-2.8.2/tests/test_pmx_integrity.py +219 -0
  103. pypmxvmd-2.8.2/tests/test_pmx_joint_editing.py +267 -0
  104. pypmxvmd-2.8.2/tests/test_pmx_legacy_patch.py +310 -0
  105. pypmxvmd-2.8.2/tests/test_pmx_malformed.py +73 -0
  106. pypmxvmd-2.8.2/tests/test_pmx_material_compatibility.py +332 -0
  107. pypmxvmd-2.8.2/tests/test_pmx_material_editing.py +445 -0
  108. pypmxvmd-2.8.2/tests/test_pmx_model_fields.py +191 -0
  109. pypmxvmd-2.8.2/tests/test_pmx_model_validation.py +131 -0
  110. pypmxvmd-2.8.2/tests/test_pmx_motion_diagnostics.py +374 -0
  111. pypmxvmd-2.8.2/tests/test_pmx_motion_repair.py +1103 -0
  112. pypmxvmd-2.8.2/tests/test_pmx_outfit_api.py +1996 -0
  113. pypmxvmd-2.8.2/tests/test_pmx_patch.py +152 -0
  114. pypmxvmd-2.8.2/tests/test_pmx_physics_components.py +371 -0
  115. pypmxvmd-2.8.2/tests/test_pmx_rigid_body_editing.py +271 -0
  116. pypmxvmd-2.8.2/tests/test_pmx_roundtrip.py +139 -0
  117. pypmxvmd-2.8.2/tests/test_pmx_sections_reader.py +358 -0
  118. pypmxvmd-2.8.2/tests/test_pmx_transactions.py +553 -0
  119. pypmxvmd-2.8.2/tests/test_pmx_validator.py +644 -0
  120. pypmxvmd-2.8.2/tests/test_pmx_vertex_reader.py +104 -0
  121. pypmxvmd-2.8.2/tests/test_pmx_writer.py +125 -0
  122. pypmxvmd-2.8.2/tests/test_pmx_writer_canonical.py +118 -0
  123. pypmxvmd-2.8.2/tests/test_quick_integration.py +31 -0
  124. pypmxvmd-2.8.2/tests/test_text_processing.py +79 -0
  125. pypmxvmd-2.8.2/tests/test_vmd_comparison.py +36 -0
  126. pypmxvmd-2.8.2/tests/test_vmd_comprehensive.py +71 -0
  127. pypmxvmd-2.8.2/tests/test_vmd_document.py +141 -0
  128. pypmxvmd-2.8.2/tests/test_vmd_editing.py +315 -0
  129. pypmxvmd-2.8.2/tests/test_vmd_format_baseline.py +197 -0
  130. pypmxvmd-2.8.2/tests/test_vmd_header.py +32 -0
  131. pypmxvmd-2.8.2/tests/test_vmd_parser.py +33 -0
  132. pypmxvmd-2.8.2/tests/test_vmd_sampler.py +91 -0
  133. pypmxvmd-2.8.2/tests/test_vmd_section_editing.py +154 -0
  134. pypmxvmd-2.8.2/tests/test_vmd_track_operations.py +120 -0
  135. pypmxvmd-2.8.2/tests/test_vpd_parser.py +37 -0
  136. pypmxvmd-2.7.2/PKG-INFO +0 -325
  137. pypmxvmd-2.7.2/README.md +0 -301
  138. pypmxvmd-2.7.2/pypmxvmd/__init__.py +0 -401
  139. pypmxvmd-2.7.2/pypmxvmd/common/__init__.py +0 -11
  140. pypmxvmd-2.7.2/pypmxvmd/common/io/_fast_binary.cp311-win_amd64.pyd +0 -0
  141. pypmxvmd-2.7.2/pypmxvmd/common/io/_fast_binary.cp38-win_amd64.pyd +0 -0
  142. pypmxvmd-2.7.2/pypmxvmd/common/models/pmx.py +0 -633
  143. pypmxvmd-2.7.2/pypmxvmd/common/parsers/_fast_pmx.cp311-win_amd64.pyd +0 -0
  144. pypmxvmd-2.7.2/pypmxvmd/common/parsers/_fast_pmx.cp38-win_amd64.pyd +0 -0
  145. pypmxvmd-2.7.2/pypmxvmd/common/parsers/_fast_vmd.cp311-win_amd64.pyd +0 -0
  146. pypmxvmd-2.7.2/pypmxvmd/common/parsers/_fast_vmd.cp38-win_amd64.pyd +0 -0
  147. pypmxvmd-2.7.2/pypmxvmd/common/parsers/pmx_parser.py +0 -1397
  148. pypmxvmd-2.7.2/pypmxvmd.egg-info/PKG-INFO +0 -325
  149. pypmxvmd-2.7.2/pypmxvmd.egg-info/SOURCES.txt +0 -58
  150. pypmxvmd-2.7.2/pypmxvmd.egg-info/entry_points.txt +0 -2
  151. pypmxvmd-2.7.2/pypmxvmd.egg-info/requires.txt +0 -3
  152. pypmxvmd-2.7.2/pyproject.toml +0 -111
  153. pypmxvmd-2.7.2/setup.py +0 -54
  154. pypmxvmd-2.7.2/tests/test_api_integration.py +0 -276
  155. pypmxvmd-2.7.2/tests/test_cython_parsers.py +0 -395
  156. pypmxvmd-2.7.2/tests/test_parser_optimization.py +0 -456
  157. pypmxvmd-2.7.2/tests/test_pmx_comprehensive.py +0 -247
  158. pypmxvmd-2.7.2/tests/test_pmx_writer.py +0 -114
  159. pypmxvmd-2.7.2/tests/test_quick_integration.py +0 -128
  160. pypmxvmd-2.7.2/tests/test_text_processing.py +0 -299
  161. pypmxvmd-2.7.2/tests/test_vmd_comparison.py +0 -162
  162. pypmxvmd-2.7.2/tests/test_vmd_comprehensive.py +0 -213
  163. pypmxvmd-2.7.2/tests/test_vmd_header.py +0 -76
  164. pypmxvmd-2.7.2/tests/test_vmd_parser.py +0 -63
  165. pypmxvmd-2.7.2/tests/test_vpd_parser.py +0 -151
  166. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd.egg-info/dependency_links.txt +0 -0
  167. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/pypmxvmd.egg-info/top_level.txt +0 -0
  168. {pypmxvmd-2.7.2 → pypmxvmd-2.8.2}/setup.cfg +0 -0
@@ -0,0 +1,3 @@
1
+ include docs/API.md
2
+ include docs/API_CN.md
3
+ include docs/index.md
@@ -0,0 +1,499 @@
1
+ Metadata-Version: 2.2
2
+ Name: pypmxvmd
3
+ Version: 2.8.2
4
+ Summary: Wrapper for reading and modifying VMD and PMX files
5
+ Author-email: PythonImporter <271374667@qq.com>
6
+ Project-URL: Homepage, https://github.com/271374667/pypmxvmd
7
+ Project-URL: Documentation, https://pypmxvmd.readthedocs.io/
8
+ Project-URL: Repository, https://github.com/271374667/pypmxvmd
9
+ Project-URL: Bug Tracker, https://github.com/271374667/pypmxvmd/issues
10
+ Keywords: mmd,mikumikudance,pmx,vmd,vpd,3d,animation
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Topic :: Multimedia :: Graphics :: 3D Modeling
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Requires-Python: >=3.11
19
+ Description-Content-Type: text/markdown
20
+ Provides-Extra: all
21
+ Requires-Dist: numpy>=2.4.6; extra == "all"
22
+ Requires-Dist: scipy>=1.17.1; extra == "all"
23
+
24
+ # PyPMXVMD
25
+
26
+ ![pypmxvmd](https://socialify.git.ci/271374667/pypmxvmd/image?description=1&font=Inter&language=1&name=1&owner=1&theme=Auto)
27
+
28
+ [English API](docs/API.md) | [中文 API](docs/API_CN.md)
29
+
30
+ Python MikuMikuDance File Parser Library
31
+
32
+ [![Python Version](https://img.shields.io/badge/python-3.11%20%7C%203.12%20%7C%203.13-blue.svg)](https://www.python.org/downloads/)
33
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
34
+ [![Version](https://img.shields.io/badge/version-2.8.2-orange.svg)](https://github.com/271374667/pypmxvmd)
35
+
36
+ PyPMXVMD is a Python library for parsing and modifying MikuMikuDance (MMD) files, supporting the following formats:
37
+
38
+ - **VMD** (Vocaloid Motion Data) - Motion/animation data
39
+ - **PMX** (Polygon Model eXtended) - 3D model data
40
+ - **VPD** (Vocaloid Pose Data) - Pose data
41
+
42
+ ## Features
43
+
44
+ - Complete PMX 2.0 reading and canonical writing through Spring 6DOF Joint
45
+ - PMX 2.1 QDEF, Flip/Impulse Morph, all six Joint types, and full Soft Body records
46
+ - Validating, atomic PMX 2.0/2.1 output with semantic round-trip coverage
47
+ - Transactional VMD editing: track index/selection, time transform, remap and merge,
48
+ segmented sampling, local morph editing and atomic save-as
49
+ - Transactional PMX extensions: bone, rigid body, joint, material, texture, IK target and
50
+ bone-morph appends, bulk vertex-weight batches and `atomic_batch()`
51
+ - Facial control: `MorphController` with eye, expression and mouth controllers, the built-in
52
+ 69-entry Tda V4X catalog, custom presets and cross-model pose resolution
53
+ - Outfit observation and weight transfer, motion diagnostics and protected repair plans
54
+ - Conversion between binary and text formats
55
+ - Object-oriented API design, easy to use
56
+ - Distributed type information via `py.typed`
57
+ - Optional Cython acceleration for core parsing and binary I/O; PMX currently uses the canonical Cursor model for complete public results
58
+ - PMX core parsing remains dependency-light; surface fitting is available with
59
+ the optional `all` extra (`numpy` and `scipy`)
60
+ - Supports Python 3.11, 3.12 and 3.13; 3.11 remains the development baseline
61
+
62
+ ## Installation
63
+
64
+ ```bash
65
+ # Core parser/writer only
66
+ pip install pypmxvmd
67
+
68
+ # Include surface fitting and other numeric features
69
+ pip install "pypmxvmd[all]"
70
+
71
+ # Add the released package to a uv project
72
+ uv add pypmxvmd
73
+
74
+ # Prepare a source checkout for development
75
+ git clone https://github.com/271374667/pypmxvmd.git
76
+ cd pypmxvmd
77
+ uv sync --group dev --python 3.11.12
78
+ ```
79
+
80
+ The core package has no mandatory third-party runtime dependencies. Install the
81
+ `all` extra when using `fit_part_to_surface()` or
82
+ `PmxVariantBuilder(surface_fit=...)`.
83
+
84
+ ### Optional: Build Cython Accelerators
85
+
86
+ The core parsing path supports Cython-accelerated modules for VMD/PMX and binary I/O.
87
+ `uv sync` builds the three native extensions through the project's setuptools backend.
88
+ The runtime automatically falls back to pure Python when compiled modules are unavailable.
89
+
90
+ ```bash
91
+ uv run --python 3.11.12 --no-sync python scripts/build_cython.py
92
+ uv run --python 3.11.12 --no-sync pytest tests/test_cython_parsers.py -m "cython and not benchmark" -ra
93
+ ```
94
+
95
+ Set `PYPMXVMD_BUILD_CYTHON=0` before `uv sync` when a pure-Python environment is
96
+ required explicitly.
97
+
98
+ ## Quick Start
99
+
100
+ ### Basic Usage
101
+
102
+ ```python
103
+ import pypmxvmd
104
+
105
+ # Load VMD motion file
106
+ motion = pypmxvmd.load_vmd("motion.vmd")
107
+ print(f"Bone frames: {len(motion.bone_frames)}")
108
+ print(f"Morph frames: {len(motion.morph_frames)}")
109
+
110
+ # Modify and save
111
+ pypmxvmd.save_vmd(motion, "modified_motion.vmd")
112
+
113
+ # Load PMX model file
114
+ model = pypmxvmd.load_pmx("model.pmx")
115
+ print(f"Vertices: {len(model.vertices)}")
116
+ print(f"Materials: {len(model.materials)}")
117
+ pypmxvmd.save_pmx(model, "canonical-model.pmx")
118
+
119
+ # Load VPD pose file
120
+ pose = pypmxvmd.load_vpd("pose.vpd")
121
+ print(f"Bone poses: {len(pose.bone_poses)}")
122
+ ```
123
+
124
+ ### Facial Control
125
+
126
+ `MorphController` binds one PMX model and queues gaze, eyelid, expression and mouth requests
127
+ into a single reviewable plan:
128
+
129
+ ```python
130
+ from pypmxvmd import BlinkTiming, MorphController, apply_vmd_edit, load_vmd_document
131
+
132
+ face = MorphController.from_pmx("model.pmx")
133
+ face.look_at((0.8, 0.1, -4.0), frame=30)
134
+ face.blink(40, timing=BlinkTiming(2, 1, 3))
135
+ face.set_expression("笑い", frame=45, strength=0.8)
136
+ face.set_mouth_open(0.4, frame=46).close_mouth(frame=51)
137
+
138
+ plan = face.plan(load_vmd_document("motion.vmd"))
139
+ apply_vmd_edit(plan.require_edit_plan(), "motion-face.vmd")
140
+ ```
141
+
142
+ `face.eyes`, `face.expressions` and `face.mouth` expose the per-part controllers for exact
143
+ keys. Models other than the built-in Tda V4X Ver1.00 profile require an explicit
144
+ `MorphRigProfile` for the controls they expose; `plan()` reports capacity gaps instead of
145
+ silently skipping them. See the API reference for the full method and field tables.
146
+
147
+ ### Automatic Format Detection
148
+
149
+ ```python
150
+ import pypmxvmd
151
+
152
+ # Automatically detect file type and load
153
+ data = pypmxvmd.load("file.vmd") # Returns VmdMotion
154
+ data = pypmxvmd.load("file.pmx") # Returns PmxModel
155
+ data = pypmxvmd.load("file.vpd") # Returns VpdPose
156
+
157
+ # Automatically detect data type and save
158
+ pypmxvmd.save(motion, "output.vmd")
159
+ pypmxvmd.save(model, "output.pmx")
160
+ pypmxvmd.save(pose, "output.vpd")
161
+ ```
162
+
163
+ PMX 2.0/2.1 binary loading and canonical saving consume every version-required
164
+ section through Joint/Soft Body. Saving validates the full model before
165
+ atomically replacing the target;
166
+ canonical output chooses deterministic index widths and is semantically stable,
167
+ but is not promised to be byte-identical to the source. Semantic validation is
168
+ available through `PmxModel.validate()`. PMX 2.1 support covers QDEF,
169
+ Flip/Impulse Morphs, Spring 6DOF/6DOF/P2P/ConeTwist/Slider/Hinge Joint records,
170
+ and all Soft Body Config/Cluster/Iteration/Material/Anchor/Pin fields. This
171
+ evidence currently comes from independent synthetic fixed-byte fixtures; no
172
+ redistributable real PMX 2.1 corpus is claimed.
173
+
174
+ PMX binary modes are explicit and keyword-only, so existing positional calls
175
+ remain compatible:
176
+
177
+ ```python
178
+ # Complete model or IncompletePmxError
179
+ model = pypmxvmd.load_pmx("model.pmx", mode="strict")
180
+
181
+ # Diagnostic model plus section/EOF evidence
182
+ result = pypmxvmd.load_pmx("model.pmx", mode="partial")
183
+
184
+ # Canonical PMX 2.0/2.1 output
185
+ pypmxvmd.write_pmx(model, "output.pmx", mode="canonical")
186
+
187
+ # Source-backed fixed-width editing
188
+ document = pypmxvmd.load_pmx_document("model.pmx")
189
+ document.model.bones[0].deform_layer = 1
190
+ pypmxvmd.write_pmx(document, "patched.pmx", mode="lossless_patch")
191
+
192
+ # Transactional editing of an existing Bone record, including variable layouts
193
+ document = pypmxvmd.load_pmx_document("model.pmx")
194
+ editor = document.edit_bones()
195
+ editor.set_deform_layer(0, 2)
196
+ editor.set_tail_offset(0, [0.0, 1.0, 0.0])
197
+ editor.write_file("bone-edited.pmx")
198
+
199
+ # Transactional editing of an existing Rigid Body record
200
+ editor = document.edit_rigid_bodies()
201
+ editor.set_bone(0, -1) # legal no-Bone sentinel
202
+ editor.set_collision(0, collision_group=0, collision_mask=0xFFFE)
203
+ editor.set_physical_parameters(0, mass=1.0, friction=0.5)
204
+ editor.write_file("rigid-body-edited.pmx")
205
+
206
+ # Transactional editing of an existing PMX 2.0 Spring 6DOF Joint
207
+ editor = document.edit_joints()
208
+ editor.set_rigid_body_references(0, -1, 1)
209
+ editor.set_rotation_limits(0, [-0.5, -0.25, -0.1], [0.5, 0.25, 0.1])
210
+ editor.set_rotation_spring(0, [0.2, 0.3, 0.4])
211
+ editor.write_file("joint-edited.pmx")
212
+
213
+ # Transactional editing of an existing Material record
214
+ editor = document.edit_materials()
215
+ editor.set_diffuse_color(0, [0.8, 0.6, 0.5, 1.0])
216
+ editor.sync_ambient_from_diffuse(0) # explicit; never happens on ordinary save
217
+ editor.set_shared_toon(0, 0) # built-in toon01.bmp
218
+ editor.write_file("material-edited.pmx")
219
+ ```
220
+
221
+ `document`/field-span reads and fixed-width `lossless_patch` writes are available
222
+ for selected directly mapped Material, Bone, Rigid Body, and Joint fields. Every patch is
223
+ range/before-byte checked, strict-reparsed, and compared against the edited model.
224
+ The Bone, Rigid Body, Joint, and Material transactions below can rebuild their
225
+ existing variable-length records. Other variable-length fields, record
226
+ insertion/deletion, global index renumbering, and PMX 2.1-specific high-level
227
+ editing remain unsupported; `preserve_layout` also remains unsupported.
228
+ Lossless mode never silently falls back to canonical output.
229
+
230
+ Legacy fixed-width consumers can migrate one allowlisted operation at a time
231
+ without adding a runtime dependency in this package. Objects that provide the
232
+ existing `PatchRecord.to_dict()` shape are accepted directly. Use
233
+ `write_legacy_patches(..., mode="dual")` to require byte-for-byte agreement
234
+ between the old algorithm and the registered `PmxDocument` engine before an
235
+ atomic output, then change the explicit mode to `document` for single-write
236
+ cutover. `legacy` remains the rollback mode. All modes reject the source path
237
+ and existing targets unless overwrite is explicitly allowed. The current
238
+ allowlist remains PMX 2.0 `bones[*].parent_index`; other Rebuilder patch
239
+ families fail closed pending field-span and semantic approval.
240
+
241
+ `PmxBoneEditor` additionally supports all PMX 2.0 fields of existing Bone
242
+ records: variable-length names, position/parent/deform layer, basic flags, both
243
+ tail modes, inheritance, fixed/local axes, external parent, and IK links/limits.
244
+ It rebuilds only changed Bone records, validates the complete model, strict-
245
+ reparses the result, and writes atomically. Bone insertion, deletion, replacement,
246
+ reordering, and global index renumbering remain unsupported and fail closed.
247
+
248
+ `PmxRigidBodyEditor` supports all fields of existing PMX 2.0 Rigid Body
249
+ records: variable-length names, Bone reference including `-1`, three shapes and
250
+ physics modes, raw collision group/mask, size/position/rotation in source units,
251
+ and all five physical parameters. It rebuilds only changed records and preserves
252
+ existing Joint index semantics. Rigid Body insertion, deletion, replacement, and
253
+ reordering remain unsupported and fail closed.
254
+
255
+ `PmxJointEditor` supports every field of existing PMX 2.0 Spring 6DOF Joint
256
+ records: variable-length names, the A/B Rigid Body references including `-1`,
257
+ position/rotation, translation/rotation min/max limits, and both spring vectors.
258
+ Rotation values remain raw radians. Limit setters require component-wise
259
+ `minimum <= maximum`; unchanged legacy source axes are preserved. Joint insertion,
260
+ deletion, replacement, reordering, and PMX 2.1 Joint types remain unsupported.
261
+
262
+ `PmxMaterialEditor` supports every serialized field of existing PMX 2.0
263
+ Material records: variable-length names/comments, colors, all eight draw flags,
264
+ edge settings, Texture/Sphere/Toon modes and references, and face-index counts.
265
+ Texture display paths remain derived from the serialized indices. Face counts
266
+ are updated as one validated collection, and ambient/diffuse synchronization is
267
+ an explicit command only. Material or texture-table insertion, deletion,
268
+ replacement, and reordering remain unsupported.
269
+
270
+ ### Text Format Conversion
271
+
272
+ PyPMXVMD supports converting binary files to readable text format for viewing and editing:
273
+
274
+ ```python
275
+ import pypmxvmd
276
+
277
+ # VMD -> Text
278
+ motion = pypmxvmd.load_vmd("motion.vmd")
279
+ pypmxvmd.save_vmd_text(motion, "motion.txt")
280
+
281
+ # Text -> VMD
282
+ motion = pypmxvmd.load_vmd_text("motion.txt")
283
+ pypmxvmd.save_vmd(motion, "motion.vmd")
284
+
285
+ # PMX -> Text
286
+ model = pypmxvmd.load_pmx("model.pmx")
287
+ pypmxvmd.save_pmx_text(model, "model.txt")
288
+
289
+ # VPD -> Text
290
+ pose = pypmxvmd.load_vpd("pose.vpd")
291
+ pypmxvmd.save_vpd_text(pose, "pose.txt")
292
+ ```
293
+
294
+ ### Using Parser Classes
295
+
296
+ If you need more control, you can use the parser classes directly:
297
+
298
+ ```python
299
+ from pypmxvmd import VmdParser, PmxParser, VpdParser
300
+
301
+ # VMD Parser
302
+ vmd_parser = VmdParser()
303
+ motion = vmd_parser.parse_file("motion.vmd", more_info=True)
304
+ vmd_parser.write_file(motion, "output.vmd")
305
+
306
+ # PMX Parser
307
+ pmx_parser = PmxParser()
308
+ model = pmx_parser.parse_file("model.pmx", more_info=True)
309
+ pmx_parser.write_file(model, "canonical-model.pmx")
310
+
311
+ # VPD Parser
312
+ vpd_parser = VpdParser()
313
+ pose = vpd_parser.parse_file("pose.vpd", more_info=True)
314
+ vpd_parser.write_file(pose, "output.vpd")
315
+ ```
316
+
317
+ ## Data Structures
318
+
319
+ ### VmdMotion (VMD Motion)
320
+
321
+ ```python
322
+ class VmdMotion:
323
+ header: VmdHeader # File header information
324
+ bone_frames: List[VmdBoneFrame] # Bone keyframes
325
+ morph_frames: List[VmdMorphFrame] # Morph keyframes
326
+ camera_frames: List[VmdCameraFrame] # Camera keyframes
327
+ light_frames: List[VmdLightFrame] # Light keyframes
328
+ shadow_frames: List[VmdShadowFrame] # Shadow keyframes
329
+ ik_frames: List[VmdIkFrame] # IK keyframes
330
+ ```
331
+
332
+ ### PmxModel (PMX Model)
333
+
334
+ ```python
335
+ class PmxModel:
336
+ header: PmxHeader # File header information
337
+ vertices: List[PmxVertex] # Vertex list
338
+ faces: List[int] # Face indices
339
+ textures: List[str] # Texture paths
340
+ materials: List[PmxMaterial] # Material list
341
+ bones: List[PmxBone] # Bone list
342
+ morphs: List[PmxMorph] # Morph list
343
+ frames: List[PmxFrame] # Display frames
344
+ rigidbodies: List[PmxRigidBody] # Rigidbody list
345
+ joints: List[PmxJoint] # Joint list
346
+ ```
347
+
348
+ ### VpdPose (VPD Pose)
349
+
350
+ ```python
351
+ class VpdPose:
352
+ model_name: str # Model name
353
+ bone_poses: List[VpdBonePose] # Bone pose list
354
+ morph_poses: List[VpdMorphPose] # Morph pose list
355
+ ```
356
+
357
+ ## API Reference
358
+
359
+ ### Core Functions
360
+
361
+ | Function | Description |
362
+ |------|------|
363
+ | `load_vmd(path)` | Load VMD file |
364
+ | `save_vmd(motion, path)` | Save VMD file |
365
+ | `load_pmx(path)` | Load PMX file |
366
+ | `load_pmx(path, mode="partial")` | Load PMX with completeness evidence |
367
+ | `load_pmx_document(path)` | Load exact source bytes and fixed-field spans |
368
+ | `save_pmx(model, path)` | Save PMX file |
369
+ | `write_pmx(model, path, mode="canonical")` | Canonical PMX writer |
370
+ | `write_pmx(document, path, mode="lossless_patch")` | Audited fixed-field patch |
371
+ | `adapt_legacy_patches(document, records)` | Map approved legacy fixed-width records |
372
+ | `dual_write_legacy_patches(document, records)` | Compare legacy and lossless outputs |
373
+ | `verify_legacy_patch_engines(document, records)` | Compare legacy and document engines without a mirrored model edit |
374
+ | `write_legacy_patches(document, records, path, mode="dual")` | Atomically run the legacy/dual/document migration stage |
375
+ | `load_vpd(path)` | Load VPD file |
376
+ | `save_vpd(pose, path)` | Save VPD file |
377
+ | `load(path)` | Auto-detect and load |
378
+ | `save(data, path)` | Auto-detect and save |
379
+
380
+ ### Text Format Functions
381
+
382
+ | Function | Description |
383
+ |------|------|
384
+ | `load_vmd_text(path)` | Load VMD from text |
385
+ | `save_vmd_text(motion, path)` | Save VMD as text |
386
+ | `load_pmx_text(path)` | Load PMX from text |
387
+ | `save_pmx_text(model, path)` | Save PMX as text |
388
+ | `load_vpd_text(path)` | Load VPD from text |
389
+ | `save_vpd_text(pose, path)` | Save VPD as text |
390
+ | `load_text(path)` | Auto-detect and load text |
391
+ | `save_text(data, path)` | Auto-detect and save text |
392
+
393
+ ## Project Structure
394
+
395
+ ```
396
+ pypmxvmd/ # Main package
397
+ __init__.py # Public API (load/save helpers)
398
+ common/ # Core implementation
399
+ io/ # Binary/text IO (+ Cython accel)
400
+ models/ # Data models (VMD/PMX/VPD)
401
+ parsers/ # Parsers (+ fast modules)
402
+ docs/ # Documentation
403
+ API.md # English API
404
+ API_CN.md # 中文 API
405
+ scripts/ # Build helpers
406
+ build_cython.py
407
+ build_wheels.py
408
+ change_version.py
409
+ verify_wheel.py
410
+ tests/ # Tests + fixtures
411
+ ```
412
+
413
+
414
+ ## Testing
415
+
416
+ ```bash
417
+ # Run correctness tests, including a local corpus when present
418
+ uv run --python 3.11.12 --no-sync pytest -m "not benchmark" -ra
419
+
420
+ # Run the local PMX/VMD corpus only
421
+ uv run --python 3.11.12 --no-sync pytest -m corpus -ra
422
+
423
+ # Run coverage test
424
+ uv run --python 3.11.12 --no-sync pytest --cov=pypmxvmd --cov-report=html
425
+ ```
426
+
427
+ ## Development
428
+
429
+ ```bash
430
+ # Resolve and install the locked development environment
431
+ uv sync --group dev --python 3.11.12
432
+
433
+ # Code formatting and linting (including import sorting)
434
+ uv run --python 3.11.12 --no-sync ruff format --check pypmxvmd tests scripts
435
+ uv run --python 3.11.12 --no-sync ruff check pypmxvmd tests scripts
436
+
437
+ # Type checking
438
+ uv run --python 3.11.12 --no-sync ty check pypmxvmd
439
+
440
+ # Build sdist and the platform wheel
441
+ uv build
442
+ ```
443
+
444
+ ## Changelog
445
+
446
+ ### v2.8.2
447
+ - `scripts/build_wheels.py` now builds each supported Python (3.11/3.12/3.13) with `uv build`
448
+ and clears previous `outputs/01_dist` artifacts first
449
+ - Release rules require English notes and every supported wheel; builds below the minimum
450
+ supported Python are untested and must not be published
451
+
452
+ ### v2.8.1
453
+ - Added `MorphController` with eye, expression and mouth controllers, the built-in Tda V4X
454
+ 69-entry catalog and cross-model expression resolution
455
+ - Added general VMD editing: track index/selection, time transform, remap, merge and
456
+ segmented sampling
457
+ - Extended PMX transactions to bone, rigid body, joint, material, texture, IK target and
458
+ bone-morph appends, plus bulk vertex-weight batches and `atomic_batch()`
459
+ - Added outfit observation and weight transfer, motion diagnostics and protected repair plans
460
+ - Added `scripts/change_version.py` and published Windows wheels for CPython 3.11, 3.12 and 3.13
461
+ - Fixed setuptools writing `License-File` into `Metadata-Version: 2.2`, which blocked PyPI uploads
462
+
463
+ ### v2.7.1
464
+ - Updated core parsers and binary I/O with Cython fast paths
465
+ - Restored the Windows CPython 3.11 native wheel build
466
+ - Improved text format auto-detection and test coverage
467
+
468
+ ### v2.5.1
469
+ - Added optional Cython acceleration for core parsing and binary I/O
470
+ - Cython path averages ~3.7x faster than the previous implementation
471
+
472
+ ### v2.0.0 (2024)
473
+ - Complete refactor to object-oriented architecture
474
+ - Added complete type annotations
475
+ - Support for text format export/import
476
+ - Improved error handling and validation
477
+ - Added progress callback support
478
+
479
+ ### v1.x (Original)
480
+ - Based on Nuthouse01's original implementation
481
+ - Functional API
482
+
483
+ ## Acknowledgments
484
+
485
+ This project is refactored from the original MMD scripting tools by [Nuthouse01](https://github.com/Nuthouse01/PMX-VMD-Scripting-Tools).
486
+
487
+ ## License
488
+
489
+ MIT License - See [LICENSE](LICENSE) file for details
490
+
491
+ ## Contributing
492
+
493
+ Issues and Pull Requests are welcome!
494
+
495
+ 1. Fork this repository
496
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
497
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
498
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
499
+ 5. Create a Pull Request