Commit bd810866 by Kai Westerkamp

recursiv struct workaround

parent 448885aa
{
"FileVersion": 3,
"EngineAssociation": "4.14",
"EngineAssociation": "4.15",
"Category": "",
"Description": "",
"Modules": [
......@@ -12,11 +12,5 @@
"Engine"
]
}
],
"Plugins": [
{
"Name": "GLTFLoader",
"Enabled": true
}
]
}
\ No newline at end of file
Subproject commit 110727d81d3f44dc58f8b2c09c8c27e4c1b6a3dd
......@@ -9,7 +9,8 @@
void AMasterTestProjectGameModeBase::InitGame(const FString & MapName, const FString & Options, FString & 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 = "";
FFileHelper::LoadFileToString(JsonRaw, *file);
......@@ -17,19 +18,43 @@ void AMasterTestProjectGameModeBase::InitGame(const FString & MapName, const FSt
UE_LOG(TILES, Log, TEXT("Loading file %s"), *file);
//UE_LOG(GLTF, Warning, TEXT("LangFile: \n %s"), *JsonRaw);
//TSharedPtr<FJsonObject> JsonParsed;
//TSharedRef<TJsonReader<TCHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(JsonRaw);
//if (FJsonSerializer::Deserialize(JsonReader, JsonParsed))
//{
// FString ExampleString = JsonParsed->GetStringField("geometricError");
// UE_LOG(TILES, Warning, TEXT("Example: \n %s"), *ExampleString);
//}
TSharedPtr<FJsonObject> JsonParsed;
TSharedRef<TJsonReader<TCHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(JsonRaw);
if (FJsonSerializer::Deserialize(JsonReader, JsonParsed))
{
FString ExampleString = JsonParsed->GetStringField("geometricError");
UE_LOG(TILES, Warning, TEXT("Example: \n %s"), *ExampleString);
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);
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
UPROPERTY()
FTileContent content;
UPROPERTY()
TArray<FTile> children;
//UPROPERTY()
//struct FTile children;
TArray<struct FTile> children;
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 };
......@@ -157,6 +158,8 @@ class MASTERTESTPROJECT_API AMasterTestProjectGameModeBase : public AGameModeBas
public:
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) {
UE_LOG(GLTF, Error, TEXT("Extension list: %s"), *FString(extensions.c_str()));
wchar_t buffer[260];
GetModuleFileName(NULL, buffer, MAX_PATH);
// GetModuleFileName(NULL, buffer, 260);
UE_LOG(GLTF, Error, TEXT("Curretn Path: %s"), *FString(buffer));
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