Commit 45adf7e6 by wester

gnarf

parent 74fa4789
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -78,13 +78,15 @@ UTexture2D* UDynamicTextureUtilities::CreateTransientDynamicTexture(int32 Width, ...@@ -78,13 +78,15 @@ UTexture2D* UDynamicTextureUtilities::CreateTransientDynamicTexture(int32 Width,
auto* Texture = UTexture2D::CreateTransient(Width, Height, PixelFormat); auto* Texture = UTexture2D::CreateTransient(Width, Height, PixelFormat);
if (Texture) if (Texture)
{ {
Texture->CompressionSettings = TextureCompressionSettings::TC_VectorDisplacementmap; Texture->CompressionSettings = TextureCompressionSettings::TC_HDR; // TC_VectorDisplacementmap;
Texture->SRGB = 0; Texture->SRGB = 0;
Texture->UpdateResource(); Texture->UpdateResource();
} }
return Texture; return Texture;
} }
//not used
UTexture2D* UDynamicTextureUtilities::CreateDynamicTextureWithData(int length, uint8* data) UTexture2D* UDynamicTextureUtilities::CreateDynamicTextureWithData(int length, uint8* data)
{ {
......
...@@ -11,7 +11,9 @@ APointCloudActor::APointCloudActor(const FObjectInitializer& ObjectInitializer) ...@@ -11,7 +11,9 @@ APointCloudActor::APointCloudActor(const FObjectInitializer& ObjectInitializer)
PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.bCanEverTick = true;
//Create Static Mesh //Create Static Mesh
static ConstructorHelpers::FObjectFinder<UStaticMesh> StaticMeshOb_AW2(TEXT("StaticMesh'/Game/PointClouds/quadchain-2-20.quadchain-2-20'")); //static ConstructorHelpers::FObjectFinder<UStaticMesh> StaticMeshOb_AW2(TEXT("StaticMesh'/Game/PointClouds/quadchain-2-20.quadchain-2-20'"));
static ConstructorHelpers::FObjectFinder<UStaticMesh> StaticMeshOb_AW2(TEXT("StaticMesh'/Game/FirstPersonBP/Blueprints/quadchain-2-20.quadchain-2-20'"));
StaticMesh = StaticMeshOb_AW2.Object; StaticMesh = StaticMeshOb_AW2.Object;
StaticMeshComponent = ObjectInitializer.CreateDefaultSubobject < UStaticMeshComponent >(this, TEXT("Poins")); StaticMeshComponent = ObjectInitializer.CreateDefaultSubobject < UStaticMeshComponent >(this, TEXT("Poins"));
StaticMeshComponent->SetStaticMesh(StaticMesh); StaticMeshComponent->SetStaticMesh(StaticMesh);
...@@ -33,6 +35,7 @@ APointCloudActor::APointCloudActor(const FObjectInitializer& ObjectInitializer) ...@@ -33,6 +35,7 @@ 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);
Material->SetScalarParameterValue(FName("TextureSize"), PointCloud->GetSizeX());
Points = PointCloud; Points = PointCloud;
StaticMeshComponent->SetMaterial(0, Material); StaticMeshComponent->SetMaterial(0, Material);
......
...@@ -342,6 +342,7 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile) ...@@ -342,6 +342,7 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile)
if (FJsonSerializer::Deserialize(JsonReader, FeatureTableJSON)) if (FJsonSerializer::Deserialize(JsonReader, FeatureTableJSON))
{ {
int32 instances_length = FeatureTableJSON->GetIntegerField("POINTS_LENGTH"); int32 instances_length = FeatureTableJSON->GetIntegerField("POINTS_LENGTH");
//instances_length = 265;
UWorld* const World = GetWorld(); UWorld* const World = GetWorld();
if (World) if (World)
{ {
...@@ -366,9 +367,11 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile) ...@@ -366,9 +367,11 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile)
uint8* pos = start; uint8* pos = start;
float minx, maxx, miny, maxy, minz, maxz; float minx, maxx, miny, maxy, minz, maxz;
minx = miny = minz = TNumericLimits< float >::Max(); minx = miny = minz = TNumericLimits< float >::Max();
maxx = maxy = maxz = TNumericLimits< float >::Min(); maxx = maxy = maxz = TNumericLimits< float >::Min();
//FString AbsoluteFilePath = "C:/Users/wester/Documents/Unreal Projects/MasterTestProjekt/Content/points.csv";
//IPlatformFile& file = FPlatformFileManager::Get().GetPlatformFile();
//IFileHandle* handle = file.OpenWrite(*AbsoluteFilePath,true);
for (size_t i = 0; i < instances_length; i+=1) for (size_t i = 0; i < instances_length; i+=1)
{ {
...@@ -376,10 +379,6 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile) ...@@ -376,10 +379,6 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile)
float y = *((float*)(pos + 4)); float y = *((float*)(pos + 4));
float z = *((float*)(pos + 8)); float z = *((float*)(pos + 8));
x = (x + 1.0) / 4;
y = (x + 1.0) / 4;
z = (x + 1.0) / 4;
minx = FMath::Min(x, minx); minx = FMath::Min(x, minx);
maxx = FMath::Max(x, maxx); maxx = FMath::Max(x, maxx);
...@@ -389,9 +388,29 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile) ...@@ -389,9 +388,29 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile)
minz = FMath::Min(z, minz); minz = FMath::Min(z, minz);
maxz = FMath::Max(z, maxz); maxz = FMath::Max(z, maxz);
pos += 12;
// FString string = FString::SanitizeFloat(x) + TEXT(";") + FString::SanitizeFloat(y) + TEXT(";") + FString::SanitizeFloat(z) + TEXT("\n");
// handle->Write((const uint8*)TCHAR_TO_ANSI(*string), string.Len());
}
//delete handle;
Points->Add(FLinearColor(x, y, z, 1.0f)); pos = start;
for (size_t i = 0; i < instances_length; i += 1)
{
float x = *((float*)pos);
float y = *((float*)(pos + 4));
float z = *((float*)(pos + 8));
x = (x - minx) / (maxx - minx);
y = (y - miny) / (maxy - miny);
z = (z - minz) / (maxz - minz);
FLinearColor point = FLinearColor(x,y, z, 1.0f);
Points->Add(point);
//UE_LOG(TILES, Warning, TEXT("%s"),*Points->Last().ToString()); //UE_LOG(TILES, Warning, TEXT("%s"),*Points->Last().ToString());
pos += 12; pos += 12;
...@@ -401,12 +420,15 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile) ...@@ -401,12 +420,15 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile)
Points->Add(FLinearColor(0.0f, 0.0f, 0.0f, 0.0f)); Points->Add(FLinearColor(0.0f, 0.0f, 0.0f, 0.0f));
} }
UTexture2D* Texture = UDynamicTextureUtilities::CreateTransientDynamicTexture(TextureSize, TextureSize, PF_A32B32G32R32F); UTexture2D* Texture = UDynamicTextureUtilities::CreateTransientDynamicTexture(TextureSize, TextureSize, PF_A32B32G32R32F);
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);
UE_LOG(TILES, Error, TEXT("Boundig %f Box: Min [%f/%f/%f] Max [%f/%f/%f]"), TNumericLimits< float >::Min(), minx, miny, minz,maxx, maxy, maxz ); UE_LOG(TILES, Error, TEXT("Boundig %f Box: Min [%f/%f/%f] Max [%f/%f/%f]"), TNumericLimits< float >::Min(), minx, miny, minz,maxx, maxy, maxz );
if(tstTexture)
PointCloud->setPoints(tstTexture);
PointCloud->setPoints(Texture); //PointCloud->setPoints(Texture);
//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);
......
...@@ -148,6 +148,8 @@ struct FTile ...@@ -148,6 +148,8 @@ struct FTile
void setVisible(bool visible); void setVisible(bool visible);
FTile() { FTile() {
float transformDefault[] = { 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 }; float transformDefault[] = { 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 };
transform.Empty(); transform.Empty();
...@@ -345,6 +347,10 @@ public: ...@@ -345,6 +347,10 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Texture") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Texture")
AStaticMeshActor *TextureTest = NULL; AStaticMeshActor *TextureTest = NULL;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Texture")
UTexture2D* tstTexture;
// Called when the game starts or when spawned // Called when the game starts or when spawned
virtual void BeginPlay() override; virtual void BeginPlay() override;
......
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