• R/O
  • HTTP
  • SSH
  • HTTPS

pymeshio: Commit

pmdとmqoの入出力ライブラリと、それを使ったBlender2.5向けのaddon。


Commit MetaInfo

Revision0f304057cda88bde341c40107b9e22fa931c7890 (tree)
Time2011-10-12 04:24:57
Authorousttrue <ousttrue@gmai...>
Commiterousttrue

Log Message

fix for pmxmca

Change Summary

Incremental Difference

--- a/pymeshio/common.py
+++ b/pymeshio/common.py
@@ -5,6 +5,7 @@ common utilities.
55 import math
66 import struct
77 import sys
8+import io
89
910
1011 def unicode(src):
@@ -311,10 +312,16 @@ class BinaryReader(object):
311312 """general BinaryReader
312313 """
313314 def __init__(self, ios):
315+ current=ios.tell()
316+ ios.seek(0, io.SEEK_END)
317+ self.end=ios.tell()
318+ ios.seek(current)
314319 self.ios=ios
315320
316321 def is_end(self):
317- return not self.ios.readable()
322+ #print(self.ios.tell(), self.end)
323+ return self.ios.tell()>=self.end
324+ #return not self.ios.readable()
318325
319326 def unpack(self, fmt, size):
320327 result=struct.unpack(fmt, self.ios.read(size))
--- a/pymeshio/converter.py
+++ b/pymeshio/converter.py
@@ -266,18 +266,19 @@ def pmd_to_pmx(src):
266266 # bones
267267 def get_panel(m):
268268 return 1
269- base=src.morphs[0]
270- assert(base.name==b"base")
271- dst.morphs=[
272- pmx.Morph(
273- name=m.name.decode('cp932'),
274- english_name=m.english_name.decode('cp932'),
275- panel=get_panel(m),
276- morph_type=1,
277- offsets=[pmx.VerexMorphOffset(base.indices[i], pos)
278- for i, pos in zip(m.indices, m.pos_list)]
279- )
280- for i, m in enumerate(src.morphs) if m.name!=b"base"]
269+ if len(src.morphs)>0:
270+ base=src.morphs[0]
271+ assert(base.name==b"base")
272+ dst.morphs=[
273+ pmx.Morph(
274+ name=m.name.decode('cp932'),
275+ english_name=m.english_name.decode('cp932'),
276+ panel=get_panel(m),
277+ morph_type=1,
278+ offsets=[pmx.VerexMorphOffset(base.indices[i], pos)
279+ for i, pos in zip(m.indices, m.pos_list)]
280+ )
281+ for i, m in enumerate(src.morphs) if m.name!=b"base"]
281282 # display_slots
282283 dst.display_slots=[
283284 pmx.DisplaySlot(u('Root'), u('Root'), 1),
--- a/pymeshio/pmd/reader.py
+++ b/pymeshio/pmd/reader.py
@@ -142,19 +142,19 @@ def __read(reader, model):
142142 ############################################################
143143 # extend1: english name
144144 ############################################################
145- if reader.read_uint(1)==0:
146- #print("no extend flag")
147- return True
148- model.english_name=reader.read_text(20)
149- model.english_comment=reader.read_text(256)
150- for bone in model.bones:
151- bone.english_name=reader.read_text(20)
152- for morph in model.morphs:
153- if morph.name==b'base':
154- continue
155- morph.english_name=reader.read_text(20)
156- for g in model.bone_group_list:
157- g.english_name=reader.read_text(50)
145+ if reader.read_uint(1)==1:
146+ print("no extend flag")
147+ #return True
148+ model.english_name=reader.read_text(20)
149+ model.english_comment=reader.read_text(256)
150+ for bone in model.bones:
151+ bone.english_name=reader.read_text(20)
152+ for morph in model.morphs:
153+ if morph.name==b'base':
154+ continue
155+ morph.english_name=reader.read_text(20)
156+ for g in model.bone_group_list:
157+ g.english_name=reader.read_text(50)
158158
159159
160160 ############################################################
Show on old repository browser