Help,How to get the LongitudeLatitudeHeight or ECEF of the mouse position?
I try to LineTraceSingleByChannel, but it is inaccurate!!
Help,How to get the LongitudeLatitudeHeight or ECEF of the mouse position?
I try to LineTraceSingleByChannel, but it is inaccurate!!
I need too! please
Who knows this question,Please!
This question is very important to me, Please!
First you can get the world coordinate of the mouse position use ConvertMouseLocationToWorldSpace, then with Cesium georeference, InaccurateTransformUeToLongitudeLatitudeHeight or InaccurateTransformUeToECEF will transform world to the longitiude and latitude.
APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0);
check(PlayerController );
FVector WorldLocation;
FVector WorldRotation;
PlayerController->DeprojectMousePositionToWorld(WorldLocation, WorldRotation);
UWorld* World = GetWorld();
check(World);
ULevel* Level = World->GetCurrentLevel();
check(Level);
AActor** GeoreferencePtr = Level->Actors.FindByPredicate([](AActor* Actor) { return Actor->IsA<ACesiumGeoreference>(); });
check(GeoreferencePtr);
ACesiumGeoreference* GeoreferenceActor = Cast<ACesiumGeoreference>(*GeoreferencePtr);
check(GeoreferenceActor);
FVector ECEFCoordinate = GeoreferenceActor->InaccurateTransformUnrealToEcef(WorldLocation);
UE_LOG(LogMainActor, Warning, (TEXT("ECEFCoordinate.X: %.6f, ECEFCoordinate.Y: %.6f,
ECEFCoordinate.Z: %.6f")), ECEFCoordinate.X, ECEFCoordinate.Y, ECEFCoordinate.Z);
glm::dvec3 WS84Coordinate = GeoreferenceActor->TransformEcefToLongitudeLatitudeHeight(glm::dvec3(ECEFCoordinate.X, ECEFCoordinate.Y, ECEFCoordinate.Z));
UE_LOG(LogMainActor, Warning, (TEXT("WS84Coordinate.x: %.6f, WS84Coordinate.y: %.6f,
WS84Coordinate.z: %.6f")), WS84Coordinate.x, WS84Coordinate.y, WS84Coordinate.z);