虚幻插件Landscaping & Landscaping Mapbox

虚幻插件Landscaping & Landscaping Mapbox

在这里插入图片描述
在这里插入图片描述
Landscaping offers an easy way to import GIS data as single Landscape or World Composition (UE4) or World Partition (UE5) or Procedural/Static Mesh.
提供了一种非常简单的方式来导入GIS数据,可以生成Landscape、静态网格体及程序化网格,支持导入shp数据等等,同时使用了Georeference插件,很好支持了常见的地理坐标。

  • 支持程序化生成道路;
  • 支持根据土地利用(landuse)shp数据生成地表植被;
  • 支持Mapbox在线地图纹理贴图;
  • 支持地形Landscape变形使得植被和道路贴合。

在这里插入图片描述

捕捉地面点代码片段

FVector SnapToFloor(FVector Location, float OffsetFromGround)
{
    
    
	UWorld* World = GEditor ? GEditor->GetEditorWorldContext(false).World() : nullptr;
	FVector HitPoint;
	FVector Start = FVector(Location.X, Location.Y, 900000);
	FVector End = Start + FVector::DownVector * 10000000;
	for (int i = 0; i < 3; i++)
	{
    
    
		if (GetSurfacePoint(Start, End, HitPoint, World))
		{
    
    
			return FVector(HitPoint.X, HitPoint.Y, HitPoint.Z + OffsetFromGround);
		}
		int sign = i % 2 == 0 ? -1 : 1;
		// if we are on the edge of a landscape, try a slight angle
		End = End + FVector(i * 15 * sign, i * 15 * sign, 0);
	}
	return Location;
}

bool GetSurfacePoint(FVector Start, FVector End, FVector& HitPoint, UWorld* InWorld)
{
    
    
	if (InWorld == nullptr)
	{
    
    
		return false;
	}
	FHitResult HitResult = FHitResult(ForceInitToZero);
	bool DidHit = InWorld->LineTraceSingleByChannel(
		HitResult,
		Start,
		End,
		ECC_Visibility
	);

	HitPoint = HitResult.ImpactPoint;
	return DidHit;
}

Github 相关内容

在这里插入图片描述

参考

  1. https://github.com/TensorWorks/LandscapeGen
  2. https://blog.csdn.net/mrbaolong/article/details/131731716

猜你喜欢

转载自blog.csdn.net/mrbaolong/article/details/131731716