#include "model.h" using namespace Mauri; auto Model::parse(Parser &pr, const std::string &path) -> Model * { Model *model = new Model(); Asset *asset = asset_manager()->get(path); if (asset->type == ASSET_VOID) parse_fail(model); const json &root = json::parse(asset->as_string(), nullptr, false); if (root.is_discarded()) parse_fail(model); pr.map_value(root, "autosize", &model->autosize, false); pr.map_value(root, "fullscreen", &model->fullscreen, false); pr.map_value(root, "passthrough", &model->passthrough, false); pr.map_value(root, "cropoffset", &model->cropoffset, vec2(0.f)); pr.map_value(root, "width", &model->width, 0.f); pr.map_value(root, "height", &model->height, 0.f); if (root.contains("material")) model->material = Material::parse(pr, root["material"]); if (!model->material) parse_fail(model); return model; } auto Model::load(Engine *engine, Object *object) -> void { this->material->load(engine, object, MATERIAL_MODEL, NULL); } Model::~Model() { if (this->material) delete this->material; }