1 #!/usr/bin/env python
\r
7 import opengl.material
\r
8 import opengl.texture
\r
9 import opengl.vertexarraymap
\r
15 io=pymeshio.mqo.IO()
\r
16 if not io.read(path):
\r
18 print(time.time()-t, "sec")
\r
20 basedir=os.path.dirname(path)
\r
21 vertexArrayMap=opengl.vertexarraymap.VertexArrayMapWithUV()
\r
22 for m in io.materials:
\r
23 material=opengl.material.MQOMaterial()
\r
24 material.rgba=(m.color.r, m.color.g, m.color.b, m.color.a)
\r
26 texturepath=os.path.join(basedir, m.tex)
\r
27 material.texture=opengl.texture.Texture(texturepath)
\r
28 vertexArrayMap.addMaterial(material)
\r
30 for o in io.objects:
\r
31 # skip mikoto objects
\r
32 if o.name.startswith("anchor"):
\r
34 if o.name.startswith("bone:"):
\r
36 if o.name.startswith("MCS:"):
\r
40 if f.index_count==3:
\r
41 vertexArrayMap.addTriangle(
\r
43 o.vertices[f.indices[0]],
\r
44 o.vertices[f.indices[1]],
\r
45 o.vertices[f.indices[2]],
\r
46 f.uv[0], f.uv[1], f.uv[2]
\r
48 elif f.index_count==4:
\r
50 vertexArrayMap.addTriangle(
\r
52 o.vertices[f.indices[0]],
\r
53 o.vertices[f.indices[1]],
\r
54 o.vertices[f.indices[2]],
\r
55 f.uv[0], f.uv[1], f.uv[2]
\r
58 vertexArrayMap.addTriangle(
\r
60 o.vertices[f.indices[2]],
\r
61 o.vertices[f.indices[3]],
\r
62 o.vertices[f.indices[0]],
\r
63 f.uv[2], f.uv[3], f.uv[0]
\r
66 vertexArrayMap.optimize()
\r
67 return vertexArrayMap
\r