From 2b593beb322cf8affc10f57d6378d640321a458e Mon Sep 17 00:00:00 2001 From: RodZill4 Date: Wed, 26 Feb 2020 22:52:03 +0100 Subject: [PATCH] Updated Godot import plugin to use new material export functions --- .../material_maker/import_plugin/ptex_import.gd | 16 +++++++++++----- addons/material_maker/plugin.cfg | 6 +++--- addons/material_maker/plugin.gd | 13 ------------- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/addons/material_maker/import_plugin/ptex_import.gd b/addons/material_maker/import_plugin/ptex_import.gd index b74fd0a..b39f6d4 100644 --- a/addons/material_maker/import_plugin/ptex_import.gd +++ b/addons/material_maker/import_plugin/ptex_import.gd @@ -46,20 +46,26 @@ func get_visible_name() -> String: return "Material Maker Importer" func import(source_file: String, save_path: String, options: Dictionary, platform_variants: Array, gen_files: Array) -> int: - var filename = save_path + "." + get_save_extension() var material = null if options.render: - material = plugin.generate_material(source_file) - while material is GDScriptFunctionState: - material = yield(material, "completed") + var gen = mm_loader.load_gen(source_file) + if gen != null: + plugin.add_child(gen) + for c in gen.get_children(): + if c.has_method("get_export_profiles"): + var result = c.export_material(source_file.get_basename(), "Godot") + while result is GDScriptFunctionState: + result = yield(result, "completed") + break + gen.queue_free() else: + var filename = save_path + "." + get_save_extension() material = SpatialMaterial.new() material.set_script(preload("res://addons/material_maker/import_plugin/ptex_spatial_material.gd")) var file : File = File.new() if file.open(source_file, File.READ) == OK: material.set_ptex_no_render(to_json(parse_json(file.get_as_text()))) file.close() - if material != null: material.uv1_scale = options.scale * Vector3(1.0, 1.0, 1.0) ResourceSaver.save(filename, material) return OK diff --git a/addons/material_maker/plugin.cfg b/addons/material_maker/plugin.cfg index 27726c0..debdbba 100644 --- a/addons/material_maker/plugin.cfg +++ b/addons/material_maker/plugin.cfg @@ -1,7 +1,7 @@ [plugin] -name="MaterialMaker" -description="Procedural Material creation tool" +name="Material Maker" +description="Import plugin for Material Maker" author="RodZilla" -version="0.6" +version="0.9" script="plugin.gd" diff --git a/addons/material_maker/plugin.gd b/addons/material_maker/plugin.gd index b6b6011..12dbbee 100644 --- a/addons/material_maker/plugin.gd +++ b/addons/material_maker/plugin.gd @@ -11,16 +11,3 @@ func _exit_tree() -> void: if importer != null: remove_import_plugin(importer) importer = null - -func generate_material(ptex_filename: String) -> Material: - var generator = mm_loader.load_gen(ptex_filename) - add_child(generator) - if generator.has_node("Material"): - var gen_material = generator.get_node("Material") - if gen_material != null: - var return_value = gen_material.render_textures() - while return_value is GDScriptFunctionState: - return_value = yield(return_value, "completed") - var prefix = ptex_filename.left(ptex_filename.rfind(".")) - return gen_material.export_textures(prefix, get_editor_interface()) - return null