I'm making a map for an ar-app in unreal engine. The data fetch and sorting process works fine, but the rendering is the big issue. Below you can see the createObject method that takes in the start and end point for one line. The line will be a streched static plane mesh, but to make it fit in I have to reposition it by the length of the two vectors and I don't know what's the issue with that.
Thank you. Cheers.
void AMapAPI::CreateObject(FVector2d start, FVector2d end) {
start *= mapSize;
end *= mapSize;
FActorSpawnParameters spawnInfo;
AMapObject* mapObject = GetWorld()->SpawnActor<AMapObject>(FVector(-0.1f, start.X, start.Y), FRotator(0, 90, 90), spawnInfo);
mapObject->meshMaterial = roadMaterial;
mapObject->staticMesh = staticMesh;
double angle = FMath::Atan2(end.Y - start.Y, end.X - start.X) * (180 / PI);
mapObject->SetActorRotation(FQuat(FRotator(angle, 90, 90)));
double scale = 0.0025;
double length = FVector2d::Distance(start, end);
double halfLength = length * 0.5;
mapObject->SetActorScale3D(FVector3d(halfLength, scale, scale));
mapObject->SetActorLocation(FVector(-0.1, start.X - halfLength, start.Y - halfLength));
mapObject->Init();
};
