- tech_res = Resource((material.name if material else obj.name)+".tech")
-
- mat_res = None
- if material:
- mat_res = resources[material.name+".mat"]
-
- if obj.technique:
- if not obj.inherit_tech:
- return tech_res
-
- st = Statement("inherit", obj.technique)
- if material:
- for slot in material.texture_slots:
- if slot and slot.texture.type=="IMAGE":
- name = image_name(slot.texture.image)
- if slot.use_map_color_diffuse:
- st.sub.append(Statement("texture", "diffuse_map", name))
- elif slot.use_map_normal:
- st.sub.append(Statement("texture", "normal_map", name))
- if obj.override_material:
- st.sub.append(tech_res.create_reference_statement("material", "surface", mat_res))
- tech_res.statements.append(st)
-
- return tech_res
-
- pass_st = Statement("pass", "")
- if material:
- pass_st.sub.append(tech_res.create_embed_statement("material", mat_res))
-
- if self.textures!="NONE":
- diffuse_tex = None
- for slot in material.texture_slots:
- if slot and slot.texture.type=="IMAGE" and slot.use_map_color_diffuse:
- diffuse_tex = slot.texture
- break
-
- if diffuse_tex:
- st = Statement("texunit", 0)
- if self.textures=="INLINE":
- ss = Statement("texture2d")
- ss.sub.append(Statement("min_filter", Token("LINEAR")))
- ss.sub.append(Statement("storage", Token("RGBA"), tex.image.size[0], tex.image.size[1]))
- texdata = ""
- for p in tex.image.pixels:
- texdata += "\\x%02X"%int(p*255)
- ss.sub.append(Statement("raw_data", texdata))
- st.sub.append(ss)
- elif tex.image:
- st.sub.append(Statement("texture", image_name(tex.image)))
- pass_st.sub.append(st)