|
| 1 | +#include "MiniRT.h" |
| 2 | + |
| 3 | +int main(int argc, char **argv) |
| 4 | +{ |
| 5 | + t_world *world; |
| 6 | + t_paint paint; |
| 7 | + t_camera cam; |
| 8 | + mlx_t *mlx; |
| 9 | + mlx_image_t *image; |
| 10 | + |
| 11 | + world = parser(argc, argv); |
| 12 | + |
| 13 | + t_pool_set *set = get_pool(); |
| 14 | + |
| 15 | + // sp1 |
| 16 | + t_obj *sp1= (t_obj *)alloc_pool(sizeof(t_obj), set->the_pool); |
| 17 | + init_shape(SPHERE, &sp1->shape); |
| 18 | + sp1->shape->material.color = create_color(0.3, 0, 1); |
| 19 | + insert_into_obj_list(&world->obj_lst, sp1); |
| 20 | + |
| 21 | + // sp2 |
| 22 | + t_obj *sp2= (t_obj *)alloc_pool(sizeof(t_obj), set->the_pool); |
| 23 | + init_shape(SPHERE, &sp2->shape); |
| 24 | + sp2->shape->material.color = create_color(0.3, 0, 1); |
| 25 | + insert_into_obj_list(&world->obj_lst, sp2); |
| 26 | + |
| 27 | + // sp3 |
| 28 | + t_obj *sp3= (t_obj *)alloc_pool(sizeof(t_obj), set->the_pool); |
| 29 | + init_shape(SPHERE, &sp3->shape); |
| 30 | + sp3->shape->material.color = create_color(0.3, 0, 1); |
| 31 | + sp3->shape->material.pattern = stripe_pattern(create_color(1, 1, 1), create_color(1, 0, 0)); |
| 32 | + set_pattern_transf(&sp3->shape->material.pattern, scale(.1, .1, .1)); |
| 33 | + insert_into_obj_list(&world->obj_lst, sp3); |
| 34 | + |
| 35 | + // pl1 |
| 36 | + t_obj *pl1= (t_obj *)alloc_pool(sizeof(t_obj), set->the_pool); |
| 37 | + init_shape(PLANE, &pl1->shape); |
| 38 | + pl1->shape->material.color = create_color(0.3, 0, 1); |
| 39 | + insert_into_obj_list(&world->obj_lst, pl1); |
| 40 | + |
| 41 | + // pl2 |
| 42 | + t_obj *pl2= (t_obj *)alloc_pool(sizeof(t_obj), set->the_pool); |
| 43 | + init_shape(PLANE, &pl2->shape); |
| 44 | + pl2->shape->material.color = create_color(0.3, 0, 1); |
| 45 | + insert_into_obj_list(&world->obj_lst, pl2); |
| 46 | + |
| 47 | + // pl3 |
| 48 | + t_obj *pl3= (t_obj *)alloc_pool(sizeof(t_obj), set->the_pool); |
| 49 | + init_shape(PLANE, &pl3->shape); |
| 50 | + pl3->shape->material.color = create_color(0.3, 0, 1); |
| 51 | + insert_into_obj_list(&world->obj_lst, pl3); |
| 52 | + |
| 53 | + // pl4 |
| 54 | + t_obj *pl4= (t_obj *)alloc_pool(sizeof(t_obj), set->the_pool); |
| 55 | + init_shape(PLANE, &pl4->shape); |
| 56 | + pl4->shape->material.color = create_color(0.3, 0, 1); |
| 57 | + insert_into_obj_list(&world->obj_lst, pl4); |
| 58 | + |
| 59 | + // LIGHT SRC 1 |
| 60 | + t_pt_light light_1 = pt_light(point(5, -5, -5), create_color(1, 1, 1)); |
| 61 | + insert_into_light_list(&world->lights_lst, light_1); |
| 62 | + |
| 63 | + // LIGHT SRC 2 |
| 64 | + t_pt_light light_2 = pt_light(point(5, -5, -5), create_color(0, 0, 1)); |
| 65 | + insert_into_light_list(&world->lights_lst, light_2); |
| 66 | + |
| 67 | + // LIGHT SRC 3 |
| 68 | + t_pt_light light_3 = pt_light(point(5, -5, -5), create_color(0, 0, 1)); |
| 69 | + insert_into_light_list(&world->lights_lst, light_3); |
| 70 | + |
| 71 | + // CAM CONFIG |
| 72 | + cam = camera(WIDHT, HEIGHT, 3.14159 / 3); |
| 73 | + cam.transform = view_transform(point(0, 1.5, -5), point(0, 1, 0), vector(0, 1, 0)); |
| 74 | + |
| 75 | + // RENDER |
| 76 | + printf("test1\n"); |
| 77 | + paint = render_canva(cam, world); |
| 78 | + printf("test2\n"); |
| 79 | + |
| 80 | + mlx_set_setting(MLX_STRETCH_IMAGE, true); |
| 81 | + mlx = mlx_init(cam.hsize, cam.vsize, "PT8", true); |
| 82 | + image = canva2image(paint, mlx); |
| 83 | + printf("test3\n"); |
| 84 | + |
| 85 | + mlx_image_to_window(mlx, image, 0, 0); |
| 86 | + |
| 87 | + mlx_loop(mlx); |
| 88 | + mlx_terminate(mlx); |
| 89 | + quit(0); |
| 90 | +} |
| 91 | + |
| 92 | +// int main(int argc, char **argv) |
| 93 | +// { |
| 94 | +// t_world *world; |
| 95 | +// t_paint paint; |
| 96 | +// mlx_t *mlx; |
| 97 | +// mlx_image_t *image; |
| 98 | + |
| 99 | +// world = parser(argc, argv); |
| 100 | + |
| 101 | +// // printf("sphere pos X[%f]Y[%f]Z[%f], colors R[%f]G[%f]B[%f], radius[%f]\n", ((t_sp *)(world->obj_lst->shape->obj))->src[X], \ |
| 102 | +// // ((t_sp *)(world->obj_lst->shape->obj))->src[Y], \ |
| 103 | +// // ((t_sp *)(world->obj_lst->shape->obj))->src[Z], \ |
| 104 | +// // world->obj_lst->shape->material.color.red, \ |
| 105 | +// // world->obj_lst->shape->material.color.green, \ |
| 106 | +// // world->obj_lst->shape->material.color.blue, \ |
| 107 | +// // ((t_sp *)(world->obj_lst->shape->obj))->radius); |
| 108 | + |
| 109 | +// // printf("light pos X[%f]Y[%f]Z[%f], colors R[%f]G[%f]B[%f]\n", world->lights_lst->light_src.pos[X], \ |
| 110 | +// // world->lights_lst->light_src.pos[Y], \ |
| 111 | +// // world->lights_lst->light_src.pos[Z], \ |
| 112 | +// // world->lights_lst->light_src.intens.red, \ |
| 113 | +// // world->lights_lst->light_src.intens.green, \ |
| 114 | +// // world->lights_lst->light_src.intens.blue); |
| 115 | + |
| 116 | +// printf("cam [%f], [%f]", world->camera.hsize, world->camera.vsize); |
| 117 | + |
| 118 | +// // RENDER |
| 119 | +// printf("test1\n"); |
| 120 | +// paint = render_canva(world->camera, world); |
| 121 | +// printf("test2\n"); |
| 122 | + |
| 123 | +// mlx_set_setting(MLX_STRETCH_IMAGE, true); |
| 124 | +// mlx = mlx_init(world->camera.hsize, world->camera.vsize, "teste", true); |
| 125 | +// image = canva2image(paint, mlx); |
| 126 | +// printf("test3\n"); |
| 127 | + |
| 128 | +// mlx_image_to_window(mlx, image, 0, 0); |
| 129 | + |
| 130 | +// mlx_loop(mlx); |
| 131 | +// mlx_terminate(mlx); |
| 132 | +// quit(0); |
| 133 | +// } |
0 commit comments