Commit 4785d8d3 by wester

asd

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