void init_scene(t_scene **scene) { t_coord coord; t_vec3 v; init_coord(&coord, 0, 0, -50); init_vec3(&v, 0, 0, 1); //init_plane(scene, coord, v, 0x0000FF); init_coord(&coord, 0, -3, 0); init_vec3(&v, 0, 1, 0); init_plane(scene, coord, v, 0x00FF66); init_coord(&coord, -5, 4, -21); init_circle(scene, coord, 0xFFFFFF, 4); init_coord(&coord, 0, 4, -21); init_circle(scene, coord, 0xFF0000, 2); init_coord(&coord, 5, 2, -25); init_vec3(&v, 0, 0, 1); init_cylinder(scene, coord, v, 2, 0x0000FF); init_coord(&coord, -10, -2, -25); init_vec3(&v, 0, 0, 1); init_cone(scene, coord, v, 0x00FFFF); }
int parse_cylinder(t_env *env, char **line) { int i[2]; t_tobj tobj; t_cylinder *obj; t_list *lst; if (env->scene == NULL) return (return_print("Error, a scene must be declared first", 0)); if ((obj = (t_cylinder *)ft_memalloc(sizeof(t_obj))) == NULL || (lst = ft_lstnewfrom(obj, sizeof(*obj))) == NULL) return (return_print("malloc error", 0)); init_cylinder(env, &tobj, obj); i[0] = 0; i[1] = 0; while (line[++i[0]]) if (parse_cyl_2(line, i, set_objenv(env, (t_obj *)obj, &tobj)) == 0) return (0); transform_object((t_obj *)obj, &tobj); obj->inter = cylinder_inter; obj->normal = cylinder_normal; if (env->scene->objects == NULL) env->scene->objects = lst; else ft_lstadd(&(env->scene->objects), lst); return (i[1] == 1 ? 1 : return_print("error cylinder imcomplete", 0)); }
void setup_scene_2() { theCamera = init_camera(vector_init(2, 1, 3), vector_init(0, 0.3, 0), vector_init(0, 1, 0), 60, (float) WIDTH / (float) HEIGHT); lights[0].position = vector_init(-2, 1.7, 3); lights[0].col = vector_init(1, 1, 1); lights[1].position = vector_init(3, 2, 3); lights[1].col = vector_init(0.4, 0.4, 0.4); lights[2].position = vector_init(4, 3, -10); lights[2].col = vector_init(0.5, 0.5, 0.5); num_lights = 3; object_count = 0; material mat; mat.shininess = 20; mat.kd = vector_init(1, 1, 1); mat.ks = vector_init(.5, .5, .5); mat.reflect_coef = 0.8; scene[object_count++] = init_sphere(0, 0, 0, .3, mat); mat.reflect_coef = 0.5; mat.shininess = 20; mat.kd = vector_init(0, 0, 1); scene[object_count++] = init_sphere(0, -.05, 1, .20, mat); mat.reflect_coef = 0.04; mat.ks = vector_init(.1, .1, .1); mat.kd = vector_init(0, 1, 0); scene[object_count++] = init_sphere(0, 1, 0, .15, mat); mat.kd = vector_init(1, 0, 0); mat.shininess = 500; scene[object_count++] = init_sphere(1, -.05, 0, .15, mat); mat.kd = vector_init(.5, 1, .7); scene[object_count++] = init_plane(0, 1, 0, 0.2, mat); mat.reflect_coef = 0.0; mat.ks = vector_init(.1, .1, .1); mat.kd = vector_init(1, 1, 0); scene[object_count++] = init_cylinder(vector_init(.0, .0, .0), vector_init(1, 0, 0), 1, .05, mat); scene[object_count++] = init_cylinder(vector_init(.0, .0, .0), vector_init(0, 1, 0), 1, .05, mat); scene[object_count++] = init_cylinder(vector_init(.0, .0, .0), vector_init(0, 0, 1), 1, .05, mat); }