mirror of
https://github.com/Relintai/material-maker.git
synced 2024-12-23 21:16:54 +01:00
Updated Godot import plugin to use new material export functions
This commit is contained in:
parent
9f32e2e19a
commit
2b593beb32
@ -46,20 +46,26 @@ func get_visible_name() -> String:
|
|||||||
return "Material Maker Importer"
|
return "Material Maker Importer"
|
||||||
|
|
||||||
func import(source_file: String, save_path: String, options: Dictionary, platform_variants: Array, gen_files: Array) -> int:
|
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
|
var material = null
|
||||||
if options.render:
|
if options.render:
|
||||||
material = plugin.generate_material(source_file)
|
var gen = mm_loader.load_gen(source_file)
|
||||||
while material is GDScriptFunctionState:
|
if gen != null:
|
||||||
material = yield(material, "completed")
|
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:
|
else:
|
||||||
|
var filename = save_path + "." + get_save_extension()
|
||||||
material = SpatialMaterial.new()
|
material = SpatialMaterial.new()
|
||||||
material.set_script(preload("res://addons/material_maker/import_plugin/ptex_spatial_material.gd"))
|
material.set_script(preload("res://addons/material_maker/import_plugin/ptex_spatial_material.gd"))
|
||||||
var file : File = File.new()
|
var file : File = File.new()
|
||||||
if file.open(source_file, File.READ) == OK:
|
if file.open(source_file, File.READ) == OK:
|
||||||
material.set_ptex_no_render(to_json(parse_json(file.get_as_text())))
|
material.set_ptex_no_render(to_json(parse_json(file.get_as_text())))
|
||||||
file.close()
|
file.close()
|
||||||
if material != null:
|
|
||||||
material.uv1_scale = options.scale * Vector3(1.0, 1.0, 1.0)
|
material.uv1_scale = options.scale * Vector3(1.0, 1.0, 1.0)
|
||||||
ResourceSaver.save(filename, material)
|
ResourceSaver.save(filename, material)
|
||||||
return OK
|
return OK
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[plugin]
|
[plugin]
|
||||||
|
|
||||||
name="MaterialMaker"
|
name="Material Maker"
|
||||||
description="Procedural Material creation tool"
|
description="Import plugin for Material Maker"
|
||||||
author="RodZilla"
|
author="RodZilla"
|
||||||
version="0.6"
|
version="0.9"
|
||||||
script="plugin.gd"
|
script="plugin.gd"
|
||||||
|
@ -11,16 +11,3 @@ func _exit_tree() -> void:
|
|||||||
if importer != null:
|
if importer != null:
|
||||||
remove_import_plugin(importer)
|
remove_import_plugin(importer)
|
||||||
importer = null
|
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
|
|
||||||
|
Loading…
Reference in New Issue
Block a user