Mesh* json_parse_mesh(const jsonvalue& json) { auto mesh = new Mesh(); if(json.object_contains("json_mesh")) { json_texture_path_push(json.object_element("json_mesh").as_string()); mesh = json_parse_mesh(load_json(json.object_element("json_mesh").as_string())); json_texture_path_pop(); } json_set_optvalue(json, mesh->frame, "frame"); json_set_optvalue(json, mesh->pos, "pos"); json_set_optvalue(json, mesh->norm, "norm"); json_set_optvalue(json, mesh->texcoord, "texcoord"); json_set_optvalue(json, mesh->triangle, "triangle"); json_set_optvalue(json, mesh->quad, "quad"); json_set_optvalue(json, mesh->point, "point"); json_set_optvalue(json, mesh->line, "line"); json_set_optvalue(json, mesh->spline, "spline"); if(json.object_contains("material")) mesh->mat = json_parse_material(json.object_element("material")); json_set_optvalue(json, mesh->subdivision_catmullclark_level, "subdivision_catmullclark_level"); json_set_optvalue(json, mesh->subdivision_catmullclark_smooth, "subdivision_catmullclark_smooth"); json_set_optvalue(json, mesh->subdivision_bezier_level, "subdivision_bezier_level"); json_set_optvalue(json, mesh->subdivision_bezier_uniform, "subdivision_bezier_uniform"); if(json.object_contains("animation")) mesh->animation = json_parse_frame_animation(json.object_element("animation")); if(json.object_contains("skinning")) mesh->skinning = json_parse_mesh_skinning(json.object_element("skinning")); if(json.object_contains("json_skinning")) mesh->skinning = json_parse_mesh_skinning(load_json(json.object_element("json_skinning").as_string())); if(json.object_contains("simulation")) mesh->simulation = json_parse_mesh_simulation(json.object_element("simulation")); if (mesh->skinning) { if (mesh->skinning->vert_rest_pos.empty()) mesh->skinning->vert_rest_pos = mesh->pos; if (mesh->skinning->vert_rest_norm.empty()) mesh->skinning->vert_rest_norm = mesh->norm; if (mesh->pos.empty()) mesh->pos = mesh->skinning->vert_rest_pos; if (mesh->norm.empty()) mesh->norm = mesh->skinning->vert_rest_norm; } return mesh; }
Surface* json_parse_surface(const jsonvalue& json) { auto surface = new Surface(); json_set_optvalue(json, surface->frame, "frame"); json_set_optvalue(json, surface->radius,"radius"); json_set_optvalue(json, surface->isquad,"isquad"); if(json.object_contains("material")) surface->mat = json_parse_material(json.object_element("material")); return surface; }
Surface* json_parse_surface(const jsonvalue& json) { auto surface = new Surface(); json_set_optvalue(json, surface->frame, "frame"); json_set_optvalue(json, surface->radius,"radius"); json_set_optvalue(json, surface->isquad,"isquad"); if(json.object_contains("material")) surface->mat = json_parse_material(json.object_element("material")); json_set_optvalue(json, surface->subdivision_level,"subdivision_level"); json_set_optvalue(json, surface->subdivision_smooth,"subdivision_smooth"); if(json.object_contains("animation")) surface->animation = json_parse_frame_animation(json.object_element("animation")); return surface; }