Backend: - Add /api/v1/ue/* endpoints (compute-points, cables, landing-points, satellites, status) returning flat JSON optimised for UE5 C++ parsing UE5 client (ue_client/): - PlanetDataManager: HTTP fetch + local mock JSON loader, spawns ComputePointActors - ComputePointActor / InteractiveObjectBase: hover/select state, material switching - GlobeInteractionComponent: drag-to-rotate via CesiumGeoreference origin shift, inertia, zoom - StereoRenderingManager: runtime SbS/TbB stereo toggle, IPD control (format TBD) - MotionCaptureInterface: protocol-agnostic gesture/rotate/zoom delegate interface (impl TBD) - PlanetPlayerController: unified mouse + motion-capture input routing - PlanetGameMode, Build.cs, Config, mock data Docs: - ue5_mvp_fused_plan.md updated to v3.0 for LED display context - ue_client_setup_guide.md: step-by-step editor setup guide - ue_todo.md: pending items blocked on vendor answers (stereo format + mocap protocol) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
97 lines
3.3 KiB
C++
97 lines
3.3 KiB
C++
#pragma once
|
||
|
||
#include "CoreMinimal.h"
|
||
#include "Components/ActorComponent.h"
|
||
#include "GlobeInteractionComponent.generated.h"
|
||
|
||
class ACesiumGeoreference;
|
||
|
||
/**
|
||
* UGlobeInteractionComponent
|
||
*
|
||
* 挂在 PlayerController 或 Pawn 上,处理地球旋转和缩放。
|
||
*
|
||
* 旋转原理:
|
||
* 修改 CesiumGeoreference 的 OriginLongitude / OriginLatitude,
|
||
* 相当于"移动地球"到新中心,视觉效果等同于旋转地球。
|
||
*
|
||
* 缩放原理:
|
||
* 沿相机到地球中心方向移动相机,改变观察高度。
|
||
*
|
||
* 使用方式:
|
||
* 在 PlanetPlayerController::BeginPlay 里 AddComponent,
|
||
* 收到拖拽/滚轮输入时调用 RotateGlobe / ZoomGlobe。
|
||
*/
|
||
UCLASS(ClassGroup=(Planet), meta=(BlueprintSpawnableComponent), BlueprintType)
|
||
class PLANETCLIENT_API UGlobeInteractionComponent : public UActorComponent
|
||
{
|
||
GENERATED_BODY()
|
||
|
||
public:
|
||
UGlobeInteractionComponent();
|
||
|
||
// -----------------------------------------------------------------------
|
||
// 可在 Details 面板调整的参数
|
||
// -----------------------------------------------------------------------
|
||
|
||
// 拖拽灵敏度:每像素对应的经纬度偏移量(度)
|
||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Planet|Globe")
|
||
float RotateSensitivity = 0.15f;
|
||
|
||
// 缩放灵敏度:每格滚轮对应的高度变化(米)
|
||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Planet|Globe")
|
||
float ZoomSensitivity = 200000.f;
|
||
|
||
// 最小观察高度(米),防止穿入地面
|
||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Planet|Globe")
|
||
double MinAltitudeMeters = 500000.0;
|
||
|
||
// 最大观察高度(米)
|
||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Planet|Globe")
|
||
double MaxAltitudeMeters = 30000000.0;
|
||
|
||
// 旋转惯性平滑系数 (0=无惯性, 1=永不停)
|
||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Planet|Globe",
|
||
meta=(ClampMin="0.0", ClampMax="0.99"))
|
||
float InertiaDamping = 0.85f;
|
||
|
||
// -----------------------------------------------------------------------
|
||
// 公开 API
|
||
// -----------------------------------------------------------------------
|
||
|
||
// 每帧由 PlayerController 调用,传入鼠标位移(像素)
|
||
UFUNCTION(BlueprintCallable, Category="Planet|Globe")
|
||
void RotateGlobe(float DeltaYaw, float DeltaPitch);
|
||
|
||
// 每帧由 PlayerController 调用,Value > 0 = 拉近,< 0 = 推远
|
||
UFUNCTION(BlueprintCallable, Category="Planet|Globe")
|
||
void ZoomGlobe(float Value);
|
||
|
||
// 立即停止惯性
|
||
UFUNCTION(BlueprintCallable, Category="Planet|Globe")
|
||
void StopInertia();
|
||
|
||
// 返回当前相机高度(米)
|
||
UFUNCTION(BlueprintPure, Category="Planet|Globe")
|
||
double GetCurrentAltitudeMeters() const { return CurrentAltitudeMeters; }
|
||
|
||
virtual void TickComponent(float DeltaTime, ELevelTick TickType,
|
||
FActorComponentTickFunction* ThisTickFunction) override;
|
||
|
||
virtual void BeginPlay() override;
|
||
|
||
private:
|
||
UPROPERTY()
|
||
ACesiumGeoreference* Georeference = nullptr;
|
||
|
||
// 惯性速度(经度/帧,纬度/帧)
|
||
float InertiaYaw = 0.f;
|
||
float InertiaPitch = 0.f;
|
||
|
||
// 当前相机高度(米),随 Zoom 更新
|
||
double CurrentAltitudeMeters = 5000000.0;
|
||
|
||
void FindGeoreference();
|
||
void ApplyAltitudeToCamera();
|
||
};
|