parent
2bb2fe10c3
commit
be7d746959
|
@ -8,6 +8,7 @@ namespace BITKit;
|
|||
/// </summary>
|
||||
public partial class CameraService:Camera3D
|
||||
{
|
||||
public static CameraService Singleton { get; private set; }
|
||||
/// <summary>
|
||||
/// 场景中所有的摄像头
|
||||
/// </summary>
|
||||
|
@ -28,6 +29,12 @@ public partial class CameraService:Camera3D
|
|||
/// <param name="camera">摄像头</param>
|
||||
/// <returns></returns>
|
||||
public static bool UnRegister(IVirtualCamera camera) => _cameras.TryRemove(camera);
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Singleton = this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理摄像头的位置
|
||||
/// </summary>
|
||||
|
|
|
@ -39,11 +39,6 @@ public partial class FreeLookCamera : Node3D,IVirtualCamera
|
|||
eulur = Rotation;
|
||||
position = Position;
|
||||
CameraService.Register(this);
|
||||
|
||||
if(PathHelper.TryGetText(GetInstanceId().ToString(),out var json))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
|
|
|
@ -39,4 +39,9 @@ public partial class GodotEntitiesService : Node,IEntitiesService
|
|||
}
|
||||
|
||||
public CancellationToken CancellationToken => _cancellationTokenSource.Token;
|
||||
|
||||
public IEntity[] Query<T>() where T : IEntityComponent
|
||||
{
|
||||
return _entities.Values.Where(x => x.TryGetComponent<T>(out _)).ToArray();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace BITKit;
|
|||
/// </summary>
|
||||
public partial class SCADAService : Node
|
||||
{
|
||||
public const string _CurrentAngle="CurrentAngle";
|
||||
public const string _CurrentRotation="CurrentRotation";
|
||||
/// <summary>
|
||||
/// 在构造函数中注入依赖
|
||||
/// </summary>
|
||||
|
@ -182,10 +184,10 @@ public partial class SCADAService : Node
|
|||
//最终角度 = 当前角度*角度权重 + 角度偏移 + 原始角度
|
||||
var euler = currentAngle * rotationComponent.Weight + rotationComponent.Offset + rotationComponent.OriginalEuler;
|
||||
//为Node3D.Rotation提交最后的角度计算结果
|
||||
rotationComponent.Rotation = Quaternion.FromEuler(euler).GetEuler().Normalized();
|
||||
rotationComponent.RotationDegrees = euler;
|
||||
|
||||
rotationComponent.SetMeta("CurrentAngle",currentAngle);
|
||||
rotationComponent.SetMeta("CurrentRotation",euler);
|
||||
rotationComponent.SetMeta(_CurrentAngle,(int)currentAngle);
|
||||
rotationComponent.SetMeta(_CurrentRotation,euler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
using System.Linq;
|
||||
using Godot;
|
||||
|
||||
namespace BITKit;
|
||||
|
||||
public partial class UXMetaElement : Node3D, IMetaDisplayElement
|
||||
{
|
||||
[Export] private bool isEnabled=true;
|
||||
[Export] private Node3D proxy;
|
||||
[Export] protected string[] MetaEntries;
|
||||
private bool _registered;
|
||||
|
||||
string IMetaDisplayElement.Text
|
||||
{
|
||||
get
|
||||
{
|
||||
var node = proxy ?? this;
|
||||
return string.Join(MetaEntries?.Length>2 ? "\n" : ":", MetaEntries!
|
||||
.Where(x => string.IsNullOrEmpty(x) is false)
|
||||
.Where(x => node.HasMeta(x))
|
||||
.Select(x => node.GetMeta(x).AsString())
|
||||
.InsertOf<string>(0, node.Name)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 IMetaDisplayElement.Position => (proxy ?? this).GlobalPosition;
|
||||
// public override void _Ready()
|
||||
// {
|
||||
// if (!isEnabled) return;
|
||||
// UXMetaService.Register(this);
|
||||
// _registered = true;
|
||||
// }
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (_registered == isEnabled) return;
|
||||
if (isEnabled)
|
||||
{
|
||||
UXMetaService.Register(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
UXMetaService.UnRegister(this);
|
||||
}
|
||||
_registered = isEnabled;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (isEnabled && _registered)
|
||||
UXMetaService.UnRegister(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BITKit;
|
||||
|
||||
public interface IMetaDisplayElement
|
||||
{
|
||||
string Text { get; }
|
||||
Vector3 Position { get; }
|
||||
}
|
||||
public partial class UXMetaService : Control
|
||||
{
|
||||
#region 静态方法
|
||||
private static readonly Queue<IMetaDisplayElement> AddQueue = new();
|
||||
private static readonly Queue<IMetaDisplayElement> RemoveQueue = new();
|
||||
private static readonly List<IMetaDisplayElement> Elements = new();
|
||||
public static void Register(IMetaDisplayElement element) => AddQueue.Enqueue(element);
|
||||
public static void UnRegister(IMetaDisplayElement element) => RemoveQueue.Enqueue(element);
|
||||
#endregion
|
||||
#region 实例方法
|
||||
private readonly Dictionary<IMetaDisplayElement, Label> _dictionary = new();
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// 标签预制体
|
||||
/// </summary>
|
||||
[Export]
|
||||
private PackedScene labelTemplate;
|
||||
/// <summary>
|
||||
/// 主要处理过程
|
||||
/// </summary>
|
||||
/// <param name="delta"></param>
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
//相机服务未初始化时返回
|
||||
if(CameraService.Singleton is null)return;
|
||||
//处理添加队列
|
||||
while (AddQueue.TryDequeue(out var newElement))
|
||||
{
|
||||
if (!Elements.TryAdd(newElement)) continue;
|
||||
var instance = labelTemplate.Instantiate<Label>();
|
||||
_dictionary.Add(newElement,instance);
|
||||
AddChild(instance);
|
||||
}
|
||||
//处理每个Element的数据
|
||||
foreach (var element in Elements)
|
||||
{
|
||||
if (_dictionary.TryGetValue(element, out var label) is false) continue;
|
||||
var pos = CameraService.Singleton.UnprojectPosition(element.Position);
|
||||
label.Position = pos;
|
||||
label.Text = element.Text;
|
||||
}
|
||||
//处理移除队列
|
||||
while (RemoveQueue.TryDequeue(out var removeElement))
|
||||
{
|
||||
if (!_dictionary.TryGetValue(removeElement, out var label)) continue;
|
||||
if (!_dictionary.TryRemove(removeElement)) continue;
|
||||
Elements.Remove(removeElement);
|
||||
label.QueueFree();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://dw884h5a1l014"]
|
||||
|
||||
[ext_resource type="Script" path="res://Artists/Scripts/UX/UXMetaService.cs" id="1_c1yne"]
|
||||
[ext_resource type="PackedScene" uid="uid://c1f7dq6mepq75" path="res://Artists/Templates/UXMetaElement.tscn" id="2_ywyc4"]
|
||||
|
||||
[node name="UXMetaService" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
script = ExtResource("1_c1yne")
|
||||
labelTemplate = ExtResource("2_ywyc4")
|
|
@ -0,0 +1,14 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://c1f7dq6mepq75"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_u8g0w"]
|
||||
outline_size = 2
|
||||
outline_color = Color(0, 0, 0, 1)
|
||||
shadow_color = Color(0.0313726, 0.0313726, 0.0313726, 0)
|
||||
|
||||
[node name="Label" type="Label"]
|
||||
offset_left = 619.0
|
||||
offset_top = 455.0
|
||||
offset_right = 676.0
|
||||
offset_bottom = 481.0
|
||||
text = "MyText"
|
||||
label_settings = SubResource("LabelSettings_u8g0w")
|
|
@ -1,11 +1,7 @@
|
|||
[gd_scene load_steps=26 format=3 uid="uid://cn6oq3npyox2m"]
|
||||
[gd_scene load_steps=24 format=3 uid="uid://cn6oq3npyox2m"]
|
||||
|
||||
[ext_resource type="Script" path="res://Artists/Scripts/Core/Exec.cs" id="1_ahx04"]
|
||||
[ext_resource type="Script" path="res://Artists/Scripts/Camera/CameraService.cs" id="1_jxrvb"]
|
||||
[ext_resource type="PackedScene" uid="uid://dl7swvw8ur323" path="res://Mods/EIPC/Models/赛昇机械臂/塞昇机械臂.glb" id="2_2irp4"]
|
||||
[ext_resource type="Script" path="res://Artists/Scripts/ECS/Entity.cs" id="2_awnir"]
|
||||
[ext_resource type="Script" path="res://Artists/Scripts/Factory/IdComponent.cs" id="3_6gssc"]
|
||||
[ext_resource type="Script" path="res://Artists/Scripts/Factory/RotationComponent.cs" id="3_t5cv0"]
|
||||
[ext_resource type="Texture2D" uid="uid://bymrjkd63p3fs" path="res://Mods/EIPC/Art/Background/智慧车间.png" id="4_lngwv"]
|
||||
[ext_resource type="PackedScene" uid="uid://du51aijsw1md8" path="res://Mods/EIPC/Models/塞昇_仓储单元.glb" id="4_twm4i"]
|
||||
[ext_resource type="PackedScene" uid="uid://c3obewoadhw2g" path="res://Mods/EIPC/Models/塞昇_装配单元.glb" id="5_slm5m"]
|
||||
|
@ -16,10 +12,12 @@
|
|||
[ext_resource type="Texture2D" uid="uid://bu1alfkonwago" path="res://Mods/EIPC/Art/Texture/赛昇_DateTime_Container.png" id="8_3erlx"]
|
||||
[ext_resource type="PackedScene" uid="uid://ckckny52056cw" path="res://Mods/EIPC/Models/塞昇_仓储台机械臂底座.glb" id="8_kpd65"]
|
||||
[ext_resource type="PackedScene" uid="uid://dexpjn6olm54e" path="res://Mods/EIPC/Models/塞昇_物料箱.glb" id="9_plq0l"]
|
||||
[ext_resource type="PackedScene" uid="uid://b5duoofl4hmtv" path="res://Mods/EIPC/Models/塞昇_交付转台.glb" id="9_x5y85"]
|
||||
[ext_resource type="Script" path="res://Artists/Scripts/Node2D/DateTimeNode.cs" id="9_y03m7"]
|
||||
[ext_resource type="PackedScene" uid="uid://cspfisaj7i6i6" path="res://Mods/EIPC/Models/塞昇_Lite快换放置座2v4.glb" id="10_505q5"]
|
||||
[ext_resource type="Script" path="res://Artists/Scripts/Data/DataPlayer.cs" id="11_o32l8"]
|
||||
[ext_resource type="PackedScene" uid="uid://y8ycnndhmpw5" path="res://Artists/Services/UXService.tscn" id="20_ajnyx"]
|
||||
[ext_resource type="PackedScene" uid="uid://hwdvb2o5dqn5" path="res://Mods/EIPC/Models/塞昇_螺钉箱.glb" id="12_85p72"]
|
||||
[ext_resource type="PackedScene" uid="uid://b052dbve60nep" path="res://Mods/EIPC/Templates/塞昇机械臂.tscn" id="12_h3fov"]
|
||||
|
||||
[sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_3gjuw"]
|
||||
panorama = ExtResource("4_lngwv")
|
||||
|
@ -95,105 +93,43 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0501724, 0)
|
|||
[node name="塞昇_仓储台屏幕" parent="." instance=ExtResource("7_7bqbr")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.0696, 0.784043, 0.734538)
|
||||
|
||||
[node name="Label3D" type="Label3D" parent="塞昇_仓储台屏幕"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.023152, 0.203988, 0.0952591)
|
||||
pixel_size = 0.0007
|
||||
text = "控制台"
|
||||
font_size = 76
|
||||
width = 32.0
|
||||
|
||||
[node name="塞昇_仓储台机械臂底座" parent="." instance=ExtResource("8_kpd65")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.837477, 0.786089, -0.355281)
|
||||
|
||||
[node name="塞昇_仓储台机械臂底座2" parent="." instance=ExtResource("8_kpd65")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.92656, 0.786089, -0.355281)
|
||||
|
||||
[node name="塞昇_交付转台" parent="." instance=ExtResource("9_x5y85")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.303, 0.815, 0.389)
|
||||
|
||||
[node name="塞昇_物料箱" parent="." instance=ExtResource("9_plq0l")]
|
||||
transform = Transform3D(-1, -8.74228e-08, 7.64274e-15, -8.74228e-08, 1, -8.74228e-08, 0, -8.74228e-08, -1, -1.418, 0.778, 0.333)
|
||||
transform = Transform3D(4.37114e-08, -8.74228e-08, 1, -8.74228e-08, 1, 8.74228e-08, -1, -8.74228e-08, 4.37114e-08, -1.418, 0.778, 0.333)
|
||||
|
||||
[node name="塞昇_Lite快换放置座2v4" parent="." instance=ExtResource("10_505q5")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.777, -0.66)
|
||||
|
||||
[node name="装配机械臂" type="Node3D" parent="."]
|
||||
[node name="装配机械臂" parent="." instance=ExtResource("12_h3fov")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.847, 0.955, -0.391)
|
||||
script = ExtResource("2_awnir")
|
||||
|
||||
[node name="RB1" parent="装配机械臂" instance=ExtResource("2_2irp4")]
|
||||
script = ExtResource("3_6gssc")
|
||||
[node name="Root" parent="装配机械臂" index="0"]
|
||||
Id = "RB1"
|
||||
|
||||
[node name="Root" parent="装配机械臂/RB1/塞昇_机械臂" index="0"]
|
||||
script = ExtResource("3_t5cv0")
|
||||
Path = "R1"
|
||||
Weight = Vector3(0, 1, 0)
|
||||
|
||||
[node name="Axis_0" parent="装配机械臂/RB1/塞昇_机械臂/Root" index="0"]
|
||||
script = ExtResource("3_t5cv0")
|
||||
Path = "R2"
|
||||
Weight = Vector3(-1, 0, 0)
|
||||
|
||||
[node name="Axis_1" parent="装配机械臂/RB1/塞昇_机械臂/Root/Axis_0" index="0"]
|
||||
script = ExtResource("3_t5cv0")
|
||||
Path = "R3"
|
||||
Weight = Vector3(1, 0, 0)
|
||||
Offset = Vector3(90, 0, 0)
|
||||
|
||||
[node name="Axis_2" parent="装配机械臂/RB1/塞昇_机械臂/Root/Axis_0/Axis_1" index="0"]
|
||||
script = ExtResource("3_t5cv0")
|
||||
Path = "R4"
|
||||
Weight = Vector3(0, 1, 0)
|
||||
|
||||
[node name="Axis_3" parent="装配机械臂/RB1/塞昇_机械臂/Root/Axis_0/Axis_1/Axis_2" index="0"]
|
||||
script = ExtResource("3_t5cv0")
|
||||
Path = "R5"
|
||||
Weight = Vector3(-1, 0, 0)
|
||||
|
||||
[node name="Axis_4" parent="装配机械臂/RB1/塞昇_机械臂/Root/Axis_0/Axis_1/Axis_2/Axis_3" index="0"]
|
||||
script = ExtResource("3_t5cv0")
|
||||
Path = "R6"
|
||||
|
||||
[node name="螺钉机械臂" type="Node3D" parent="."]
|
||||
[node name="螺钉机械臂" parent="." instance=ExtResource("12_h3fov")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.929088, 0.955, -0.391)
|
||||
script = ExtResource("2_awnir")
|
||||
|
||||
[node name="RB2" parent="螺钉机械臂" instance=ExtResource("2_2irp4")]
|
||||
script = ExtResource("3_6gssc")
|
||||
[node name="Root" parent="螺钉机械臂" index="0"]
|
||||
Id = "RB2"
|
||||
|
||||
[node name="Root" parent="螺钉机械臂/RB2/塞昇_机械臂" index="0"]
|
||||
script = ExtResource("3_t5cv0")
|
||||
Path = "R1"
|
||||
Weight = Vector3(0, 1, 0)
|
||||
[node name="塞昇_螺钉箱" parent="." instance=ExtResource("12_85p72")]
|
||||
|
||||
[node name="Axis_0" parent="螺钉机械臂/RB2/塞昇_机械臂/Root" index="0"]
|
||||
script = ExtResource("3_t5cv0")
|
||||
Path = "R2"
|
||||
Weight = Vector3(-1, 0, 0)
|
||||
|
||||
[node name="Axis_1" parent="螺钉机械臂/RB2/塞昇_机械臂/Root/Axis_0" index="0"]
|
||||
script = ExtResource("3_t5cv0")
|
||||
Path = "R3"
|
||||
Weight = Vector3(1, 0, 0)
|
||||
Offset = Vector3(90, 0, 0)
|
||||
|
||||
[node name="Axis_2" parent="螺钉机械臂/RB2/塞昇_机械臂/Root/Axis_0/Axis_1" index="0"]
|
||||
script = ExtResource("3_t5cv0")
|
||||
Path = "R4"
|
||||
Weight = Vector3(0, 1, 0)
|
||||
|
||||
[node name="Axis_3" parent="螺钉机械臂/RB2/塞昇_机械臂/Root/Axis_0/Axis_1/Axis_2" index="0"]
|
||||
script = ExtResource("3_t5cv0")
|
||||
Path = "R5"
|
||||
Weight = Vector3(-1, 0, 0)
|
||||
|
||||
[node name="Axis_4" parent="螺钉机械臂/RB2/塞昇_机械臂/Root/Axis_0/Axis_1/Axis_2/Axis_3" index="0"]
|
||||
script = ExtResource("3_t5cv0")
|
||||
Path = "R6"
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="."]
|
||||
visible = false
|
||||
layout_direction = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_right = 1920.0
|
||||
offset_bottom = 1080.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("4_lngwv")
|
||||
expand_mode = 5
|
||||
|
||||
[node name="Control" type="Control" parent="."]
|
||||
[node name="UX Node" type="Control" parent="."]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
|
@ -201,38 +137,38 @@ anchor_bottom = 1.0
|
|||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="Control"]
|
||||
[node name="TextureRect" type="TextureRect" parent="UX Node"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -795.0
|
||||
offset_right = 795.0
|
||||
offset_bottom = 112.51
|
||||
offset_left = -775.0
|
||||
offset_right = 776.0
|
||||
offset_bottom = 132.0
|
||||
grow_horizontal = 2
|
||||
texture = ExtResource("7_ejfcw")
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="TextureRect2" type="NinePatchRect" parent="Control"]
|
||||
[node name="TextureRect2" type="NinePatchRect" parent="UX Node"]
|
||||
layout_direction = 2
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -275.0
|
||||
offset_top = 17.0
|
||||
offset_right = -19.0
|
||||
offset_bottom = 49.0
|
||||
offset_left = -288.0
|
||||
offset_top = 32.0
|
||||
offset_right = -32.0
|
||||
offset_bottom = 80.0
|
||||
grow_horizontal = 0
|
||||
texture = ExtResource("8_3erlx")
|
||||
patch_margin_left = 4
|
||||
patch_margin_top = 2
|
||||
patch_margin_top = 16
|
||||
patch_margin_right = 4
|
||||
patch_margin_bottom = 2
|
||||
patch_margin_bottom = 16
|
||||
metadata/_edit_group_ = true
|
||||
|
||||
[node name="Label" type="Label" parent="Control/TextureRect2"]
|
||||
[node name="Label" type="Label" parent="UX Node/TextureRect2"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
|
@ -245,24 +181,57 @@ vertical_alignment = 1
|
|||
script = ExtResource("9_y03m7")
|
||||
timeFormat = "yyyy-MM-dd HH:mm:ss"
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="Control"]
|
||||
own_world_3d = true
|
||||
transparent_bg = true
|
||||
[node name="Label" type="Label" parent="UX Node"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -113.0
|
||||
offset_top = 240.0
|
||||
offset_right = 113.0
|
||||
offset_bottom = 344.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "操作方式:
|
||||
按住[鼠标中键]旋转视角
|
||||
按住[Shift]+[鼠标中键]拖动视角
|
||||
滑动[鼠标滚轮]缩放视角
|
||||
按下[Home]切换性能视图"
|
||||
|
||||
[node name="DataPlayer" type="Node" parent="."]
|
||||
script = ExtResource("11_o32l8")
|
||||
|
||||
[node name="FreeLookCamera" type="Node3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.596306, -0.00489426)
|
||||
transform = Transform3D(0.87193, 0.185093, -0.453298, 0, 0.925795, 0.378025, 0.489631, -0.329612, 0.807228, 0.0278897, 0.747776, -0.0496664)
|
||||
script = ExtResource("7_t1qox")
|
||||
fov = 45
|
||||
isEnabled = true
|
||||
wheelCurve = SubResource("Curve_ro1wv")
|
||||
distance = 2.0
|
||||
distance = 4.0
|
||||
maxDistance = 8.0
|
||||
stringResource = SubResource("Resource_appdf")
|
||||
|
||||
[node name="UXService" parent="." instance=ExtResource("20_ajnyx")]
|
||||
[node name="Label3D" type="Label3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.01909, 0.387762)
|
||||
pixel_size = 0.0019
|
||||
text = "转台的零件非常多
|
||||
正在纯手动优化(重画一个)"
|
||||
font_size = 59
|
||||
|
||||
[editable path="装配机械臂/RB1"]
|
||||
[editable path="螺钉机械臂/RB2"]
|
||||
[node name="Label3D2" type="Label3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.43103, 1.02646, 0.383217)
|
||||
pixel_size = 0.0009
|
||||
text = "物料小车模型非常复杂
|
||||
手动优化步骤非常多"
|
||||
font_size = 69
|
||||
|
||||
[node name="Label3D3" type="Label3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0158046, 1.35607, -0.64637)
|
||||
text = "螺钉枪和夹爪的模型也非常复杂
|
||||
需要很多步骤去优化"
|
||||
font_size = 12
|
||||
|
||||
[editable path="装配机械臂"]
|
||||
[editable path="螺钉机械臂"]
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,43 @@
|
|||
[remap]
|
||||
|
||||
importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://b5duoofl4hmtv"
|
||||
path="res://.godot/imported/塞昇_交付转台.glb-968a985a2cb5d0138ef33b40e5b312d4.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Mods/EIPC/Models/塞昇_交付转台.glb"
|
||||
dest_files=["res://.godot/imported/塞昇_交付转台.glb-968a985a2cb5d0138ef33b40e5b312d4.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
nodes/root_type="Node3D"
|
||||
nodes/root_name="Scene Root"
|
||||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
meshes/light_baking=1
|
||||
meshes/lightmap_texel_size=0.2
|
||||
skins/use_named_skins=true
|
||||
animation/import=true
|
||||
animation/fps=30
|
||||
animation/trimming=false
|
||||
animation/remove_immutable_tracks=true
|
||||
import_script/path=""
|
||||
_subresources={
|
||||
"materials": {
|
||||
"BaseColor": {
|
||||
"use_external/enabled": true,
|
||||
"use_external/path": "res://Artists/Materials/Material_Table_Base.tres"
|
||||
},
|
||||
"Metallic_Dark": {
|
||||
"use_external/enabled": true,
|
||||
"use_external/path": "res://Artists/Materials/Material_Table_Metallica.tres"
|
||||
}
|
||||
}
|
||||
}
|
||||
gltf/embedded_image_handling=1
|
Binary file not shown.
|
@ -0,0 +1,32 @@
|
|||
[remap]
|
||||
|
||||
importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://hwdvb2o5dqn5"
|
||||
path="res://.godot/imported/塞昇_螺钉箱.glb-7fa17270651bccfcbfa51e8df02beac5.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Mods/EIPC/Models/塞昇_螺钉箱.glb"
|
||||
dest_files=["res://.godot/imported/塞昇_螺钉箱.glb-7fa17270651bccfcbfa51e8df02beac5.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
nodes/root_type="Node3D"
|
||||
nodes/root_name="Scene Root"
|
||||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
meshes/light_baking=1
|
||||
meshes/lightmap_texel_size=0.2
|
||||
skins/use_named_skins=true
|
||||
animation/import=true
|
||||
animation/fps=30
|
||||
animation/trimming=false
|
||||
animation/remove_immutable_tracks=true
|
||||
import_script/path=""
|
||||
_subresources={}
|
||||
gltf/embedded_image_handling=1
|
Binary file not shown.
|
@ -0,0 +1,76 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://b052dbve60nep"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dl7swvw8ur323" path="res://Mods/EIPC/Models/赛昇机械臂/塞昇机械臂.glb" id="1_1e8se"]
|
||||
[ext_resource type="Script" path="res://Artists/Scripts/ECS/Entity.cs" id="2_gninw"]
|
||||
[ext_resource type="Script" path="res://Artists/Scripts/Factory/RotationComponent.cs" id="2_jew8k"]
|
||||
[ext_resource type="Script" path="res://Artists/Scripts/Factory/IdComponent.cs" id="3_oookn"]
|
||||
[ext_resource type="Script" path="res://Artists/Scripts/UX/UXMetaElement.cs" id="5_mwcgj"]
|
||||
|
||||
[node name="塞昇机械臂" instance=ExtResource("1_1e8se")]
|
||||
script = ExtResource("2_gninw")
|
||||
|
||||
[node name="Root" parent="." index="0"]
|
||||
script = ExtResource("3_oookn")
|
||||
Id = "PLC-ZK"
|
||||
|
||||
[node name="Axis_1" parent="Root" index="0"]
|
||||
script = ExtResource("2_jew8k")
|
||||
Path = "R1"
|
||||
Weight = Vector3(0, 1, 0)
|
||||
|
||||
[node name="Axis_2" parent="Root/Axis_1" index="0"]
|
||||
script = ExtResource("2_jew8k")
|
||||
Path = "R2"
|
||||
Weight = Vector3(1, 0, 0)
|
||||
|
||||
[node name="Axis_3" parent="Root/Axis_1/Axis_2" index="0"]
|
||||
script = ExtResource("2_jew8k")
|
||||
Path = "R3"
|
||||
Weight = Vector3(1, 0, 0)
|
||||
Offset = Vector3(135, 0, 0)
|
||||
|
||||
[node name="Axis_4" parent="Root/Axis_1/Axis_2/Axis_3" index="0"]
|
||||
script = ExtResource("2_jew8k")
|
||||
Path = "R4"
|
||||
Weight = Vector3(0, 1, 0)
|
||||
|
||||
[node name="Axis_5" parent="Root/Axis_1/Axis_2/Axis_3/Axis_4" index="0"]
|
||||
script = ExtResource("2_jew8k")
|
||||
Path = "R5"
|
||||
Weight = Vector3(-1, 0, 0)
|
||||
|
||||
[node name="Axis_6" parent="Root/Axis_1/Axis_2/Axis_3/Axis_4/Axis_5" index="0"]
|
||||
script = ExtResource("2_jew8k")
|
||||
Path = "R6"
|
||||
Weight = Vector3(0, 1, 0)
|
||||
|
||||
[node name="Meta_R1" type="Node3D" parent="." index="1" node_paths=PackedStringArray("proxy")]
|
||||
script = ExtResource("5_mwcgj")
|
||||
proxy = NodePath("../Root/Axis_1")
|
||||
MetaEntries = PackedStringArray("CurrentAngle")
|
||||
|
||||
[node name="Meta_R2" type="Node3D" parent="." index="2" node_paths=PackedStringArray("proxy")]
|
||||
script = ExtResource("5_mwcgj")
|
||||
proxy = NodePath("../Root/Axis_1/Axis_2")
|
||||
MetaEntries = PackedStringArray("CurrentAngle")
|
||||
|
||||
[node name="Meta_R3" type="Node3D" parent="." index="3" node_paths=PackedStringArray("proxy")]
|
||||
script = ExtResource("5_mwcgj")
|
||||
proxy = NodePath("../Root/Axis_1/Axis_2/Axis_3")
|
||||
MetaEntries = PackedStringArray("CurrentAngle")
|
||||
|
||||
[node name="Meta_R4" type="Node3D" parent="." index="4" node_paths=PackedStringArray("proxy")]
|
||||
script = ExtResource("5_mwcgj")
|
||||
proxy = NodePath("../Root/Axis_1/Axis_2/Axis_3/Axis_4")
|
||||
MetaEntries = PackedStringArray("CurrentAngle")
|
||||
|
||||
[node name="Meta_R5" type="Node3D" parent="." index="5" node_paths=PackedStringArray("proxy")]
|
||||
script = ExtResource("5_mwcgj")
|
||||
proxy = NodePath("../Root/Axis_1/Axis_2/Axis_3/Axis_4/Axis_5")
|
||||
MetaEntries = PackedStringArray("CurrentAngle")
|
||||
|
||||
[node name="Meta_R6" type="Node3D" parent="." index="6" node_paths=PackedStringArray("proxy")]
|
||||
script = ExtResource("5_mwcgj")
|
||||
isEnabled = false
|
||||
proxy = NodePath("../Root/Axis_1/Axis_2/Axis_3/Axis_4/Axis_5/Axis_6")
|
||||
MetaEntries = PackedStringArray("CurrentAngle")
|
140
README.md
140
README.md
|
@ -12,7 +12,7 @@
|
|||
该项目为`基准演示`,主要通过一些场景展现该软件的所有功能
|
||||
|
||||
由于Godot未提供相关的编辑器功能(例如`暴露可编辑的class`和`自定义接口实例`),该项目的进度并没有`Unity`的实现速度快
|
||||
|
||||
***
|
||||
## Installation 安装过程
|
||||
1.首先你需要安装 **Godot4.0.3 Net** 👉[GodotEngine.Net](https://godotengine.org/download/windows/)
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
|||
3.最后在**Godot**中导入**iFactory.Godot**
|
||||
|
||||
4.安装完成⭐
|
||||
|
||||
***
|
||||
## Features 功能与模块
|
||||
### 场景介绍
|
||||
* #### 基于AGV小车提供的三维环境感知场景
|
||||
|
@ -139,5 +139,141 @@
|
|||
- [ ] 基于HTML或类HTML的`用户界面框架`——统一技术栈,使用html编写用户界面,例如`Html`和`Unity.UI Toolkit`的关系
|
||||
- [ ] `标识解析`——支持手动注册与解析标识
|
||||
- [ ] `实训平台`——提供线上教学线下考试的服务
|
||||
***
|
||||
## Getting Started 使用指南
|
||||
所有注释和指南都包括在代码中,用例正在编写中
|
||||
### 依赖注入
|
||||
基于`Microsoft.Extensions.DependencyInjection`的依赖注入服务
|
||||
用例:
|
||||
#### 注册服务
|
||||
```csharp
|
||||
public interface IService{}
|
||||
public class MyService:Node,IService
|
||||
{
|
||||
//注入服务
|
||||
BITApp.ServiceCollection.AddSingleton<IService>(this);
|
||||
}
|
||||
```
|
||||
#### 注入服务
|
||||
##### 初始化加载(可能遇到服务还没注入的情况)
|
||||
```csharp
|
||||
public class MyService:Node
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
var myService = BITApp.ServiceProvider.GetService<IService>();
|
||||
}
|
||||
}
|
||||
```
|
||||
##### 基于封装的懒加载
|
||||
```csharp
|
||||
public class MyService:Node
|
||||
{
|
||||
//声明懒加载服务
|
||||
private readonly ServiceLoader<IService> myService=new();
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
//如果服务未加载,则跳过执行
|
||||
if(myService.Loaded is false)return;
|
||||
//获取服务
|
||||
var _myService = myService.Value;
|
||||
//执行
|
||||
_myService.DoSomething();
|
||||
}
|
||||
}
|
||||
```
|
||||
***
|
||||
### 实体,数据与系统的结构
|
||||
> Root/场景
|
||||
> > `Service` \ `System` 处理逻辑和数据的服务或系统
|
||||
> > > `RotationService` 获取数据并应用角度的服务
|
||||
>
|
||||
> > `Entity` 存放数据的基本实体
|
||||
> > > `RotationComponent`存放数据的组件,例如角度偏移`Offset`和角度权重`Weight`等数据
|
||||
### 创建基本组件
|
||||
组件需要继承自`EntityComponent`或者`IEntityComponent`,这样`Entity`才能识别并注册组件
|
||||
```csharp
|
||||
//基本的角度组件
|
||||
/// <summary>
|
||||
/// ECS中iFactory.Rotation的角度组件
|
||||
/// </summary>
|
||||
public partial class RotationComponent : EntityComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取角度的路径
|
||||
/// </summary>
|
||||
[Export] public string Path { get; private set; }
|
||||
/// <summary>
|
||||
/// 角度的绝对权重,例如90* (0,0,1) = 0,0,90
|
||||
/// </summary>
|
||||
[Export] public Vector3 Weight { get; private set; }
|
||||
/// <summary>
|
||||
/// 角度的相对偏移
|
||||
/// </summary>
|
||||
[Export] public Vector3 Offset { get; private set; }
|
||||
/// <summary>
|
||||
/// 默认角度的缓存
|
||||
/// </summary>
|
||||
public Vector3 OriginalEuler { get; private set; }
|
||||
public override void _Ready()
|
||||
{
|
||||
//保存默认角度
|
||||
OriginalEuler = Rotation;
|
||||
}
|
||||
}
|
||||
```
|
||||
### 创建服务
|
||||
基于场景的服务,可直接放入场景中的节点即可
|
||||
|
||||
基于全局的服务,可在Godot.ProjectSettings.AutoLoad中添加自动加载
|
||||
#### 非ECS服务
|
||||
```csharp
|
||||
public partial class RotationService:Node
|
||||
{
|
||||
//在构造函数中注入依赖
|
||||
public ApplyRotationService()
|
||||
{
|
||||
BITApp.ServiceCollection.AddSingleton(this);
|
||||
}
|
||||
//非基于ECS的注册方式,例如Node在_Ready回调中调用该方法注册
|
||||
public static void Register(IObj obj);
|
||||
//基于非ECS的注册方式,例如Node在Dispose方法中调用该方法注销
|
||||
public static void UnRegister(IObj obj)
|
||||
//通常情况下,Register和UnRegister最好使用Queue作为队列的方式注册和注销元素,而非List<T>.Add和List<T>.Remove
|
||||
//使用消息队列可以解决异步中动态注册和注销导致队列被更改的问题
|
||||
public override _Process(double delta)
|
||||
{
|
||||
//在这里遍历已注册的元素,并
|
||||
foreach(var element in registriedElement)
|
||||
{
|
||||
//你的Code,不,是你的Code
|
||||
element.Rotation = new(0,1,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
#### 基于ECS的服务(System)
|
||||
目前`IEntitiesService`的实例为`GodotEntitiesService`
|
||||
```csharp
|
||||
public partial class RotationService:Node
|
||||
{
|
||||
//在构造函数中注入依赖
|
||||
public ApplyRotationService()
|
||||
{
|
||||
BITApp.ServiceCollection.AddSingleton(this);
|
||||
}
|
||||
public override _Process(double delta)
|
||||
{
|
||||
foreach(var entity in EntitiesManager.Query<RotationComponent>())
|
||||
{
|
||||
if(entity.TryGetComponent<RotationComponent>(out var rotationComponent)
|
||||
{
|
||||
//获取该组件的角度
|
||||
var angle = //你的Code
|
||||
//应用组件计算后的角度
|
||||
rotationComponent.Rotation = angle * rotationComponent.Weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
|
@ -23,6 +23,7 @@ EntitiesManager="*res://Artists/Services/entities_manager.tscn"
|
|||
SCADAService="*res://Artists/Services/scada_service.tscn"
|
||||
BITApp="*res://Artists/Services/BITApp.tscn"
|
||||
DebugMenu="*res://addons/debug_menu/debug_menu.tscn"
|
||||
UXMetaService="*res://Artists/Services/UXMetaService.tscn"
|
||||
UXService="*res://Artists/Services/UXService.tscn"
|
||||
|
||||
[display]
|
||||
|
@ -31,6 +32,8 @@ window/size/viewport_width=1920
|
|||
window/size/viewport_height=1080
|
||||
window/stretch/mode="viewport"
|
||||
window/vsync/vsync_mode=2
|
||||
mouse_cursor/vsync/vsync_mode=3
|
||||
mouse_cursor/stretch/aspect="keep"
|
||||
|
||||
[dotnet]
|
||||
|
||||
|
|
Loading…
Reference in New Issue