Commit 4785d8d3 by wester

asd

parent 125a43db
......@@ -33,7 +33,14 @@ APointCloudActor::APointCloudActor(const FObjectInitializer& ObjectInitializer)
void APointCloudActor::setPoints(UTexture2D* PointCloud) {
Material->SetTextureParameterValue(FName("PointCloud"), PointCloud);
Poitns = PointCloud;
Points = PointCloud;
StaticMeshComponent->SetMaterial(0, Material);
}
void APointCloudActor::setColors(UTexture2D* Colors) {
Material->SetTextureParameterValue(FName("Colors"), Colors);
this->Colors = Colors;
StaticMeshComponent->SetMaterial(0, Material);
}
......
......@@ -14,6 +14,7 @@ public:
// Sets default values for this actor's properties
APointCloudActor(const FObjectInitializer& ObjectInitializer);
void setPoints(UTexture2D* Points);
void setColors(UTexture2D* Colors);
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Material")
UMaterialInstanceDynamic* Material;
......@@ -25,7 +26,10 @@ public:
UStaticMeshComponent* StaticMeshComponent;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Points")
UTexture2D* Poitns;
UTexture2D* Points;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Points")
UTexture2D* Colors;
protected:
......
......@@ -345,6 +345,9 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile)
UWorld* const World = GetWorld();
if (World)
{
APointCloudActor *PointCloud = World->SpawnActor<APointCloudActor>(APointCloudActor::StaticClass());
int32 TextureSize = FMath::FloorToInt(FMath::Sqrt(instances_length)) + 1;
int32 fill = TextureSize*TextureSize - instances_length;
......@@ -376,28 +379,19 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile)
UDynamicTextureUtilities::UpdateDynamicVectorTexture(*Points, Texture);
UE_LOG(TILES, Warning, TEXT("Created Position Texture Number Points %d, TextureSize: %d, Fill: %d, "), instances_length, TextureSize, fill);
UWorld* const World = GetWorld();
if (World)
{
APointCloudActor *PointCloud = World->SpawnActor<APointCloudActor>(APointCloudActor::StaticClass());
PointCloud->setPoints(Texture);
#if WITH_EDITOR
PointCloud->SetFolderPath(FName(*("SpawnedGLTF/" + this->GetName())));
#endif
PointCloud->AttachToActor(this, FAttachmentTransformRules::KeepWorldTransform);
}
PointCloud->setPoints(Texture);
//ass texture to mAterial
if (TextureTest) {
UMaterialInstanceDynamic *Material = UMaterialInstanceDynamic::Create(TextureTest->GetStaticMeshComponent()->GetMaterial(0), nullptr);
Material->SetTextureParameterValue(FName("DynamicTexture"), Texture);
TextureTest->GetStaticMeshComponent()->SetMaterial(0,Material);
//TextureTest->GetStaticMeshComponent()->SetMaterial(0,Material);
}
}
else {
UE_LOG(TILES, Error, TEXT("Pointcloud Quantized not supported Position Required"));
}
if (FeatureTableJSON->HasField("RGB")) {
// RGB = uint8[3]
uint32 featureTableBinaryOffset = pntheader->getFeatureStart() + pntheader->featureTable.featureTableJSONByteLength;
......@@ -408,30 +402,28 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile)
// creat pooint texture
TArray<FLinearColor> *ColorRGB = new TArray<FLinearColor>();
uint8* pos = start;
UE_LOG(TILES, Error, TEXT("Color %s"), *FLinearColor((*pos) / 255, (*(pos + 1)) / 255, (*(pos + 2)) / 255).ToString() );
UE_LOG(TILES, Error, TEXT("Start %d Color %s"), start, *FLinearColor((*pos) / 255.0, (*(pos + 1)) / 255.0, (*(pos + 2)) / 255.0).ToString());
for (size_t i = 0; i < instances_length; i += 1)
{
ColorRGB->Add(FLinearColor((*pos)/255, (*(pos + 1))/255, (*(pos + 2))/255));
FLinearColor temp = FLinearColor((*pos) / 255.0, (*(pos + 1)) / 255.0, (*(pos + 2)) / 255.0);
ColorRGB->Add(temp);
pos += 3;
}
for (size_t i = 0; i < fill; i += 1)
{
ColorRGB->Add(FLinearColor(1.0f, 0.0f, 0.0f));
}
UTexture2D* Texture = UDynamicTextureUtilities::CreateTransientDynamicTexture(TextureSize, TextureSize, PF_A32B32G32R32F);
UDynamicTextureUtilities::UpdateDynamicVectorTexture(*ColorRGB, Texture);
UTexture2D* ColorTexture = UDynamicTextureUtilities::CreateTransientDynamicTexture(TextureSize, TextureSize, PF_A32B32G32R32F);
UDynamicTextureUtilities::UpdateDynamicVectorTexture(*ColorRGB, ColorTexture);
UE_LOG(TILES, Warning, TEXT("Created Color Texture Number Points %d, TextureSize: %d, Fill: %d, "), instances_length, TextureSize, fill);
//ass texture to mAterial
if (TextureTest) {
UMaterialInstanceDynamic *Material = UMaterialInstanceDynamic::Create(TextureTest->GetStaticMeshComponent()->GetMaterial(0), nullptr);
Material->SetTextureParameterValue(FName("DynamicTexture"), Texture);
//TextureTest->GetStaticMeshComponent()->SetMaterial(0, Material);
}
PointCloud->setColors(ColorTexture);
}
#if WITH_EDITOR
PointCloud->SetFolderPath(FName(*("SpawnedGLTF/" + this->GetName())));
#endif
PointCloud->AttachToActor(this, FAttachmentTransformRules::KeepWorldTransform);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment