OSDN Git Service

refactoring export_pmd
[meshio/pymeshio.git] / examples / mqobuilder.py
index b0dcd88..cc20b66 100644 (file)
@@ -3,37 +3,36 @@
 \r
 import time\r
 import os\r
-import pymeshio.mqo\r
+import pymeshio.mqo.reader\r
 import opengl.material\r
 import opengl.texture\r
 import opengl.vertexarraymap\r
 \r
 \r
 def build(path):\r
-    # load scenee\r
     t=time.time()\r
-    io=pymeshio.mqo.IO()\r
-    if not io.read(path):\r
+    model=pymeshio.mqo.reader.read_from_file(path)\r
+    if not model:\r
         return\r
     print(time.time()-t, "sec")\r
     # build\r
     basedir=os.path.dirname(path)\r
     vertexArrayMap=opengl.vertexarraymap.VertexArrayMapWithUV()\r
-    for m in io.materials:\r
+    for m in model.materials:\r
         material=opengl.material.MQOMaterial()\r
         material.rgba=(m.color.r, m.color.g, m.color.b, m.color.a)\r
         if m.tex:\r
-            texturepath=os.path.join(basedir, m.tex)\r
+            texturepath=os.path.join(basedir, m.tex.decode('cp932'))\r
             material.texture=opengl.texture.Texture(texturepath)\r
         vertexArrayMap.addMaterial(material)\r
 \r
-    for o in io.objects:\r
+    for o in model.objects:\r
         # skip mikoto objects\r
-        if o.name.startswith("anchor"):\r
+        if o.name.startswith(b"anchor"):\r
             continue\r
-        if o.name.startswith("bone:"):\r
+        if o.name.startswith(b"bone:"):\r
             continue\r
-        if o.name.startswith("MCS:"):\r
+        if o.name.startswith(b"MCS:"):\r
             continue\r
 \r
         for f in o.faces:\r