From 8936dadc385f66fc9bf7eb998bbd35fee3598db2 Mon Sep 17 00:00:00 2001 From: Florent Berthaut <florent.berthaut@univ-lille.fr> Date: Sun, 17 Sep 2023 22:45:16 +0200 Subject: [PATCH] Updated tunnel to use multimesh instance --- techniques/control/Tunnel/Tunnel.gd | 76 +++++++---- techniques/control/Tunnel/Tunnel.gdshader | 13 ++ techniques/control/Tunnel/Tunnel.tscn | 27 +++- techniques/control/Tunnel/TunnelParamData.gd | 1 + techniques/control/Tunnel/TunnelPreset.gd | 129 +++++++------------ 5 files changed, 141 insertions(+), 105 deletions(-) create mode 100644 techniques/control/Tunnel/Tunnel.gdshader diff --git a/techniques/control/Tunnel/Tunnel.gd b/techniques/control/Tunnel/Tunnel.gd index d5d9aea..c141e5e 100644 --- a/techniques/control/Tunnel/Tunnel.gd +++ b/techniques/control/Tunnel/Tunnel.gd @@ -9,14 +9,17 @@ var _slices = [] var tunnel_preset_array = [] @onready var _area : Area3D = get_node("Area3D") -var NUMBER_OF_SLICES = 50 -var RADIUS = 0.1 +@onready var _nb_slices : int = $MultiSlice.multimesh.instance_count + +const NUMBER_OF_SLICES : int = 100 +const RADIUS : float = 0.1 func _ready(): super._ready() _update_tunnel_preset_array() - _generate_slice() - _update_slices() + #_generate_slice() + #_update_slices() + _update_multislice() func _update_tunnel_preset_array(): tunnel_preset_array = [] @@ -56,11 +59,7 @@ func _update_slices() : s.scale.z = 0.5 s.rotation_degrees.x = 0 for param in tunnel_preset_array[_preset_index]: - var value : float - if param.data_type == DATA_TYPE.array: - value = _find_value_in_array(ratio,param.array) - else: - value = param.curve.sample(ratio) + var value : float = param.curve.sample(ratio) if value > 1.0 : value/=127 @@ -77,8 +76,45 @@ func _update_slices() : s.rotation_degrees.x = value*180 "tunnel_density" : s.scale.y = value + #FIXME add other params i+=1.0 +func _update_multislice() : + for s in range(_nb_slices) : + var col : Color + col.h = 0.5 + col.s = 1.0 + col.v = 0.5 + var trans : Transform3D = Transform3D() + trans.origin = Vector3((s-_nb_slices/2)*(1.0/_nb_slices), 0, 0) + var rot : Vector3 = Vector3(0.0, 0.0, PI/2.0) + var sca : Vector3 = Vector3(0.9,1.0,1.0) + var ratio : float = float(s) / float(_nb_slices) + for param in tunnel_preset_array[_preset_index]: + var value : float = param.curve.sample(ratio) + if value > 1.0 : + value/=127 + + match param.name: + "tunnel_color_scale" : + col = col.from_hsv(fmod(value*5.0,1.0), 1.0 - abs(value*2.0-1.0), value) + pass + "tunnel_height" : + sca.y = value*0.9+0.1 + sca.z = value*0.9+0.1 + "tunnel_rotation" : + rot.x = value*PI/4.0 + "tunnel_density" : + sca.x = value*0.8+0.1 + pass + + #trans.basis = trans.basis.from_euler(Vector3(0.0, 0.0, PI/2.0)) + trans.basis = Basis.from_euler(rot).scaled(sca) + $MultiSlice.multimesh.set_instance_transform(s, trans) + $MultiSlice.multimesh.set_instance_custom_data(s, Color(col.r,col.g,col.b,1.0)) + + + func _physics_process(delta): if !Engine.is_editor_hint() : if _ivmi._pd_mode!=IvmiScene.PdMode.NONE: @@ -92,11 +128,7 @@ func _physics_process(delta): var ratio = clamp(col_pos.x+0.5,0,1) #set all active parameters for param in tunnel_preset_array[_preset_index]: - var value - if param.data_type == DATA_TYPE.array: - value = _find_value_in_array(ratio,param.array) - else: - value = param.curve.sample(ratio) + var value : float = param.curve.sample(ratio) if value > 1.0 : value/=127 col.set_property(param.name, [value]) @@ -104,17 +136,10 @@ func _physics_process(delta): func get_extent(): return Vector3(1.0, 0.2, 0.2) -# Find the highest vec.x < x in the array -func _find_value_in_array(x,array): - var val : float = array[array.size()-1].y - for vec in array: - if vec.x<=x: - val = vec.y - return val - func _cycle_preset(): _preset_index = (_preset_index+1)%tunnel_preset_array.size() - _update_slices() + #pdate_slices() + _update_multislice() func _set_property(prop, vals) : @@ -126,9 +151,10 @@ func _set_property(prop, vals) : func _update_tunnel(): _update_tunnel_preset_array() - _update_slices() + _update_multislice() func _set_preset_index(val): if val < (get_child_count()-1) and val >= 0: _preset_index = val - _update_tunnel() + #_update_tunnel() + _update_multislice() diff --git a/techniques/control/Tunnel/Tunnel.gdshader b/techniques/control/Tunnel/Tunnel.gdshader new file mode 100644 index 0000000..bcc7fe5 --- /dev/null +++ b/techniques/control/Tunnel/Tunnel.gdshader @@ -0,0 +1,13 @@ +shader_type spatial; + +varying vec3 col; +varying float dep; + +void vertex() { + col = INSTANCE_CUSTOM.rgb; + dep = VERTEX.x; +} + +void fragment() { + ALBEDO = col*(dep*0.5+0.5); +} diff --git a/techniques/control/Tunnel/Tunnel.tscn b/techniques/control/Tunnel/Tunnel.tscn index f665d75..a9e31d2 100644 --- a/techniques/control/Tunnel/Tunnel.tscn +++ b/techniques/control/Tunnel/Tunnel.tscn @@ -1,20 +1,45 @@ -[gd_scene load_steps=3 format=3 uid="uid://bngkenwtwh5fg"] +[gd_scene load_steps=7 format=3 uid="uid://bngkenwtwh5fg"] [ext_resource type="Script" path="res://addons/ivmi-builder/techniques/control/Tunnel/Tunnel.gd" id="1"] +[ext_resource type="Shader" path="res://addons/ivmi-builder/techniques/control/Tunnel/Tunnel.gdshader" id="2_kaxyo"] [sub_resource type="BoxShape3D" id="1"] resource_local_to_scene = true margin = 0.0 size = Vector3(1, 0.1, 0.1) +[sub_resource type="ShaderMaterial" id="ShaderMaterial_mccv5"] +render_priority = 0 +shader = ExtResource("2_kaxyo") + +[sub_resource type="CylinderMesh" id="CylinderMesh_3cymo"] +material = SubResource("ShaderMaterial_mccv5") +top_radius = 0.05 +bottom_radius = 0.05 +height = 0.01 +radial_segments = 5 +rings = 1 + +[sub_resource type="MultiMesh" id="MultiMesh_5i54s"] +resource_local_to_scene = true +transform_format = 1 +use_custom_data = true +instance_count = 100 +mesh = SubResource("CylinderMesh_3cymo") +buffer = PackedFloat32Array(-3.93403e-08, -0.9, 0, -0.5, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.49, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.48, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.47, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.46, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.45, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.44, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.43, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.42, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.41, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.4, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.39, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.38, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.37, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.36, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.35, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.34, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.33, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.32, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.31, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.3, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.29, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.28, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.27, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.26, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.25, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.24, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.23, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.22, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.21, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.2, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.19, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.18, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.17, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.16, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.15, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.14, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.13, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.12, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.11, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.1, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.09, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.08, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.07, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.06, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.05, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.04, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.03, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.02, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, -0.01, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.01, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.02, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.03, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.04, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.05, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.06, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.07, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.08, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.09, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.1, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.11, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.12, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.13, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.14, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.15, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.16, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.17, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.18, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.19, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.2, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.21, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.22, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.23, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.24, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.25, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.26, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.27, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.28, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.29, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.3, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.31, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.32, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.33, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.34, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.35, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.36, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.37, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.38, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.39, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.4, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.41, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.42, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.43, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.44, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.45, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.46, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.47, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.48, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1, -3.93403e-08, -0.9, 0, 0.49, 1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1) + [node name="Tunnel" type="Node3D"] transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0) script = ExtResource("1") [node name="Slices" type="Node3D" parent="."] +visible = false [node name="Area3D" type="Area3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.01, 0, 0) [node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"] shape = SubResource("1") + +[node name="MultiSlice" type="MultiMeshInstance3D" parent="."] +multimesh = SubResource("MultiMesh_5i54s") diff --git a/techniques/control/Tunnel/TunnelParamData.gd b/techniques/control/Tunnel/TunnelParamData.gd index 1838f0f..9b3322d 100644 --- a/techniques/control/Tunnel/TunnelParamData.gd +++ b/techniques/control/Tunnel/TunnelParamData.gd @@ -4,3 +4,4 @@ var name = "undefined" var data_type var array = [] var curve +var string : String diff --git a/techniques/control/Tunnel/TunnelPreset.gd b/techniques/control/Tunnel/TunnelPreset.gd index 04b86eb..b76c80f 100644 --- a/techniques/control/Tunnel/TunnelPreset.gd +++ b/techniques/control/Tunnel/TunnelPreset.gd @@ -1,31 +1,19 @@ @tool extends "res://addons/ivmi-builder/core/IvmiNode.gd" -enum DATA_TYPE {curve,array} +enum DATA_TYPE {curve,array,string} @export var active = true -@export var _height_active: bool = false : set = _set_height_active -@export var _height_data_type: DATA_TYPE = DATA_TYPE.array : set = _set_height_data_type @export var _height_curve: Curve : set = _set_height_curve -@export var _height_array = [] : set = _set_height_array # (Array,Vector2) - -@export var _color_active: bool = false : set = _set_color_active -@export var _color_data_type: DATA_TYPE = DATA_TYPE.array : set = _set_color_data_type @export var _color_curve: Curve : set = _set_color_curve -@export var _color_array = [] : set = _set_color_array # (Array,Vector2) - -@export var _rotation_active: bool = false : set = _set_rotation_active -@export var _rotation_data_type: DATA_TYPE = DATA_TYPE.array : set = _set_rotation_data_type @export var _rotation_curve: Curve : set = _set_rotation_curve -@export var _rotation_array = [] : set = _set_rotation_array # (Array,Vector2) - -@export var _density_active: bool = false : set = _set_density_active -@export var _density_data_type: DATA_TYPE = DATA_TYPE.array : set = _set_density_data_type +@export var _speed_curve: Curve : set = _set_speed_curve @export var _density_curve: Curve : set = _set_density_curve -@export var _density_array = [] : set = _set_density_array # (Array,Vector2) +@export var _brightness_curve: Curve : set = _set_brightness_curve +@export var _noisiness_curve: Curve : set = _set_noisiness_curve var tunnel_param_data_script = preload("res://addons/ivmi-builder/techniques/control/Tunnel/TunnelParamData.gd") @@ -36,52 +24,57 @@ func _ready() : _color_curve.connect("changed",Callable(self,"_on_color_curve_changed")) if _rotation_curve: _rotation_curve.connect("changed",Callable(self,"_on_rotation_curve_changed")) + if _speed_curve: + _speed_curve.connect("changed",Callable(self,"_on_speed_curve_changed")) if _density_curve: _density_curve.connect("changed",Callable(self,"_on_density_curve_changed")) + if _brightness_curve: + _brightness_curve.connect("changed",Callable(self,"_on_brightness_curve_changed")) + if _noisiness_curve: + _noisiness_curve.connect("changed",Callable(self,"_on_noisiness_curve_changed")) func get_tunnel_preset_data(): var tunnel_param_data_array = [] - if _height_active: + if _height_curve: var tunnel_param_data = tunnel_param_data_script.new() tunnel_param_data.name = "tunnel_height" - tunnel_param_data.data_type = _height_data_type - if _height_data_type == DATA_TYPE.array: - tunnel_param_data.array = _height_array - else: - tunnel_param_data.curve = _height_curve - #print(name) - #print(tunnel_param_data.curve) - #print(tunnel_param_data.curve.get_point_count()) + tunnel_param_data.curve = _height_curve tunnel_param_data_array.append(tunnel_param_data) - if _rotation_active: + if _rotation_curve: var tunnel_param_data = tunnel_param_data_script.new() tunnel_param_data.name = "tunnel_rotation" - tunnel_param_data.data_type = _rotation_data_type - if _rotation_data_type == DATA_TYPE.array: - tunnel_param_data.array = _rotation_array - else: - tunnel_param_data.curve = _rotation_curve + tunnel_param_data.curve = _rotation_curve + tunnel_param_data_array.append(tunnel_param_data) + + if _speed_curve: + var tunnel_param_data = tunnel_param_data_script.new() + tunnel_param_data.name = "tunnel_speed" + tunnel_param_data.curve = _speed_curve tunnel_param_data_array.append(tunnel_param_data) - if _color_active: + if _color_curve: var tunnel_param_data = tunnel_param_data_script.new() tunnel_param_data.name = "tunnel_color_scale" - tunnel_param_data.data_type = _color_data_type - if _color_data_type == DATA_TYPE.array: - tunnel_param_data.array = _color_array - else: - tunnel_param_data.curve = _color_curve + tunnel_param_data.curve = _color_curve tunnel_param_data_array.append(tunnel_param_data) - if _density_active: + if _density_curve: var tunnel_param_data = tunnel_param_data_script.new() tunnel_param_data.name = "tunnel_density" - tunnel_param_data.data_type = _density_data_type - if _density_data_type == DATA_TYPE.array: - tunnel_param_data.array = _density_array - else: - tunnel_param_data.curve = _density_curve + tunnel_param_data.curve = _density_curve + tunnel_param_data_array.append(tunnel_param_data) + + if _brightness_curve: + var tunnel_param_data = tunnel_param_data_script.new() + tunnel_param_data.name = "tunnel_brightness" + tunnel_param_data.curve = _brightness_curve + tunnel_param_data_array.append(tunnel_param_data) + + if _noisiness_curve: + var tunnel_param_data = tunnel_param_data_script.new() + tunnel_param_data.name = "tunnel_noisiness" + tunnel_param_data.curve = _noisiness_curve tunnel_param_data_array.append(tunnel_param_data) return tunnel_param_data_array @@ -93,66 +86,44 @@ func _update_tunnel(): parent._update_tunnel() -func _set_height_active(val): - _height_active = val - _update_tunnel() -func _set_height_data_type(val): - _height_data_type = val - _update_tunnel() func _set_height_curve(val): _height_curve = val _update_tunnel() func _on_height_curve_changed() : _update_tunnel() -func _set_height_array(val): - _height_array = val - _update_tunnel() -func _set_color_active(val): - _color_active = val - _update_tunnel() -func _set_color_data_type(val): - _color_data_type = val - _update_tunnel() func _set_color_curve(val): _color_curve = val _update_tunnel() func _on_color_curve_changed() : _update_tunnel() -func _set_color_array(val): - _color_array = val - _update_tunnel() -func _set_rotation_active(val): - _rotation_active = val - _update_tunnel() -func _set_rotation_data_type(val): - _rotation_data_type = val - _update_tunnel() func _set_rotation_curve(val): _rotation_curve = val _update_tunnel() func _on_rotation_curve_changed() : _update_tunnel() -func _set_rotation_array(val): - _rotation_array = val - _update_tunnel() - -func _set_density_active(val): - _density_active = val +func _set_speed_curve(val): + _speed_curve = val _update_tunnel() -func _set_density_data_type(val): - _density_data_type = val +func _on_speed_curve_changed() : _update_tunnel() + func _set_density_curve(val): _density_curve = val _update_tunnel() func _on_density_curve_changed() : _update_tunnel() -func _set_density_array(val): - _density_array = val + +func _set_brightness_curve(val): + _brightness_curve = val _update_tunnel() +func _on_brightness_curve_changed() : + _update_tunnel() - - +func _set_noisiness_curve(val): + _noisiness_curve = val + _update_tunnel() +func _on_noisiness_curve_changed() : + _update_tunnel() -- GitLab