5 return 1.055*(l**(1/2.4))-0.055
10 self.material_tex = False
11 self.srgb_colors = True
14 def export(self, context, out_file):
15 from .outfile import open_output
16 out_file = open_output(out_file)
18 from .export_mesh import MeshExporter
19 mesh_export = MeshExporter()
20 for k, v in self.__dict__.items():
21 setattr(mesh_export, k, v)
23 out_file.begin("mesh")
24 mesh = mesh_export.export(context, out_file)
27 out_file.begin("technique")
28 out_file.begin("pass", '""')
36 out_file.begin("material")
37 out_file.write("diffuse", 1.0, 1.0, 1.0, 1.0)
40 for u in mesh.uv_layers:
41 if u.name=="material_tex":
43 out_file.begin("texunit", index)
44 out_file.begin("texture2d")
45 out_file.write("min_filter", "NEAREST")
46 out_file.write("mag_filter", "NEAREST")
47 out_file.write("storage", "RGB", len(mesh.materials), 1)
49 for m in mesh.materials:
50 color = [int(cm(c)*255) for c in m.diffuse_color]
51 texdata += "\\x%02X\\x%02X\\x%02X"%tuple(color)
53 out_file.write("raw_data", texdata)
57 mat = mesh.materials[0]
58 out_file.begin("material")
59 if any((s and s.use_map_color_diffuse) for s in mat.texture_slots):
60 out_file.write("diffuse", 1.0, 1.0, 1.0, 1.0)
62 out_file.write("ambient", amb, amb, amb, 1.0)
64 diff = mat.diffuse_color
65 out_file.write("diffuse", cm(diff.r), cm(diff.g), cm(diff.b), 1.0)
66 amb = diff*mat.ambient
67 out_file.write("ambient", cm(amb.r), cm(amb.g), cm(amb.b), 1.0)
68 spec = mat.specular_color*mat.specular_intensity
69 out_file.write("specular", spec.r, spec.g, spec.b, 1.0)
70 out_file.write("shininess", mat.specular_hardness);
73 if self.textures!="NONE":
74 for slot in mesh.materials[0].texture_slots:
83 for u in mesh.uv_layers:
84 if u.name==slot.uv_layer:
87 index = mesh.uv_layers[0].unit
89 out_file.begin("texunit", index)
90 if self.textures=="INLINE":
91 out_file.begin("texture2d")
92 out_file.write("min_filter", "LINEAR")
93 out_file.write("storage", "RGBA", tex.image.size[0], tex.image.size[1])
95 for p in tex.image.pixels:
96 texdata += "\\x%02X"%int(p*255)
98 out_file.write("raw_data", texdata)
101 out_file.write("texture", '"%s"'%tex.image.name)