mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
Updated Godot integration
This commit is contained in:
parent
2b67c5a4f5
commit
e573a78fd6
@ -174,7 +174,7 @@ func export_textures(prefix, editor_interface = null):
|
|||||||
if texture != null:
|
if texture != null:
|
||||||
var image = texture.get_data()
|
var image = texture.get_data()
|
||||||
image.save_png("%s_%s.png" % [ prefix, t.texture ])
|
image.save_png("%s_%s.png" % [ prefix, t.texture ])
|
||||||
if Engine.editor_hint:
|
if Engine.editor_hint and editor_interface != null:
|
||||||
var resource_filesystem = editor_interface.get_resource_filesystem()
|
var resource_filesystem = editor_interface.get_resource_filesystem()
|
||||||
resource_filesystem.scan()
|
resource_filesystem.scan()
|
||||||
yield(resource_filesystem, "filesystem_changed")
|
yield(resource_filesystem, "filesystem_changed")
|
||||||
|
@ -191,12 +191,12 @@ func save_file(filename):
|
|||||||
set_save_path(filename)
|
set_save_path(filename)
|
||||||
set_need_save(false)
|
set_need_save(false)
|
||||||
|
|
||||||
func export_textures(size = null):
|
func export_textures():
|
||||||
if save_path != null:
|
if save_path != null:
|
||||||
var prefix = save_path.left(save_path.rfind("."))
|
var prefix = save_path.left(save_path.rfind("."))
|
||||||
for c in get_children():
|
for c in get_children():
|
||||||
if c is GraphNode and c.generator.has_method("export_textures"):
|
if c is GraphNode and c.generator.has_method("export_textures"):
|
||||||
c.generator.export_textures(prefix, size)
|
c.generator.export_textures(prefix, editor_interface)
|
||||||
|
|
||||||
# Cut / copy / paste
|
# Cut / copy / paste
|
||||||
|
|
||||||
|
@ -47,5 +47,6 @@ func import(source_file: String, save_path: String, options: Dictionary, platfor
|
|||||||
var material = plugin.generate_material(source_file)
|
var material = plugin.generate_material(source_file)
|
||||||
while material is GDScriptFunctionState:
|
while material is GDScriptFunctionState:
|
||||||
material = yield(material, "completed")
|
material = yield(material, "completed")
|
||||||
|
if material != null:
|
||||||
ResourceSaver.save(filename, material)
|
ResourceSaver.save(filename, material)
|
||||||
return OK
|
return OK
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
tool
|
||||||
extends Tree
|
extends Tree
|
||||||
|
|
||||||
func get_drag_data(position):
|
func get_drag_data(position):
|
||||||
|
@ -8,13 +8,13 @@
|
|||||||
[ext_resource path="res://addons/material_maker/engine/renderer.tscn" type="PackedScene" id=6]
|
[ext_resource path="res://addons/material_maker/engine/renderer.tscn" type="PackedScene" id=6]
|
||||||
[ext_resource path="res://addons/material_maker/node_factory.gd" type="Script" id=7]
|
[ext_resource path="res://addons/material_maker/node_factory.gd" type="Script" id=7]
|
||||||
|
|
||||||
[sub_resource type="PanoramaSky" id=6]
|
[sub_resource type="PanoramaSky" id=1]
|
||||||
resource_local_to_scene = true
|
resource_local_to_scene = true
|
||||||
panorama = ExtResource( 4 )
|
panorama = ExtResource( 4 )
|
||||||
|
|
||||||
[sub_resource type="Environment" id=7]
|
[sub_resource type="Environment" id=2]
|
||||||
background_mode = 2
|
background_mode = 2
|
||||||
background_sky = SubResource( 6 )
|
background_sky = SubResource( 1 )
|
||||||
|
|
||||||
[node name="MainWindow" type="Panel"]
|
[node name="MainWindow" type="Panel"]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
@ -107,7 +107,7 @@ render_target_update_mode = 0
|
|||||||
|
|
||||||
[node name="Camera" type="Camera" parent="VBoxContainer/HBoxContainer/ProjectsPane/BackgroundPreview/Viewport"]
|
[node name="Camera" type="Camera" parent="VBoxContainer/HBoxContainer/ProjectsPane/BackgroundPreview/Viewport"]
|
||||||
transform = Transform( 1, 0, 0, 0, 0.766044, 0.642788, 0, -0.642788, 0.766044, 0, 2.24976, 2.68115 )
|
transform = Transform( 1, 0, 0, 0, 0.766044, 0.642788, 0, -0.642788, 0.766044, 0, 2.24976, 2.68115 )
|
||||||
environment = SubResource( 7 )
|
environment = SubResource( 2 )
|
||||||
current = true
|
current = true
|
||||||
|
|
||||||
[node name="Projects" type="Panel" parent="VBoxContainer/HBoxContainer/ProjectsPane"]
|
[node name="Projects" type="Panel" parent="VBoxContainer/HBoxContainer/ProjectsPane"]
|
||||||
|
@ -8,11 +8,15 @@ var renderer = null
|
|||||||
|
|
||||||
func _enter_tree():
|
func _enter_tree():
|
||||||
add_tool_menu_item("Material Maker", self, "open_material_maker")
|
add_tool_menu_item("Material Maker", self, "open_material_maker")
|
||||||
importer = preload("res://addons/material_maker/import_plugin/ptex_import.gd").new(self)
|
add_tool_menu_item("Register Material Maker Import", self, "register_material_maker_import")
|
||||||
add_import_plugin(importer)
|
|
||||||
renderer = preload("res://addons/material_maker/engine/renderer.tscn").instance()
|
renderer = preload("res://addons/material_maker/engine/renderer.tscn").instance()
|
||||||
add_child(renderer)
|
add_child(renderer)
|
||||||
|
|
||||||
|
func register_material_maker_import(__):
|
||||||
|
importer = preload("res://addons/material_maker/import_plugin/ptex_import.gd").new(self)
|
||||||
|
add_import_plugin(importer)
|
||||||
|
remove_tool_menu_item("Register Material Maker Import")
|
||||||
|
|
||||||
func _exit_tree():
|
func _exit_tree():
|
||||||
remove_tool_menu_item("Material Maker")
|
remove_tool_menu_item("Material Maker")
|
||||||
if material_maker != null:
|
if material_maker != null:
|
||||||
@ -31,7 +35,7 @@ func _set_state(s):
|
|||||||
mm_button = s.mm_button
|
mm_button = s.mm_button
|
||||||
material_maker = s.material_maker
|
material_maker = s.material_maker
|
||||||
|
|
||||||
func open_material_maker(foo = null):
|
func open_material_maker(__):
|
||||||
if material_maker == null:
|
if material_maker == null:
|
||||||
material_maker = preload("res://addons/material_maker/window_dialog.tscn").instance()
|
material_maker = preload("res://addons/material_maker/window_dialog.tscn").instance()
|
||||||
var panel = material_maker.get_node("MainWindow")
|
var panel = material_maker.get_node("MainWindow")
|
||||||
@ -51,7 +55,7 @@ func generate_material(ptex_filename: String) -> Material:
|
|||||||
add_child(generator)
|
add_child(generator)
|
||||||
if generator.has_node("Material"):
|
if generator.has_node("Material"):
|
||||||
var gen_material = generator.get_node("Material")
|
var gen_material = generator.get_node("Material")
|
||||||
print(renderer)
|
if gen_material != null:
|
||||||
var return_value = gen_material.render_textures(renderer)
|
var return_value = gen_material.render_textures(renderer)
|
||||||
while return_value is GDScriptFunctionState:
|
while return_value is GDScriptFunctionState:
|
||||||
return_value = yield(return_value, "completed")
|
return_value = yield(return_value, "completed")
|
||||||
|
@ -38,7 +38,6 @@ func _ready():
|
|||||||
func _on_Environment_item_selected(id):
|
func _on_Environment_item_selected(id):
|
||||||
current_environment.visible = false
|
current_environment.visible = false
|
||||||
current_environment = environments.get_child(id)
|
current_environment = environments.get_child(id)
|
||||||
print(current_environment.environment)
|
|
||||||
$MaterialPreview/Preview3d/CameraPivot/Camera.set_environment(current_environment.environment)
|
$MaterialPreview/Preview3d/CameraPivot/Camera.set_environment(current_environment.environment)
|
||||||
get_node("../../ProjectsPane/BackgroundPreview/Viewport/Camera").set_environment(current_environment.environment)
|
get_node("../../ProjectsPane/BackgroundPreview/Viewport/Camera").set_environment(current_environment.environment)
|
||||||
current_environment.visible = true
|
current_environment.visible = true
|
||||||
@ -75,6 +74,7 @@ func _on_Background_toggled(button_pressed):
|
|||||||
func on_gui_input(event):
|
func on_gui_input(event):
|
||||||
if event is InputEventMouseButton:
|
if event is InputEventMouseButton:
|
||||||
$MaterialPreview/Preview3d/ObjectRotate.stop(false)
|
$MaterialPreview/Preview3d/ObjectRotate.stop(false)
|
||||||
|
$Config/Rotate.pressed = false
|
||||||
match event.button_index:
|
match event.button_index:
|
||||||
BUTTON_WHEEL_UP:
|
BUTTON_WHEEL_UP:
|
||||||
camera.translation.z *= 1.01 if event.shift else 1.1
|
camera.translation.z *= 1.01 if event.shift else 1.1
|
||||||
@ -96,9 +96,8 @@ func on_gui_input(event):
|
|||||||
elif event.button_mask & BUTTON_MASK_RIGHT:
|
elif event.button_mask & BUTTON_MASK_RIGHT:
|
||||||
camera_stand.rotate(camera_basis.z.normalized(), -motion.x)
|
camera_stand.rotate(camera_basis.z.normalized(), -motion.x)
|
||||||
|
|
||||||
|
func _on_Rotate_toggled(button_pressed):
|
||||||
func _on_Rotate_pressed():
|
if button_pressed:
|
||||||
if $MaterialPreview/Preview3d/ObjectRotate.is_playing():
|
|
||||||
$MaterialPreview/Preview3d/ObjectRotate.stop(false)
|
|
||||||
else:
|
|
||||||
$MaterialPreview/Preview3d/ObjectRotate.play("rotate")
|
$MaterialPreview/Preview3d/ObjectRotate.play("rotate")
|
||||||
|
else:
|
||||||
|
$MaterialPreview/Preview3d/ObjectRotate.stop(false)
|
||||||
|
@ -65,12 +65,14 @@ items = [ "Epping Forest", null, false, -1, null, "Moonless Golf", null, false,
|
|||||||
selected = 0
|
selected = 0
|
||||||
|
|
||||||
[node name="Rotate" type="Button" parent="Config"]
|
[node name="Rotate" type="Button" parent="Config"]
|
||||||
margin_left = 348.0
|
margin_left = 235.0
|
||||||
margin_right = 368.0
|
margin_right = 255.0
|
||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
rect_pivot_offset = Vector2( -4, 7 )
|
rect_pivot_offset = Vector2( -4, 7 )
|
||||||
hint_tooltip = "Show in main view"
|
hint_tooltip = "Rotate object"
|
||||||
size_flags_horizontal = 10
|
size_flags_horizontal = 2
|
||||||
|
toggle_mode = true
|
||||||
|
pressed = true
|
||||||
text = "R"
|
text = "R"
|
||||||
|
|
||||||
[node name="Background" type="Button" parent="Config"]
|
[node name="Background" type="Button" parent="Config"]
|
||||||
@ -99,6 +101,6 @@ size_flags_vertical = 8
|
|||||||
[connection signal="resized" from="." to="." method="_on_Preview_resized"]
|
[connection signal="resized" from="." to="." method="_on_Preview_resized"]
|
||||||
[connection signal="item_selected" from="Config/Model" to="." method="_on_Model_item_selected"]
|
[connection signal="item_selected" from="Config/Model" to="." method="_on_Model_item_selected"]
|
||||||
[connection signal="item_selected" from="Config/Environment" to="." method="_on_Environment_item_selected"]
|
[connection signal="item_selected" from="Config/Environment" to="." method="_on_Environment_item_selected"]
|
||||||
[connection signal="pressed" from="Config/Rotate" to="." method="_on_Rotate_pressed"]
|
[connection signal="toggled" from="Config/Rotate" to="." method="_on_Rotate_toggled"]
|
||||||
[connection signal="toggled" from="Config/Background" to="." method="_on_Background_toggled"]
|
[connection signal="toggled" from="Config/Background" to="." method="_on_Background_toggled"]
|
||||||
[connection signal="gui_input" from="Preview2D" to="." method="_on_Preview2D_gui_input"]
|
[connection signal="gui_input" from="Preview2D" to="." method="_on_Preview2D_gui_input"]
|
||||||
|
@ -2,7 +2,6 @@ tool
|
|||||||
extends Control
|
extends Control
|
||||||
class_name MMGradientEditor
|
class_name MMGradientEditor
|
||||||
|
|
||||||
|
|
||||||
class GradientCursor:
|
class GradientCursor:
|
||||||
extends ColorRect
|
extends ColorRect
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user