From 9605a347880a8ad2809383c6851661550fc23c6b Mon Sep 17 00:00:00 2001 From: ousttrue Date: Sun, 2 Oct 2011 23:07:06 +0900 Subject: [PATCH] fix refactoring --- blender25-meshio/__init__.pyc | Bin 6922 -> 0 bytes examples/mqobuilder.py | 9 ++++----- examples/pmdbuilder.py | 22 +++++++++++----------- examples/pmxbuilder.py | 5 ++--- pymeshio/mqo/__init__.py | 15 +-------------- pymeshio/mqo/reader.py | 7 ++++--- pymeshio/pmd/__init__.py | 10 ---------- pymeshio/pmx/reader.py | 2 +- test/mqo_test.py | 4 ---- test/mqo_test.pyc | Bin 911 -> 699 bytes test/pmd_test.py | 5 ----- test/pmd_test.pyc | Bin 2810 -> 2556 bytes 12 files changed, 23 insertions(+), 56 deletions(-) delete mode 100644 blender25-meshio/__init__.pyc diff --git a/blender25-meshio/__init__.pyc b/blender25-meshio/__init__.pyc deleted file mode 100644 index 24c46909b3d74415a8d2e32f261a1813ea843969..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6922 zcmd5=&2Jn@6|eU9*yGr766eFodN!L)CfUsx76=fQd^+A(V8>fdw93d*)1EHdJ?@#F zboXR4s~{mIH?-o!fxU5qQ*KCb=fIUefh(sKS0woTUUg=AoQMr}gc!T4>*H1Rt5@&+ z>Q^=RkIC_`U;JsMrn27<-Z$_he{qxwCX}y~@2D&Ofbs|NT2THdUSrBH;5DxN3A~ER zpTz5s@~7~cR{mjIn!)Rc@{i(mO!>3wN)>}0SH@A#l-eCp@eAdjQ2t334yYEdvdBTTi#a(v-leYGN#%baa;KF4 zp=9Qie_1l8l{usQirO7e@t++tM@7YMC)IlSTU^qkNE#;D38G4=Txm7@i{(n=QFJlo zqBp&UNym_h+DV$mZIh0m;I-48C=LdY4ThPFB1xHShNkJ8I5_`HR1BiRYX$O!r64q= zYo+BzD~i+0cb@Pi1BX$~OM|GHoQ8B?b7^g5abe}tdnIaTl5_$BzDa6v&|-%aMf=gu zy|@`Px05rd*h$mY)rEy@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Nnk zGsa}L$~iHdV@2SXH8jbO-2}A0KxW^dRWGPIASw@Caul*BA$t(=XB5vs;8jNv#G^nm zoP`K!MMByvKK}}xA`$MVQzYqvHvM$Uq+VhkwS&lWA(5w57{V?%>hs{nVn4Wv$FJAC z&{#~PV@R=-?wAr)+3X-2B&Ek*h(iIFvjOn9eEam@|90inbz9***+#wk#q-Kd@s1?g zN?nTm^Y>r>b!BtydagE;#VP8>_E*2*?~m8JNI8U2BnbA2lyA=FEX}eM9%hju-r3$K zm}#koz#*yjUL?%n-Xfa+JKSTBgZaLI6V3iA?oCpiH^n`PZSH+798(fKgIvZr=@b`G z?CB}F{g6g|4dXn-lhEb!2v`)-RdkLWlyX^MqxvgZU_^ljnuSHZn8P!ASPrPDmjx=4 zy&h2Y=DeTj_He1^QW3^a#*iqdfWJOM^;&HD14Q?YO?{}8BUENW)r+b=DX;~!0)8Pc zS2ultg?kO$T>!Rb1-1^UtfQrBxUN7)+*Nc(p5i^ubKu%EagE$b0BhZQY)W1!zalT; zts(*zv)zoQy#~=Tg7xNzmh6|V>Fd<`8vsz>fKV6xG*8uC=+oR%x{#-dW6~y2hXQ`* zZV2JJ*=mIy?6<*IfP>dDG<+7dL%-y)o(BZm(1pb=f#jCF_mImIt)&Gxh~R$=D<*8w z9^&nxJ;xCR>N2~-JuTFc>RG%K;?w1TV$FWuxEBXs!w4nFMmgk9m~<)NUiQb%(y&^V zLkMjnyJ|ZP!bB8~%{IWSHeOWkFi1Uvms-)Hg}6FMHBT(WOB{Mg3KHKFC)bqAf% u*ZhqSO*utu2;3Bo3>KZ!&a5*%GCy4ypPwld=VuEO^K*q_VYDz>bp8!DUx4WV diff --git a/examples/mqobuilder.py b/examples/mqobuilder.py index b0dcd88..abfc9c5 100644 --- a/examples/mqobuilder.py +++ b/examples/mqobuilder.py @@ -10,16 +10,15 @@ import opengl.vertexarraymap def build(path): - # load scenee t=time.time() - io=pymeshio.mqo.IO() - if not io.read(path): + model=pymeshio.mqo.reader.read_from_file(path) + if not model: return print(time.time()-t, "sec") # build basedir=os.path.dirname(path) vertexArrayMap=opengl.vertexarraymap.VertexArrayMapWithUV() - for m in io.materials: + for m in model.materials: material=opengl.material.MQOMaterial() material.rgba=(m.color.r, m.color.g, m.color.b, m.color.a) if m.tex: @@ -27,7 +26,7 @@ def build(path): material.texture=opengl.texture.Texture(texturepath) vertexArrayMap.addMaterial(material) - for o in io.objects: + for o in model.objects: # skip mikoto objects if o.name.startswith("anchor"): continue diff --git a/examples/pmdbuilder.py b/examples/pmdbuilder.py index 846c7b2..ee5361f 100644 --- a/examples/pmdbuilder.py +++ b/examples/pmdbuilder.py @@ -3,7 +3,7 @@ import time import os -import pymeshio.pmd +import pymeshio.pmd.reader import opengl.material import opengl.texture import opengl.vertexarray @@ -12,14 +12,14 @@ import opengl.vertexarray def build(path): # load scenee t=time.time() - io=pymeshio.pmd.IO() - if not io.read(path): + model=pymeshio.pmd.reader.read_from_file(path) + if not model: return print(time.time()-t, "sec") # build basedir=os.path.dirname(path) indexedVertexArray=opengl.vertexarray.IndexedVertexArray() - for v in io.vertices: + for v in model.vertices: # left-handed y-up to right-handed y-up indexedVertexArray.addVertex( (v.pos[0], v.pos[1], -v.pos[2], 1), @@ -32,18 +32,18 @@ def build(path): textureMap={} faceIndex=0 def indices(): - for i in io.indices: + for i in model.indices: yield i indexGen=indices() - for i, m in enumerate(io.materials): + for i, m in enumerate(model.materials): material=opengl.material.MQOMaterial() material.vcol=True material.rgba=( - m.diffuse[0], - m.diffuse[1], - m.diffuse[2], - m.diffuse[3]) - texturefile=m.texture.decode('cp932') + m.diffuse_color[0], + m.diffuse_color[1], + m.diffuse_color[2], + m.alpha) + texturefile=m.texture_file.decode('cp932') texturepath=os.path.join(basedir, texturefile) if os.path.isfile(texturepath): if not texturepath in textureMap: diff --git a/examples/pmxbuilder.py b/examples/pmxbuilder.py index 76f39f4..44a6907 100644 --- a/examples/pmxbuilder.py +++ b/examples/pmxbuilder.py @@ -3,16 +3,15 @@ import time import os -import pymeshio.pmx.loader +import pymeshio.pmx.reader import opengl.material import opengl.texture import opengl.vertexarray def build(path): - # load scenee t=time.time() - model=pymeshio.pmx.loader.load(path) + model=pymeshio.pmx.reader.read_from_file(path) if not model: return print(time.time()-t, "sec") diff --git a/pymeshio/mqo/__init__.py b/pymeshio/mqo/__init__.py index 45aca2e..6eeda67 100644 --- a/pymeshio/mqo/__init__.py +++ b/pymeshio/mqo/__init__.py @@ -8,7 +8,7 @@ import os import sys import math import pymeshio.common -import pymeshio.mqo.loader +import pymeshio.mqo.reader import warnings @@ -227,16 +227,3 @@ class Model(object): self.objects=[] -class IO(object): - def __init__(self): - pass - - def read(self, path): - warnings.warn("'pymeshio.mqo.IO.read' will be replaced by 'pymeshio.mqo.loader.load'") - model=pymeshio.mqo.loader.load_from_file(path) - if model: - self.has_mikoto=model.has_mikoto - self.materials=model.materials - self.objects=model.objects - return True - diff --git a/pymeshio/mqo/reader.py b/pymeshio/mqo/reader.py index b3e0919..1b7e365 100644 --- a/pymeshio/mqo/reader.py +++ b/pymeshio/mqo/reader.py @@ -20,7 +20,7 @@ class Reader(object): """ __slots__=[ "has_mikoto", - "eof", "io", "lines", + "eof", "ios", "lines", "materials", "objects", ] def __init__(self, ios): @@ -169,11 +169,12 @@ class Reader(object): def read_from_file(path): - with open(path, 'rb') as ios: - read(ios) + with io.open(path, 'rb') as ios: + return read(ios) def read(ios): + print(type(ios), ios) assert(isinstance(ios, io.IOBase)) reader=Reader(ios) model=pymeshio.mqo.Model() diff --git a/pymeshio/pmd/__init__.py b/pymeshio/pmd/__init__.py index df77c79..f6c9bb3 100644 --- a/pymeshio/pmd/__init__.py +++ b/pymeshio/pmd/__init__.py @@ -561,13 +561,3 @@ class Model(object): ) -class IO(object): - def __init__(self): - pass - - def read(self, path): - warnings.warn("'pymeshio.mqo.IO.read' will be replaced by 'pymeshio.mqo.loader.load'") - model=pymeshio.pmd.reader.read_from_file(path) - if model: - return True - diff --git a/pymeshio/pmx/reader.py b/pymeshio/pmx/reader.py index cfb228e..40358bb 100644 --- a/pymeshio/pmx/reader.py +++ b/pymeshio/pmx/reader.py @@ -301,7 +301,7 @@ def read(ios): rigidbody_index_size=reader.read_uint(1) # pmx custom reader - reader=Reader(reader.io, + reader=Reader(reader.ios, text_encoding, extended_uv, vertex_index_size, diff --git a/test/mqo_test.py b/test/mqo_test.py index cb68799..b2bbd1b 100644 --- a/test/mqo_test.py +++ b/test/mqo_test.py @@ -5,13 +5,9 @@ import sys MQO_FILE="resources/cube.mqo" -def test_old_mqo_load(): - io=pymeshio.mqo.IO() - assert io.read(MQO_FILE) def test_mqo_read(): model=pymeshio.mqo.reader.read_from_file(MQO_FILE) - print(model.materials) assert pymeshio.mqo.Model==model.__class__ assert 6==len(model.materials) assert 1==len(model.objects) diff --git a/test/mqo_test.pyc b/test/mqo_test.pyc index c489dfc339ab6915cbd66e06cd08ecc522387f04..6179dfd4e684003ab6112c9076bb05ff0f4d798b 100644 GIT binary patch literal 699 zcmbtR!A=`75FPI(0n((0Rz39x_7u2Om8z<0g{XuIshWyQw2~Ee9c4GW>(t{2MS=@( z;D6~I-dNcdam8NGKF^yOzp>-{VgGM)H_m7~BK*H%@kf{(pQ4Irs#+X9!7)u^%Hioy z9@8ztx)T38=^(dwz!>uzKxf#lU1oScTc4Xz{l|vm6sQ>M5Q|F~PgE)@BPwI^9lB9; z_0QR*ORzm!M#Kl?cjy|D6#3oY-;-dWeza87QvH^iw-iC4oI5Uhu!YD-Udi#hFsn^% zcu`m{5m4$S#+g}eoPWKAdhTqk=S5{g%IUA4`up+8k?(>(wYjPM9+1{qHDlH~DCWm+A8u|6N&I|pLs{y kTak<64Nv6JCzASK>q`ZTw9n{&U70U(A3^ItVaC1q5qj{T3jhEB literal 911 zcmb_aO^?$s5FIB?w_Cb=Nu0QH$Z5HNgb+eNwZKYjSES;yiezOISDV(Yi^mnJ1Q(VA z|Cb*CZ@f+U0g%L#@jQ>`&9l>AN5l1-pOcz)PlEp|41NOB;8SFYE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