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.


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

Shared Options

Filename

This determines the path of the file to use for loading.

Line Range

Properties First Index and Num Points to Read will determine the range of points to process while reading the given file.

Setting the Num Points to Read to 0 will read data until the end of the file, setting both to 0 will read the whole

Async

Click here to learn more.

ASCII Options

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 determines, which columns to use, as which data sources
Use 0-based indexing when specifying the column ID
Set to -1 to skip this data source


// This will include the necessery header files
#include "PointCloud.h"
#include "IO/PointCloudFileIO_ASCII.h"

// 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
FPointCloudImportSettings_ASCII_Columns 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.Intensity = 6;	// Use seventh column in the file as Intensity

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

// Load the Cloud from ASCII file
UPointCloud *MyPointCloud = UPointCloudFileIO_ASCII::CreatePointCloudFromFile(
                	MyPointCloudPath, 0, 0, false, RGBRange, SourceColumns);

Example of importing ASCII file with Intensity only

// This will include the necessery header files
#include "PointCloud.h"

// Load the Cloud from any file using default settings
UPointCloud *MyPointCloud = UPointCloud::CreateFromFile(MyPointCloudPath, 0, 0, false);

Example of importing a file using default settings

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 create a new Point Cloud Actor and assign our asset to it.

// This will include the necessery header files
#include "PointCloud.h"
#include "PointCloudActor.h"

// Create new Point Cloud Actor
APointCloudActor* MyPointCloudActor = GetWorld()->SpawnActor<APointCloudActor>();

// Load the Cloud from any file using default settings
UPointCloud *MyPointCloud = UPointCloud::CreateFromFile(MyPointCloudPath, 0, 0, false);

// 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.