使用Cesium for Unreal插件构建航班轨迹

使用Cesium for Unreal插件构建航班轨迹

Build a Flight Tracker with Cesium for Unreal

使用航班ADS-B数据创建USplineComponent(样条曲线组件)构建航班轨迹,并通过Timeline控制动画飞行的速度。

飞行轨迹

飞行轨迹

航班ADS-B数据

导入航班Excel或者csv数据到FAircraftRawData。

USTRUCT(BlueprintType)
struct FAircraftRawData : public FTableRowBase
{
  GENERATED_USTRUCT_BODY()

  public:
    FAircraftRawData()
      : Longitude(0.0)
      , Latitude(0.0)
      , Height(0.0)
    {}

  UPROPERTY(EditAnywhere, Category = "FlightTracker")
    double Longitude;
  UPROPERTY(EditAnywhere, Category = "FlightTracker")
    double Latitude;
  UPROPERTY(EditAnywhere, Category = "FlightTracker")
    double Height;
};

生成曲线轨迹

  void APlaneTrack::LoadSplineTrackPoints()
  {
    if (this->AircraftsRawDataTable != nullptr && this->CesiumGeoreference != nullptr)
    {
      int32 PointIndex = 0;
      for (auto& row : this->AircraftsRawDataTable->GetRowMap())
      {
        FAircraftRawData* Point = (FAircraftRawData*)row.Value;
        // Get row data point in lat/long/alt and transform it into UE4 points
        double PointLatitude = Point->Latitude;
        double PointLongitude = Point->Longitude;
        double PointHeight = Point->Height;

        // Compute the position in UE coordinates
        glm::dvec3 UECoords = this->CesiumGeoreference->TransformLongitudeLatitudeHeightToUe(glm::dvec3(PointLongitude, PointLatitude, PointHeight));
        FVector SplinePointPosition = FVector(UECoords.x, UECoords.y, UECoords.z);
        this->SplineTrack->AddSplinePointAtIndex(SplinePointPosition, PointIndex, ESplineCoordinateSpace::World, false);

        // Get the up vector at the position to orient the aircraft
        const CesiumGeospatial::Ellipsoid& Ellipsoid = CesiumGeospatial::Ellipsoid::WGS84;
        glm::dvec3 upVector = Ellipsoid.geodeticSurfaceNormal(CesiumGeospatial::Cartographic(FMath::DegreesToRadians(PointLongitude), FMath::DegreesToRadians(PointLatitude), FMath::DegreesToRadians(PointHeight)));

        // Compute the up vector at each point to correctly orient the plane
        glm::dvec4 ecefUp(upVector, 0.0);
        const glm::dmat4& ecefToUnreal = this->CesiumGeoreference->GetEllipsoidCenteredToUnrealWorldTransform();
        glm::dvec4 unrealUp = ecefToUnreal * ecefUp;
        this->SplineTrack->SetUpVectorAtSplinePoint(PointIndex, FVector(unrealUp.x, unrealUp.y, unrealUp.z), ESplineCoordinateSpace::World, false);

        PointIndex++;
      }
      this->SplineTrack->UpdateSpline();
    }
  }
  
曲线轨迹

蓝图实现控制动画

蓝图控制动画

蓝图控制不同角度观察飞机姿态

切换预设好的摄像机

参考文档

  1. Build a Flight Tracker with Cesium for Unreal
  2. Cesium for Unreal Getting Started Tutorials
  3. 使用Cesium for Unreal插件构建航班轨迹
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容