Download

Procedural Landscape Generation from Data (BP, C++)

Hey folks, we want to create procedural landscapes from freely available geological and height data. We’ve been following the book “Unreal Engine 4 Scripting with C++ Cookbook”, which is a little older. The code adapted accordingly also works well, until it comes to updating the landscape. It crashes at:


int32 numHeights = (rect.Width()+1)*(rect.Height()+1);
TArray<uint16> Data;
Data.Init( 0, numHeights );
for( int i = 0; i < Data.Num(); i++ ) {
float nx = (i % cols) / cols; // normalized x value
float ny = (i / cols) / rows; // normalized y value
Data* = GeoHeightData( nx, ny, 16, 4, 4 );
}
LandscapeEditorUtils::SetHeightmapData( landscape, Data );

The function


LandscapeEditorUtils::SetHeightmapData( landscape, Data );

no longer exists. In LandscapeEdit.h you can find the


LandscapeEdit::SetHeightData

. This is defined by


SetHeightData(InMinX, InMinY, InMaxX, InMaxY, (uint16*)ImportHeightData->GetData(), 0, false, nullptr);

is this function the equivalent to SetHeightmapData? The engine crushes with this approach too.

Do you have any suggestions or workarounds for creating procedural landscapes, either from blueprint or code? We also checked out the approach of Christian Sparks (https://hippowombat.tumblr.com/post/…-ue4-420#notes), which is cool, but we need the landscape for runtime applications.
Thx!

reiti