From 169057d48d44846bc433753f20ee884204be9192 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 15 Sep 2014 13:23:11 +0300 Subject: [PATCH] Add an object property for inheriting the specified technique This allows using object-specific textures while still sharing material and shaders. --- blender/io_mspgl/export_object.py | 15 ++++++++++++++- blender/io_mspgl/properties.py | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/blender/io_mspgl/export_object.py b/blender/io_mspgl/export_object.py index 00410a23..a12474af 100644 --- a/blender/io_mspgl/export_object.py +++ b/blender/io_mspgl/export_object.py @@ -50,7 +50,20 @@ class ObjectExporter: out_file.end() if self.external_tech and obj.technique: - out_file.write("technique", '"{}"'.format(obj.technique)) + if obj.inherit_tech and mesh.materials[0].texture_slots: + out_file.begin("technique") + out_file.begin("inherit", '"{}"'.format(obj.technique)) + for slot in mesh.materials[0].texture_slots: + if slot and slot.texture.type=="IMAGE": + name = image_name(slot.texture.image) + if slot.use_map_color_diffuse: + out_file.write("texture", '"diffuse_map"', '"{}"'.format(name)) + elif slot.use_map_normal: + out_file.write("texture", '"normal_map"', '"{}"'.format(name)) + out_file.end() + out_file.end() + else: + out_file.write("technique", '"{}"'.format(obj.technique)) elif self.separate_tech: path, base = os.path.split(out_file.filename) if self.shared_tech and mesh.materials: diff --git a/blender/io_mspgl/properties.py b/blender/io_mspgl/properties.py index dcc8cc34..f6de7a36 100644 --- a/blender/io_mspgl/properties.py +++ b/blender/io_mspgl/properties.py @@ -11,8 +11,10 @@ class MspGLProperties(bpy.types.Panel): obj = context.active_object self.layout.prop(obj, "technique"); + self.layout.prop(obj, "inherit_tech"); self.layout.prop(obj, "compound"); def register_properties(): bpy.types.Object.technique = bpy.props.StringProperty(name="Technique", description="Name of the technique to use for rendering") + bpy.types.Object.inherit_tech = bpy.props.BoolProperty(name="Inherit technique", description="Inherit from the technique to customize textures") bpy.types.Object.compound = bpy.props.BoolProperty(name="Compound with parent", description="Join this object to its parent when exporting") -- 2.43.0