Commit bd810866 by Kai Westerkamp

recursiv struct workaround

parent 448885aa
{ {
"FileVersion": 3, "FileVersion": 3,
"EngineAssociation": "4.14", "EngineAssociation": "4.15",
"Category": "", "Category": "",
"Description": "", "Description": "",
"Modules": [ "Modules": [
...@@ -12,11 +12,5 @@ ...@@ -12,11 +12,5 @@
"Engine" "Engine"
] ]
} }
],
"Plugins": [
{
"Name": "GLTFLoader",
"Enabled": true
}
] ]
} }
\ No newline at end of file
Subproject commit 110727d81d3f44dc58f8b2c09c8c27e4c1b6a3dd
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
void AMasterTestProjectGameModeBase::InitGame(const FString & MapName, const FString & Options, FString & ErrorMessage) { void AMasterTestProjectGameModeBase::InitGame(const FString & MapName, const FString & Options, FString & ErrorMessage) {
Super::InitGame(MapName, Options, ErrorMessage); Super::InitGame(MapName, Options, ErrorMessage);
FString file = "D:\\Dropbox\\Studium\\MasterArbeit\\3d-tiles\\examples\\tileset.json"; //FString file = "D:\\Dropbox\\Studium\\MasterArbeit\\3d-tiles\\examples\\tileset.json";
FString file = "D:\\Dropbox\\Studium\\MasterArbeit\\3d-tiles-samples\\tilesets\\TilesetWithDiscreteLOD\\tileset.json";
FString JsonRaw = ""; FString JsonRaw = "";
FFileHelper::LoadFileToString(JsonRaw, *file); FFileHelper::LoadFileToString(JsonRaw, *file);
...@@ -17,19 +18,43 @@ void AMasterTestProjectGameModeBase::InitGame(const FString & MapName, const FSt ...@@ -17,19 +18,43 @@ void AMasterTestProjectGameModeBase::InitGame(const FString & MapName, const FSt
UE_LOG(TILES, Log, TEXT("Loading file %s"), *file); UE_LOG(TILES, Log, TEXT("Loading file %s"), *file);
//UE_LOG(GLTF, Warning, TEXT("LangFile: \n %s"), *JsonRaw); //UE_LOG(GLTF, Warning, TEXT("LangFile: \n %s"), *JsonRaw);
//TSharedPtr<FJsonObject> JsonParsed; TSharedPtr<FJsonObject> JsonParsed;
//TSharedRef<TJsonReader<TCHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(JsonRaw); TSharedRef<TJsonReader<TCHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(JsonRaw);
//if (FJsonSerializer::Deserialize(JsonReader, JsonParsed)) if (FJsonSerializer::Deserialize(JsonReader, JsonParsed))
//{ {
// FString ExampleString = JsonParsed->GetStringField("geometricError"); FString ExampleString = JsonParsed->GetStringField("geometricError");
// UE_LOG(TILES, Warning, TEXT("Example: \n %s"), *ExampleString); UE_LOG(TILES, Warning, TEXT("Example: \n %s"), *ExampleString);
//}
FTileset tileset; FTileset tileset;
bool success = FJsonObjectConverter::JsonObjectStringToUStruct<FTileset>(JsonRaw, &tileset, 0, 0); bool success = FJsonObjectConverter::JsonObjectToUStruct<FTileset>(JsonParsed.ToSharedRef() , &tileset, 0, 0);
//bool success = FJsonObjectConverter::JsonObjectStringToUStruct<FTileset>(JsonRaw, &tileset, 0, 0);
UE_LOG(TILES, Warning, TEXT("Parsed: Success:%s Version:\"%s\" geometricError:%f"), success ? TEXT("True") : TEXT("False"), *tileset.asset.version, tileset.geometricError); TSharedPtr<FJsonObject> root = JsonParsed->GetObjectField("root");
parseTile(root, &tileset.root);
UE_LOG(TILES, Warning, TEXT("Parsed: Success:%s Version:\"%s\" geometricError:%f"), success ? TEXT("True") : TEXT("False"), *tileset.asset.version, tileset.geometricError);
}
}
void AMasterTestProjectGameModeBase::parseTile(TSharedPtr<FJsonObject> json, FTile *targetTile) {
bool success = FJsonObjectConverter::JsonObjectToUStruct<FTile>(json.ToSharedRef(), targetTile, 0, 0);
if (json->HasField("children")) {
const TArray<TSharedPtr<FJsonValue>> children = json->GetArrayField("children");
UE_LOG(TILES, Warning, TEXT("\nTile: Success:%s Version:\"%s\" Children: "), success ? TEXT("True") : TEXT("False"), *targetTile->content.url);
for (TSharedPtr<FJsonValue> child : children)
{
FTile newTile;
parseTile(child->AsObject(), &newTile);
targetTile->children.Add(newTile);
}
}
else {
UE_LOG(TILES, Warning, TEXT("Tile: Success:%s Version:\"%s\" no Childs "), success ? TEXT("True") : TEXT("False"), *targetTile->content.url);
}
} }
...@@ -114,8 +114,9 @@ struct FTile ...@@ -114,8 +114,9 @@ struct FTile
UPROPERTY() UPROPERTY()
FTileContent content; FTileContent content;
UPROPERTY() //UPROPERTY()
TArray<FTile> children; //struct FTile children;
TArray<struct FTile> children;
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 };
...@@ -157,6 +158,8 @@ class MASTERTESTPROJECT_API AMasterTestProjectGameModeBase : public AGameModeBas ...@@ -157,6 +158,8 @@ class MASTERTESTPROJECT_API AMasterTestProjectGameModeBase : public AGameModeBas
public: public:
virtual void InitGame(const FString & MapName, const FString & Options, FString & ErrorMessage); virtual void InitGame(const FString & MapName, const FString & Options, FString & ErrorMessage);
void parseTile(TSharedPtr<FJsonObject> json, FTile *targetTile);
}; };
...@@ -252,7 +252,7 @@ void AProceduralEntity::loadModel(std::string path) { ...@@ -252,7 +252,7 @@ void AProceduralEntity::loadModel(std::string path) {
UE_LOG(GLTF, Error, TEXT("Extension list: %s"), *FString(extensions.c_str())); UE_LOG(GLTF, Error, TEXT("Extension list: %s"), *FString(extensions.c_str()));
wchar_t buffer[260]; wchar_t buffer[260];
GetModuleFileName(NULL, buffer, MAX_PATH); // GetModuleFileName(NULL, buffer, 260);
UE_LOG(GLTF, Error, TEXT("Curretn Path: %s"), *FString(buffer)); UE_LOG(GLTF, Error, TEXT("Curretn Path: %s"), *FString(buffer));
return; return;
......
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