Let’s start by creating a new function, which will contain the whole process (you are free to apply the exact same principles as Events or any other set up). Let’s call it MyPointCloudFunction.

Creating new function in  Blueprint .

Creating new function in Blueprint.


The simplest way to create the Point Cloud asset from file is


Once the function is ready, we’ll go straight into loading the data and storing it as an asset variable.

Line Range

Properties First Line and Last Line will determine the range of lines to process while reading the given file. In this example we will load points 1000 - 50000 (or less if the file doesn't actually hold that much), discarding the rest.
Setting the Last Line to 0 will read data until the end of the file, while setting both to 0 will read the whole

RGB Range

This will determine normalization and clipping range for color values

Example:
Setting this to
(0, 255) will result in all values being clipped to 0 - 255 range, then normalized for 0 - 1 range.
-100 would be clipped to 0, then normalized to 0.0f
0
does not need to be clipped, and will be normalized to 0.0f
51
does not need to be clipped, and will be normalized to 0.2f
255
does not need to be clipped, and will be normalized to 1.0f
512
would be clipped to 255, then normalized to 1.0f

If set to (0, 0), the best match will be automatically determined based on the data contained within the file.

WARNING: Applying incorrect range will most likely result in incorrect color representation.

Source Columns

This object determines, which columns to use as which data sources
Use 0-based indexing when specifying the column ID

In this example, we will:

  • Use first column in the file as X location

  • Use second column in the file as Y location

  • Use third column in the file as Z location

  • Use seventh column in the file as Red channel

  • Do not use Green nor Blue channels - this will result in Cloud importing as Intensity data only

// This will load points 1000 - 50000 (or less if the file doesn't actually
// hold that much), discarding the rest
int32 FirstLine = 1000;
int32 LastLine = 50000;

// This will determine normalization and clipping range for color values
// If set to FVector2D::ZeroVector or (0, 0), the best match will be automatically
// determined based on the data contained within the file.
FVector2D RGBRange = FVector2D::ZeroVector;

// This object determines, which columns to use as which data sources
// Use 0-based indexing when specifying the column ID
FPointCloudImportSettingsColumns SourceColumns;
SourceColumns.LocationX = 0;	// Use first column in the file as X location
SourceColumns.LocationY = 1;	// Use second column in the file as Y location
SourceColumns.LocationZ = 2;	// Use third column in the file as Z location
SourceColumns.Red = 6;		// Use seventh column in the file as Red channel

// Do not use Green nor Blue channels
// This will result in Cloud importing as Intensity data only
SourceColumns.Green = -1;			
SourceColumns.Blue = -1;

// Load the file, then build the Cloud
UPointCloud *MyPointCloud = UPointCloudStatics::LoadPointCloudFromFile(
							MyPointCloudPath,
                            				FirstLine, LastLine,
							RGBRange, SourceColumns);
Loading the cloud from file.

Loading the cloud from file.


At this point you can do with the asset as you would with one imported through the Content Browser. In this example, we'll assign it to some hypothetical Point Cloud Actor.

// Get the target Point Cloud Actor
APointCloudActor *MyPointCloudActor = MyActorGettingFunction();

// Assign the loaded Cloud
MyPointCloudActor->GetPointCloudComponent()->SetPointCloud(MyPointCloud);
Assign the Cloud asset to a Point Cloud Actor.

Assign the Cloud asset to a Point Cloud Actor.


Here are the full code snippet and full-sized Blueprint screenshot of the complete process.

// This will load points 1000 - 50000 (or less if the file doesn't actually
// hold that much), discarding the rest
int32 FirstLine = 1000;
int32 LastLine = 50000;

// This will determine normalization and clipping range for color values
// If set to FVector2D::ZeroVector or (0, 0), the best match will be automatically
// determined based on the data contained within the file.
FVector2D RGBRange = FVector2D::ZeroVector;

// This object determines, which columns to use as which data sources
// Use 0-based indexing when specifying the column ID
FPointCloudImportSettingsColumns SourceColumns;
SourceColumns.LocationX = 0;	// Use first column in the file as X location
SourceColumns.LocationY = 1;	// Use second column in the file as Y location
SourceColumns.LocationZ = 2;	// Use third column in the file as Z location
SourceColumns.Red = 6;		// Use seventh column in the file as Red channel

// Do not use Green nor Blue channels
// This will result in Cloud importing as Intensity data only
SourceColumns.Green = -1;			
SourceColumns.Blue = -1;

// Load the file, then build the Cloud
UPointCloud *MyPointCloud = UPointCloudStatics::LoadPointCloudFromFile(
							MyPointCloudPath,
                            				FirstLine, LastLine,
							RGBRange, SourceColumns);
	
// Get the target Point Cloud Actor
APointCloudActor *MyPointCloudActor = MyActorGettingFunction();

// Assign the loaded Cloud
MyPointCloudActor->GetPointCloudComponent()->SetPointCloud(MyPointCloud);

Complete Blueprint of the function.