Commit 311c1bbf by wester

gitmodules

big pointclouds
parent 0e37126e
......@@ -10,3 +10,4 @@ Saved
*.suo
*.xcodeproj
*.xcworkspace
/gdal-2.1.3
......@@ -4,3 +4,4 @@
[submodule "ThirdParty/assimp"]
path = assimp
url = https://github.com/assimp/assimp.git
ignore = dirty
This source diff could not be displayed because it is too large. You can view the blob instead.
No preview for this file type
......@@ -35,13 +35,14 @@ APointCloudActor::APointCloudActor(const FObjectInitializer& ObjectInitializer)
}
void APointCloudActor::setPoints(UTexture2D* PointCloud, FVector pos, FVector scale){
void APointCloudActor::setPoints(UTexture2D* PointCloud, FVector pos, FVector scale, float TextureOffset){
if (pos.Y < 0) pos.Y = 0;
UE_LOG(TILES, Log, TEXT("PointclodActor pos: %s size: %s"), *pos.ToString(), *scale.ToString());
Material->SetTextureParameterValue(FName("PointCloud"), PointCloud);
Material->SetScalarParameterValue(FName("TextureSize"), PointCloud->GetSizeX());
Material->SetVectorParameterValue(FName("CloudCenter"), pos);
Material->SetVectorParameterValue(FName("BoundigBox"), scale);
Material->SetScalarParameterValue(FName("TextureOffset"), TextureOffset);
Points = PointCloud;
StaticMeshComponent->SetMaterial(0, Material);
......
......@@ -13,7 +13,7 @@ class MASTERTESTPROJECT_API APointCloudActor : public AActor
public:
// Sets default values for this actor's properties
APointCloudActor(const FObjectInitializer& ObjectInitializer);
void setPoints(UTexture2D* Points, FVector pos, FVector scale);
void setPoints(UTexture2D* Points, FVector pos, FVector scale, float TextureOffset);
void setColors(UTexture2D* Colors);
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Material")
......
......@@ -339,29 +339,25 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile)
UE_LOG(TILES, Warning, TEXT("PointCloudHeader: FeatureTable JSON: %s"), *featureJSONString);
TSharedPtr<FJsonObject> FeatureTableJSON;
TSharedRef<TJsonReader<TCHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(featureJSONString);
if (FJsonSerializer::Deserialize(JsonReader, FeatureTableJSON))
{
int32 instances_length = FeatureTableJSON->GetIntegerField("POINTS_LENGTH");
//instances_length = 265;
UWorld* const World = GetWorld();
if (World)
if (World && FJsonSerializer::Deserialize(JsonReader, FeatureTableJSON))
{
APointCloudActor *PointCloud = World->SpawnActor<APointCloudActor>(APointCloudActor::StaticClass());
int32 instances_length = FeatureTableJSON->GetIntegerField("POINTS_LENGTH");
int32 TextureSize = FMath::FloorToInt(FMath::Sqrt(instances_length)) + 1;
int32 fill = TextureSize*TextureSize - instances_length;
int32 quadchainsize = pow(2, 20);
if (!FeatureTableJSON->HasField("POSITION")) {
UE_LOG(TILES, Error, TEXT("Pointcloud Quantized not supported Position Required"));
return;
}
if (FeatureTableJSON->HasField("POSITION")) {
// POSITION = float32[3]
uint32 featureTableBinaryOffset = pntheader->getFeatureStart() + pntheader->featureTable.featureTableJSONByteLength;
TSharedPtr<FJsonObject> binaryBodyReference = FeatureTableJSON->GetObjectField("POSITION");
int32 byteOffset = binaryBodyReference->GetIntegerField("byteOffset");
uint8* start = (uint8*)(data.GetData() + pntheader->getFeatureBinaryStart() + byteOffset);
//TODO create wit copy
//UTexture2D* points = UDynamicTextureUtilities::CreateDynamicTextureWithData(instances_length, start);
// creat pooint texture
TArray<FLinearColor> *Points = new TArray<FLinearColor>();
uint8* pos = start;
......@@ -369,10 +365,6 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile)
minx = miny = minz = TNumericLimits< float >::Max();
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)
{
float x = *((float*)pos);
......@@ -389,13 +381,8 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile)
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;
pos = start;
for (size_t i = 0; i < instances_length; i += 1)
{
......@@ -416,30 +403,19 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile)
{
Points->Add(FLinearColor(0.0f, 0.0f, 0.0f, 0.0f));
}
UTexture2D* Texture = UDynamicTextureUtilities::CreateTransientDynamicTexture(TextureSize, TextureSize, PF_A32B32G32R32F);
UTexture2D* PointsTeture = UDynamicTextureUtilities::CreateTransientDynamicTexture(TextureSize, TextureSize, PF_A32B32G32R32F);
UDynamicTextureUtilities::UpdateDynamicVectorTexture(*Points, PointsTeture);
FVector min = FVector(minx, miny, minz);
FVector max = FVector(maxx, maxy, maxz);
FVector size = max - min;
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, 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 Box: Min [%s] Max [%s] Size [%s]"), *min.ToString(), *max.ToString(), *size.ToString());
/* if(tstTexture)
PointCloud->setPoints(tstTexture);
else*/
PointCloud->setPoints(Texture, FVector(minx, miny, minz), FVector((maxx - minx), (maxy - miny), (maxz - minz)));
//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);
}
}
else {
UE_LOG(TILES, Error, TEXT("Pointcloud Quantized not supported Position Required"));
}
UTexture2D* ColorTexture = nullptr;
if (FeatureTableJSON->HasField("RGB")) {
// RGB = uint8[3]
uint32 featureTableBinaryOffset = pntheader->getFeatureStart() + pntheader->featureTable.featureTableJSONByteLength;
......@@ -460,22 +436,31 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile)
{
ColorRGB->Add(FLinearColor(1.0f, 0.0f, 0.0f));
}
UTexture2D* ColorTexture = UDynamicTextureUtilities::CreateTransientDynamicTexture(TextureSize, TextureSize, PF_A32B32G32R32F);
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, byteOffset: %d"), instances_length, TextureSize, fill, byteOffset);
PointCloud->setColors(ColorTexture);
}
//Testing Texture
if (TextureTest) {
UMaterialInstanceDynamic *Material = UMaterialInstanceDynamic::Create(TextureTest->GetStaticMeshComponent()->GetMaterial(0), nullptr);
Material->SetTextureParameterValue(FName("DynamicTexture"), PointsTeture);
TextureTest->GetStaticMeshComponent()->SetMaterial(0,Material);
}
for (size_t i = 0; i < instances_length; i+=quadchainsize)
{
APointCloudActor *PointCloud = World->SpawnActor<APointCloudActor>(APointCloudActor::StaticClass());
PointCloud->setPoints(PointsTeture, min, size, i);
#if WITH_EDITOR
PointCloud->SetFolderPath(FName(*("SpawnedGLTF/" + this->GetName())));
#endif
PointCloud->AttachToActor(this, FAttachmentTransformRules::KeepWorldTransform);
if (ColorTexture)
PointCloud->setColors(ColorTexture);
}
}
UE_LOG(TILES, Log, TEXT("PointCloudHeader: End"));
}
void ATilesetActor::parse3DTile(const TArray<uint8> data, FTile *tile)
......
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