char texture[20];
std::wstring getTexture()const;
+ void setTexture(const char *src);
};
inline std::ostream &operator<<(std::ostream &os,
const Material &rhs)
strncpy(name, src, 20);
}
+void Material::setTexture(const char *src)
+{
+ strncpy(texture, src, 20);
+}
+
} // namespace
} // namespace
return len(material.getTextures())>0
@staticmethod
- def getTexturePath(m, dirname):
- tex=""
- aplane=""
- # texture
+ def eachTexturePath(m, dirname):
for texture in m.getTextures():
if texture and texture.tex and texture.tex.getImage():
image=texture.tex.getImage()
if not image:
continue
- imagePath=Blender.sys.expandpath(image.getFilename())
- if len(dirname)>0 and imagePath.startswith(dirname):
- # 相対パスに変換する
- imagePath=imagePath[len(dirname)+1:len(imagePath)]
- if texture.mtCol>0:
- tex=" tex(\"%s\")" % imagePath
- elif texture.mtAlpha>0:
- aplane=" aplane(\"%s\")" % imagePath
- return tex, aplane
+ yield image.getFilename()
class mesh:
return material.texture_slots[0]
@staticmethod
- def getTexturePath(m, dirname):
- tex=""
- aplane=""
- # texture
+ def eachTexturePath(m):
for slot in m.texture_slots:
if slot and slot.texture:
texture=slot.texture
image=texture.image
if not image:
continue
- imagePath=image.filename
- if len(dirname)>0 and imagePath.startswith(dirname):
- # \e$BAjBP%Q%9$KJQ49$9$k\e(B
- imagePath=imagePath[len(dirname)+1:len(imagePath)]
- #imagePath=Blender.sys.expandpath(
- # imagePath).replace("\\", '/')
- if slot.map_colordiff:
- tex=" tex(\"%s\")" % imagePath
- elif slot.map_alpha:
- aplane=" aplane(\"%s\")" % imagePath
- return tex, aplane
-
+ yield image.filename
class mesh:
@staticmethod
# each material \r
io.write("Material %d {\r\n" % (len(self.materials)))\r
for m in self.materials:\r
- tex, aplane=bl.material.getTexturePath(m, dirname)\r
- if len(tex):\r
- # textureがある場合は下地を白に\r
- io.write("\"%s\" shader(3) col(1 1 1 1)" % m.name)\r
- else:\r
- # 無い場合はそのまま\r
- io.write(materialToMqo(m))\r
- io.write(tex)\r
- io.write(aplane)\r
+ io.write(materialToMqo(m))\r
+ # ToDo separated alpha texture\r
+ for filename in bl.material.eachTexturePath(m):\r
+ if len(dirname)>0 and filename.startswith(dirname):\r
+ # 相対パスに変換する\r
+ filename=filename[len(dirname)+1:]\r
+ io.write(" tex(\"%s\")" % filename)\r
+ break\r
io.write("\r\n") \r
# end of chunk\r
io.write("}\r\n") \r
# flag
material.flag=1 if m.enableSSS else 0
+ def toCP932(s):
+ return s
+
+
else:
# for 2.5
import bpy
# flag
material.flag=1 if m.subsurface_scattering.enabled else 0
+ def toCP932(s):
+ return s.encode('cp932')
+
+
class Node(object):
__slots__=['o', 'children']
def __init__(self, o):
material.vertex_count=len(indices)
material.toon_index=0
- # ToDo
- material.texture=""
+ textures=[os.path.basename(path)
+ for path in bl.material.eachTexturePath(m)]
+ if len(textures)>0:
+ material.setTexture(toCP932('*'.join(textures)))
# 面
for i in indices:
assert(i<vertexCount)