filename_ext = ".object"
+ textures = bpy.props.EnumProperty(name="Textures", description="Export textures", default="REF",
+ items=(("NONE", "None", "Ignore textures"),
+ ("REF", "Referenced", "Reference external data"),
+ ("INLINE", "Inline", "Embed textures in the object")))
material_tex = bpy.props.BoolProperty(name="Material texture", description="Generate a texture based on material colors", default=False)
def prepare_exporter(self, exporter):
self.compound = False
self.object = False
self.material_tex = False
+ self.textures = "REF"
self.smoothing = "MSPGL"
def stripify(self, mesh, progress = None):
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()