1 #!/usr/bin/env python
\r
6 import pymeshio.mqo.reader
\r
7 import opengl.material
\r
8 import opengl.texture
\r
9 import opengl.vertexarraymap
\r
14 model=pymeshio.mqo.reader.read_from_file(path)
\r
17 print(time.time()-t, "sec")
\r
19 basedir=os.path.dirname(path)
\r
20 vertexArrayMap=opengl.vertexarraymap.VertexArrayMapWithUV()
\r
21 for m in model.materials:
\r
22 material=opengl.material.MQOMaterial()
\r
23 material.rgba=(m.color.r, m.color.g, m.color.b, m.color.a)
\r
25 texturepath=os.path.join(basedir, m.tex.decode('cp932'))
\r
26 material.texture=opengl.texture.Texture(texturepath)
\r
27 vertexArrayMap.addMaterial(material)
\r
29 for o in model.objects:
\r
30 # skip mikoto objects
\r
31 if o.name.startswith(b"anchor"):
\r
33 if o.name.startswith(b"bone:"):
\r
35 if o.name.startswith(b"MCS:"):
\r
39 if f.index_count==3:
\r
40 vertexArrayMap.addTriangle(
\r
42 o.vertices[f.indices[0]],
\r
43 o.vertices[f.indices[1]],
\r
44 o.vertices[f.indices[2]],
\r
45 f.uv[0], f.uv[1], f.uv[2]
\r
47 elif f.index_count==4:
\r
49 vertexArrayMap.addTriangle(
\r
51 o.vertices[f.indices[0]],
\r
52 o.vertices[f.indices[1]],
\r
53 o.vertices[f.indices[2]],
\r
54 f.uv[0], f.uv[1], f.uv[2]
\r
57 vertexArrayMap.addTriangle(
\r
59 o.vertices[f.indices[2]],
\r
60 o.vertices[f.indices[3]],
\r
61 o.vertices[f.indices[0]],
\r
62 f.uv[2], f.uv[3], f.uv[0]
\r
65 vertexArrayMap.optimize()
\r
66 return vertexArrayMap
\r