Доработка. Значки назначения помех и выполнения помех у цели.
This commit is contained in:
@@ -7,12 +7,17 @@ func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Функция делает присваивает заданое значение видимости селектору
|
||||
# Функция присваивает заданое значение видимости селектору
|
||||
func set_sel_visible(value: bool):
|
||||
selected = value
|
||||
$selector.visible = value
|
||||
|
||||
|
||||
# Функция присваивает заданое значение видимости селектору
|
||||
func set_track_visible(value: bool): $track.visible = value
|
||||
# Функция присваивает заданое значение видимости индикатору выполнения
|
||||
func set_ecm_visible(value: bool): $ecm_done.visible = value
|
||||
|
||||
func _on_bip_gui_input(event):
|
||||
if event is InputEventMouseButton and event.pressed:
|
||||
match event.button_index:
|
||||
|
||||
106
scenes/bip.tscn
106
scenes/bip.tscn
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=12 format=3 uid="uid://nl1vklubr5kr"]
|
||||
[gd_scene load_steps=14 format=3 uid="uid://nl1vklubr5kr"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/bip.gd" id="1_4t8mr"]
|
||||
[ext_resource type="Shader" path="res://shaders/bip.gdshader" id="2_17aco"]
|
||||
@@ -104,12 +104,106 @@ shader_parameter/ant_band_count_0 = 3
|
||||
|
||||
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_hqs6j"]
|
||||
|
||||
[sub_resource type="Shader" id="Shader_81bae"]
|
||||
code = "shader_type canvas_item;
|
||||
|
||||
uniform vec4 color: source_color = vec4(1, 1, 1, 1);
|
||||
uniform vec4 color_up: source_color = vec4(1, 1, 1, 1); /* Цвет вспышки при обновлении */
|
||||
const float ds = 0.01425; /* Относительное расстояние на котором выполняется сглаживание краёв */
|
||||
const float dsr = 12.125;
|
||||
const vec2 center = vec2(0.5, 0.5); /* Центр должен быть в (0.5, 0.5), но это не так */
|
||||
const float radius = 0.075 - ds * 2.0; /* Радиус должен быть 0.5, но это не так */
|
||||
|
||||
uniform float speed: hint_range(0.0, 1024.0) = 0.0; /* Время вспышки при обновлении, c */
|
||||
uniform int ant_band_count_0 = 3;
|
||||
|
||||
uniform float ant_band_r0_0 = 0.3;
|
||||
|
||||
uniform float ant_band_r1_0 = 0.4;
|
||||
|
||||
float smooth_px(float r, float R, float dss)
|
||||
{
|
||||
return 1.0 - smoothstep(R - dss, R + dss, r);
|
||||
}
|
||||
|
||||
void sector(inout vec4 c, vec2 uv, vec2 cnt, float a, float da, float r0, float r1, vec4 col)
|
||||
{
|
||||
float l = distance(cnt, uv);
|
||||
vec2 d = uv - cnt;
|
||||
float sf = 500.0;
|
||||
float theta = atan(d.x, d.y) * sf;
|
||||
da /= 2.0;
|
||||
float a0 = radians(a - da);
|
||||
float a1 = radians(a + da);
|
||||
float va = smooth_px(a0 * sf, theta, dsr) - smooth_px(a1 * sf, theta, dsr);
|
||||
float vr = smooth_px(r0, l, ds) - smooth_px(r1, l, ds);
|
||||
float rgb = sqrt(va * vr);
|
||||
c.rgb += col.rgb * rgb * col.a;
|
||||
c.a += rgb * col.a;
|
||||
}
|
||||
|
||||
|
||||
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 = -cnt; i <= cnt; i ++)
|
||||
{
|
||||
float v = float(i & 1);
|
||||
vec4 col = v * c0 + (1.0f - v) * c1;
|
||||
sector(c, uv, p0, float(i) * da, da, r0, r1, col);
|
||||
}
|
||||
}
|
||||
|
||||
vec2 rotateUVmatrinx(vec2 uv, vec2 pivot, float rotation)
|
||||
{
|
||||
mat2 rotation_matrix=mat2( vec2(sin(rotation),-cos(rotation)),
|
||||
vec2(cos(rotation),sin(rotation))
|
||||
);
|
||||
uv -= pivot;
|
||||
uv *= rotation_matrix;
|
||||
uv += pivot;
|
||||
return uv;
|
||||
}
|
||||
|
||||
|
||||
void vertex()
|
||||
{
|
||||
float dir = 0.0;
|
||||
dir += speed * TIME;
|
||||
VERTEX = rotateUVmatrinx(VERTEX, center, radians(dir));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void fragment()
|
||||
{
|
||||
|
||||
ivec2 isz = textureSize(TEXTURE, 0);
|
||||
vec2 uv = UV * vec2(float(isz.x), float(isz.y)); // координаты текущей точки в пикселях
|
||||
COLOR = vec4(0, 0, 0, 0.0); //texture(TEXTURE, UV); // Цвет текущей точки
|
||||
|
||||
// Сетка антенн
|
||||
antenas(COLOR, uv, center, ant_band_count_0, ant_band_r0_0, ant_band_r1_0, color, color_up);
|
||||
}
|
||||
"
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_lpmq6"]
|
||||
shader = SubResource("Shader_60ho7")
|
||||
shader = SubResource("Shader_81bae")
|
||||
shader_parameter/color = Color(0.0862745, 0.560784, 0.72549, 0.886275)
|
||||
shader_parameter/color_up = Color(1, 1, 1, 0)
|
||||
shader_parameter/speed = -73.0
|
||||
shader_parameter/ant_band_count_0 = 9
|
||||
shader_parameter/ant_band_r0_0 = 0.45
|
||||
shader_parameter/ant_band_r1_0 = 0.5
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_h3oo7"]
|
||||
shader = SubResource("Shader_81bae")
|
||||
shader_parameter/color = Color(1, 0, 0, 1)
|
||||
shader_parameter/color_up = Color(1, 1, 1, 0)
|
||||
shader_parameter/speed = 66.064
|
||||
shader_parameter/ant_band_count_0 = 3
|
||||
shader_parameter/ant_band_r0_0 = 0.47
|
||||
shader_parameter/ant_band_r1_0 = 0.5
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_lkrha"]
|
||||
shader = ExtResource("3_fiufo")
|
||||
@@ -159,6 +253,14 @@ scale = Vector2(20, 20)
|
||||
texture = SubResource("PlaceholderTexture2D_hqs6j")
|
||||
centered = false
|
||||
|
||||
[node name="ecm_done" type="Sprite2D" parent="."]
|
||||
visible = false
|
||||
material = SubResource("ShaderMaterial_h3oo7")
|
||||
position = Vector2(-5, -5)
|
||||
scale = Vector2(30, 30)
|
||||
texture = SubResource("PlaceholderTexture2D_hqs6j")
|
||||
centered = false
|
||||
|
||||
[node name="track" type="Sprite2D" parent="."]
|
||||
visible = false
|
||||
material = SubResource("ShaderMaterial_lkrha")
|
||||
|
||||
@@ -87,6 +87,8 @@ func _ready():
|
||||
signaller.connect('rto_threat_unsel', Callable(self, 'on_rto_threat_unsel').bind(nodes))
|
||||
signaller.connect('threat_selected', Callable(self, 'on_threat_selected').bind(nodes))
|
||||
signaller.connect('interfer_selected', Callable(self, 'on_interfer_selected').bind(nodes))
|
||||
signaller.connect('interfer_new', Callable(self, 'on_interfer_new'))
|
||||
interfer.connect('interfer_update', Callable(self, 'on_interfer_new'))
|
||||
|
||||
func on_enter_tree() -> void:
|
||||
call_deferred('_on_btn_scale_pressed')
|
||||
@@ -112,6 +114,23 @@ func on_threat_update(th):
|
||||
map_threat_to_bip(th, bip)
|
||||
|
||||
|
||||
## Обработчик выбора помехи для цели
|
||||
func on_interfer_new(ecm):
|
||||
if interfer.thrs.has(ecm.ispp):
|
||||
var th_id = interfer.thrs[ecm.ispp]
|
||||
var bip = get_node('%d' % th_id)
|
||||
if ecm.krp != interfer.INTERFER_OFF:
|
||||
bip.set_track_visible(true)
|
||||
if ecm.svk == 1:
|
||||
print_debug(ecm.svk)
|
||||
bip.set_ecm_visible(true)
|
||||
else: bip.set_ecm_visible(false)
|
||||
else:
|
||||
bip.set_ecm_visible(false)
|
||||
bip.set_track_visible(false)
|
||||
|
||||
|
||||
|
||||
## Обработчик сигнала обнаружения цели
|
||||
func on_threat_new(th) -> void:
|
||||
var bip = Bip.instantiate()
|
||||
|
||||
@@ -10,9 +10,9 @@ const float radius = 0.075 - ds * 2.0; /* Радиус долж
|
||||
uniform float speed: hint_range(0.0, 1024.0) = 0.0; /* Время вспышки при обновлении, c */
|
||||
uniform int ant_band_count_0 = 3;
|
||||
|
||||
const float ant_band_r0_0 = 0.3;
|
||||
uniform float ant_band_r0_0 = 0.3;
|
||||
|
||||
const float ant_band_r1_0 = 0.4;
|
||||
uniform float ant_band_r1_0 = 0.4;
|
||||
|
||||
float smooth_px(float r, float R, float dss)
|
||||
{
|
||||
|
||||
@@ -69,11 +69,11 @@ void fragment()
|
||||
float py1 = 0.0;
|
||||
COLOR = vec4(1.0, 0.0, 0.0, 0.0); //texture(TEXTURE, UV); // Цвет текущей точки
|
||||
get_line_points(px0, px1, py0, py1, 330.0);
|
||||
COLOR.a += line(vec2(px0, py0), vec2(px1, py1), 5.0, UV);
|
||||
COLOR.a += line(vec2(px0, py0), vec2(px1, py1), 15.0, UV);
|
||||
get_line_points(px0, px1, py0, py1, 90.0);
|
||||
COLOR.a += line(vec2(px0, py0), vec2(px1, py1), 5.0, UV);
|
||||
COLOR.a += line(vec2(px0, py0), vec2(px1, py1), 15.0, UV);
|
||||
get_line_points(px0, px1, py0, py1, 210.0);
|
||||
COLOR.a += line(vec2(px0, py0), vec2(px1, py1), 5.0, UV);
|
||||
COLOR.a += line(vec2(px0, py0), vec2(px1, py1), 15.0, UV);
|
||||
COLOR *= smooth_px(length(UV-center), radius, DSS);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user