#include #include "rapidjson/document.h" #include "rapidjson/writer.h" #include "rapidjson/stringbuffer.h" #include "aixlog.hpp" #include "entity.h" #include "mesh.h" #include "util.h" #include "scene_loader.h" bool slLoadFile(const char* file_name, Entity* entity_array, uint& entity_count, uint max_entities) { if (entity_array == nullptr) { LOG(ERROR) << "entity array not initialized\n"; return false; } rapidjson::Document doc; char* contents = utilDumpTextFile(file_name); if (contents == nullptr) { LOG(ERROR) << "Error reading file: " << file_name << "\n"; return false; } if (doc.Parse(contents).HasParseError() || !doc.IsObject()) { LOG(ERROR) << "Error parrsing scene file: " << file_name << "\n"; return false; } // entities if (doc.HasMember("entities")) { const rapidjson::Value& e = doc["entities"]; assert (e.IsArray()); for (uint i = 0; i < e.Size(); i++) { assert(e[i].HasMember("name")); assert(e[i]["name"].IsString()); assert(i < max_entities); std::string s = e[i]["name"].GetString(); LOG(INFO) << "e[" << i << "][\"name\"]: " << s << "\n"; } } return true; }