回答編集履歴
6
変数名変更
test
CHANGED
@@ -134,19 +134,19 @@
|
|
134
134
|
|
135
135
|
mocfiles = glob.glob('./live2D/' + str(dir) + '/**/*.moc')
|
136
136
|
|
137
|
-
model_e
|
137
|
+
model_value = str(mocfiles)[len(dir) + 13:-2].replace('\', '/')
|
138
138
|
|
139
139
|
|
140
140
|
|
141
141
|
phyfiles = glob.glob('./live2D/' + str(dir) + '/**/*physics.json')
|
142
142
|
|
143
|
-
physics_e
|
143
|
+
physics_vslue = str(phyfiles)[len(dir) + 13:-2].replace('\', '/')
|
144
144
|
|
145
145
|
|
146
146
|
|
147
147
|
mtnfiles = glob.glob('./live2D/' + str(dir) + '/**/*.mtn')
|
148
148
|
|
149
|
-
motions_idle_e
|
149
|
+
motions_idle_value = [{"file": str(mtn)[len(dir) + 10:].replace('\', '/')} for mtn in mtnfiles]
|
150
150
|
|
151
151
|
|
152
152
|
|
@@ -154,7 +154,7 @@
|
|
154
154
|
|
155
155
|
"name": "Live2D",
|
156
156
|
|
157
|
-
"model": model_e
|
157
|
+
"model": model_value,
|
158
158
|
|
159
159
|
"textures": [
|
160
160
|
|
@@ -164,13 +164,13 @@
|
|
164
164
|
|
165
165
|
"motions": {
|
166
166
|
|
167
|
-
"idle": motions_idle_e
|
167
|
+
"idle": motions_idle_value,
|
168
168
|
|
169
169
|
"tap": [{"name": 0, "file": 0}]},
|
170
170
|
|
171
171
|
"expressions": [{"name": 0, "file": 0}],
|
172
172
|
|
173
|
-
"physics": physics_e
|
173
|
+
"physics": physics_value,
|
174
174
|
|
175
175
|
"lip_sync": "true"
|
176
176
|
|
5
追記
test
CHANGED
@@ -119,3 +119,65 @@
|
|
119
119
|
|
120
120
|
|
121
121
|
`dic["motions"]["idle"]`を空リストで用意しておいて、**新しい辞書**をappendしていけばいいのでは。
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
----
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
というかこの感じなら
|
130
|
+
|
131
|
+
```python
|
132
|
+
|
133
|
+
for dir in files_dir:
|
134
|
+
|
135
|
+
mocfiles = glob.glob('./live2D/' + str(dir) + '/**/*.moc')
|
136
|
+
|
137
|
+
model_entry = str(mocfiles)[len(dir) + 13:-2].replace('\', '/')
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
phyfiles = glob.glob('./live2D/' + str(dir) + '/**/*physics.json')
|
142
|
+
|
143
|
+
physics_entry = str(phyfiles)[len(dir) + 13:-2].replace('\', '/')
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
mtnfiles = glob.glob('./live2D/' + str(dir) + '/**/*.mtn')
|
148
|
+
|
149
|
+
motions_idle_entry = [{"file": str(mtn)[len(dir) + 10:].replace('\', '/')} for mtn in mtnfiles]
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
dic = {
|
154
|
+
|
155
|
+
"name": "Live2D",
|
156
|
+
|
157
|
+
"model": model_entry,
|
158
|
+
|
159
|
+
"textures": [
|
160
|
+
|
161
|
+
"Texture2D/texture_00.png"
|
162
|
+
|
163
|
+
],
|
164
|
+
|
165
|
+
"motions": {
|
166
|
+
|
167
|
+
"idle": motions_idle_entry,
|
168
|
+
|
169
|
+
"tap": [{"name": 0, "file": 0}]},
|
170
|
+
|
171
|
+
"expressions": [{"name": 0, "file": 0}],
|
172
|
+
|
173
|
+
"physics": physics_entry,
|
174
|
+
|
175
|
+
"lip_sync": "true"
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
(略)
|
180
|
+
|
181
|
+
```
|
182
|
+
|
183
|
+
と構築するかな、と思いました。
|
4
文字数制限? かもしれないので省略
test
CHANGED
@@ -28,47 +28,7 @@
|
|
28
28
|
|
29
29
|
... {"file":"../motion/angry01.mtn"},
|
30
30
|
|
31
|
-
... {"file":"../motion/angry02.mtn"},
|
32
|
-
|
33
|
-
... {"file":"../motion/bye01.mtn"},
|
34
|
-
|
35
|
-
... {"file":"../motion/cry01.mtn"},
|
36
|
-
|
37
|
-
... {"file":"../motion/idle01.mtn"},
|
38
|
-
|
39
|
-
... {"file":"../motion/idle02.mtn"},
|
40
|
-
|
41
|
-
... {"file":"../motion/kime01.mtn"},
|
42
|
-
|
43
|
-
|
31
|
+
(略)
|
44
|
-
|
45
|
-
... {"file":"../motion/nf02.mtn"},
|
46
|
-
|
47
|
-
... {"file":"../motion/nf03.mtn"},
|
48
|
-
|
49
|
-
... {"file":"../motion/nf04.mtn"},
|
50
|
-
|
51
|
-
... {"file":"../motion/nf05.mtn"},
|
52
|
-
|
53
|
-
... {"file":"../motion/nf_left01.mtn"},
|
54
|
-
|
55
|
-
... {"file":"../motion/nf_right01.mtn"},
|
56
|
-
|
57
|
-
... {"file":"../motion/pui01.mtn"},
|
58
|
-
|
59
|
-
... {"file":"../motion/sad01.mtn"},
|
60
|
-
|
61
|
-
... {"file":"../motion/serious01.mtn"},
|
62
|
-
|
63
|
-
... {"file":"../motion/shame01.mtn"},
|
64
|
-
|
65
|
-
... {"file":"../motion/smile01.mtn"},
|
66
|
-
|
67
|
-
... {"file":"../motion/smile02.mtn"},
|
68
|
-
|
69
|
-
... {"file":"../motion/smile03.mtn"},
|
70
|
-
|
71
|
-
... {"file":"../motion/sneeze01.mtn"},
|
72
32
|
|
73
33
|
... {"file":"../motion/surprised01.mtn"}
|
74
34
|
|
@@ -86,49 +46,7 @@
|
|
86
46
|
|
87
47
|
'motions': {'idle': [{'file': '../motion/angry01.mtn'},
|
88
48
|
|
89
|
-
{'file': '../motion/angry02.mtn'},
|
90
|
-
|
91
|
-
{'file': '../motion/bye01.mtn'},
|
92
|
-
|
93
|
-
{'file': '../motion/cry01.mtn'},
|
94
|
-
|
95
|
-
{'file': '../motion/idle01.mtn'},
|
96
|
-
|
97
|
-
{'file': '../motion/idle02.mtn'},
|
98
|
-
|
99
|
-
{'file': '../motion/kime01.mtn'},
|
100
|
-
|
101
|
-
{'file': '../motion/nf01.mtn'},
|
102
|
-
|
103
|
-
{'file': '../motion/nf02.mtn'},
|
104
|
-
|
105
|
-
{'file': '../motion/nf03.mtn'},
|
106
|
-
|
107
|
-
{'file': '../motion/nf04.mtn'},
|
108
|
-
|
109
|
-
{'file': '../motion/nf05.mtn'},
|
110
|
-
|
111
|
-
{'file': '../motion/nf_left01.mtn'},
|
112
|
-
|
113
|
-
{'file': '../motion/nf_right01.mtn'},
|
114
|
-
|
115
|
-
{'file': '../motion/pui01.mtn'},
|
116
|
-
|
117
|
-
{'file': '../motion/sad01.mtn'},
|
118
|
-
|
119
|
-
{'file': '../motion/serious01.mtn'},
|
120
|
-
|
121
|
-
{'file': '../motion/shame01.mtn'},
|
122
|
-
|
123
|
-
{'file': '../motion/smile01.mtn'},
|
124
|
-
|
125
|
-
{'file': '../motion/smile02.mtn'},
|
126
|
-
|
127
|
-
{'file': '../motion/smile03.mtn'},
|
128
|
-
|
129
|
-
{'file': '../motion/sneeze01.mtn'},
|
130
|
-
|
131
|
-
{'file': '../motion/surprised01.mtn'}]},
|
49
|
+
(略) {'file': '../motion/surprised01.mtn'}]},
|
132
50
|
|
133
51
|
'textures': ['XXX.png']}
|
134
52
|
|
3
追記
test
CHANGED
@@ -149,3 +149,55 @@
|
|
149
149
|
この部分で、具体的にどういうコードを書いて何が起こったのかを書きましょう。
|
150
150
|
|
151
151
|
**あなたがなにをしたのかまったく伝わりません。**
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
----
|
156
|
+
|
157
|
+
`"tap"`がわからないので手を付けませんが、"idle"はこうじゃないですか?
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
```python
|
162
|
+
|
163
|
+
for dir in files_dir :
|
164
|
+
|
165
|
+
# dic = {"name":"Live2D","model":"moc/Live2D.moc","textures":["Texture2D/texture_00.png"],"motions":{"idle":[{"name":0,"file":0}],"tap":[{"name":0,"file":0}]},"expressions":[{"name":0,"file":0}],"physics":"physics/physics.json","lip_sync":"true"}
|
166
|
+
|
167
|
+
dic = {"name":"Live2D","model":"moc/Live2D.moc","textures":["Texture2D/texture_00.png"],"motions":{"idle":[],"tap":[{"name":0,"file":0}]},"expressions":[{"name":0,"file":0}],"physics":"physics/physics.json","lip_sync":"true"}
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
mocfiles = glob.glob('./live2D/'+str(dir)+'/**/*.moc')
|
172
|
+
|
173
|
+
dic["model"] = str(mocfiles)[len(dir)+13:-2].replace('\','/')
|
174
|
+
|
175
|
+
phyfiles = glob.glob('./live2D/'+str(dir)+'/**/*physics.json')
|
176
|
+
|
177
|
+
dic["physics"] = str(phyfiles)[len(dir)+13:-2].replace('\','/')
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
mtnfiles = glob.glob('./live2D/'+str(dir)+'/**/*.mtn')
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
for mtn in mtnfiles:
|
186
|
+
|
187
|
+
# dic["motions"]["idle"] が list
|
188
|
+
|
189
|
+
dic["motions"]["idle"].append({"file":str(mtn)[len(dir)+10:].replace('\','/')})
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
with open (r"./Live2D/"+dir+"/model.json","w") as f:
|
194
|
+
|
195
|
+
f.write(json.dumps(dic, ensure_ascii=False, indent=4, sort_keys=False, separators=(',', ': ')))
|
196
|
+
|
197
|
+
print(json.dumps(dic, ensure_ascii=False, indent=4, sort_keys=False, separators=(',', ': ')))
|
198
|
+
|
199
|
+
```
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
`dic["motions"]["idle"]`を空リストで用意しておいて、**新しい辞書**をappendしていけばいいのでは。
|
2
意図を明確にした
test
CHANGED
@@ -136,7 +136,9 @@
|
|
136
136
|
|
137
137
|
|
138
138
|
|
139
|
+
リテラルとして表現可能なオブジェクトである以上、Pythonの辞書で表現できないわけがありません。
|
140
|
+
|
139
|
-
あ
|
141
|
+
純粋にコードに問題があるだけです。
|
140
142
|
|
141
143
|
|
142
144
|
|
1
些細
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
`"idle"`要素(array)の最初のデータの末尾に`,`が抜けていますが、これ自体普通にPythonのオブジェクトとして解釈可能
|
9
|
+
`"idle"`要素(array)の最初のデータの末尾に`,`が抜けていますが、そこさえ修正してしまえば、これ自体普通にPythonのオブジェクトとして解釈可能なコードになっています。
|
10
10
|
|
11
11
|
|
12
12
|
|