OSDN Git Service

fix mqobuilder
[meshio/pymeshio.git] / examples / mqobuilder.py
index b73fbe8..b0dcd88 100644 (file)
@@ -4,8 +4,9 @@
 import time\r
 import os\r
 import pymeshio.mqo\r
-from opengl import material\r
-from opengl import vertexarraymap\r
+import opengl.material\r
+import opengl.texture\r
+import opengl.vertexarraymap\r
 \r
 \r
 def build(path):\r
@@ -17,9 +18,15 @@ def build(path):
     print(time.time()-t, "sec")\r
     # build\r
     basedir=os.path.dirname(path)\r
-    vertexArrayMap=vertexarraymap.VertexArrayMapWithUV(\r
-            [material.MQOMaterial.create(m, basedir) \r
-                for m in io.materials])\r
+    vertexArrayMap=opengl.vertexarraymap.VertexArrayMapWithUV()\r
+    for m in io.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
+            material.texture=opengl.texture.Texture(texturepath)\r
+        vertexArrayMap.addMaterial(material)\r
+\r
     for o in io.objects:\r
         # skip mikoto objects\r
         if o.name.startswith("anchor"):\r