// main function int main(int argc, char** argv) { auto args = parse_cmdline(argc, argv, { "03_animate", "view scene", { {"resolution", "r", "image resolution", typeid(int), true, jsonvalue() } }, { {"scene_filename", "", "scene filename", typeid(string), false, jsonvalue("scene.json")}, {"image_filename", "", "image filename", typeid(string), true, jsonvalue("")} } }); // generate/load scene either by creating a test scene or loading from json file scene_filename = args.object_element("scene_filename").as_string(); scene = nullptr; if(scene_filename.length() > 9 and scene_filename.substr(0,9) == "testscene") { int scene_type = atoi(scene_filename.substr(9).c_str()); scene = create_test_scene(scene_type); scene_filename = scene_filename + ".json"; } else { scene = load_json_scene(scene_filename); } error_if_not(scene, "scene is nullptr"); image_filename = (args.object_element("image_filename").as_string() != "") ? args.object_element("image_filename").as_string() : scene_filename.substr(0,scene_filename.size()-5)+".png"; if(not args.object_element("resolution").is_null()) { scene->image_height = args.object_element("resolution").as_int(); scene->image_width = scene->camera->width * scene->image_height / scene->camera->height; } animate_reset(scene); subdivide(scene); uiloop(); }
// main function int main(int argc, char** argv) { auto args = parse_cmdline(argc, argv, { "03_model", "raytrace a scene", { {"resolution", "r", "image resolution", "int", true, jsonvalue() } }, { {"scene_filename", "", "scene filename", "string", false, jsonvalue("scene.json")}, {"image_filename", "", "image filename", "string", true, jsonvalue("")} } }); scene_filename = args.object_element("scene_filename").as_string(); image_filename = (args.object_element("image_filename").as_string() != "") ? args.object_element("image_filename").as_string() : scene_filename.substr(0,scene_filename.size()-5)+".png"; scene = load_json_scene(scene_filename); if(! args.object_element("resolution").is_null()) { scene->image_height = args.object_element("resolution").as_int(); scene->image_width = scene->camera->width * scene->image_height / scene->camera->height; } subdivide(scene); uiloop(); }