-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.gd
147 lines (120 loc) · 3.46 KB
/
Main.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
extends Control
# Texture
onready var top_text = $UI/Top/Preview.texture
onready var left_text = $UI/Left/Preview.texture
onready var right_text = $UI/Right/Preview.texture
var black_text
#
onready var size = $UI/TopOptions/Size
onready var height = $UI/TopOptions/Height
onready var uv_adapt = $UI/TopOptions/UV_Adapt
onready var top_color = $UI/Top/Color
onready var left_color = $UI/Left/Color
onready var right_color = $UI/Right/Color
onready var antialiasing = $UI/Antialiasing
# Window
onready var load_window = $FileDialog
onready var save_window = $SaveDialog
# Result
onready var viewport = $Viewport
onready var iso = $Viewport/IsoGenerator
onready var result = $Result
var current_load : int
func _ready():
var test_args = [
"C:\\tempo\\1.jpg", # text top
"C:\\tempo\\forest_face.png", # text left
"C:\\tempo\\grass_face.png", # text right
"#ffffff", # color top
"#ffffff", # color left
"#ffffff", # color right
"32", # size
"0.5", # height
"1", # uv_adapt
"1", # antialiasing
"C:\\tempo\\new_test_1.png" # save test
]
if OS.get_cmdline_args().size() == 11:
call_deferred("args_gen_10", OS.get_cmdline_args())
else:
_generate()
func args_gen_10(args):
var image = Image.new()
image.load(args[0])
iso.top_texture = ImageTexture.new()
iso.top_texture.create_from_image(image)
image = Image.new()
image.load(args[1])
iso.left_texture = ImageTexture.new()
iso.left_texture.create_from_image(image)
image = Image.new()
image.load(args[2])
iso.right_texture = ImageTexture.new()
iso.right_texture.create_from_image(image)
######
size.value = float(args[6])
height.value = float(args[7])
uv_adapt.selected = int(args[8])
top_color.color = Color(args[3])
left_color.color = Color(args[4])
right_color.color = Color(args[5])
antialiasing.pressed = bool(int(args[9]))
_generate()
yield(get_tree(), "idle_frame")
yield(get_tree(), "idle_frame")
yield(get_tree(), "idle_frame")
viewport.get_texture().get_data().save_png(args[10])
get_tree().quit()
func _on_Load_Top_pressed():
load_window.popup()
current_load = 0
func _on_Load_Left_pressed():
load_window.popup()
current_load = 1
func _on_Load_Right_pressed():
load_window.popup()
current_load = 2
func _on_FileDialog_file_selected(path):
var image = Image.new()
image.load(path)
match(current_load):
0:
iso.top_texture = top_text
top_text.create_from_image(image)
1:
iso.left_texture = left_text
left_text.create_from_image(image)
2:
iso.right_texture = right_text
right_text.create_from_image(image)
_generate()
func _generate():
# Iso Update
iso.top_color = top_color.color
iso.left_color = left_color.color
iso.right_color = right_color.color
iso.height = height.value
iso.antialiasing = antialiasing.pressed
iso.rect_size.x = size.value*2
iso.rect_size.y = size.value*2 #sqrt(pow(size.value,2)+pow(size.value*2,2))/2.0
match(uv_adapt.get_selected_id()):
0:
iso.adapt_uv = IsoGenerator.UvAdaptMode.NONE
1:
iso.adapt_uv = IsoGenerator.UvAdaptMode.TOP
2:
iso.adapt_uv = IsoGenerator.UvAdaptMode.BOTTOM
# Viewport Update
viewport.size.x = size.value*2
viewport.size.y = size.value*2#sqrt(pow(size.value,2)+pow(size.value*2,2))/2.0
yield(get_tree(), "idle_frame")
result.update()
func _on_Color_changed(color):
_generate()
func _on_SaveDialog_file_selected(path):
viewport.get_texture().get_data().save_png(path)
func _on_SaveButton_pressed():
save_window.popup()
#Updated per type
func _on_Value_Change(color):
_generate()