Commit a4e16831 by wester

a

parent af788340
......@@ -9,12 +9,16 @@ void UHttpDownloader::DownloadFile(const FString &URL)
TSharedRef< IHttpRequest > HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetVerb("GET");
HttpRequest->SetURL(URL);
//HttpRequest->SetURL(TEXT("http://localhost/tileset.json"));
HttpRequest->OnProcessRequestComplete().BindUObject(this, &UHttpDownloader::OnResponseReceived);
// Execute the request
//UE_LOG(TILES, Log, TEXT("Downlaoding: %s "), *HttpRequest->GetURL());
HttpRequest->ProcessRequest();
bool sucess = HttpRequest->ProcessRequest();
UE_LOG(TILES, Log, TEXT("Downlaoding : %s successfull Start %d "), *HttpRequest->GetURL(), (int)sucess);
}
......
......@@ -17,16 +17,19 @@ void UTileDownloader::GetTileContent(ATilesetActor *Actor, FTileContent *Content
void UTileDownloader::OnResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
{
UE_LOG(TILES, Log, TEXT("Tiledownloader Response: %s Success: %s"), *Request->GetURL());
//FIXME download with error in http
if (Response.IsValid()) {
if (Request->GetURL().EndsWith(TEXT(".json"))) {
UE_LOG(TILES, Log, TEXT("Downloded Tilset: %s Scucess: %s"), *Request->GetURL(), bWasSuccessful ? TEXT("True") : TEXT("False"));
parent->tileset = actor->parseTileset(Response->GetContentAsString(), Request->GetURL());
if(parent->tileset)
parent->tileset->parent = parentTile;
}
else {
FString url = Request->GetURL();
UE_LOG(TILES, Log, TEXT("Downloded Tile: %s Scucess: %s "), *Request->GetURL(), bWasSuccessful ? TEXT("True") : TEXT("False"));
UE_LOG(TILES, Warning, TEXT("Downloded Tile: %s Scucess: %s "), *Request->GetURL(), bWasSuccessful ? TEXT("True") : TEXT("False"));
actor->parse3DTile(Response->GetContent(), parentTile);
}
}
......
......@@ -28,7 +28,7 @@ void ATilesetActor::BeginPlay()
//rootTileset = new FTileContent();
rootTileset.url = relativeURL;
UE_LOG(TILES, Error, TEXT("Tileset load %s: %s %s"), GetWorld()->IsServer() ? TEXT("Server") : TEXT("Client") , *relativeURL, *host);
UE_LOG(TILES, Error, TEXT("Tileset load %s: \"%s\" \"%s\""), GetWorld()->IsServer() ? TEXT("Server") : TEXT("Client") , *host, *relativeURL);
//UE_LOG(TILES, Error, TEXT("Tileset load : %s %s"), *relativeURL, *host);
UTileDownloader *downloader = NewObject<UTileDownloader>(UTileDownloader::StaticClass());
downloader->GetTileContent(this, &rootTileset, host);
......@@ -117,7 +117,7 @@ void FTile::setVisible(bool visible)
UTileDownloader *downloader = NewObject<UTileDownloader>(UTileDownloader::StaticClass());
downloader->GetTileContent(parentTilset->parentActor, &content, parentTilset->absoluteURL, this);
content.loadingStarted = true;
UE_LOG(TILES, Log, TEXT("Set Tile visible %s %s:"), parentTilset->parentActor->GetWorld()->IsServer() ? TEXT("Server") : TEXT("Client") , *content.url);
UE_LOG(TILES, Warning, TEXT("Set Tile visible %s %s:"), parentTilset->parentActor->GetWorld()->IsServer() ? TEXT("Server") : TEXT("Client") , *content.url);
}
else {
......@@ -184,6 +184,8 @@ void ATilesetActor::updateScreenSpaceError(FTile* current, double currentSSE, do
FTileset* ATilesetActor::parseTileset(FString JsonString, FString BaseURL)
{
//UE_LOG(TILES, Log, TEXT("JSON: %s"), *JsonString);
//TODO error Handling
TSharedPtr<FJsonObject> JsonParsed;
TSharedRef<TJsonReader<TCHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(JsonString);
......@@ -325,7 +327,7 @@ void ATilesetActor::parseInstanced3DTile(const TArray<uint8> data, FTile * tile)
tile->content.absoluteTileTranforms.Add(trans.ToMatrixWithScale());
gltf->SetActorTransform(trans);
outputString += "]";
UE_LOG(TILES, Warning, TEXT("InStanced 3D Model Positions %s"), *outputString);
UE_LOG(TILES, Log, TEXT("InStanced 3D Model Positions %s"), *outputString);
}
else {
UE_LOG(TILES, Warning, TEXT("INStanced 3D Model Position Quantized not Supported in %s"), *tile->content.url);
......@@ -342,7 +344,7 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile)
{
PointCloudHeader *pntheader = (PointCloudHeader*)data.GetData();
FString featureJSONString = pntheader->getpartAsString(pntheader->getFeatureStart(), pntheader->featureTable.featureTableJSONByteLength);
UE_LOG(TILES, Warning, TEXT("PointCloudHeader: FeatureTable JSON: %s"), *featureJSONString);
UE_LOG(TILES, Log, TEXT("PointCloudHeader: FeatureTable JSON: %s"), *featureJSONString);
TSharedPtr<FJsonObject> FeatureTableJSON;
TSharedRef<TJsonReader<TCHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(featureJSONString);
UWorld* const World = GetWorld();
......@@ -415,8 +417,8 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile)
FVector max = FVector(maxx, maxy, maxz);
FVector size = max - min;
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 Box: Min [%s] Max [%s] Size [%s]"), *min.ToString(), *max.ToString(), *size.ToString());
UE_LOG(TILES, Log, TEXT("Created Position Texture Number Points %d, TextureSize: %d, Fill: %d"), instances_length, TextureSize, fill);
UE_LOG(TILES, Log, TEXT("Pointcloud Boundig Box: Min [%s] Max [%s] Size [%s]"), *min.ToString(), *max.ToString(), *size.ToString());
......@@ -444,7 +446,7 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile)
}
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);
UE_LOG(TILES, Log, TEXT("Created Color Texture Number Points %d, TextureSize: %d, Fill: %d, byteOffset: %d"), instances_length, TextureSize, fill, byteOffset);
}
......@@ -471,6 +473,17 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile)
void ATilesetActor::parse3DTile(const TArray<uint8> data, FTile *tile)
{
if (!tile) {
char *ansiiData = new char[data.Num() + 2];
memcpy(ansiiData, (void*)(data.GetData()), data.Num()); //Assumes bytesRead is always smaller than 1024 bytes
ansiiData[data.Num()] = 0; //Add null terminator
FString temp = ANSI_TO_TCHAR(ansiiData); //Convert to FString
delete ansiiData;
UE_LOG(TILES, Error, TEXT("Something went horribly wrong in processing a Tile: %s"), *temp);
return;
}
TileHeader *header = (TileHeader*) data.GetData();
tile->content.content = data;
......
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