WIP: PFD instrument

This commit is contained in:
Marek S. Łukasiewicz 2025-12-15 23:01:10 +01:00
parent 4be36eb39e
commit 740a72bcb6
23 changed files with 432 additions and 32 deletions

View file

@ -0,0 +1,41 @@
Roboto Mono
Copyright 2015 Google
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=====================================================================
Socket.IO
MIT License
Copyright (c) 2014-2022 Guillermo Rauch
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Binary file not shown.

View file

@ -0,0 +1,35 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://chqgmpsthpbgt"
path="res://.godot/imported/RobotoMono-Regular.ttf-48a8b9dfd581c05f54f90e11c9fc9d5f.fontdata"
[deps]
source_file="res://instruments/RobotoMono-Regular.ttf"
dest_files=["res://.godot/imported/RobotoMono-Regular.ttf-48a8b9dfd581c05f54f90e11c9fc9d5f.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
disable_embedded_bitmaps=true
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=4
keep_rounding_remainders=true
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}

BIN
project/instruments/heading-ticks.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c36kaqyfalb2v"
path="res://.godot/imported/heading-ticks.png-8d0b08e5e3af463192c04d5a2068a1e0.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://instruments/heading-ticks.png"
dest_files=["res://.godot/imported/heading-ticks.png-8d0b08e5e3af463192c04d5a2068a1e0.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
project/instruments/horizon-mask.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c5nbrnus8pcyd"
path="res://.godot/imported/horizon-mask.png-03d2bafdd84b9816ae1fe68fc4baf43d.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://instruments/horizon-mask.png"
dest_files=["res://.godot/imported/horizon-mask.png-03d2bafdd84b9816ae1fe68fc4baf43d.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
project/instruments/horizon-overlay.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b703lu8yhaoav"
path="res://.godot/imported/horizon-overlay.png-7e128e1a0dd8183251d6119879899864.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://instruments/horizon-overlay.png"
dest_files=["res://.godot/imported/horizon-overlay.png-7e128e1a0dd8183251d6119879899864.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
project/instruments/horizon.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bxdfrv8bovdai"
path="res://.godot/imported/horizon.png-9384af1095d9251c4f8861113a545ccf.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://instruments/horizon.png"
dest_files=["res://.godot/imported/horizon.png-9384af1095d9251c4f8861113a545ccf.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=8 format=3 uid="uid://cis4s43ubuynp"]
[gd_scene load_steps=9 format=3 uid="uid://cis4s43ubuynp"]
[ext_resource type="Script" uid="uid://01bmfj4wthwg" path="res://instruments.gd" id="1_wlkep"]
[ext_resource type="PackedScene" uid="uid://bgkpwebqksth5" path="res://instruments/controls.tscn" id="2_372d7"]
[ext_resource type="PackedScene" uid="uid://b26tu6wb2h3ce" path="res://instruments/pfd.tscn" id="2_uhiu3"]
[sub_resource type="QuadMesh" id="QuadMesh_nowl7"]
@ -21,14 +22,11 @@ albedo_texture = SubResource("ViewportTexture_h5at3")
[node name="Instruments" type="Node3D"]
script = ExtResource("1_wlkep")
lidia_hostname = "192.168.1.2"
[node name="SubViewport" type="SubViewport" parent="."]
size = Vector2i(1024, 1024)
[node name="TextureRect" type="TextureRect" parent="SubViewport"]
offset_right = 512.0
offset_bottom = 512.0
expand_mode = 5
[node name="PFD" parent="SubViewport" instance=ExtResource("2_uhiu3")]
[node name="Quad" type="MeshInstance3D" parent="."]
transform = Transform3D(0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, -0.35, 0, 0)

BIN
project/instruments/pfd-background.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://colp4xsovikmv"
path="res://.godot/imported/pfd-background.png-99626101f4d3a30d7dd189ac71adf1c0.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://instruments/pfd-background.png"
dest_files=["res://.godot/imported/pfd-background.png-99626101f4d3a30d7dd189ac71adf1c0.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
project/instruments/pfd-ref.png (Stored with Git LFS)

Binary file not shown.

View file

@ -0,0 +1,50 @@
@tool
class_name PFD
extends Node2D
@export var euler_attitude_deg: Vector3:
set(value):
euler_attitude_deg = value
horizon_pivot.rotation = deg_to_rad(-value.x)
const px_per_deg: float = 6.56
horizon_background.position.y = px_per_deg * clamp(value.y, -30, 30)
heading_ticks.rotation = deg_to_rad(-value.z)
heading_label.text = "%03d" % (int(round(value.z) + 360) % 360)
@export var airspeed: float:
set(value):
airspeed = value
airspeed_label.text = str(int(round(value)))
@export var groundspeed: float:
set(value):
groundspeed = value
groundspeed_label.text = str(int(round(value)))
@export var altitude: float:
set(value):
altitude = value
var step = 1
if value > 49.5:
step = 5
if value > 99.5:
step = 10
altitude_label.text = str(int(step * round(value / step)))
@export var climbrate: float = 1000:
set(value):
climbrate = value
climbrate_arrow.scale.y = clamp(value / 1000.0, -1, 1)
@onready var horizon_pivot: Node2D = $HorizonMask/HorizonOrigin/Pivot
@onready var horizon_background: Node2D = $HorizonMask/HorizonOrigin/Pivot/Background
@onready var heading_ticks: Node2D = $HeadingOrigin/Ticks
@onready var climbrate_arrow: Node2D = $ClimbrateOrigin/Polygon2D
@onready var airspeed_label: Label = $Airspeed
@onready var groundspeed_label: Label = $Groundspeed
@onready var altitude_label: Label = $Altitude
@onready var heading_label: Label = $Heading
func update(aircraft: Transform3D, velocity: Vector3):
var godot_euler = aircraft.basis.get_euler()
euler_attitude_deg = Vector3(godot_euler.z, -godot_euler.x, -godot_euler.y) * rad_to_deg(1)

View file

@ -0,0 +1 @@
uid://368tfiyen071

View file

@ -0,0 +1,103 @@
[gd_scene load_steps=9 format=3 uid="uid://b26tu6wb2h3ce"]
[ext_resource type="Texture2D" uid="uid://colp4xsovikmv" path="res://instruments/pfd-background.png" id="1_inkqg"]
[ext_resource type="Script" uid="uid://368tfiyen071" path="res://instruments/pfd.gd" id="1_t02it"]
[ext_resource type="Texture2D" uid="uid://c5nbrnus8pcyd" path="res://instruments/horizon-mask.png" id="2_t02it"]
[ext_resource type="Texture2D" uid="uid://bxdfrv8bovdai" path="res://instruments/horizon.png" id="3_kwqn1"]
[ext_resource type="Texture2D" uid="uid://b703lu8yhaoav" path="res://instruments/horizon-overlay.png" id="4_1vq1p"]
[ext_resource type="Texture2D" uid="uid://c36kaqyfalb2v" path="res://instruments/heading-ticks.png" id="5_3w2cf"]
[ext_resource type="FontFile" uid="uid://chqgmpsthpbgt" path="res://instruments/RobotoMono-Regular.ttf" id="6_wtx4e"]
[ext_resource type="Texture2D" uid="uid://toojp8r3424r" path="res://instruments/pfd-ref.png" id="7_86xjv"]
[node name="PFD" type="Node2D"]
script = ExtResource("1_t02it")
[node name="Background" type="Sprite2D" parent="."]
position = Vector2(512, 512)
texture = ExtResource("1_inkqg")
[node name="HorizonMask" type="Sprite2D" parent="."]
clip_children = 1
position = Vector2(512, 512)
texture = ExtResource("2_t02it")
[node name="HorizonOrigin" type="Node2D" parent="HorizonMask"]
position = Vector2(-82, -244)
[node name="Pivot" type="Node2D" parent="HorizonMask/HorizonOrigin"]
[node name="Background" type="Sprite2D" parent="HorizonMask/HorizonOrigin/Pivot"]
texture = ExtResource("3_kwqn1")
[node name="RollArrowContour" type="Polygon2D" parent="HorizonMask/HorizonOrigin/Pivot"]
position = Vector2(-430, -267)
color = Color(0, 0, 0, 1)
polygon = PackedVector2Array(430, 70, 416, 92, 444, 92)
[node name="RollArrowFill" type="Polygon2D" parent="HorizonMask/HorizonOrigin/Pivot"]
position = Vector2(-430, -267)
polygon = PackedVector2Array(430, 74, 420, 90, 440, 90)
[node name="Overlay" type="Sprite2D" parent="HorizonMask/HorizonOrigin"]
texture = ExtResource("4_1vq1p")
[node name="HeadingOrigin" type="Node2D" parent="."]
position = Vector2(430, 794)
[node name="Ticks" type="Sprite2D" parent="HeadingOrigin"]
texture = ExtResource("5_3w2cf")
[node name="ClimbrateOrigin" type="Node2D" parent="."]
position = Vector2(711, 268)
[node name="Polygon2D" type="Polygon2D" parent="ClimbrateOrigin"]
polygon = PackedVector2Array(12, 0, -12, 0, -12, -121, 0, -133, 12, -121)
[node name="Airspeed" type="Label" parent="."]
offset_left = 35.0
offset_top = 233.0
offset_right = 154.0
offset_bottom = 298.0
theme_override_fonts/font = ExtResource("6_wtx4e")
theme_override_font_sizes/font_size = 48
text = "0"
horizontal_alignment = 2
vertical_alignment = 1
[node name="Groundspeed" type="Label" parent="."]
offset_left = 59.0
offset_top = 477.0
offset_right = 178.0
offset_bottom = 542.0
theme_override_fonts/font = ExtResource("6_wtx4e")
theme_override_font_sizes/font_size = 33
text = "0"
horizontal_alignment = 2
vertical_alignment = 1
[node name="Altitude" type="Label" parent="."]
offset_left = 859.0
offset_top = 233.0
offset_right = 978.0
offset_bottom = 298.0
theme_override_fonts/font = ExtResource("6_wtx4e")
theme_override_font_sizes/font_size = 48
text = "0"
horizontal_alignment = 2
vertical_alignment = 1
[node name="Heading" type="Label" parent="."]
offset_left = 370.0
offset_top = 498.0
offset_right = 489.0
offset_bottom = 563.0
theme_override_fonts/font = ExtResource("6_wtx4e")
theme_override_font_sizes/font_size = 33
text = "000"
horizontal_alignment = 1
vertical_alignment = 1
[node name="Reference" type="Sprite2D" parent="."]
visible = false
position = Vector2(512, 512)
texture = ExtResource("7_86xjv")