Работа в процессе
This commit is contained in:
14
canvas.gd
14
canvas.gd
@@ -1,14 +0,0 @@
|
||||
@tool
|
||||
extends Sprite2D
|
||||
|
||||
# const band_ants = [Vector4(8, 600, 650, 10), Vector4(8, 650, 700, 30), Vector4(12, 750, 800, 50)]
|
||||
var band_ants: PackedInt32Array = PackedInt32Array([8, 8, 12])
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
material.set_shader_parameter('band_ants', band_ants)
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
@@ -2,14 +2,31 @@
|
||||
|
||||
extends PanelContainer
|
||||
|
||||
@export var text: String = '': get = get_text, set = set_text
|
||||
@export var texture_state0: Texture2D = preload('res://data/кнопка-квадрат-0.png'): set = _state_set_texture
|
||||
@export var texture_state1: Texture2D = preload('res://data/кнопка-квадрат-1.png'): set = _state_set_texture
|
||||
@export var pressed: bool = false: get = is_pressed, set = set_pressed
|
||||
@export var toggle_mode: bool = false: get = is_toggle_mode, set = set_toggle_mode
|
||||
|
||||
func _state_set_texture(val: Texture2D): $state.set_texture(val)
|
||||
func _state_get_texture(): return $state.get_texture()
|
||||
@export var texture_state0: Texture2D = preload('res://data/кнопка-квадрат-0.png'):
|
||||
set(val): $state.set_texture(val)
|
||||
|
||||
|
||||
@export var texture_state1: Texture2D = preload('res://data/кнопка-квадрат-1.png'):
|
||||
set(val): $state.set_texture(val)
|
||||
|
||||
|
||||
@export var text: String = '':
|
||||
set(val): $button.set_text(val)
|
||||
get: return $button.get_text()
|
||||
|
||||
|
||||
@export var pressed: bool = false:
|
||||
set(val): $button.set_pressed(val)
|
||||
get: return $button.is_pressed()
|
||||
|
||||
|
||||
@export var toggle_mode: bool = false:
|
||||
set(val):
|
||||
if is_inside_tree():
|
||||
$button.set_toggle_mode(val)
|
||||
get: return $button.is_toggle_mode()
|
||||
|
||||
|
||||
func set_text (val: String): $button.set_text(val)
|
||||
func set_pressed (val: bool): $button.set_pressed(val)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
[ext_resource type="PackedScene" uid="uid://lwmw4egynmd1" path="res://scenes/контроль.tscn" id="2_h2mc4"]
|
||||
|
||||
[node name="tab_switch" type="TabContainer"]
|
||||
offset_top = -2.0
|
||||
offset_top = 0.0
|
||||
offset_right = 1600.0
|
||||
offset_bottom = 1200.0
|
||||
|
||||
|
||||
125
scenes/работа.gd
125
scenes/работа.gd
@@ -1,35 +1,63 @@
|
||||
extends Panel
|
||||
|
||||
const RADIO_GROUPE_NAMES = \
|
||||
['btn_off', 'btn_p4', 'btn_p5', 'btn_p6', 'btn_p7',
|
||||
'btn_p8', 'btn_p9', 'btn_p10', 'btn_p11', 'btn_p12',
|
||||
'btn_p13', 'btn_p14', 'btn_p15', 'btn_p16', 'btn_auto_rfi']
|
||||
@export_color_no_alpha var col_red
|
||||
@export_color_no_alpha var col_grey
|
||||
|
||||
enum DRAG_FSM { IDLE, DRAG }
|
||||
var radio_groupe: Array
|
||||
var drag_pos_begin: Vector2
|
||||
var drag_fsm: DRAG_FSM
|
||||
var drag_button: MouseButton
|
||||
var pc0: Vector2
|
||||
var ant_dir_width_begin: float
|
||||
var ant_dir_begin: float
|
||||
""" Состояние перетаскивания """
|
||||
|
||||
var drag_pos_begin: Vector2
|
||||
""" Точка начала перетаскивания """
|
||||
|
||||
var drag_fsm: DRAG_FSM = DRAG_FSM.IDLE
|
||||
""" Текущее состояние перетаскивания """
|
||||
|
||||
var drag_button: MouseButton
|
||||
""" Кнопка мыши нажатая при перетаскивании """
|
||||
|
||||
var ant_width_begin: float
|
||||
""" Ширина ДН антенны в момент начала перетаскивания """
|
||||
|
||||
var ant_dir_begin: float
|
||||
""" Направление антенны в момент начала перетаскивания """
|
||||
|
||||
var ant_center: Vector2
|
||||
""" Центр антенн """
|
||||
|
||||
signal drag_begin
|
||||
""" Вызывается в момент начала перетаскивания """
|
||||
|
||||
signal drag_continue
|
||||
""" Вызывается во время продолжения перетаскивания """
|
||||
|
||||
signal drag_end
|
||||
""" Вызывается в момент завершения перетаскивания """
|
||||
|
||||
signal full_screen
|
||||
""" Вызывается при смене режима окна полный экран - оконный """
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
$btn_strobe.button_connect('pressed', Callable(self, 'on_button_stobe_pressed'))
|
||||
$canvas/animator.play('вращение')
|
||||
$'рамка-режим/btn_off'.set_pressed(true)
|
||||
var nodes = $'рамка-режим'.get_children()
|
||||
pc0 = $canvas.material.get('shader_parameter/pc0')
|
||||
ant_center = $canvas.material.get('shader_parameter/pc0')
|
||||
$canvas.material.set('shader_parameter/ap_ant_col', col_grey)
|
||||
var nodes: = get_tree().get_nodes_in_group('группа-режим-помехи')
|
||||
for btn in nodes:
|
||||
if btn.name in RADIO_GROUPE_NAMES:
|
||||
radio_groupe.append(btn)
|
||||
btn.button_connect('pressed', Callable(self, '_on_button_pressed').bind(btn))
|
||||
btn.button_connect('pressed', Callable(self, 'on_button_pressed').bind(btn, nodes))
|
||||
|
||||
|
||||
func _on_button_pressed(btn):
|
||||
func on_button_stobe_pressed():
|
||||
if $btn_strobe.is_pressed():
|
||||
$canvas.material.set('shader_parameter/ap_ant_col', col_red)
|
||||
else:
|
||||
$canvas.material.set('shader_parameter/ap_ant_col', col_grey)
|
||||
|
||||
|
||||
func on_button_pressed(btn_this, btn_others):
|
||||
# поведение радиокнопок в группе
|
||||
for btn0 in radio_groupe:
|
||||
btn0.set_pressed(btn0 == btn)
|
||||
for btn_other in btn_others: btn_other.set_pressed(btn_this == btn_other)
|
||||
|
||||
|
||||
func hypot(x: float, y: float) -> float:
|
||||
@@ -46,37 +74,62 @@ func map_xy_ang(pos0: Vector2, pos: Vector2) -> Vector2:
|
||||
return Vector2(ang, radius)
|
||||
|
||||
|
||||
func get_ant_width(position: Vector2, prev: float) -> float:
|
||||
var radp: Vector2 = map_xy_ang(pc0, position)
|
||||
var ap_ant_w: float = prev + (drag_pos_begin.y - position.y) / 5.0
|
||||
func get_ant_width(pos: Vector2, prev: float) -> float:
|
||||
var ap_ant_w: float = prev + (drag_pos_begin.y - pos.y) / 5.0
|
||||
if ap_ant_w < 5.0: ap_ant_w = 5.0
|
||||
if ap_ant_w > 90.0: ap_ant_w = 90.0
|
||||
return ap_ant_w
|
||||
|
||||
|
||||
func set_ant_dir(position: Vector2):
|
||||
var radp: Vector2 = map_xy_ang(pc0, position)
|
||||
func set_ant_dir(pos: Vector2):
|
||||
var radp: Vector2 = map_xy_ang(ant_center, pos)
|
||||
if radp.y < 600:
|
||||
$canvas.material.set('shader_parameter/sec_var', radp.x)
|
||||
|
||||
|
||||
func _on_drag_continue(event):
|
||||
if drag_button == MOUSE_BUTTON_RIGHT:
|
||||
var ap_ant_w: float = get_ant_width(event.position, ant_width_begin)
|
||||
$canvas.material.set('shader_parameter/ap_ant_w', ap_ant_w)
|
||||
elif drag_button == MOUSE_BUTTON_LEFT:
|
||||
set_ant_dir(event.position)
|
||||
|
||||
|
||||
func _on_drag_begin(event):
|
||||
drag_pos_begin = event.position
|
||||
if drag_button == MOUSE_BUTTON_LEFT:
|
||||
set_ant_dir(event.position)
|
||||
elif drag_button == MOUSE_BUTTON_RIGHT:
|
||||
ant_width_begin = $canvas.material.get('shader_parameter/ap_ant_w')
|
||||
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventMouseMotion:
|
||||
if drag_fsm == DRAG_FSM.DRAG:
|
||||
if drag_button == MOUSE_BUTTON_RIGHT:
|
||||
var ap_ant_w: float = get_ant_width(event.position, ant_dir_width_begin)
|
||||
$canvas.material.set('shader_parameter/ap_ant_w', ap_ant_w)
|
||||
elif drag_button == MOUSE_BUTTON_LEFT:
|
||||
set_ant_dir(event.position)
|
||||
if event is InputEventMouseButton:
|
||||
emit_signal('drag_continue', event)
|
||||
elif event is InputEventMouseButton:
|
||||
drag_button = event.button_index
|
||||
if event.pressed:
|
||||
if drag_fsm == DRAG_FSM.IDLE:
|
||||
drag_fsm = DRAG_FSM.DRAG
|
||||
drag_pos_begin = event.position
|
||||
if drag_button == MOUSE_BUTTON_LEFT:
|
||||
set_ant_dir(event.position)
|
||||
elif drag_button == MOUSE_BUTTON_RIGHT:
|
||||
ant_dir_width_begin = $canvas.material.get('shader_parameter/ap_ant_w')
|
||||
emit_signal('drag_begin', event)
|
||||
else:
|
||||
drag_fsm = DRAG_FSM.IDLE
|
||||
emit_signal('drag_end', event)
|
||||
elif event is InputEventKey:
|
||||
if event.pressed and event.physical_keycode == KEY_F11:
|
||||
emit_signal('full_screen')
|
||||
|
||||
|
||||
func toggle_full_screen(id: int):
|
||||
var mode = DisplayServer.window_get_mode(id)
|
||||
if mode == DisplayServer.WINDOW_MODE_FULLSCREEN:
|
||||
mode = DisplayServer.WINDOW_MODE_WINDOWED
|
||||
else:
|
||||
mode = DisplayServer.WINDOW_MODE_FULLSCREEN
|
||||
DisplayServer.window_set_mode(mode, id)
|
||||
|
||||
|
||||
func _on_full_screen():
|
||||
toggle_full_screen(1)
|
||||
toggle_full_screen(0)
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
[node name="Работа" type="Panel"]
|
||||
script = ExtResource("1_6kl7p")
|
||||
col_red = Color(1, 0.568627, 0.431373, 1)
|
||||
col_grey = Color(0.6, 0.6, 0.6, 1)
|
||||
|
||||
[node name="canvas" parent="." instance=ExtResource("2_jfiel")]
|
||||
|
||||
@@ -20,7 +22,7 @@ offset_right = 1589.0
|
||||
offset_bottom = 1162.0
|
||||
text = "Режим помехи"
|
||||
|
||||
[node name="btn_off" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_off" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 10.0
|
||||
offset_top = 30.0
|
||||
@@ -28,7 +30,7 @@ offset_right = 100.0
|
||||
offset_bottom = 80.0
|
||||
text = "Откл"
|
||||
|
||||
[node name="btn_p4" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p4" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 110.0
|
||||
offset_top = 210.0
|
||||
@@ -36,7 +38,7 @@ offset_right = 200.0
|
||||
offset_bottom = 260.0
|
||||
text = "13"
|
||||
|
||||
[node name="btn_p5" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p5" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
offset_left = 10.0
|
||||
@@ -47,7 +49,7 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "12"
|
||||
|
||||
[node name="btn_p6" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p6" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 210.0
|
||||
offset_top = 150.0
|
||||
@@ -55,7 +57,7 @@ offset_right = 300.0
|
||||
offset_bottom = 200.0
|
||||
text = "10"
|
||||
|
||||
[node name="btn_p7" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p7" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 310.0
|
||||
offset_top = 150.0
|
||||
@@ -63,7 +65,7 @@ offset_right = 400.0
|
||||
offset_bottom = 200.0
|
||||
text = "11"
|
||||
|
||||
[node name="btn_p8" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p8" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 110.0
|
||||
offset_top = 150.0
|
||||
@@ -71,7 +73,7 @@ offset_right = 200.0
|
||||
offset_bottom = 200.0
|
||||
text = "9"
|
||||
|
||||
[node name="btn_p9" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p9" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 10.0
|
||||
offset_top = 150.0
|
||||
@@ -79,7 +81,7 @@ offset_right = 100.0
|
||||
offset_bottom = 200.0
|
||||
text = "8"
|
||||
|
||||
[node name="btn_p10" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p10" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
offset_left = 310.0
|
||||
@@ -90,7 +92,7 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "7"
|
||||
|
||||
[node name="btn_p11" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p11" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 310.0
|
||||
offset_top = 30.0
|
||||
@@ -98,7 +100,7 @@ offset_right = 399.0
|
||||
offset_bottom = 80.0
|
||||
text = "3"
|
||||
|
||||
[node name="btn_p12" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p12" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
offset_left = 10.0
|
||||
@@ -109,7 +111,7 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "4"
|
||||
|
||||
[node name="btn_p13" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p13" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
offset_left = 110.0
|
||||
@@ -120,7 +122,7 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "5"
|
||||
|
||||
[node name="btn_p14" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p14" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
offset_left = 210.0
|
||||
@@ -131,7 +133,7 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "6"
|
||||
|
||||
[node name="btn_p15" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p15" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
offset_left = 210.0
|
||||
@@ -142,7 +144,7 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "2"
|
||||
|
||||
[node name="btn_p16" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p16" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 110.0
|
||||
offset_top = 30.0
|
||||
@@ -150,7 +152,7 @@ offset_right = 200.0
|
||||
offset_bottom = 80.0
|
||||
text = "1"
|
||||
|
||||
[node name="btn_auto_rfi" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_auto_rfi" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 210.0
|
||||
offset_top = 210.0
|
||||
@@ -744,12 +746,20 @@ horizontal_alignment = 1
|
||||
|
||||
[node name="btn_auto_threat" parent="." instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 983.0
|
||||
offset_left = 980.0
|
||||
offset_top = 1101.0
|
||||
offset_right = 1172.0
|
||||
offset_bottom = 1153.0
|
||||
offset_right = 1170.0
|
||||
offset_bottom = 1151.0
|
||||
text = "Автоматически"
|
||||
|
||||
[node name="btn_strobe" parent="." instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 980.0
|
||||
offset_top = 30.0
|
||||
offset_right = 1170.0
|
||||
offset_bottom = 80.0
|
||||
text = "Строб"
|
||||
|
||||
[node name="надпись-выбор-цели" type="Label" parent="."]
|
||||
layout_mode = 2
|
||||
offset_left = 983.0
|
||||
@@ -758,3 +768,7 @@ offset_right = 1172.0
|
||||
offset_bottom = 1098.0
|
||||
text = "Выбор цели"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[connection signal="drag_begin" from="." to="." method="_on_drag_begin"]
|
||||
[connection signal="drag_continue" from="." to="." method="_on_drag_continue"]
|
||||
[connection signal="full_screen" from="." to="." method="_on_full_screen" flags=3]
|
||||
|
||||
@@ -5,12 +5,12 @@ extends NinePatchRect
|
||||
|
||||
@export var horizontal_alignment: HorizontalAlignment = HorizontalAlignment.HORIZONTAL_ALIGNMENT_CENTER:
|
||||
get: return $header.horizontal_alignment
|
||||
set(align): $header.horizontal_alignment = align
|
||||
set(val): $header.horizontal_alignment = val
|
||||
|
||||
|
||||
@export var vertical_alignment: VerticalAlignment = VerticalAlignment.VERTICAL_ALIGNMENT_CENTER:
|
||||
get: return $header.vertical_alignment
|
||||
set(align): $header.vertical_alignment = align
|
||||
set(val): $header.vertical_alignment = val
|
||||
|
||||
|
||||
@export var text: String = 'caption text':
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
[sub_resource type="Shader" id="1"]
|
||||
code = "shader_type canvas_item;
|
||||
|
||||
uniform vec4 blue0: source_color = vec4(0.38, 0.47, 0.51, 1.0);
|
||||
uniform vec4 blue1: source_color = vec4(0.39, 0.44, 0.50, 1.0);
|
||||
uniform vec4 red: source_color = vec4(1.00, 0.38, 0.227, 1.0);
|
||||
uniform float d4 = 180.0;
|
||||
uniform vec2 pc0;
|
||||
uniform vec2 pc1;
|
||||
uniform vec2 pc2;
|
||||
@@ -15,6 +11,7 @@ uniform vec2 tr1;
|
||||
uniform vec2 tr2;
|
||||
uniform float sec_var = 0.0;
|
||||
uniform float ap_ant_w = 12.0;
|
||||
uniform vec4 ap_ant_col;
|
||||
|
||||
#define ANTENNAS_GRID_SIZE 7
|
||||
|
||||
@@ -42,6 +39,11 @@ 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 ap_ant_alpha = 0.3;
|
||||
|
||||
const vec4 blue0 = vec4(0.38, 0.47, 0.51, 1.0);
|
||||
const vec4 blue1 = vec4(0.39, 0.44, 0.50, 1.0);
|
||||
|
||||
|
||||
float SMOOTH(float r, float R)
|
||||
@@ -50,45 +52,7 @@ float SMOOTH(float r, float R)
|
||||
}
|
||||
|
||||
|
||||
float RANGE(float a, float b, float x)
|
||||
{
|
||||
return step(a, x) * (1.0 - step(b, x));
|
||||
}
|
||||
|
||||
|
||||
float RS(float a, float b, float x)
|
||||
{
|
||||
return smoothstep(a - 1.0, a + 1.0, x) * (1.0 - smoothstep(b - 1.0, b + 1.0, x));
|
||||
}
|
||||
|
||||
|
||||
vec2 modulate_move(float a, float b, float c, float d, float time)
|
||||
{
|
||||
return vec2(a * cos(time) + b * cos(2.0 * time), c * sin(time) + d * sin(2.0 * time));
|
||||
}
|
||||
|
||||
|
||||
vec3 radar_scan_line(vec2 uv, vec2 center, float time, float radius, vec3 color)
|
||||
{
|
||||
//angle of the line
|
||||
float theta0 = time * 90.0;
|
||||
vec2 d = uv - center;
|
||||
float r = sqrt(dot(d, d));
|
||||
if (r < radius)
|
||||
{
|
||||
//compute the distance to the line theta=theta0
|
||||
vec2 p = radius * vec2(cos(theta0 * PI / 180.0), - sin(theta0 * PI / 180.0));
|
||||
float l = length(d - p * clamp(dot(d, p) / dot(p, p), 0.0, 1.0));
|
||||
//compute gradient based on angle difference to theta0
|
||||
float theta = mod(180.0 * atan(d.y, d.x) / PI + theta0, 360.0);
|
||||
float gradient = clamp(1.0 - theta / 90.0, 0.0, 1.0);
|
||||
return color * SMOOTH(l, 1.0) + 0.5 * gradient * color;
|
||||
}
|
||||
else return vec3(0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
void sector(inout vec3 c, vec2 uv, vec2 center, float a, float da, float r0, float r1, vec3 color)
|
||||
void sector(inout vec3 c, vec2 uv, vec2 center, float a, float da, float r0, float r1, vec3 color, float alpha)
|
||||
{
|
||||
float l = distance(center, uv);
|
||||
vec2 d = uv - center;
|
||||
@@ -99,110 +63,7 @@ void sector(inout vec3 c, vec2 uv, vec2 center, float a, float da, float r0, flo
|
||||
float a1 = radians(a + da);
|
||||
float va = SMOOTH(a0 * sf, theta) - SMOOTH(a1 * sf, theta);
|
||||
float vr = SMOOTH(r0, l) - SMOOTH(r1, l);
|
||||
c += color * sqrt(va * vr);
|
||||
}
|
||||
|
||||
|
||||
void rotate_uv(inout vec2 uv, float a)
|
||||
{
|
||||
float mid = 0.5;
|
||||
uv.x = cos(a) * (uv.x - mid) + sin(a) * (uv.y - mid) + mid;
|
||||
uv.y = cos(a) * (uv.x - mid) - sin(a) * (uv.x - mid) + mid;
|
||||
}
|
||||
|
||||
|
||||
void sector2(inout vec3 c, vec2 uv, vec2 center, float a, float da, float r0, float r1, vec3 color)
|
||||
{
|
||||
rotate_uv(uv, 0.0);
|
||||
float l = distance(center, uv);
|
||||
vec2 d = uv - center;
|
||||
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(a0 * sf, theta) - SMOOTH(a1 * sf, theta);
|
||||
float vr = SMOOTH(r0, l) - SMOOTH(r1, l);
|
||||
c += color * sqrt(va * vr);
|
||||
}
|
||||
|
||||
|
||||
void circle(inout vec3 c, vec2 uv, vec2 p0, float radius, float width, vec3 color)
|
||||
{
|
||||
float r = length(uv - p0);
|
||||
c += (SMOOTH(r - width / 2.0, radius) - SMOOTH(r + width / 2.0, radius)) * color;
|
||||
}
|
||||
|
||||
|
||||
float circle2(vec2 uv, vec2 center, float radius, float width, float opening)
|
||||
{
|
||||
vec2 d = uv - center;
|
||||
float r = sqrt(dot(d, d));
|
||||
d = normalize(d);
|
||||
if (abs(d.y) > opening)
|
||||
return SMOOTH(r - width / 2.0, radius) - SMOOTH(r + width / 2.0, radius);
|
||||
else
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
float circle3(vec2 uv, vec2 center, float radius, float width)
|
||||
{
|
||||
vec2 d = uv - center;
|
||||
float r = sqrt(dot(d, d));
|
||||
d = normalize(d);
|
||||
float theta = 180.0 * (atan(d.y, d.x) / PI);
|
||||
return smoothstep(2.0, 2.1, abs(mod(theta + 2.0, 45.0) - 2.0))
|
||||
* mix(0.5, 1.0, step(45.0, abs(mod(theta, 180.0) - 90.0)))
|
||||
* (SMOOTH(r - width / 2.0, radius) - SMOOTH(r + width / 2.0, radius));
|
||||
}
|
||||
|
||||
|
||||
float triangles(vec2 uv, vec2 center, float radius)
|
||||
{
|
||||
vec2 d = uv - center;
|
||||
return RS(-8.0, 0.0, d.x - radius) * (1.0 - smoothstep(7.0 + d.x - radius, 9.0 + d.x - radius, abs(d.y)))
|
||||
+ RS( 0.0, 8.0, d.x + radius) * (1.0 - smoothstep(7.0 - d.x - radius, 9.0 - d.x - radius, abs(d.y)))
|
||||
+ RS(-8.0, 0.0, d.y - radius) * (1.0 - smoothstep(7.0 + d.y - radius, 9.0 + d.y - radius, abs(d.x)))
|
||||
+ RS( 0.0, 8.0, d.y + radius) * (1.0 - smoothstep(7.0 - d.y - radius, 9.0 - d.y - radius, abs(d.x)));
|
||||
}
|
||||
|
||||
|
||||
float _cross(vec2 uv, vec2 center, float radius)
|
||||
{
|
||||
vec2 d = uv - center;
|
||||
int x = int(d.x);
|
||||
int y = int(d.y);
|
||||
float r = sqrt(dot(d, d));
|
||||
if ((r < radius) && ((x == y) || (x == -y)))
|
||||
return 1.0;
|
||||
else return 0.0;
|
||||
}
|
||||
|
||||
|
||||
void cross_lines(inout vec3 color, vec2 uv, vec2 pc, float r0, float w, vec3 c)
|
||||
{
|
||||
vec2 d = uv - pc;
|
||||
int x = int(d.x);
|
||||
int y = int(d.y);
|
||||
float r = sqrt(dot(d, d));
|
||||
if ((r < r0) && ((x == y) || (x == -y)))
|
||||
color += c;
|
||||
color += vec3(0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
float dots(vec2 uv, vec2 center, float radius)
|
||||
{
|
||||
vec2 d = uv - center;
|
||||
float r = sqrt(dot(d, d));
|
||||
if (r <= 2.5)
|
||||
return 1.0;
|
||||
if ((r <= radius) && ((abs(d.y + 0.5) <= 1.0) && (mod(d.x + 1.0, 50.0) < 2.0)))
|
||||
return 1.0;
|
||||
else if ((abs(d.y + 0.5) <= 1.0) && (r >= 50.0) && (r < 115.0))
|
||||
return 0.5;
|
||||
else
|
||||
return 0.0;
|
||||
c += color * sqrt(va * vr) * alpha;
|
||||
}
|
||||
|
||||
|
||||
@@ -212,32 +73,14 @@ void bip1(inout vec3 color, vec2 uv, vec2 center, float r, vec3 c, float a)
|
||||
}
|
||||
|
||||
|
||||
float bip2(vec2 uv, float time, vec2 center)
|
||||
{
|
||||
float r = length(uv - center);
|
||||
float R = 8.0 + mod(87.0 * time, 80.0);
|
||||
return (0.5 - 0.5 * cos(30.0 * time)) * SMOOTH(r, 5.0)
|
||||
+ SMOOTH(6.0, r) - SMOOTH(8.0, r)
|
||||
+ smoothstep(max(8.0, R - 20.0), R, r) - SMOOTH(R,r);
|
||||
}
|
||||
|
||||
|
||||
vec3 circle_h(inout vec3 c, vec2 uv, vec2 c0, float r, vec3 color)
|
||||
{
|
||||
return 1.0 * color;
|
||||
}
|
||||
|
||||
|
||||
void antenas(inout vec3 c, vec2 uv, vec2 p0, float cnt, float r0, float r1, vec3 c0, vec3 c1, float a)
|
||||
{
|
||||
float da = 180.0f / float(cnt);
|
||||
c0 *= a;
|
||||
c1 *= a;
|
||||
for (int i = int(-cnt); i <= int(cnt); i ++)
|
||||
for (int i = int(-cnt); i <= int(cnt); i ++)
|
||||
{
|
||||
float v = float(i & 1);
|
||||
vec3 col = v * c0 + (1.0f - v) * c1;
|
||||
sector(c, uv, p0, float(i) * da, da, r0, r1, col);
|
||||
sector(c, uv, p0, float(i) * da, da, r0, r1, col, a);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,17 +94,6 @@ void circle_thin(inout vec3 color, vec2 uv, vec2 p, float r, float w, vec3 c, fl
|
||||
}
|
||||
|
||||
|
||||
void line(inout vec3 color, vec2 uv, vec2 p0, vec2 p1, vec3 c, float a)
|
||||
{
|
||||
vec2 d = uv - p0;
|
||||
float radius = distance(p0, p1);
|
||||
float theta0 = acos(dot(normalize(p0), normalize(p1)));
|
||||
vec2 p = radius * vec2(cos(theta0), -sin(theta0));
|
||||
float l = length(d - p * clamp(dot(d, p) / dot(p, p), 0.0, 1.0));
|
||||
color += c * SMOOTH(l, 1.0);
|
||||
}
|
||||
|
||||
|
||||
void line_r(inout vec3 color, vec2 uv, vec2 center, float theta0, float radius, vec3 c, float a)
|
||||
{
|
||||
vec2 d = uv - center;
|
||||
@@ -290,7 +122,7 @@ void fragment()
|
||||
COLOR = vec4(0, 0, 0, 1.0); //texture(TEXTURE, UV); // Цвет текущей точки
|
||||
|
||||
// Сектор направления
|
||||
sector(COLOR.rgb, uv, pc0, get_ang_atack(450.0 - sec_var), ap_ant_w, float(ant_band_r0_0), float(ant_band_r1_6), red.rgb);
|
||||
sector(COLOR.rgb, uv, pc0, get_ang_atack(450.0 - sec_var), ap_ant_w, float(ant_band_r0_0), float(ant_band_r1_6), ap_ant_col.rgb, ap_ant_alpha);
|
||||
|
||||
// Сетка антенн
|
||||
antenas(COLOR.rgb, uv, pc0, ant_band_count_0, ant_band_r0_0, ant_band_r1_0, blue1.rgb, blue0.rgb, 0.4);
|
||||
@@ -307,21 +139,17 @@ void fragment()
|
||||
bip1(COLOR.rgb, uv, tr2, 13.0, blue1.rgb, 1.0);
|
||||
|
||||
// Качка
|
||||
circle_thin(COLOR.rgb, uv, pc1, d4 / 2.0, line_width, blue1.rgb, 1.0);
|
||||
line_r(COLOR.rgb, uv, pc1, 0, d4 / 2.0, blue1.rgb, 1.0);
|
||||
line_r(COLOR.rgb, uv, pc1, 90, d4 / 2.0, blue1.rgb, 1.0);
|
||||
line_r(COLOR.rgb, uv, pc1, 180, d4 / 2.0, blue1.rgb, 1.0);
|
||||
line_r(COLOR.rgb, uv, pc1, 270, d4 / 2.0, blue1.rgb, 1.0);
|
||||
circle_thin(COLOR.rgb, uv, pc1, d4, line_width, blue1.rgb, 1.0);
|
||||
line_r(COLOR.rgb, uv, pc1, 0, d4, blue1.rgb, 1.0);
|
||||
line_r(COLOR.rgb, uv, pc1, 90, d4, blue1.rgb, 1.0);
|
||||
line_r(COLOR.rgb, uv, pc1, 180, d4, blue1.rgb, 1.0);
|
||||
line_r(COLOR.rgb, uv, pc1, 270, d4, blue1.rgb, 1.0);
|
||||
bip1(COLOR.rgb, uv, pc2, 13.0, blue1.rgb, 1.0);
|
||||
}
|
||||
"
|
||||
|
||||
[resource]
|
||||
shader = SubResource("1")
|
||||
shader_parameter/blue0 = Color(0.38, 0.47, 0.51, 1)
|
||||
shader_parameter/blue1 = Color(0.39, 0.44, 0.5, 1)
|
||||
shader_parameter/red = Color(1, 0.38, 0.227, 1)
|
||||
shader_parameter/d4 = 180.0
|
||||
shader_parameter/pc0 = Vector2(610, 600)
|
||||
shader_parameter/pc1 = Vector2(110, 1070)
|
||||
shader_parameter/pc2 = Vector2(100, 1065)
|
||||
@@ -330,3 +158,4 @@ shader_parameter/tr1 = Vector2(1000, 600)
|
||||
shader_parameter/tr2 = Vector2(300, 400)
|
||||
shader_parameter/sec_var = 0.0
|
||||
shader_parameter/ap_ant_w = 12.0
|
||||
shader_parameter/ap_ant_col = null
|
||||
|
||||
Reference in New Issue
Block a user