pypmxvmd 2.0.0__tar.gz → 2.0.1__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 → pypmxvmd-2.0.1}/PKG-INFO +2 -2
- {pypmxvmd-2.0.0 → pypmxvmd-2.0.1}/pypmxvmd/__init__.py +2 -2
- {pypmxvmd-2.0.0 → pypmxvmd-2.0.1}/pypmxvmd.egg-info/PKG-INFO +2 -2
- {pypmxvmd-2.0.0 → pypmxvmd-2.0.1}/pypmxvmd.egg-info/SOURCES.txt +1 -0
- {pypmxvmd-2.0.0 → pypmxvmd-2.0.1}/pyproject.toml +2 -2
- pypmxvmd-2.0.1/tests/test_vmd_comparison.py +162 -0
- pypmxvmd-2.0.1/tests/test_vmd_parser.py +63 -0
- pypmxvmd-2.0.0/tests/test_vmd_parser.py +0 -37
- {pypmxvmd-2.0.0 → pypmxvmd-2.0.1}/README.md +0 -0
- {pypmxvmd-2.0.0 → pypmxvmd-2.0.1}/pypmxvmd.egg-info/dependency_links.txt +0 -0
- {pypmxvmd-2.0.0 → pypmxvmd-2.0.1}/pypmxvmd.egg-info/entry_points.txt +0 -0
- {pypmxvmd-2.0.0 → pypmxvmd-2.0.1}/pypmxvmd.egg-info/requires.txt +0 -0
- {pypmxvmd-2.0.0 → pypmxvmd-2.0.1}/pypmxvmd.egg-info/top_level.txt +0 -0
- {pypmxvmd-2.0.0 → pypmxvmd-2.0.1}/setup.cfg +0 -0
- {pypmxvmd-2.0.0 → pypmxvmd-2.0.1}/tests/test_api_integration.py +0 -0
- {pypmxvmd-2.0.0 → pypmxvmd-2.0.1}/tests/test_pmx_comprehensive.py +0 -0
- {pypmxvmd-2.0.0 → pypmxvmd-2.0.1}/tests/test_pmx_writer.py +0 -0
- {pypmxvmd-2.0.0 → pypmxvmd-2.0.1}/tests/test_quick_integration.py +0 -0
- {pypmxvmd-2.0.0 → pypmxvmd-2.0.1}/tests/test_text_processing.py +0 -0
- {pypmxvmd-2.0.0 → pypmxvmd-2.0.1}/tests/test_vmd_comprehensive.py +0 -0
- {pypmxvmd-2.0.0 → pypmxvmd-2.0.1}/tests/test_vmd_header.py +0 -0
- {pypmxvmd-2.0.0 → pypmxvmd-2.0.1}/tests/test_vpd_parser.py +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pypmxvmd
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.1
|
|
4
4
|
Summary: Wrapper for reading and modifying VMD and PMX files
|
|
5
|
-
Author-email:
|
|
5
|
+
Author-email: PythonImporter <271374667@qq.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/pypmxvmd/pypmxvmd
|
|
7
7
|
Project-URL: Documentation, https://pypmxvmd.readthedocs.io/
|
|
8
8
|
Project-URL: Repository, https://github.com/pypmxvmd/pypmxvmd
|
|
@@ -36,8 +36,8 @@ from .common.models.vmd import VmdMotion
|
|
|
36
36
|
from .common.models.pmx import PmxModel
|
|
37
37
|
from .common.models.vpd import VpdPose
|
|
38
38
|
|
|
39
|
-
__version__ = "2.0.
|
|
40
|
-
__author__ = "
|
|
39
|
+
__version__ = "2.0.1"
|
|
40
|
+
__author__ = "PythonImporter"
|
|
41
41
|
__description__ = "Python MikuMikuDance File Parser"
|
|
42
42
|
|
|
43
43
|
# Core parser instances (reused for efficiency)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pypmxvmd
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.1
|
|
4
4
|
Summary: Wrapper for reading and modifying VMD and PMX files
|
|
5
|
-
Author-email:
|
|
5
|
+
Author-email: PythonImporter <271374667@qq.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/pypmxvmd/pypmxvmd
|
|
7
7
|
Project-URL: Documentation, https://pypmxvmd.readthedocs.io/
|
|
8
8
|
Project-URL: Repository, https://github.com/pypmxvmd/pypmxvmd
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "pypmxvmd"
|
|
3
|
-
version = "2.0.
|
|
3
|
+
version = "2.0.1"
|
|
4
4
|
description = "Wrapper for reading and modifying VMD and PMX files"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.8"
|
|
7
7
|
authors = [
|
|
8
|
-
{name = "
|
|
8
|
+
{name = "PythonImporter", email = "271374667@qq.com"}
|
|
9
9
|
]
|
|
10
10
|
keywords = ["mmd", "mikumikudance", "pmx", "vmd", "vpd", "3d", "animation"]
|
|
11
11
|
classifiers = [
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""VMD解析器对比测试脚本
|
|
3
|
+
|
|
4
|
+
此脚本对比三个项目的VMD解析能力:
|
|
5
|
+
1. mmd_scripting - 原始有bug的版本
|
|
6
|
+
2. pymmd - 修复后的版本
|
|
7
|
+
3. pypmxvmd - 重构后的版本(应该也已修复)
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import sys
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
# 添加项目根目录到路径
|
|
14
|
+
project_root = Path(__file__).parent.parent
|
|
15
|
+
sys.path.insert(0, str(project_root))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def test_format_strings():
|
|
19
|
+
"""测试Bug 2: 结构体对齐错误"""
|
|
20
|
+
print("\n" + "="*80)
|
|
21
|
+
print("Bug 2 测试: 结构体格式字符串对齐")
|
|
22
|
+
print("="*80)
|
|
23
|
+
|
|
24
|
+
import struct
|
|
25
|
+
|
|
26
|
+
# Bug 2的问题:缺少 < 前缀导致使用原生对齐,会添加填充字节
|
|
27
|
+
|
|
28
|
+
# 错误的格式(无<前缀)- 原始mmd_scripting版本
|
|
29
|
+
fmt_shadowframe_buggy = "I b f"
|
|
30
|
+
fmt_ikdispframe_buggy = "I ? I"
|
|
31
|
+
|
|
32
|
+
# 正确的格式(有<前缀)- 修复后的pymmd和pypmxvmd版本
|
|
33
|
+
fmt_shadowframe_fixed = "<I b f"
|
|
34
|
+
fmt_ikdispframe_fixed = "<I ? I"
|
|
35
|
+
|
|
36
|
+
buggy_shadow_size = struct.calcsize(fmt_shadowframe_buggy)
|
|
37
|
+
fixed_shadow_size = struct.calcsize(fmt_shadowframe_fixed)
|
|
38
|
+
buggy_ik_size = struct.calcsize(fmt_ikdispframe_buggy)
|
|
39
|
+
fixed_ik_size = struct.calcsize(fmt_ikdispframe_fixed)
|
|
40
|
+
|
|
41
|
+
print(f"\n[+] 结构体大小对比:")
|
|
42
|
+
print(f" 阴影帧 (Shadow Frame):")
|
|
43
|
+
print(f" 有bug版本 '{fmt_shadowframe_buggy}': {buggy_shadow_size} 字节")
|
|
44
|
+
print(f" 修复版本 '{fmt_shadowframe_fixed}': {fixed_shadow_size} 字节")
|
|
45
|
+
print(f" 差异: {buggy_shadow_size - fixed_shadow_size} 字节")
|
|
46
|
+
|
|
47
|
+
print(f"\n IK帧 (IK Disp Frame):")
|
|
48
|
+
print(f" 有bug版本 '{fmt_ikdispframe_buggy}': {buggy_ik_size} 字节")
|
|
49
|
+
print(f" 修复版本 '{fmt_ikdispframe_fixed}': {fixed_ik_size} 字节")
|
|
50
|
+
print(f" 差异: {buggy_ik_size - fixed_ik_size} 字节")
|
|
51
|
+
|
|
52
|
+
# 验证修复是否正确
|
|
53
|
+
if buggy_shadow_size == 12 and fixed_shadow_size == 9:
|
|
54
|
+
print(f"\n[OK] 阴影帧修复正确: 从12字节(有填充)修复为9字节(无填充)")
|
|
55
|
+
else:
|
|
56
|
+
print(f"\n[!] 警告: 阴影帧大小不符合预期")
|
|
57
|
+
|
|
58
|
+
if buggy_ik_size == 12 and fixed_ik_size == 9:
|
|
59
|
+
print(f"[OK] IK帧修复正确: 从12字节(有填充)修复为9字节(无填充)")
|
|
60
|
+
else:
|
|
61
|
+
print(f"[!] 警告: IK帧大小不符合预期")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def check_parser_format_strings():
|
|
65
|
+
"""检查各个解析器的格式字符串定义"""
|
|
66
|
+
print("\n" + "="*80)
|
|
67
|
+
print("解析器格式字符串检查")
|
|
68
|
+
print("="*80)
|
|
69
|
+
|
|
70
|
+
# 检查pypmxvmd解析器
|
|
71
|
+
try:
|
|
72
|
+
from pypmxvmd.common.parsers.vmd_parser import VmdParser
|
|
73
|
+
parser = VmdParser()
|
|
74
|
+
|
|
75
|
+
print(f"\n[+] pypmxvmd 解析器:")
|
|
76
|
+
print(f" _FMT_SHADOWFRAME = {repr(parser._FMT_SHADOWFRAME)}")
|
|
77
|
+
print(f" _FMT_IKDISPFRAME = {repr(parser._FMT_IKDISPFRAME)}")
|
|
78
|
+
print(f" _FMT_MORPHFRAME = {repr(parser._FMT_MORPHFRAME)}")
|
|
79
|
+
|
|
80
|
+
has_prefix = (
|
|
81
|
+
parser._FMT_SHADOWFRAME.startswith('<') and
|
|
82
|
+
parser._FMT_IKDISPFRAME.startswith('<') and
|
|
83
|
+
parser._FMT_MORPHFRAME.startswith('<')
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
if has_prefix:
|
|
87
|
+
print(f" [OK] 所有格式字符串都有 '<' 前缀 - Bug已修复")
|
|
88
|
+
else:
|
|
89
|
+
print(f" [FAIL] 某些格式字符串缺少 '<' 前缀 - Bug仍存在")
|
|
90
|
+
|
|
91
|
+
except Exception as e:
|
|
92
|
+
print(f" [ERROR] 无法加载pypmxvmd解析器: {e}")
|
|
93
|
+
|
|
94
|
+
# 检查pymmd解析器
|
|
95
|
+
try:
|
|
96
|
+
from pymmd.common.parsers.vmd_parser import VmdParser as PyMMDParser
|
|
97
|
+
parser = PyMMDParser()
|
|
98
|
+
|
|
99
|
+
print(f"\n[+] pymmd 解析器:")
|
|
100
|
+
print(f" _FMT_SHADOWFRAME = {repr(parser._FMT_SHADOWFRAME)}")
|
|
101
|
+
print(f" _FMT_IKDISPFRAME = {repr(parser._FMT_IKDISPFRAME)}")
|
|
102
|
+
print(f" _FMT_MORPHFRAME = {repr(parser._FMT_MORPHFRAME)}")
|
|
103
|
+
|
|
104
|
+
has_prefix = (
|
|
105
|
+
parser._FMT_SHADOWFRAME.startswith('<') and
|
|
106
|
+
parser._FMT_IKDISPFRAME.startswith('<') and
|
|
107
|
+
parser._FMT_MORPHFRAME.startswith('<')
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
if has_prefix:
|
|
111
|
+
print(f" [OK] 所有格式字符串都有 '<' 前缀 - Bug已修复")
|
|
112
|
+
else:
|
|
113
|
+
print(f" [FAIL] 某些格式字符串缺少 '<' 前缀 - Bug仍存在")
|
|
114
|
+
|
|
115
|
+
except Exception as e:
|
|
116
|
+
print(f" [ERROR] 无法加载pymmd解析器: {e}")
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def test_bug_description():
|
|
120
|
+
"""显示bug的详细说明"""
|
|
121
|
+
print("\n" + "="*80)
|
|
122
|
+
print("VMD解析器Bug说明")
|
|
123
|
+
print("="*80)
|
|
124
|
+
|
|
125
|
+
print("""
|
|
126
|
+
[BUG 1] 位置跟踪错误 (Position Tracking Error)
|
|
127
|
+
问题位置: 多个解析函数的长度检查
|
|
128
|
+
错误代码: if (len(data) - self._io_handler._position) < struct.calcsize(...)
|
|
129
|
+
修复代码: if len(data) < struct.calcsize(...)
|
|
130
|
+
|
|
131
|
+
影响: 由于data在读取时会被消费(del data[:size]),len(data)已经是剩余长度,
|
|
132
|
+
再减去_position会导致负值,使解析器完全跳过morph/camera/light/shadow/IK帧。
|
|
133
|
+
|
|
134
|
+
[BUG 2] 结构体对齐错误 (Struct Alignment Error)
|
|
135
|
+
问题位置: 格式字符串定义(lines 30-39)
|
|
136
|
+
错误代码: FMT_SHADOWFRAME = "I b f" # 12字节(有填充)
|
|
137
|
+
FMT_IKDISPFRAME = "I ? I" # 12字节(有填充)
|
|
138
|
+
修复代码: FMT_SHADOWFRAME = "<I b f" # 9字节(无填充)
|
|
139
|
+
FMT_IKDISPFRAME = "<I ? I" # 9字节(无填充)
|
|
140
|
+
|
|
141
|
+
影响: 缺少 < 前缀导致struct使用原生对齐并添加填充字节,使shadow帧和IK帧
|
|
142
|
+
多消费3字节,导致后续数据解析错误。
|
|
143
|
+
""")
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
if __name__ == "__main__":
|
|
147
|
+
print("\n" + "="*80)
|
|
148
|
+
print("VMD解析器Bug修复验证测试")
|
|
149
|
+
print("="*80)
|
|
150
|
+
|
|
151
|
+
# 显示bug说明
|
|
152
|
+
test_bug_description()
|
|
153
|
+
|
|
154
|
+
# 测试格式字符串大小
|
|
155
|
+
test_format_strings()
|
|
156
|
+
|
|
157
|
+
# 检查解析器的格式字符串
|
|
158
|
+
check_parser_format_strings()
|
|
159
|
+
|
|
160
|
+
print("\n" + "="*80)
|
|
161
|
+
print("测试完成")
|
|
162
|
+
print("="*80)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""VMD解析器测试脚本"""
|
|
3
|
+
|
|
4
|
+
import sys
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
# 添加项目根目录到路径
|
|
8
|
+
sys.path.insert(0, str(Path(__file__).parent))
|
|
9
|
+
|
|
10
|
+
from pypmxvmd.common.parsers.vmd_parser import VmdParser
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_vmd_parser():
|
|
14
|
+
"""测试VMD解析器并输出为文本"""
|
|
15
|
+
parser = VmdParser()
|
|
16
|
+
|
|
17
|
+
# 查找项目中的VMD文件进行测试
|
|
18
|
+
project_root = Path(__file__).parent
|
|
19
|
+
vmd_files = list(project_root.glob("**/*.vmd"))
|
|
20
|
+
|
|
21
|
+
if not vmd_files:
|
|
22
|
+
print("未找到VMD文件进行测试")
|
|
23
|
+
return
|
|
24
|
+
|
|
25
|
+
for vmd_file in vmd_files[:1]: # 只测试第一个文件
|
|
26
|
+
print(f"\n{'='*60}")
|
|
27
|
+
print(f"测试VMD文件: {vmd_file}")
|
|
28
|
+
print(f"{'='*60}\n")
|
|
29
|
+
|
|
30
|
+
try:
|
|
31
|
+
# 解析VMD文件
|
|
32
|
+
result = parser.parse_file(vmd_file, more_info=True)
|
|
33
|
+
print(f"\n✅ 解析成功!")
|
|
34
|
+
print(f" 版本: {result.header.version}")
|
|
35
|
+
print(f" 模型: {result.header.model_name}")
|
|
36
|
+
print(f" 骨骼帧数: {len(result.bone_frames)}")
|
|
37
|
+
print(f" 变形帧数: {len(result.morph_frames)}")
|
|
38
|
+
print(f" 相机帧数: {len(result.camera_frames)}")
|
|
39
|
+
print(f" 光源帧数: {len(result.light_frames)}")
|
|
40
|
+
print(f" 阴影帧数: {len(result.shadow_frames)}")
|
|
41
|
+
print(f" IK帧数: {len(result.ik_frames)}")
|
|
42
|
+
|
|
43
|
+
# 输出为文本文件
|
|
44
|
+
output_txt = vmd_file.with_suffix('.txt')
|
|
45
|
+
parser.write_text_file(result, output_txt)
|
|
46
|
+
print(f"\n📄 文本输出已保存至: {output_txt}")
|
|
47
|
+
|
|
48
|
+
# 显示部分变形帧数据用于验证
|
|
49
|
+
if result.morph_frames:
|
|
50
|
+
print(f"\n🔍 前5个变形帧预览:")
|
|
51
|
+
for i, morph in enumerate(result.morph_frames[:5]):
|
|
52
|
+
print(f" [{i+1}] 帧{morph.frame_number}: {morph.morph_name} = {morph.weight:.6f}")
|
|
53
|
+
else:
|
|
54
|
+
print(f"\n⚠️ 警告: 未找到变形帧数据!")
|
|
55
|
+
|
|
56
|
+
except Exception as e:
|
|
57
|
+
print(f"\n❌ 解析失败: {e}")
|
|
58
|
+
import traceback
|
|
59
|
+
traceback.print_exc()
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
if __name__ == "__main__":
|
|
63
|
+
test_vmd_parser()
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""VMD解析器测试脚本"""
|
|
3
|
-
|
|
4
|
-
import sys
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
|
|
7
|
-
# 添加项目根目录到路径
|
|
8
|
-
sys.path.insert(0, str(Path(__file__).parent))
|
|
9
|
-
|
|
10
|
-
from pypmxvmd.common.parsers.vmd_parser import VmdParser
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def test_vmd_parser():
|
|
14
|
-
"""测试VMD解析器"""
|
|
15
|
-
parser = VmdParser()
|
|
16
|
-
|
|
17
|
-
# 查找项目中的VMD文件进行测试
|
|
18
|
-
project_root = Path(__file__).parent
|
|
19
|
-
vmd_files = list(project_root.glob("**/*.vmd"))
|
|
20
|
-
|
|
21
|
-
if not vmd_files:
|
|
22
|
-
print("未找到VMD文件进行测试")
|
|
23
|
-
return
|
|
24
|
-
|
|
25
|
-
for vmd_file in vmd_files[:1]: # 只测试第一个文件
|
|
26
|
-
print(f"测试VMD文件: {vmd_file}")
|
|
27
|
-
try:
|
|
28
|
-
result = parser.parse_file(vmd_file, more_info=True)
|
|
29
|
-
print(f"解析成功!版本: {result.header.version}, 模型: {result.header.model_name}")
|
|
30
|
-
except Exception as e:
|
|
31
|
-
print(f"解析失败: {e}")
|
|
32
|
-
import traceback
|
|
33
|
-
traceback.print_exc()
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if __name__ == "__main__":
|
|
37
|
-
test_vmd_parser()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|