3

in UE4 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[i] = 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

Reiti
  • 57
  • 4
  • I was about to say "read the manual" and then I looked at it - the Unreal documentation seems to have gone downhill a lot over the past decade. Have you tried the Unreal forums? I would expect to find far more experts there than here. – molbdnilo Dec 11 '19 at 09:13
  • The documentation for landscape creation via code is very incomplete and outdated. I posted the question in unreal forum and answerhub either. I wonder why the height data adjustment worked in the C++ cookbook, but in 4.23.1 it's impossible to customize a landscape in runtime. – Reiti Dec 11 '19 at 09:26
  • *"It crashes at [..] The function `LandscapeEditorUtils::SetHeightmapData( landscape, Data );` no longer exists"*. Compilation errors are not crash. – Jarod42 Dec 11 '19 at 10:15
  • The engine crashes during compiling and tears down. – Reiti Dec 11 '19 at 10:23

0 Answers0