X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=blender%2Fio_mesh_mspgl%2Fexport_mspgl.py;fp=blender%2Fio_mesh_mspgl%2Fexport_mspgl.py;h=0e96c4249631ebc17844f1e3267beab1469c49f7;hb=b0fe4fa54e881e7dc2495a1078b7ffe6076d4744;hp=f888dc4528d9981250e9b6ea950d35244ac7b4ee;hpb=7af1f6d70e6ef191991ac909aa134b88d7bdb826;p=libs%2Fgl.git diff --git a/blender/io_mesh_mspgl/export_mspgl.py b/blender/io_mesh_mspgl/export_mspgl.py index f888dc45..0e96c424 100644 --- a/blender/io_mesh_mspgl/export_mspgl.py +++ b/blender/io_mesh_mspgl/export_mspgl.py @@ -75,6 +75,7 @@ class Exporter: self.compound = False self.object = False self.material_tex = False + self.textures = "REF" self.smoothing = "MSPGL" def stripify(self, mesh, progress = None): @@ -385,6 +386,38 @@ class Exporter: out_file.write("specular", spec.r, spec.g, spec.b, 1.0) out_file.write("shininess", mat.specular_hardness); out_file.end() + + if self.textures!="NONE": + for slot in mesh.materials[0].texture_slots: + if not slot: + continue + + tex = slot.texture + if tex.type!="IMAGE": + continue + + if slot.uv_layer: + for u in mesh.uv_layers: + if u.name==slot.uv_layer: + index = u.unit + else: + index = mesh.uv_layers[0].unit + + out_file.begin("texunit", index) + if self.textures=="INLINE": + out_file.begin("texture2d") + out_file.write("min_filter", "LINEAR") + out_file.write("storage", "RGBA", tex.image.size[0], tex.image.size[1]) + texdata = '"' + for p in tex.image.pixels: + texdata += "\\x%02X"%int(p*255) + texdata += '"' + out_file.write("raw_data", texdata) + out_file.end() + else: + out_file.write("texture", '"%s"'%tex.image.name) + out_file.end() + out_file.end() out_file.end()