int main(int argc, const char** argv) { // command line yc_parser* parser = yc_init_parser(argc, argv, "test obj"); const char* filename = yc_parse_args(parser, "scene", "scene filename", 0, true); yc_done_parser(parser); // load scene ym_timer yocto_timer = ym_timer(); yo_scene* scene = yo_load_obj(filename, true, true); double yocto_elapsed = yocto_timer.elapsed(); printf("yocto obj: %d shapes in %lg ms\n", (int)scene->shapes.size(), yocto_elapsed); yo_free_scene(scene); // tinyobj load scene ym_timer tiny_timer = ym_timer(); std::vector<tinyobj::shape_t> shapes; std::vector<tinyobj::material_t> materials; std::string err; tinyobj::LoadObj(shapes, materials, err, filename); double tiny_elapsed = tiny_timer.elapsed(); printf("tiny obj: %d shapes in %lg ms\n", (int)shapes.size(), tiny_elapsed); // done return EXIT_SUCCESS; }
int main(int argc, const char** argv) { // command line params yc_parser* parser = yc_init_parser(argc, argv, "make tests"); const char* filename_in = yc_parse_args(parser, "filename_in", "input filename", 0, true); const char* filename_out = yc_parse_args(parser, "filename_out", "output filename", 0, true); yc_done_parser(parser); yo_scene* scene = load(filename_in); save(filename_out, scene); }
int main(int argc, const char** argv) { const char* filenames[4096]; // command line params yc_parser* parser = yc_init_parser(argc, argv, "view images"); yc_parse_argsa(parser, "image", "image filename", 0, true, filenames, 4096); yc_done_parser(parser); // loading images view_img* imgs; int nimgs = load_images(filenames, &imgs); // start ui loop ui_loop(nimgs, imgs); // done return EXIT_SUCCESS; }
int main(int argc, const char** argv) { // command line yc_parser* parser = yc_init_parser(argc, argv, "view meshes"); float amb = yc_parse_optf(parser, "--ambient", 0, "ambient factor", 0); bool camera_lights = yc_parse_optb(parser, "--camera_lights", "-c", "enable camera lights", false); int camera = yc_parse_opti(parser, "--camera", "-C", "camera", 0); bool no_ui = yc_parse_optb(parser, "--no-ui", 0, "runs offline", false); float aspect = yc_parse_optf(parser, "--aspect", "-a", "image aspect", 16.0f / 9.0f); float dt = yc_parse_optf(parser, "--delta_time", "-dt", "delta time", 1 / 60.0f); int res = yc_parse_opti(parser, "--resolution", "-r", "image resolution", 720); const char* imfilename = yc_parse_opts(parser, "--output", "-o", "image filename", "out.png"); const char* filename = yc_parse_args(parser, "scene", "scene filename", 0, true); yc_done_parser(parser); // load scene yo_scene* scene = load_scene(filename); scene->cameras[camera].width = aspect * scene->cameras[camera].height; // init rigid simulation yb_scene* scene_bvh; ysr_scene* rigid_scene = make_rigid_scene(scene, &scene_bvh); // start ui_loop(filename, imfilename, scene, rigid_scene, dt, (int)round(res * aspect), res, camera_lights, amb, no_ui); // done // TODO: clean bvh ysr_free_scene(rigid_scene); yo_free_scene(scene); return EXIT_SUCCESS; }