t_cylinder *get_cylinder(int fd) { int r; char *line; t_cylinder *c; c = new_cylinder(NULL, 0, NULL, NULL); while ((r = get_next_line(fd, &line)) > 0 && ft_strcmp(line, "----------")) { if (!ft_strcmp("p1:", line)) c->center = get_vector(fd); if (!ft_strcmp("p2:", line)) c->upper = get_vector(fd); if (!ft_strcmp("radius:", line)) { r = get_next_line(fd, &line); c->radius = ft_atodouble(&line); } if (!ft_strcmp("color:", line)) c->color = get_color(fd); if (!ft_strcmp("axis:", line)) c->axis = normalize(get_vector(fd)); } if (r == -1) exit(-1); return (c); }
void load_scene5_objects(t_scene *scene) { add_object(scene, new_object(CONE, new_cone(new_vector(0, 1, -0.5), new_vector(8, 4, -5), 30), new_color(LIGHT_BLUE), 100)); add_object(scene, new_object(CYLINDER, new_cylinder(new_vector(0, 1, -0.3), new_vector(-10, 0, -5), 2), new_color(PASTEL_BLUE), 100)); add_object(scene, new_object(SPHERE, new_sphere(-1, 3, 2, 2), new_color(BLUE), 100)); add_object(scene, new_object(PLANE, new_plane(0, -1, 0, 0), new_color(DARK_GREY), 100)); }
int handle_input(t_env* env, char* line) { char** input; int nb_args; input = id_strwordtab(line, " \t", &nb_args); if (input == NULL) return (-1); if (id_strcmp(input[0], "c") == 0) return (fill_camera(env, input, nb_args)); else if (id_strcmp(input[0], "S") == 0) return (new_sphere(env, input, nb_args)); else if (id_strcmp(input[0], "P") == 0) return (new_plane(env, input, nb_args)); else if (id_strcmp(input[0], "C") == 0) return (new_cylinder(env, input, nb_args)); else if (id_strcmp(input[0], "Li") == 0) return (new_light(env, input, nb_args)); id_wordtabfree(input); return (0); }
t_cylinder *get_cylinder(int fd) { int r; char *line; t_vect *center; double radius; t_color *color; while ((r = get_next_line(fd, &line)) > 0 && ft_strcmp(line, "----------")) { if (!ft_strcmp("pos:", line)) center = get_vector(fd); if (!ft_strcmp("radius:", line)) { r = get_next_line(fd, &line); radius = ft_atodouble(&line); } if (!ft_strcmp("color:", line)) color = get_color(fd); } if (r == -1) exit(-1); return (new_cylinder(center, radius, color)); }