Доработка. Переключение режимов карты - РТО

This commit is contained in:
sasha80
2023-09-29 08:54:10 +03:00
parent b489cc497d
commit 130e2cdf7a
3 changed files with 41 additions and 35 deletions

View File

@@ -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);

View File

@@ -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('группа-режим-помехи')

View File

@@ -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