From 130e2cdf7a9f0637af85336df8171c144e1cd28b Mon Sep 17 00:00:00 2001 From: sasha80 Date: Fri, 29 Sep 2023 08:54:10 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0.=20=D0=9F=D0=B5=D1=80=D0=B5=D0=BA=D0=BB=D1=8E?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=80=D0=B5=D0=B6=D0=B8=D0=BC?= =?UTF-8?q?=D0=BE=D0=B2=20=D0=BA=D0=B0=D1=80=D1=82=D1=8B=20-=20=D0=A0?= =?UTF-8?q?=D0=A2=D0=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scenes/canvas.gd | 4 ++- scenes/работа.gd | 8 +++--- shaders/shader_edu.tres | 64 ++++++++++++++++++++++------------------- 3 files changed, 41 insertions(+), 35 deletions(-) diff --git a/scenes/canvas.gd b/scenes/canvas.gd index 804b4cb..1d1793d 100644 --- a/scenes/canvas.gd +++ b/scenes/canvas.gd @@ -1,5 +1,7 @@ extends Sprite2D +func sv(val: float) -> float: return val / ($строб.scale.x / 2.0) * 0.125 + func set_strob_visible(val: bool): $строб.visible = val func set_strob_center(val: Vector2): $строб.position = val func set_strob_dir(val: float): $строб.material.set('shader_parameter/dir', val) @@ -17,4 +19,4 @@ func get_strob_radius() -> float: return $строб.material.get('shader_par func get_radius_outter() -> float: return material.get('shader_parameter/radius_outter') func get_radius_inner() -> float: return material.get('shader_parameter/radius_inner') -func sv(val: float) -> float: return val / ($строб.scale.x / 2.0) * 0.125 +func set_view_mode(val: int): material.set('shader_parameter/mode', val); diff --git a/scenes/работа.gd b/scenes/работа.gd index 205624f..6bc596c 100644 --- a/scenes/работа.gd +++ b/scenes/работа.gd @@ -43,8 +43,7 @@ enum DragFSM { } -## Переключант режим окна программы полный экран - обычный -func _on_full_screen(): toggle_full_screen(window_0_id) +func on_button_view_toggled(toggled: bool): $canvas.set_view_mode(int(toggled)) ## Обработчик сигнала изменения списка целей @@ -53,8 +52,9 @@ func on_threats_resized(threats: Dictionary): $count_all_pad/count_all.text = '% ## Производит инициализацию func _ready(): - $btn_strobe.button_connect('pressed', Callable(self, 'on_button_strobe_pressed')) - $btn_off.set_pressed(true) + $btn_strob.button_connect('pressed', Callable(self, 'on_button_strobe_pressed')) + $btn_view.button_connect('toggled', Callable(self, 'on_button_view_toggled')) + $grd_btns/btn_off.set_pressed(true) on_button_strobe_pressed() drag_fsm = DragFSM.OFF var nodes: Array = get_tree().get_nodes_in_group('группа-режим-помехи') diff --git a/shaders/shader_edu.tres b/shaders/shader_edu.tres index f51e41b..f7d68e1 100644 --- a/shaders/shader_edu.tres +++ b/shaders/shader_edu.tres @@ -9,30 +9,33 @@ uniform vec4 color0: source_color = vec4(0.38, 0.47, 0.51, 0.4); uniform vec4 color1: source_color = vec4(0.39, 0.44, 0.50, 0.4); uniform float radius_inner = 200.0; /* Радиус внутренний. Должно быть равно ant_band_r0_0 */ uniform float radius_outter = 550.0; /* Радиус внешний. Должно быть равно ant_band_r1_6 */ +uniform int mode = 0; /* Режим отображения. Приоритет РТО - 0, приоритет РЛС - 1 */ -const float ant_band_count_0 = 2.0; -const float ant_band_count_1 = 2.0; -const float ant_band_count_2 = 2.0; -const float ant_band_count_3 = 2.0; -const float ant_band_count_4 = 2.0; -const float ant_band_count_5 = 2.0; -const float ant_band_count_6 = 2.0; +const int ant_band_count_0 = 2; +const int ant_band_count_1 = 2; +const int ant_band_count_2 = 2; +const int ant_band_count_3 = 2; +const int ant_band_count_4 = 2; +const int ant_band_count_5 = 2; +const int ant_band_count_6 = 2; + +const float ant_band_r0_0[] = {200.0, 480.0}; +const float ant_band_r0_1[] = {250.0, 490.0}; +const float ant_band_r0_2[] = {300.0, 500.0}; +const float ant_band_r0_3[] = {350.0, 510.0}; +const float ant_band_r0_4[] = {400.0, 520.0}; +const float ant_band_r0_5[] = {450.0, 530.0}; +const float ant_band_r0_6[] = {500.0, 540.0}; + +const float ant_band_r1_0[] = {250.0, 490.0}; +const float ant_band_r1_1[] = {300.0, 500.0}; +const float ant_band_r1_2[] = {350.0, 510.0}; +const float ant_band_r1_3[] = {400.0, 520.0}; +const float ant_band_r1_4[] = {450.0, 530.0}; +const float ant_band_r1_5[] = {500.0, 540.0}; +const float ant_band_r1_6[] = {550.0, 550.0}; -const float ant_band_r0_0 = 200.0; -const float ant_band_r0_1 = 250.0; -const float ant_band_r0_2 = 300.0; -const float ant_band_r0_3 = 350.0; -const float ant_band_r0_4 = 400.0; -const float ant_band_r0_5 = 450.0; -const float ant_band_r0_6 = 500.0; -const float ant_band_r1_0 = 250.0; -const float ant_band_r1_1 = 300.0; -const float ant_band_r1_2 = 350.0; -const float ant_band_r1_3 = 400.0; -const float ant_band_r1_4 = 450.0; -const float ant_band_r1_5 = 500.0; -const float ant_band_r1_6 = 550.0; const float d4 = 90.0; const float ds = 1.0; @@ -60,10 +63,10 @@ void sector(inout vec4 c, vec2 uv, vec2 center, float a, float da, float r0, flo } -void antenas(inout vec4 c, vec2 uv, vec2 p0, float cnt, float r0, float r1, vec4 c0, vec4 c1) +void antenas(inout vec4 c, vec2 uv, vec2 p0, int cnt, float r0, float r1, vec4 c0, vec4 c1) { float da = 180.0f / float(cnt); - for (int i = int(-cnt); i <= int(cnt); i ++) + for (int i = -cnt; i <= cnt; i ++) { float v = float(i & 1); vec4 col = v * c0 + (1.0f - v) * c1; @@ -113,13 +116,13 @@ void fragment() COLOR = vec4(0, 0, 0, 0.0); //texture(TEXTURE, UV); // Цвет текущей точки // Сетка антенн - antenas(COLOR, uv, pc0, ant_band_count_0, ant_band_r0_0, ant_band_r1_0, color1, color0); - antenas(COLOR, uv, pc0, ant_band_count_1, ant_band_r0_1, ant_band_r1_1, color0, color1); - antenas(COLOR, uv, pc0, ant_band_count_2, ant_band_r0_2, ant_band_r1_2, color1, color0); - antenas(COLOR, uv, pc0, ant_band_count_3, ant_band_r0_3, ant_band_r1_3, color0, color1); - antenas(COLOR, uv, pc0, ant_band_count_4, ant_band_r0_4, ant_band_r1_4, color1, color0); - antenas(COLOR, uv, pc0, ant_band_count_5, ant_band_r0_5, ant_band_r1_5, color0, color1); - antenas(COLOR, uv, pc0, ant_band_count_6, ant_band_r0_6, ant_band_r1_6, color1, color0); + antenas(COLOR, uv, pc0, ant_band_count_0, ant_band_r0_0[mode], ant_band_r1_0[mode], color1, color0); + antenas(COLOR, uv, pc0, ant_band_count_1, ant_band_r0_1[mode], ant_band_r1_1[mode], color0, color1); + antenas(COLOR, uv, pc0, ant_band_count_2, ant_band_r0_2[mode], ant_band_r1_2[mode], color1, color0); + antenas(COLOR, uv, pc0, ant_band_count_3, ant_band_r0_3[mode], ant_band_r1_3[mode], color0, color1); + antenas(COLOR, uv, pc0, ant_band_count_4, ant_band_r0_4[mode], ant_band_r1_4[mode], color1, color0); + antenas(COLOR, uv, pc0, ant_band_count_5, ant_band_r0_5[mode], ant_band_r1_5[mode], color0, color1); + antenas(COLOR, uv, pc0, ant_band_count_6, ant_band_r0_6[mode], ant_band_r1_6[mode], color1, color0); } " @@ -131,3 +134,4 @@ shader_parameter/color0 = Color(0.380392, 0.470588, 0.509804, 0.537255) shader_parameter/color1 = Color(0.3315, 0.45645, 0.51, 0.537255) shader_parameter/radius_inner = 200.0 shader_parameter/radius_outter = 550.0 +shader_parameter/mode = 0