2023-06-12 15:51:41 +08:00
|
|
|
using Godot;
|
|
|
|
|
|
|
|
namespace BITKit;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 虚拟相机接口定义
|
|
|
|
/// </summary>
|
|
|
|
public interface IVirtualCamera:IActivable
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// 相机的FOV
|
|
|
|
/// </summary>
|
|
|
|
int FOV { get; }
|
|
|
|
/// <summary>
|
|
|
|
/// 相机是否已启用
|
|
|
|
/// </summary>
|
|
|
|
bool IsEnabled { get; }
|
|
|
|
/// <summary>
|
|
|
|
/// 相机坐标
|
|
|
|
/// </summary>
|
|
|
|
Vector3 Position { get; }
|
|
|
|
/// <summary>
|
|
|
|
/// 相机旋转
|
|
|
|
/// </summary>
|
2023-06-15 21:52:13 +08:00
|
|
|
Vector3 Rotation { get; }
|
2023-06-12 15:51:41 +08:00
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 基于Node3D的包括基础功能的虚拟相机
|
|
|
|
/// </summary>
|
|
|
|
public partial class VirtualCamera : Node3D, IVirtualCamera
|
|
|
|
{
|
|
|
|
[Export] private int fov;
|
|
|
|
[Export] private bool isEnabled;
|
|
|
|
public int FOV => fov;
|
|
|
|
|
|
|
|
public bool IsEnabled => isEnabled;
|
|
|
|
|
|
|
|
Vector3 IVirtualCamera.Position => GlobalPosition;
|
2023-06-15 21:52:13 +08:00
|
|
|
Vector3 IVirtualCamera.Rotation => Rotation;
|
2023-06-12 15:51:41 +08:00
|
|
|
|
|
|
|
public void SetActive(bool active)
|
|
|
|
{
|
|
|
|
isEnabled = active;
|
|
|
|
}
|
|
|
|
|
2023-06-29 01:01:52 +08:00
|
|
|
public bool Enabled
|
|
|
|
{
|
|
|
|
get => isEnabled;
|
|
|
|
set => isEnabled = value;
|
|
|
|
}
|
|
|
|
|
2023-06-12 15:51:41 +08:00
|
|
|
public override void _Ready()
|
|
|
|
{
|
|
|
|
CameraService.Register(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Dispose(bool disposing)
|
|
|
|
{
|
|
|
|
if (disposing)
|
|
|
|
{
|
|
|
|
CameraService.UnRegister(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|