Esempio n. 1
0
Material* json_parse_material(const jsonvalue& json) {
    auto material = new Material();
    json_set_optvalue(json, material->kd, "kd");
    json_set_optvalue(json, material->ks, "ks");
    json_set_optvalue(json, material->kr, "kr");
    json_set_optvalue(json, material->ke, "ke");
    json_set_optvalue(json, material->n, "n");
    json_set_optvalue(json, material->microfacet, "microfacet");
    json_parse_opttexture(json, material->ke_txt, "ke_txt");
    json_parse_opttexture(json, material->kd_txt, "kd_txt");
    json_parse_opttexture(json, material->ks_txt, "ks_txt");
    json_parse_opttexture(json, material->norm_txt, "norm_txt");
    return material;
}
Esempio n. 2
0
Scene* json_parse_scene(const jsonvalue& json) {
    // prepare scene
    auto scene = new Scene();
    // camera
    if (json.object_contains("camera")) scene->camera = json_parse_camera(json.object_element("camera"));
    if (json.object_contains("lookat_camera")) scene->camera = json_parse_lookatcamera(json.object_element("lookat_camera"));
    // surfaces
    if(json.object_contains("surfaces")) scene->surfaces = json_parse_surfaces(json.object_element("surfaces"));
    // meshes
    if(json.object_contains("json_meshes")) {
        json_texture_path_push(json.object_element("json_meshes").as_string());
        scene->meshes = json_parse_meshes(load_json(json.object_element("json_meshes").as_string()));
        json_texture_path_pop();
    }
    if(json.object_contains("meshes")) {
        scene->meshes = json_parse_meshes(json.object_element("meshes"));
    }
    // lights
    if(json.object_contains("lights")) scene->lights = json_parse_lights(json.object_element("lights"));
    // animation
    if(json.object_contains("animation")) scene->animation = json_parse_scene_animation(json.object_element("animation"));
    // rendering parameters
    json_set_optvalue(json, scene->image_width, "image_width");
    json_set_optvalue(json, scene->image_height, "image_height");
    json_set_optvalue(json, scene->image_samples, "image_samples");
    json_set_optvalue(json, scene->background, "background");
    json_parse_opttexture(json, scene->background_txt, "background_txt");
    json_set_optvalue(json, scene->ambient, "ambient");
    json_set_optvalue(json, scene->path_max_depth, "path_max_depth");
    json_set_optvalue(json, scene->path_sample_brdf, "path_sample_brdf");
    json_set_optvalue(json, scene->path_shadows, "path_shadows");
    // done
    return scene;
}
Scene* json_parse_scene(const jsonvalue& json) {
    // prepare scene
    auto scene = new Scene();
    // camera
    if (json.object_contains("camera")) scene->camera = json_parse_camera(json.object_element("camera"));
    if (json.object_contains("lookat_camera")) scene->camera = json_parse_lookatcamera(json.object_element("lookat_camera"));
    // surfaces
    if(json.object_contains("surfaces")) scene->surfaces = json_parse_surfaces(json.object_element("surfaces"));
    if(json.object_contains("lights")) scene->lights = json_parse_lights(json.object_element("lights"));
    // rendering parameters
    json_set_optvalue(json, scene->image_width, "image_width");
    json_set_optvalue(json, scene->image_height, "image_height");
    json_set_optvalue(json, scene->image_samples, "image_samples");
    json_set_optvalue(json, scene->background, "background");
    json_parse_opttexture(json, scene->background_txt, "background_txt");
    json_set_optvalue(json, scene->ambient, "ambient");
    // done
    return scene;
}
Esempio n. 4
0
Material* json_parse_material(const jsonvalue& json) {
    auto material = new Material();
    json_set_optvalue(json, material->kd, "kd");
    json_set_optvalue(json, material->ks, "ks");
    json_set_optvalue(json, material->kr, "kr");
    json_set_optvalue(json, material->ke, "ke");
    json_set_optvalue(json, material->n, "n");

    json_set_optvalue(json, material->num_blurred_samples, "num_blurred_samples");
    json_set_optvalue(json, material->blurred_reflection_size, "blurred_reflection_size");

    // JSON options for custom texturing
    json_set_optvalue(json, material->tiling, "tiling");
    json_set_optvalue(json, material->bilinear_filter, "bilinear_filter");
    json_set_optvalue(json, material->mipmap_filter, "mipmap_filter");

    // Hook up the textures of varying resolutions for mipmapping
    json_parse_opttexture(json, material->mipmap_texture_1, "mipmap_texture_1");
    json_parse_opttexture(json, material->mipmap_texture_2, "mipmap_texture_2");
    json_parse_opttexture(json, material->mipmap_texture_3, "mipmap_texture_3");
    json_parse_opttexture(json, material->mipmap_texture_4, "mipmap_texture_4");
    json_parse_opttexture(json, material->mipmap_texture_5, "mipmap_texture_5");
    json_parse_opttexture(json, material->mipmap_texture_6, "mipmap_texture_6");
    json_parse_opttexture(json, material->mipmap_texture_7, "mipmap_texture_7");
    json_parse_opttexture(json, material->mipmap_texture_8, "mipmap_texture_8");
    json_parse_opttexture(json, material->mipmap_texture_9, "mipmap_texture_9");
    json_parse_opttexture(json, material->mipmap_texture_10, "mipmap_texture_10");

    json_set_optvalue(json, material->microfacet, "microfacet");
    json_parse_opttexture(json, material->ke_txt, "ke_txt");
    json_parse_opttexture(json, material->kd_txt, "kd_txt");
    json_parse_opttexture(json, material->ks_txt, "ks_txt");
    json_parse_opttexture(json, material->norm_txt, "norm_txt");
    return material;
}