diff --git a/src/globals.gd b/src/globals.gd index 285881f..70a585e 100644 --- a/src/globals.gd +++ b/src/globals.gd @@ -10,6 +10,7 @@ var D = { var data := {} var settings := { SCALE_FACTOR = DafaultConfig.settings.game_settings.SCALE_FACTOR, + ROTATION_SPEED = DafaultConfig.settings.game_settings.ROTATION_SPEED, } # global signals diff --git a/src/models/icosahedron/Icosahedron.tscn b/src/models/icosahedron/Icosahedron.tscn index 7df0023..9a1d6c4 100644 --- a/src/models/icosahedron/Icosahedron.tscn +++ b/src/models/icosahedron/Icosahedron.tscn @@ -59,6 +59,7 @@ shader_parameter/color = Vector3(0, 1, 0) [node name="Icosahedron" type="Node3D"] script = ExtResource("1_w7qn7") +shader_type = -1 [node name="CutPlane" type="MeshInstance3D" parent="."] transform = Transform3D(-0.761007, -0.570635, -0.308616, -0.107281, 0.579858, -0.807623, 0.639811, -0.581498, -0.502495, -0.843964, 0.0584427, -0.468957) diff --git a/src/models/icosahedron/components/Icosahedron.gd b/src/models/icosahedron/components/Icosahedron.gd index a13da23..9fc1c2f 100644 --- a/src/models/icosahedron/components/Icosahedron.gd +++ b/src/models/icosahedron/components/Icosahedron.gd @@ -10,10 +10,7 @@ const EDGE_NOISE = preload('res://src/models/icosahedron/resources/edge_noise.re @export var DEBUG_VISUAL: bool @export var scaling_enabled = false @export var scale_factor: float -@export var shader_type: int = 0: - set(val): - shader_type = val - #set_shader_type(val) +@export var shader_type: int var show_face_numbers: bool @export var inital_transfrm := Quaternion() @onready var cut_plane: CutPlane = $CutPlane diff --git a/src/models/icosahedron/components/MeshIcosahedron.gd b/src/models/icosahedron/components/MeshIcosahedron.gd index 4cfe6a7..b25b014 100644 --- a/src/models/icosahedron/components/MeshIcosahedron.gd +++ b/src/models/icosahedron/components/MeshIcosahedron.gd @@ -16,19 +16,27 @@ const MATERIAL_002 = preload('res://src/models/icosahedron/test/Material.face_in EDGE_HIGHLIGHT_V_1, ] +@export var default_shaders := [ + ICOSAHEDRON_SHADER_V_1, + OUTLINE_V_1, +] + @onready var icosahedron: Icosahedron = $".." @onready var collider: Collider = $'../Collider' var angle_good := false var is_alt := false var is_rotating := false -@export var currnt_type := -1 +var currnt_type : int var show_face_numbers := false # Called when the node enters the scene tree for the first time. func _ready() -> void: currnt_type = icosahedron.shader_type show_face_numbers = icosahedron.show_face_numbers - set_type(currnt_type) + if currnt_type >= 0: + set_type(currnt_type) + else: + set_default_type() if Utils.main_scene(self) in ['MainScene', 'LoopScene', 'MenuScene']: # wierd trick to not get errors when scaling and rotating mesh when its mounted in runtime transform.basis = Basis(icosahedron.transform.basis.get_rotation_quaternion()) @@ -48,13 +56,19 @@ func set_color(c: Vector3): ShaderUtils.set_shader_param(self, "color", c, i) func set_type(type: int): - currnt_type = type var variant: Vector4 = IcosahedronVarints.figure_variants_v2[type] if show_face_numbers: - self.material_override = MATERIAL_002 - else: - ShaderUtils.apply_shaders(applied_shaders, self) - + self.material_overlay = MATERIAL_002 + ShaderUtils.apply_shaders(applied_shaders, self) + ShaderUtils.set_shader_param(self, "cutplane_visible", 0, 0) set_cutplane(variant) var variant_color: Array = TwTheme.figure_variants_v2[type] set_color(Op.v3(variant_color)) + +func set_default_type(): + if show_face_numbers: + self.material_overlay = MATERIAL_002 + ShaderUtils.apply_shaders(default_shaders, self) + + var variant_color: Array = TwTheme.T.figure_variants.default + set_color(Op.v3(variant_color)) diff --git a/src/models/icosahedron/test/variant_test.gd b/src/models/icosahedron/test/variant_test.gd index 6fc1b2a..596d185 100644 --- a/src/models/icosahedron/test/variant_test.gd +++ b/src/models/icosahedron/test/variant_test.gd @@ -2,12 +2,24 @@ extends Node3D const IcosahedronScene = preload('res://src/models/icosahedron/Icosahedron.tscn') var controlledNode -# TODO get from defaults + @export var ROTATION_SPEED: float = G.settings.ROTATION_SPEED -@export var show_face_numbers: bool = false + +@export_category("variant settings") +@export var show_face_numbers: bool = true +@export_range(0, 19) var variant_type: int = 0 +@export var use_default := false + # Called when the node enters the scene tree for the first time. func _ready() -> void: - var new_figure = IcosahedronScene.instantiate().with_type(1).with_face_numbers(show_face_numbers) + var new_figure + if use_default: + new_figure = IcosahedronScene.instantiate() + else: + new_figure = IcosahedronScene.instantiate()\ + .with_type(variant_type)\ + .with_face_numbers(show_face_numbers) + add_child(new_figure) controlledNode = new_figure.mesh_icosahedron diff --git a/src/models/icosahedron/test/variant_test.tscn b/src/models/icosahedron/test/variant_test.tscn index be7de18..e4f88af 100644 --- a/src/models/icosahedron/test/variant_test.tscn +++ b/src/models/icosahedron/test/variant_test.tscn @@ -24,7 +24,7 @@ shader_parameter/bg_color = Color(0.729, 0.902, 0.992, 1) [node name="VariantTest" type="Node3D"] script = ExtResource("1_4av47") -show_face_numbers = true +use_default = true [node name="Environment" type="Node3D" parent="."]