美文网首页
使用Cesium for Unreal插件构建航班轨迹

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

作者: wblong | 来源:发表于2021-04-18 21:25 被阅读0次

    使用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插件构建航班轨迹

    相关文章

      网友评论

          本文标题:使用Cesium for Unreal插件构建航班轨迹

          本文链接:https://www.haomeiwen.com/subject/vqavlltx.html