pypmxvmd 2.0.0__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.
- pypmxvmd-2.0.0/PKG-INFO +310 -0
- pypmxvmd-2.0.0/README.md +274 -0
- pypmxvmd-2.0.0/pypmxvmd/__init__.py +401 -0
- pypmxvmd-2.0.0/pypmxvmd.egg-info/PKG-INFO +310 -0
- pypmxvmd-2.0.0/pypmxvmd.egg-info/SOURCES.txt +18 -0
- pypmxvmd-2.0.0/pypmxvmd.egg-info/dependency_links.txt +1 -0
- pypmxvmd-2.0.0/pypmxvmd.egg-info/entry_points.txt +2 -0
- pypmxvmd-2.0.0/pypmxvmd.egg-info/requires.txt +19 -0
- pypmxvmd-2.0.0/pypmxvmd.egg-info/top_level.txt +1 -0
- pypmxvmd-2.0.0/pyproject.toml +113 -0
- pypmxvmd-2.0.0/setup.cfg +4 -0
- pypmxvmd-2.0.0/tests/test_api_integration.py +272 -0
- pypmxvmd-2.0.0/tests/test_pmx_comprehensive.py +248 -0
- pypmxvmd-2.0.0/tests/test_pmx_writer.py +114 -0
- pypmxvmd-2.0.0/tests/test_quick_integration.py +129 -0
- pypmxvmd-2.0.0/tests/test_text_processing.py +300 -0
- pypmxvmd-2.0.0/tests/test_vmd_comprehensive.py +214 -0
- pypmxvmd-2.0.0/tests/test_vmd_header.py +76 -0
- pypmxvmd-2.0.0/tests/test_vmd_parser.py +37 -0
- pypmxvmd-2.0.0/tests/test_vpd_parser.py +151 -0
pypmxvmd-2.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pypmxvmd
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Wrapper for reading and modifying VMD and PMX files
|
|
5
|
+
Author-email: PyPMXVMD Team <pypmxvmd@example.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/pypmxvmd/pypmxvmd
|
|
7
|
+
Project-URL: Documentation, https://pypmxvmd.readthedocs.io/
|
|
8
|
+
Project-URL: Repository, https://github.com/pypmxvmd/pypmxvmd
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/pypmxvmd/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.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Topic :: Multimedia :: Graphics :: 3D Modeling
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: >=3.8
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
Requires-Dist: typing-extensions>=4.0.0; python_version < "3.10"
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
26
|
+
Requires-Dist: pytest-cov>=2.0; extra == "dev"
|
|
27
|
+
Requires-Dist: black>=22.0; extra == "dev"
|
|
28
|
+
Requires-Dist: isort>=5.0; extra == "dev"
|
|
29
|
+
Requires-Dist: flake8>=4.0; extra == "dev"
|
|
30
|
+
Requires-Dist: mypy>=0.900; extra == "dev"
|
|
31
|
+
Provides-Extra: gui
|
|
32
|
+
Provides-Extra: translation
|
|
33
|
+
Requires-Dist: googletrans==4.0.0rc1; extra == "translation"
|
|
34
|
+
Provides-Extra: image
|
|
35
|
+
Requires-Dist: Pillow>=8.0.0; extra == "image"
|
|
36
|
+
|
|
37
|
+
# PyPMXVMD
|
|
38
|
+
|
|
39
|
+
Python MikuMikuDance File Parser Library
|
|
40
|
+
|
|
41
|
+
[](https://www.python.org/downloads/)
|
|
42
|
+
[](LICENSE)
|
|
43
|
+
[](https://github.com/pypmxvmd/pypmxvmd)
|
|
44
|
+
|
|
45
|
+
PyPMXVMD is a Python library for parsing and modifying MikuMikuDance (MMD) files, supporting the following formats:
|
|
46
|
+
|
|
47
|
+
- **VMD** (Vocaloid Motion Data) - Motion/animation data
|
|
48
|
+
- **PMX** (Polygon Model eXtended) - 3D model data
|
|
49
|
+
- **VPD** (Vocaloid Pose Data) - Pose data
|
|
50
|
+
|
|
51
|
+
## Features
|
|
52
|
+
|
|
53
|
+
- Full support for reading and writing VMD, PMX, and VPD files
|
|
54
|
+
- Conversion between binary and text formats
|
|
55
|
+
- Object-oriented API design, easy to use
|
|
56
|
+
- Complete type annotation support
|
|
57
|
+
- No external dependencies (core functionality)
|
|
58
|
+
- Supports Python 3.8+
|
|
59
|
+
|
|
60
|
+
## Installation
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Install from source
|
|
64
|
+
git clone https://github.com/pypmxvmd/pypmxvmd.git
|
|
65
|
+
cd pypmxvmd
|
|
66
|
+
pip install -e .
|
|
67
|
+
|
|
68
|
+
# Install development dependencies
|
|
69
|
+
pip install -e ".[dev]"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Quick Start
|
|
73
|
+
|
|
74
|
+
### Basic Usage
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
import pypmxvmd
|
|
78
|
+
|
|
79
|
+
# Load VMD motion file
|
|
80
|
+
motion = pypmxvmd.load_vmd("motion.vmd")
|
|
81
|
+
print(f"Bone frames: {len(motion.bone_frames)}")
|
|
82
|
+
print(f"Morph frames: {len(motion.morph_frames)}")
|
|
83
|
+
|
|
84
|
+
# Modify and save
|
|
85
|
+
pypmxvmd.save_vmd(motion, "modified_motion.vmd")
|
|
86
|
+
|
|
87
|
+
# Load PMX model file
|
|
88
|
+
model = pypmxvmd.load_pmx("model.pmx")
|
|
89
|
+
print(f"Vertices: {len(model.vertices)}")
|
|
90
|
+
print(f"Materials: {len(model.materials)}")
|
|
91
|
+
|
|
92
|
+
# Load VPD pose file
|
|
93
|
+
pose = pypmxvmd.load_vpd("pose.vpd")
|
|
94
|
+
print(f"Bone poses: {len(pose.bone_poses)}")
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Automatic Format Detection
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
import pypmxvmd
|
|
101
|
+
|
|
102
|
+
# Automatically detect file type and load
|
|
103
|
+
data = pypmxvmd.load("file.vmd") # Returns VmdMotion
|
|
104
|
+
data = pypmxvmd.load("file.pmx") # Returns PmxModel
|
|
105
|
+
data = pypmxvmd.load("file.vpd") # Returns VpdPose
|
|
106
|
+
|
|
107
|
+
# Automatically detect data type and save
|
|
108
|
+
pypmxvmd.save(motion, "output.vmd")
|
|
109
|
+
pypmxvmd.save(model, "output.pmx")
|
|
110
|
+
pypmxvmd.save(pose, "output.vpd")
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Text Format Conversion
|
|
114
|
+
|
|
115
|
+
PyPMXVMD supports converting binary files to readable text format for viewing and editing:
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
import pypmxvmd
|
|
119
|
+
|
|
120
|
+
# VMD -> Text
|
|
121
|
+
motion = pypmxvmd.load_vmd("motion.vmd")
|
|
122
|
+
pypmxvmd.save_vmd_text(motion, "motion.txt")
|
|
123
|
+
|
|
124
|
+
# Text -> VMD
|
|
125
|
+
motion = pypmxvmd.load_vmd_text("motion.txt")
|
|
126
|
+
pypmxvmd.save_vmd(motion, "motion.vmd")
|
|
127
|
+
|
|
128
|
+
# PMX -> Text
|
|
129
|
+
model = pypmxvmd.load_pmx("model.pmx")
|
|
130
|
+
pypmxvmd.save_pmx_text(model, "model.txt")
|
|
131
|
+
|
|
132
|
+
# VPD -> Text
|
|
133
|
+
pose = pypmxvmd.load_vpd("pose.vpd")
|
|
134
|
+
pypmxvmd.save_vpd_text(pose, "pose.txt")
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Using Parser Classes
|
|
138
|
+
|
|
139
|
+
If you need more control, you can use the parser classes directly:
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
from pypmxvmd import VmdParser, PmxParser, VpdParser
|
|
143
|
+
|
|
144
|
+
# VMD Parser
|
|
145
|
+
vmd_parser = VmdParser()
|
|
146
|
+
motion = vmd_parser.parse_file("motion.vmd", more_info=True)
|
|
147
|
+
vmd_parser.write_file(motion, "output.vmd")
|
|
148
|
+
|
|
149
|
+
# PMX Parser
|
|
150
|
+
pmx_parser = PmxParser()
|
|
151
|
+
model = pmx_parser.parse_file("model.pmx", more_info=True)
|
|
152
|
+
pmx_parser.write_file(model, "output.pmx")
|
|
153
|
+
|
|
154
|
+
# VPD Parser
|
|
155
|
+
vpd_parser = VpdParser()
|
|
156
|
+
pose = vpd_parser.parse_file("pose.vpd", more_info=True)
|
|
157
|
+
vpd_parser.write_file(pose, "output.vpd")
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Data Structures
|
|
161
|
+
|
|
162
|
+
### VmdMotion (VMD Motion)
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
class VmdMotion:
|
|
166
|
+
header: VmdHeader # File header information
|
|
167
|
+
bone_frames: List[VmdBoneFrame] # Bone keyframes
|
|
168
|
+
morph_frames: List[VmdMorphFrame] # Morph keyframes
|
|
169
|
+
camera_frames: List[VmdCameraFrame] # Camera keyframes
|
|
170
|
+
light_frames: List[VmdLightFrame] # Light keyframes
|
|
171
|
+
shadow_frames: List[VmdShadowFrame] # Shadow keyframes
|
|
172
|
+
ik_frames: List[VmdIkFrame] # IK keyframes
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### PmxModel (PMX Model)
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
class PmxModel:
|
|
179
|
+
header: PmxHeader # File header information
|
|
180
|
+
vertices: List[PmxVertex] # Vertex list
|
|
181
|
+
faces: List[int] # Face indices
|
|
182
|
+
textures: List[str] # Texture paths
|
|
183
|
+
materials: List[PmxMaterial] # Material list
|
|
184
|
+
bones: List[PmxBone] # Bone list
|
|
185
|
+
morphs: List[PmxMorph] # Morph list
|
|
186
|
+
frames: List[PmxFrame] # Display frames
|
|
187
|
+
rigidbodies: List[PmxRigidBody] # Rigidbody list
|
|
188
|
+
joints: List[PmxJoint] # Joint list
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### VpdPose (VPD Pose)
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
class VpdPose:
|
|
195
|
+
model_name: str # Model name
|
|
196
|
+
bone_poses: List[VpdBonePose] # Bone pose list
|
|
197
|
+
morph_poses: List[VpdMorphPose] # Morph pose list
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## API Reference
|
|
201
|
+
|
|
202
|
+
### Core Functions
|
|
203
|
+
|
|
204
|
+
| Function | Description |
|
|
205
|
+
|------|------|
|
|
206
|
+
| `load_vmd(path)` | Load VMD file |
|
|
207
|
+
| `save_vmd(motion, path)` | Save VMD file |
|
|
208
|
+
| `load_pmx(path)` | Load PMX file |
|
|
209
|
+
| `save_pmx(model, path)` | Save PMX file |
|
|
210
|
+
| `load_vpd(path)` | Load VPD file |
|
|
211
|
+
| `save_vpd(pose, path)` | Save VPD file |
|
|
212
|
+
| `load(path)` | Auto-detect and load |
|
|
213
|
+
| `save(data, path)` | Auto-detect and save |
|
|
214
|
+
|
|
215
|
+
### Text Format Functions
|
|
216
|
+
|
|
217
|
+
| Function | Description |
|
|
218
|
+
|------|------|
|
|
219
|
+
| `load_vmd_text(path)` | Load VMD from text |
|
|
220
|
+
| `save_vmd_text(motion, path)` | Save VMD as text |
|
|
221
|
+
| `load_pmx_text(path)` | Load PMX from text |
|
|
222
|
+
| `save_pmx_text(model, path)` | Save PMX as text |
|
|
223
|
+
| `load_vpd_text(path)` | Load VPD from text |
|
|
224
|
+
| `save_vpd_text(pose, path)` | Save VPD as text |
|
|
225
|
+
| `load_text(path)` | Auto-detect and load text |
|
|
226
|
+
| `save_text(data, path)` | Auto-detect and save text |
|
|
227
|
+
|
|
228
|
+
## Project Structure
|
|
229
|
+
|
|
230
|
+
```
|
|
231
|
+
pypmxvmd/
|
|
232
|
+
├── pypmxvmd/ # Main package
|
|
233
|
+
│ ├── __init__.py # Public API
|
|
234
|
+
│ ├── common/ # Common components
|
|
235
|
+
│ │ ├── models/ # Data models
|
|
236
|
+
│ │ │ ├── vmd.py # VMD data structures
|
|
237
|
+
│ │ │ ├── pmx.py # PMX data structures
|
|
238
|
+
│ │ │ └── vpd.py # VPD data structures
|
|
239
|
+
│ │ └── parsers/ # Parsers
|
|
240
|
+
│ │ ├── vmd_parser_nuthouse.py
|
|
241
|
+
│ │ ├── pmx_parser_nuthouse.py
|
|
242
|
+
│ │ └── vpd_parser.py
|
|
243
|
+
│ └── presentation/ # Presentation layer
|
|
244
|
+
│ ├── cli/ # Command-line interface
|
|
245
|
+
│ └── gui/ # Graphical interface
|
|
246
|
+
├── tests/ # Tests
|
|
247
|
+
├── docs/ # Documentation
|
|
248
|
+
└── mmd_scripting/ # Legacy code (reference)
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Testing
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
# Run all tests
|
|
255
|
+
pytest tests/ -v
|
|
256
|
+
|
|
257
|
+
# Run specific test
|
|
258
|
+
pytest tests/test_vmd_parser.py -v
|
|
259
|
+
|
|
260
|
+
# Run coverage test
|
|
261
|
+
pytest tests/ --cov=pypmxvmd --cov-report=html
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Development
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
# Install development dependencies
|
|
268
|
+
pip install -e ".[dev]"
|
|
269
|
+
|
|
270
|
+
# Code formatting
|
|
271
|
+
black pypmxvmd/
|
|
272
|
+
isort pypmxvmd/
|
|
273
|
+
|
|
274
|
+
# Type checking
|
|
275
|
+
mypy pypmxvmd/
|
|
276
|
+
|
|
277
|
+
# Code linting
|
|
278
|
+
flake8 pypmxvmd/
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## Version History
|
|
282
|
+
|
|
283
|
+
### v2.0.0 (2024)
|
|
284
|
+
- Complete refactor to object-oriented architecture
|
|
285
|
+
- Added complete type annotations
|
|
286
|
+
- Support for text format export/import
|
|
287
|
+
- Improved error handling and validation
|
|
288
|
+
- Added progress callback support
|
|
289
|
+
|
|
290
|
+
### v1.x (Original)
|
|
291
|
+
- Based on Nuthouse01's original implementation
|
|
292
|
+
- Functional API
|
|
293
|
+
|
|
294
|
+
## Acknowledgments
|
|
295
|
+
|
|
296
|
+
This project is refactored from the original MMD scripting tools by [Nuthouse01](https://github.com/Nuthouse01/PMX-VMD-Scripting-Tools).
|
|
297
|
+
|
|
298
|
+
## License
|
|
299
|
+
|
|
300
|
+
MIT License - See [LICENSE](LICENSE) file for details
|
|
301
|
+
|
|
302
|
+
## Contributing
|
|
303
|
+
|
|
304
|
+
Issues and Pull Requests are welcome!
|
|
305
|
+
|
|
306
|
+
1. Fork this repository
|
|
307
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
308
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
309
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
310
|
+
5. Create a Pull Request
|
pypmxvmd-2.0.0/README.md
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
# PyPMXVMD
|
|
2
|
+
|
|
3
|
+
Python MikuMikuDance File Parser Library
|
|
4
|
+
|
|
5
|
+
[](https://www.python.org/downloads/)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://github.com/pypmxvmd/pypmxvmd)
|
|
8
|
+
|
|
9
|
+
PyPMXVMD is a Python library for parsing and modifying MikuMikuDance (MMD) files, supporting the following formats:
|
|
10
|
+
|
|
11
|
+
- **VMD** (Vocaloid Motion Data) - Motion/animation data
|
|
12
|
+
- **PMX** (Polygon Model eXtended) - 3D model data
|
|
13
|
+
- **VPD** (Vocaloid Pose Data) - Pose data
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- Full support for reading and writing VMD, PMX, and VPD files
|
|
18
|
+
- Conversion between binary and text formats
|
|
19
|
+
- Object-oriented API design, easy to use
|
|
20
|
+
- Complete type annotation support
|
|
21
|
+
- No external dependencies (core functionality)
|
|
22
|
+
- Supports Python 3.8+
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Install from source
|
|
28
|
+
git clone https://github.com/pypmxvmd/pypmxvmd.git
|
|
29
|
+
cd pypmxvmd
|
|
30
|
+
pip install -e .
|
|
31
|
+
|
|
32
|
+
# Install development dependencies
|
|
33
|
+
pip install -e ".[dev]"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
### Basic Usage
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
import pypmxvmd
|
|
42
|
+
|
|
43
|
+
# Load VMD motion file
|
|
44
|
+
motion = pypmxvmd.load_vmd("motion.vmd")
|
|
45
|
+
print(f"Bone frames: {len(motion.bone_frames)}")
|
|
46
|
+
print(f"Morph frames: {len(motion.morph_frames)}")
|
|
47
|
+
|
|
48
|
+
# Modify and save
|
|
49
|
+
pypmxvmd.save_vmd(motion, "modified_motion.vmd")
|
|
50
|
+
|
|
51
|
+
# Load PMX model file
|
|
52
|
+
model = pypmxvmd.load_pmx("model.pmx")
|
|
53
|
+
print(f"Vertices: {len(model.vertices)}")
|
|
54
|
+
print(f"Materials: {len(model.materials)}")
|
|
55
|
+
|
|
56
|
+
# Load VPD pose file
|
|
57
|
+
pose = pypmxvmd.load_vpd("pose.vpd")
|
|
58
|
+
print(f"Bone poses: {len(pose.bone_poses)}")
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Automatic Format Detection
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
import pypmxvmd
|
|
65
|
+
|
|
66
|
+
# Automatically detect file type and load
|
|
67
|
+
data = pypmxvmd.load("file.vmd") # Returns VmdMotion
|
|
68
|
+
data = pypmxvmd.load("file.pmx") # Returns PmxModel
|
|
69
|
+
data = pypmxvmd.load("file.vpd") # Returns VpdPose
|
|
70
|
+
|
|
71
|
+
# Automatically detect data type and save
|
|
72
|
+
pypmxvmd.save(motion, "output.vmd")
|
|
73
|
+
pypmxvmd.save(model, "output.pmx")
|
|
74
|
+
pypmxvmd.save(pose, "output.vpd")
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Text Format Conversion
|
|
78
|
+
|
|
79
|
+
PyPMXVMD supports converting binary files to readable text format for viewing and editing:
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
import pypmxvmd
|
|
83
|
+
|
|
84
|
+
# VMD -> Text
|
|
85
|
+
motion = pypmxvmd.load_vmd("motion.vmd")
|
|
86
|
+
pypmxvmd.save_vmd_text(motion, "motion.txt")
|
|
87
|
+
|
|
88
|
+
# Text -> VMD
|
|
89
|
+
motion = pypmxvmd.load_vmd_text("motion.txt")
|
|
90
|
+
pypmxvmd.save_vmd(motion, "motion.vmd")
|
|
91
|
+
|
|
92
|
+
# PMX -> Text
|
|
93
|
+
model = pypmxvmd.load_pmx("model.pmx")
|
|
94
|
+
pypmxvmd.save_pmx_text(model, "model.txt")
|
|
95
|
+
|
|
96
|
+
# VPD -> Text
|
|
97
|
+
pose = pypmxvmd.load_vpd("pose.vpd")
|
|
98
|
+
pypmxvmd.save_vpd_text(pose, "pose.txt")
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Using Parser Classes
|
|
102
|
+
|
|
103
|
+
If you need more control, you can use the parser classes directly:
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from pypmxvmd import VmdParser, PmxParser, VpdParser
|
|
107
|
+
|
|
108
|
+
# VMD Parser
|
|
109
|
+
vmd_parser = VmdParser()
|
|
110
|
+
motion = vmd_parser.parse_file("motion.vmd", more_info=True)
|
|
111
|
+
vmd_parser.write_file(motion, "output.vmd")
|
|
112
|
+
|
|
113
|
+
# PMX Parser
|
|
114
|
+
pmx_parser = PmxParser()
|
|
115
|
+
model = pmx_parser.parse_file("model.pmx", more_info=True)
|
|
116
|
+
pmx_parser.write_file(model, "output.pmx")
|
|
117
|
+
|
|
118
|
+
# VPD Parser
|
|
119
|
+
vpd_parser = VpdParser()
|
|
120
|
+
pose = vpd_parser.parse_file("pose.vpd", more_info=True)
|
|
121
|
+
vpd_parser.write_file(pose, "output.vpd")
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Data Structures
|
|
125
|
+
|
|
126
|
+
### VmdMotion (VMD Motion)
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
class VmdMotion:
|
|
130
|
+
header: VmdHeader # File header information
|
|
131
|
+
bone_frames: List[VmdBoneFrame] # Bone keyframes
|
|
132
|
+
morph_frames: List[VmdMorphFrame] # Morph keyframes
|
|
133
|
+
camera_frames: List[VmdCameraFrame] # Camera keyframes
|
|
134
|
+
light_frames: List[VmdLightFrame] # Light keyframes
|
|
135
|
+
shadow_frames: List[VmdShadowFrame] # Shadow keyframes
|
|
136
|
+
ik_frames: List[VmdIkFrame] # IK keyframes
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### PmxModel (PMX Model)
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
class PmxModel:
|
|
143
|
+
header: PmxHeader # File header information
|
|
144
|
+
vertices: List[PmxVertex] # Vertex list
|
|
145
|
+
faces: List[int] # Face indices
|
|
146
|
+
textures: List[str] # Texture paths
|
|
147
|
+
materials: List[PmxMaterial] # Material list
|
|
148
|
+
bones: List[PmxBone] # Bone list
|
|
149
|
+
morphs: List[PmxMorph] # Morph list
|
|
150
|
+
frames: List[PmxFrame] # Display frames
|
|
151
|
+
rigidbodies: List[PmxRigidBody] # Rigidbody list
|
|
152
|
+
joints: List[PmxJoint] # Joint list
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### VpdPose (VPD Pose)
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
class VpdPose:
|
|
159
|
+
model_name: str # Model name
|
|
160
|
+
bone_poses: List[VpdBonePose] # Bone pose list
|
|
161
|
+
morph_poses: List[VpdMorphPose] # Morph pose list
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## API Reference
|
|
165
|
+
|
|
166
|
+
### Core Functions
|
|
167
|
+
|
|
168
|
+
| Function | Description |
|
|
169
|
+
|------|------|
|
|
170
|
+
| `load_vmd(path)` | Load VMD file |
|
|
171
|
+
| `save_vmd(motion, path)` | Save VMD file |
|
|
172
|
+
| `load_pmx(path)` | Load PMX file |
|
|
173
|
+
| `save_pmx(model, path)` | Save PMX file |
|
|
174
|
+
| `load_vpd(path)` | Load VPD file |
|
|
175
|
+
| `save_vpd(pose, path)` | Save VPD file |
|
|
176
|
+
| `load(path)` | Auto-detect and load |
|
|
177
|
+
| `save(data, path)` | Auto-detect and save |
|
|
178
|
+
|
|
179
|
+
### Text Format Functions
|
|
180
|
+
|
|
181
|
+
| Function | Description |
|
|
182
|
+
|------|------|
|
|
183
|
+
| `load_vmd_text(path)` | Load VMD from text |
|
|
184
|
+
| `save_vmd_text(motion, path)` | Save VMD as text |
|
|
185
|
+
| `load_pmx_text(path)` | Load PMX from text |
|
|
186
|
+
| `save_pmx_text(model, path)` | Save PMX as text |
|
|
187
|
+
| `load_vpd_text(path)` | Load VPD from text |
|
|
188
|
+
| `save_vpd_text(pose, path)` | Save VPD as text |
|
|
189
|
+
| `load_text(path)` | Auto-detect and load text |
|
|
190
|
+
| `save_text(data, path)` | Auto-detect and save text |
|
|
191
|
+
|
|
192
|
+
## Project Structure
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
pypmxvmd/
|
|
196
|
+
├── pypmxvmd/ # Main package
|
|
197
|
+
│ ├── __init__.py # Public API
|
|
198
|
+
│ ├── common/ # Common components
|
|
199
|
+
│ │ ├── models/ # Data models
|
|
200
|
+
│ │ │ ├── vmd.py # VMD data structures
|
|
201
|
+
│ │ │ ├── pmx.py # PMX data structures
|
|
202
|
+
│ │ │ └── vpd.py # VPD data structures
|
|
203
|
+
│ │ └── parsers/ # Parsers
|
|
204
|
+
│ │ ├── vmd_parser_nuthouse.py
|
|
205
|
+
│ │ ├── pmx_parser_nuthouse.py
|
|
206
|
+
│ │ └── vpd_parser.py
|
|
207
|
+
│ └── presentation/ # Presentation layer
|
|
208
|
+
│ ├── cli/ # Command-line interface
|
|
209
|
+
│ └── gui/ # Graphical interface
|
|
210
|
+
├── tests/ # Tests
|
|
211
|
+
├── docs/ # Documentation
|
|
212
|
+
└── mmd_scripting/ # Legacy code (reference)
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Testing
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# Run all tests
|
|
219
|
+
pytest tests/ -v
|
|
220
|
+
|
|
221
|
+
# Run specific test
|
|
222
|
+
pytest tests/test_vmd_parser.py -v
|
|
223
|
+
|
|
224
|
+
# Run coverage test
|
|
225
|
+
pytest tests/ --cov=pypmxvmd --cov-report=html
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## Development
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
# Install development dependencies
|
|
232
|
+
pip install -e ".[dev]"
|
|
233
|
+
|
|
234
|
+
# Code formatting
|
|
235
|
+
black pypmxvmd/
|
|
236
|
+
isort pypmxvmd/
|
|
237
|
+
|
|
238
|
+
# Type checking
|
|
239
|
+
mypy pypmxvmd/
|
|
240
|
+
|
|
241
|
+
# Code linting
|
|
242
|
+
flake8 pypmxvmd/
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## Version History
|
|
246
|
+
|
|
247
|
+
### v2.0.0 (2024)
|
|
248
|
+
- Complete refactor to object-oriented architecture
|
|
249
|
+
- Added complete type annotations
|
|
250
|
+
- Support for text format export/import
|
|
251
|
+
- Improved error handling and validation
|
|
252
|
+
- Added progress callback support
|
|
253
|
+
|
|
254
|
+
### v1.x (Original)
|
|
255
|
+
- Based on Nuthouse01's original implementation
|
|
256
|
+
- Functional API
|
|
257
|
+
|
|
258
|
+
## Acknowledgments
|
|
259
|
+
|
|
260
|
+
This project is refactored from the original MMD scripting tools by [Nuthouse01](https://github.com/Nuthouse01/PMX-VMD-Scripting-Tools).
|
|
261
|
+
|
|
262
|
+
## License
|
|
263
|
+
|
|
264
|
+
MIT License - See [LICENSE](LICENSE) file for details
|
|
265
|
+
|
|
266
|
+
## Contributing
|
|
267
|
+
|
|
268
|
+
Issues and Pull Requests are welcome!
|
|
269
|
+
|
|
270
|
+
1. Fork this repository
|
|
271
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
272
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
273
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
274
|
+
5. Create a Pull Request
|