Good morning, I’m currently working to a Point Cloud Streaming that takes data from a camera and convert them into a point cloud. The code is this:
void UNiagaraPointCloudComponent::UpdatePointCloudTextures(TArray& PointPositions,
TArray& PointColors)
{
if(ensure(PointPosTexture) && ensure(PointColTexture) && ensure(UpdateTextureRegion))
{
/AsyncTask(ENamedThreads::ActualRenderingThread, &
{/
/**
* Asynchronously update a set of regions of a texture with new data.
* @param MipIndex - the mip number to update
* @param NumRegions - number of regions to update
* @param Regions - regions to update
* @param SrcPitch - the pitch of the source data in bytes
* @param SrcBpp - the size one pixel data in bytes
* @param SrcData - the source data
* @param bFreeData - if true, the SrcData and Regions pointers will be freed after the update.
*/
TArray Colors;
for (int i = 0; i < PointColors.Num();i=i+4) {
Colors.Add( FColor(PointColors[i + 2], PointColors[i + 1], PointColors[i + 0], PointColors[i+3]));
}
int j=UKismetMathLibrary::RandomIntegerInRange(0, Colors.Num() % PointPositions.Num());
FColor color = Colors[j];
PointPosTexture->UpdateTextureRegions(0, 1, UpdateTextureRegion, PointPosTexture->GetSizeX() * sizeof(FLinearColor), sizeof(FLinearColor), (uint8*)PointPositions.GetData());
PointColTexture->UpdateTextureRegions(0, 1, UpdateTextureRegion, PointColTexture->GetSizeX() * sizeof(FColor), sizeof(FColor), (uint8*)Colors.GetData());
}
}
This code works in the Editor and the colours are right, however when I package it, the colors change to white.
I hope you have enough information to help me. Thanks.