1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#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<bool>(root, "autosize", &model->autosize, false);
pr.map_value<bool>(root, "fullscreen", &model->fullscreen, false);
pr.map_value<bool>(root, "passthrough", &model->passthrough, false);
pr.map_value<vec2>(root, "cropoffset", &model->cropoffset, vec2(0.f));
pr.map_value<f32>(root, "width", &model->width, 0.f);
pr.map_value<f32>(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;
}
|