Hey guys, im encountering a really weird error for Procedural Mesh Generation in cesium 3d tiles world, where the placement in the cesium world is somewhat off. Basically im trying to draw a 3d zone around a specific coordinate area that is defined by the user,im testing it with this building at my school
i went and got the coordinates in google maps and verified that they were correct in cesium, meaning cesium can acurrately go to those coordinates in my unreal editor (forgot to mention im using Cesium for Unreal with UE 5.0.3 (LWC are enabled)
however when the mesh actually generates it places itself slightly off from where it needs to be, I have verified that the mesh is drawing at the exact coordinates the Cesium TransformLongitudeLatitudeHeighttoUnreal is giving it. I also tested it by giving it the raw ECEF coordinates instead with no change in where the mesh gets generated
im really at a loss for what is happening and how i can fix it so i was hoping one of you might be able to assist me
the code for my function is below.
void ASADEZoneActor::CreateMeshFromCoordinates(const TArray<FGeoVertex>& GeoVertices)
{
UE_LOG(LogTemp, Log, TEXT("Getting Georeference..."));
ACesiumGeoreference* Georeference = GetGeoreference();
if (!Georeference) return;
TArray<FVector> MeshVertices;
for (const FGeoVertex& Vertex : GeoVertices)
{
FVector BasePosition = ConvertGeoCoordinatesToUnrealWorld(Vertex.Latitude, Vertex.Longitude, 0);
MeshVertices.Add(BasePosition);
FVector HighPosition = ConvertGeoCoordinatesToUnrealWorld(Vertex.Latitude, Vertex.Longitude, 400);
MeshVertices.Add(HighPosition);
}
TArray<int32> Triangles;
for (int32 i=0; i<MeshVertices.Num()-1; i+=2)
{
UE_LOG(LogTemp, Log, TEXT("Creating triangles..."));
int32 NextBaseIndex = (i+2) % MeshVertices.Num();
Triangles.Append({i, i+1, NextBaseIndex});
Triangles.Append({i+1, NextBaseIndex+1, NextBaseIndex});
}
UE_LOG(LogTemp, Log, TEXT("Getting MeshComponent..."));
// Directly use the ProceduralMeshComponent member
if(!ProceduralMeshComponent)
{
UE_LOG(LogTemp, Warning, TEXT("MeshComponent not initialized."));
return;
}
UE_LOG(LogTemp, Log, TEXT("Creating MeshSection..."));
ProceduralMeshComponent->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
ProceduralMeshComponent->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap);
ProceduralMeshComponent->CreateMeshSection_LinearColor(0, MeshVertices, Triangles, TArray<FVector>(), TArray<FVector2D>(), TArray<FLinearColor>(), TArray<FProcMeshTangent>(), true);
UE_LOG(LogTemp, Log, TEXT("Loading default material..."));
UMaterial* DefaultMaterial = LoadObject<UMaterial>(nullptr, TEXT("Material'/Game/Materials/M_Wireframe.M_Wireframe'"));
{
UE_LOG(LogTemp, Log, TEXT("Setting default material..."));
ProceduralMeshComponent->SetMaterial(0, DefaultMaterial);
}
}