2018-07-28 21:21:05 +02:00
|
|
|
tool
|
|
|
|
extends ViewportContainer
|
|
|
|
|
2018-08-07 09:31:41 +02:00
|
|
|
var preview_maximized = false
|
|
|
|
|
2018-07-28 21:21:05 +02:00
|
|
|
const ENVIRONMENTS = [
|
|
|
|
"experiment", "lobby", "night", "park", "schelde"
|
|
|
|
]
|
|
|
|
|
|
|
|
func _ready():
|
2018-08-12 19:25:18 +02:00
|
|
|
var m
|
|
|
|
m = $MaterialPreview/Objects/Cube.get_surface_material(0).duplicate()
|
2018-07-29 23:43:24 +02:00
|
|
|
$MaterialPreview/Objects/Cube.set_surface_material(0, m)
|
|
|
|
$MaterialPreview/Objects/Cylinder.set_surface_material(0, m)
|
2018-08-12 19:25:18 +02:00
|
|
|
m = $MaterialPreview/Objects/Sphere.get_surface_material(0).duplicate()
|
|
|
|
$MaterialPreview/Objects/Sphere.set_surface_material(0, m)
|
2018-07-28 21:21:05 +02:00
|
|
|
$ObjectRotate.play("rotate")
|
2018-08-07 09:31:41 +02:00
|
|
|
$Preview2D.material = $Preview2D.material.duplicate(true)
|
|
|
|
_on_Environment_item_selected($Config/Environment.selected)
|
|
|
|
_on_Preview_resized()
|
2018-07-28 21:21:05 +02:00
|
|
|
|
|
|
|
func _on_Environment_item_selected(id):
|
2018-09-03 21:35:44 +02:00
|
|
|
$MaterialPreview/WorldEnvironment.environment.background_sky.panorama = load("res://addons/material_maker/panoramas/"+ENVIRONMENTS[id]+".hdr")
|
2018-07-29 19:19:35 +02:00
|
|
|
|
|
|
|
func _on_Model_item_selected(id):
|
2018-08-07 09:31:41 +02:00
|
|
|
var model = $Config/Model.get_item_text(id)
|
2018-07-29 19:19:35 +02:00
|
|
|
for c in $MaterialPreview/Objects.get_children():
|
|
|
|
c.visible = (c.get_name() == model)
|
2018-07-29 23:43:24 +02:00
|
|
|
|
|
|
|
func get_materials():
|
2018-08-10 12:31:15 +02:00
|
|
|
return [ $MaterialPreview/Objects/Cube.get_surface_material(0), $MaterialPreview/Objects/Sphere.get_surface_material(0) ]
|
2018-08-07 09:31:41 +02:00
|
|
|
|
|
|
|
func get_2d_material():
|
|
|
|
return $Preview2D.material
|
|
|
|
|
|
|
|
func _on_Preview_resized():
|
|
|
|
if preview_maximized:
|
|
|
|
var size = min(rect_size.x, rect_size.y)
|
|
|
|
$Preview2D.rect_position = 0.5*Vector2(rect_size.x-size, rect_size.y-size)
|
|
|
|
$Preview2D.rect_size = Vector2(size, size)
|
|
|
|
else:
|
|
|
|
$Preview2D.rect_position = Vector2(0, rect_size.y-64)
|
|
|
|
$Preview2D.rect_size = Vector2(64, 64)
|
|
|
|
|
|
|
|
func _on_Preview2D_gui_input(ev):
|
|
|
|
if ev is InputEventMouseButton && ev.button_index == 1 && ev.doubleclick:
|
|
|
|
preview_maximized = !preview_maximized
|
|
|
|
_on_Preview_resized()
|
2018-08-05 18:46:23 +02:00
|
|
|
|
|
|
|
|