├── bmp ├── test.bmp ├── abgral.bmp └── negativ_chauch.bmp ├── src ├── lib │ ├── my_putchar.c │ ├── my_puterror.c │ ├── my_memset.c │ ├── my_putstr.c │ ├── my_strlen.c │ ├── my_strdup.c │ ├── epur_line.c │ ├── my_strcat.c │ ├── my_putnbr.c │ ├── my_strcmp.c │ ├── my_str_isnum.c │ └── my_atoi_base.c ├── main.c ├── default_size_window.c ├── expose_hook.c ├── clear_img.c ├── show_list.c ├── my_free_list.c ├── my_linked_list_len.c ├── load_cos_and_sin.c ├── my_rev_list.c ├── get_column_number.c ├── add_elem.c ├── free_light_list.c ├── free_object_list.c ├── get_file.c ├── get_adress_specs.c ├── filter_color.c ├── get_color_hex_str.c ├── my_pixel_put.c ├── resize_aliasing.c ├── init_rt.c ├── check_eyes_number.c ├── get_window_size.c ├── get_wolf_param.c ├── pixel_put_to_image.c ├── redirect_appropriate_function.c ├── damier.c ├── raytracing.c ├── calc_matrice.c ├── thread_create.c ├── normal_perturbation.c ├── plan.c ├── check_separator_number.c ├── object_list_two.c ├── add_light.c ├── get_light_specs.c ├── pars_first_line.c ├── read_file.c ├── open_file.c ├── key_hook.c ├── add_object.c ├── pixel_backscreen.c ├── check_color_syntax.c ├── check_option.c ├── get_general_params.c ├── get_eyes_spec.c ├── search_inter.c ├── resize_window_aliasing.c ├── resize_window_anti_aliasing.c ├── aliasing.c ├── apply_color.c ├── apply_filter2.c ├── reflexion_calc.c ├── get_backscreen.c ├── antialiasing.c ├── cylinder.c ├── parabole.c ├── cpy_light_list.c ├── sphere.c ├── fill_struct_tab.c ├── apply_filter1.c ├── cone.c ├── aff_loading.c ├── matrice_rotate.c ├── check_right_name.c ├── hyperbole.c ├── transparency.c ├── cpy_object_list.c ├── general_params.c ├── calc_rot_eye.c ├── loop_light.c ├── object_loop.c ├── reflexion.c ├── bsc.c ├── bmp.c ├── cpy_general_struct.c ├── get_specs.c ├── init_param.c ├── check_shadow.c ├── object_list_one.c └── negative_object.c ├── .gitattributes ├── .gitignore ├── scenes_obligatoires ├── scene_1.conf ├── scene_2.conf ├── scene_6.conf ├── scene_3.conf ├── scene_4.conf ├── scene_5.conf └── scene_7.conf ├── scene ├── abgral.conf ├── domois_a.conf~ ├── chauch.conf ├── test.conf ├── abgral3.conf ├── acca.conf ├── abgral2.conf ├── abgral2.conf~ └── domois_a.conf └── Makefile /bmp/test.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kefranabg/Raytracer/master/bmp/test.bmp -------------------------------------------------------------------------------- /bmp/abgral.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kefranabg/Raytracer/master/bmp/abgral.bmp -------------------------------------------------------------------------------- /bmp/negativ_chauch.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kefranabg/Raytracer/master/bmp/negativ_chauch.bmp -------------------------------------------------------------------------------- /src/lib/my_putchar.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** my_putchar.c for in /home/domois_a//Projets/tmp/Raytracer/src/lib 3 | ** 4 | ** Made by adrien domoison 5 | ** Login 6 | ** 7 | ** Started on Mon Apr 29 21:14:45 2013 adrien domoison 8 | ** Last update Sun Jun 9 16:21:11 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int my_putchar(char c) 14 | { 15 | return (write(STDIN_FILENO, &c, 1)); 16 | } 17 | -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** main.c for rt in /home/chauch_a//raytracer-2017-chanut_g 3 | ** 4 | ** Made by alan chauchet 5 | ** Login 6 | ** 7 | ** Started on Wed Apr 3 11:31:07 2013 alan chauchet 8 | ** Last update Mon May 27 14:22:55 2013 thomas loeb 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int main(int ac, char **av) 14 | { 15 | if (ac < 2) 16 | return (my_puterror(USAGE)); 17 | return (bsc(av), ac); 18 | } 19 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /src/default_size_window.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** default_size_window.c for default_size_window.c in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Wed May 15 16:22:00 2013 franck abgrall 8 | ** Last update Wed May 15 16:24:21 2013 franck abgrall 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void default_size_window(t_rt *rt) 14 | { 15 | rt->size.size_x = DEFAULT_SIZE_X; 16 | rt->size.size_y = DEFAULT_SIZE_Y; 17 | } 18 | -------------------------------------------------------------------------------- /src/expose_hook.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** expose_hook.c for rt in /home/chauch_a//Dropbox/Raytracer/raytracer-2017-chanut_g 3 | ** 4 | ** Made by alan chauchet 5 | ** Login 6 | ** 7 | ** Started on Fri May 17 17:39:49 2013 alan chauchet 8 | ** Last update Sun Jun 9 18:33:19 2013 adrien domoison 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int expose_hook(t_rt *rt) 14 | { 15 | mlx_put_image_to_window(rt->mlx_init.mlx_ptr, rt->mlx_init.win_ptr, 16 | rt->img_tab[rt->pos].img_ptr, 0, 0); 17 | return (EXIT_SUCCESS); 18 | } 19 | -------------------------------------------------------------------------------- /src/lib/my_puterror.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** my_puterror.c for in /home/domois_a//Projets/tmp/Raytracer/src/lib 3 | ** 4 | ** Made by adrien domoison 5 | ** Login 6 | ** 7 | ** Started on Mon Apr 29 21:14:37 2013 adrien domoison 8 | ** Last update Sun Jun 9 16:13:51 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int my_puterror(char *str) 14 | { 15 | if (str != NULL) 16 | write(STDERR_FILENO, str, my_strlen(str)); 17 | else 18 | write(STDERR_FILENO, "(null)", 6); 19 | return (EXIT_FAILURE); 20 | } 21 | -------------------------------------------------------------------------------- /src/lib/my_memset.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** my_memset.c for in /home/domois_a//Projets/tmp/Raytracer/src 3 | ** 4 | ** Made by adrien domoison 5 | ** Login 6 | ** 7 | ** Started on Mon Apr 29 21:48:11 2013 adrien domoison 8 | ** Last update Mon Apr 29 21:48:12 2013 adrien domoison 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void my_memset(char *str, char set, unsigned int size) 14 | { 15 | unsigned int count; 16 | 17 | count = 0; 18 | while (count < size) 19 | { 20 | str[count] = set; 21 | ++count; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/lib/my_putstr.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** my_putstr.c for in /home/domois_a//Projets/tmp/Raytracer/src/lib 3 | ** 4 | ** Made by adrien domoison 5 | ** Login 6 | ** 7 | ** Started on Mon Apr 29 21:15:07 2013 adrien domoison 8 | ** Last update Mon Apr 29 21:22:27 2013 adrien domoison 9 | */ 10 | 11 | #include 12 | #include 13 | #include "raytracer.h" 14 | 15 | int my_putstr(char *str) 16 | { 17 | if (str != NULL) 18 | return (write(STDOUT_FILENO, str, my_strlen(str))); 19 | return (write(STDOUT_FILENO, "(null)", 6)); 20 | } 21 | -------------------------------------------------------------------------------- /src/clear_img.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** clear_img.c for rt in /home/domois_a//MERGE 3 | ** 4 | ** Made by adrien domoison 5 | ** Login 6 | ** 7 | ** Started on Sun Jun 9 17:45:41 2013 adrien domoison 8 | ** Last update Sun Jun 9 18:05:27 2013 adrien domoison 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void clear_img(t_rt *rt) 14 | { 15 | int pos; 16 | int max; 17 | 18 | pos = 0; 19 | max = rt->size.win_y * rt->size.win_y; 20 | while (pos <= max) 21 | { 22 | aff_loading(rt, pos, max, 0x000000); 23 | pos++; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/show_list.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** show_list.c for in /home/domois_a//Projets/tmp/Raytracer/src 3 | ** 4 | ** Made by adrien domoison 5 | ** Login 6 | ** 7 | ** Started on Tue Apr 30 14:42:41 2013 adrien domoison 8 | ** Last update Tue Apr 30 14:53:01 2013 adrien domoison 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int show_list(t_list *list) 14 | { 15 | t_list *tmp; 16 | 17 | tmp = list; 18 | while (tmp != NULL) 19 | { 20 | my_putstr(tmp->line); 21 | my_putchar('\n'); 22 | tmp = tmp->next; 23 | } 24 | return (0); 25 | } 26 | -------------------------------------------------------------------------------- /src/my_free_list.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** free_list.c for in /home/domois_a//Projets/tmp/raytracer-2017-chanut_g 3 | ** 4 | ** Made by adrien domoison 5 | ** Login 6 | ** 7 | ** Started on Tue Apr 30 15:33:09 2013 adrien domoison 8 | ** Last update Sun Jun 9 16:14:50 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void my_free_list(t_list *list) 14 | { 15 | t_list *tmp; 16 | 17 | tmp = NULL; 18 | while (list != NULL) 19 | { 20 | tmp = list; 21 | list = list->next; 22 | free(tmp->line); 23 | free(tmp); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/my_linked_list_len.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** my_linked_list_len.c for in /home/domois_a//Projets/tmp/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by adrien domoison 5 | ** Login 6 | ** 7 | ** Started on Tue Apr 30 15:53:44 2013 adrien domoison 8 | ** Last update Sun Jun 9 16:14:47 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int my_linked_list_len(t_list *list) 14 | { 15 | t_list *tmp; 16 | int i; 17 | 18 | i = 0; 19 | tmp = list; 20 | while (tmp != NULL) 21 | { 22 | ++i; 23 | tmp = tmp->next; 24 | } 25 | return (i); 26 | } 27 | -------------------------------------------------------------------------------- /src/load_cos_and_sin.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** load_cos_and_sin.c for rt in /home/chauch_a//Dropbox/Raytracer/raytracer-2017-chanut_g 3 | ** 4 | ** Made by alan chauchet 5 | ** Login 6 | ** 7 | ** Started on Thu May 16 10:57:52 2013 alan chauchet 8 | ** Last update Sun Jun 9 16:04:46 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void load_cos_and_sin(t_rt *rt) 14 | { 15 | int count; 16 | 17 | count = 0; 18 | while (count < 360) 19 | { 20 | rt->cosinus[count] = cos(RAD(count)); 21 | rt->sinus[count] = sin(RAD(count)); 22 | count++; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/my_rev_list.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** my_rev_list.c for in /home/domois_a//Projets/tmp/Raytracer 3 | ** 4 | ** Made by adrien domoison 5 | ** Login 6 | ** 7 | ** Started on Tue Apr 30 14:54:15 2013 adrien domoison 8 | ** Last update Tue Apr 30 14:55:09 2013 adrien domoison 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void my_rev_list(t_list **list) 14 | { 15 | t_list *tmp; 16 | t_list *tmp2; 17 | 18 | tmp = NULL; 19 | while (*list != NULL) 20 | { 21 | tmp2 = (*list)->next; 22 | (*list)->next = tmp; 23 | tmp = *list; 24 | *list = tmp2; 25 | } 26 | *list = tmp; 27 | } 28 | -------------------------------------------------------------------------------- /src/get_column_number.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** get_column_number.c for get_column_number in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Mon May 13 17:40:43 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:08:04 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int get_column_number(int specs_nb, t_rt *rt) 14 | { 15 | int count; 16 | 17 | count = 0; 18 | while (count < SIZE_TAB) 19 | { 20 | if (specs_nb == rt->ref_tab[count]) 21 | return (count + 1); 22 | count++; 23 | } 24 | return (EXIT_FAILURE); 25 | } 26 | -------------------------------------------------------------------------------- /src/add_elem.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** add_elem.c for in /home/domois_a//Projets/tmp/Raytracer 3 | ** 4 | ** Made by adrien domoison 5 | ** Login 6 | ** 7 | ** Started on Tue Apr 30 14:24:42 2013 adrien domoison 8 | ** Last update Sun Jun 9 16:13:40 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int add_elem(t_list **list, char *str, int count) 14 | { 15 | t_list *elem; 16 | 17 | if ((elem = malloc(sizeof(t_list))) == NULL) 18 | return (my_puterror(MALLOC_ERROR)); 19 | elem->line = my_strdup(str, FALSE); 20 | elem->next = *list; 21 | elem->line_nb = count; 22 | *list = elem; 23 | return (EXIT_SUCCESS); 24 | } 25 | -------------------------------------------------------------------------------- /src/free_light_list.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** free_light_list.c for free_light_list.c in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Fri May 17 01:05:09 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:08:47 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int free_light_list(t_rt *rt) 14 | { 15 | t_light *tmp; 16 | t_light *tmp_to_free; 17 | 18 | tmp = rt->first_light; 19 | while (tmp != NULL) 20 | { 21 | tmp_to_free = tmp; 22 | tmp = tmp->next; 23 | free(tmp_to_free); 24 | } 25 | return (EXIT_SUCCESS); 26 | } 27 | -------------------------------------------------------------------------------- /src/free_object_list.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** free_object_list.c for free_object_list.c in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Tue May 14 21:17:59 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:08:43 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int free_object_list(t_rt *rt) 14 | { 15 | t_object *tmp; 16 | t_object *tmp_to_free; 17 | 18 | tmp = rt->first_object; 19 | while (tmp != NULL) 20 | { 21 | tmp_to_free = tmp; 22 | tmp = tmp->next; 23 | free(tmp_to_free); 24 | } 25 | return (EXIT_SUCCESS); 26 | } 27 | -------------------------------------------------------------------------------- /src/lib/my_strlen.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** my_strlen.c for in /home/domois_a//Projets/tmp/Raytracer/src/lib 3 | ** 4 | ** Made by adrien domoison 5 | ** Login 6 | ** 7 | ** Started on Tue Apr 29 14:04:07 2013 adrien domoison 8 | ** Last update Tue May 14 21:05:59 2013 franck abgrall 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int my_strlen(char *str) 14 | { 15 | int i; 16 | 17 | i = 0; 18 | if (str == NULL) 19 | return (0); 20 | while (str[i] != '\0') 21 | i++; 22 | return (i); 23 | } 24 | 25 | int my_strlen_rt(char *str) 26 | { 27 | int i; 28 | 29 | i = 0; 30 | if (str == NULL) 31 | return (0); 32 | while (str[i] != SEPARATOR && str[i] != '\0') 33 | i++; 34 | return (i); 35 | } 36 | -------------------------------------------------------------------------------- /src/get_file.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** get_file.c for in /home/domois_a//Projets/tmp/Raytracer/src 3 | ** 4 | ** Made by adrien domoison 5 | ** Login 6 | ** 7 | ** Started on Tue Apr 30 10:40:51 2013 adrien domoison 8 | ** Last update Sun Jun 9 16:07:38 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int get_file(char *file_name, t_rt *rt) 14 | { 15 | t_list *list; 16 | 17 | list = NULL; 18 | if (open_file(file_name, &list, rt) == EXIT_FAILURE) 19 | return (EXIT_FAILURE); 20 | if (list == NULL) 21 | return (my_puterror(EMPTY_FILE)); 22 | if (pars_first_line(list, rt) == EXIT_FAILURE) 23 | { 24 | my_free_list(list); 25 | return (EXIT_FAILURE); 26 | } 27 | my_free_list(list); 28 | return (EXIT_SUCCESS); 29 | } 30 | -------------------------------------------------------------------------------- /src/get_adress_specs.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** get_adress_specs.c for get_adress_specs.c in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Mon May 13 18:38:34 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:08:23 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int get_adress_specs(t_list *list, int column_nb) 14 | { 15 | int count; 16 | int count_separators; 17 | 18 | count = 0; 19 | count_separators = 0; 20 | while (list->line[count] != '\0') 21 | { 22 | if (list->line[count] == SEPARATOR) 23 | count_separators++; 24 | if (count_separators == column_nb) 25 | return (count + 1); 26 | count++; 27 | } 28 | return (EXIT_FAILURE); 29 | } 30 | -------------------------------------------------------------------------------- /src/filter_color.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** filter_color.c for rt in /home/chauch_a//Dropbox/Raytracer/transparence 3 | ** 4 | ** Made by alan chauchet 5 | ** Login 6 | ** 7 | ** Started on Tue Jun 4 20:16:35 2013 alan chauchet 8 | ** Last update Sat Jun 8 15:13:19 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | static t_filter g_filter[10] = 14 | { 15 | {&negativ_filter}, 16 | {&mix_filter}, 17 | {&sepia_filter}, 18 | {&black_white_filter}, 19 | {&red_filter}, 20 | {&green_filter}, 21 | {&blue_filter}, 22 | {&purple_filter}, 23 | {&cyan_filter}, 24 | {&grey_filter}, 25 | }; 26 | 27 | void filter_color(t_rt *rt, int *color) 28 | { 29 | if (rt->general_param.filter > 0) 30 | *color = g_filter[rt->general_param.filter - 1].filter_fctn(*color); 31 | } 32 | -------------------------------------------------------------------------------- /src/get_color_hex_str.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** get_color_hex_str.c for get_color_hex_str.c in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Wed May 15 00:18:37 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:08:13 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int get_color_hex_str(char **color_hex, char *str) 14 | { 15 | int count; 16 | 17 | if (((*color_hex) = malloc(sizeof(*(*color_hex)) 18 | * (my_strlen_rt(str) + 1))) == NULL) 19 | return (my_puterror(MALLOC_ERROR)); 20 | count = 0; 21 | while (str[count] != SEPARATOR) 22 | { 23 | (*color_hex)[count] = str[count]; 24 | count++; 25 | } 26 | (*color_hex)[count] = '\0'; 27 | return (EXIT_SUCCESS); 28 | } 29 | -------------------------------------------------------------------------------- /src/lib/my_strdup.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** my_strdup.c for in /home/domois_a//Projets/tmp/Raytracer/src/lib 3 | ** 4 | ** Made by adrien domoison 5 | ** Login 6 | ** 7 | ** Started on Mon Apr 29 21:16:22 2013 adrien domoison 8 | ** Last update Tue Apr 30 14:34:50 2013 adrien domoison 9 | */ 10 | 11 | #include 12 | #include "raytracer.h" 13 | 14 | char *my_strdup(char *str, int free_str) 15 | { 16 | unsigned int count; 17 | char *res; 18 | 19 | count = 0; 20 | if ((res = malloc(sizeof(char) * (my_strlen(str) + 1))) == NULL) 21 | { 22 | my_puterror(MALLOC_ERROR); 23 | return (NULL); 24 | } 25 | while (str[count] != '\0') 26 | { 27 | res[count] = str[count]; 28 | count++; 29 | } 30 | res[count] = '\0'; 31 | if (free_str == TRUE) 32 | free(str); 33 | return (res); 34 | } 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /src/my_pixel_put.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** my_pixel_put.c for rt in /home/chauch_a//Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by alan chauchet 5 | ** Login 6 | ** 7 | ** Started on Fri May 17 14:31:52 2013 alan chauchet 8 | ** Last update Sat Jun 1 18:28:08 2013 franck abgrall 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void my_pixel_put(t_rt *rt, int x, int y, int color) 14 | { 15 | int pos; 16 | unsigned char data[3]; 17 | 18 | if (x >= 0 && x <= rt->size.size_x && y >= 0 && y <= rt->size.size_y) 19 | { 20 | data[0] = (color & 0xFF0000) >> 16; 21 | data[1] = (color & 0x00FF00) >> 8; 22 | data[2] = (color & 0x0000FF); 23 | pos = x * 4 + y * rt->mlx_init.size_line; 24 | rt->mlx_init.data[pos] = data[2]; 25 | rt->mlx_init.data[pos + 1] = data[1]; 26 | rt->mlx_init.data[pos + 2] = data[0]; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/resize_aliasing.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** resize_aliasing.c for resize_aliasing.c in /home/abgral_f//Dropbox/Raytracer/transparence/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Sat Jun 8 06:04:58 2013 franck abgrall 8 | ** Last update Sun Jun 9 15:59:26 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int resize_aliasing(t_rt *rt) 14 | { 15 | if (rt->general_param.aliasing > 1 && 16 | (rt->size.size_x < 1000 || rt->size.size_y < 1000)) 17 | return (my_puterror(ALIASING_ERROR)); 18 | if (rt->general_param.anti_aliasing > 1 && 19 | rt->general_param.aliasing > 1) 20 | return (my_puterror(ERROR_ALIASING)); 21 | if (rt->general_param.anti_aliasing >= 1) 22 | resize_window_anti_aliasing(rt); 23 | if (rt->general_param.aliasing > 1) 24 | resize_window_aliasing(rt); 25 | return (EXIT_SUCCESS); 26 | } 27 | -------------------------------------------------------------------------------- /src/init_rt.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** init_rt.c for init_rt.c in /home/abgral_f//Dropbox/Raytracer/transparence/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Sat Jun 8 06:00:50 2013 franck abgrall 8 | ** Last update Sun Jun 9 18:19:54 2013 adrien domoison 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void init_rt(t_rt *rt) 14 | { 15 | rt->general_param.nb_img = 1; 16 | rt->general_param.speed = 0; 17 | rt->general_param.anti_aliasing = 1; 18 | rt->general_param.aliasing = 1; 19 | rt->general_param.threads = 1; 20 | rt->general_param.filter = 0; 21 | rt->general_param.ambiance_light = 0; 22 | rt->general_param.backscreen.name = NULL; 23 | rt->pos = 0; 24 | rt->eye.check = FALSE; 25 | rt->first_line = NULL; 26 | rt->first_light = NULL; 27 | rt->last_light = NULL; 28 | rt->first_object = NULL; 29 | rt->last_object = NULL; 30 | } 31 | -------------------------------------------------------------------------------- /src/check_eyes_number.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** check_eyes_number.c for check_eyes_number.c in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Tue May 14 21:41:30 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:41:16 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int check_eyes_number(t_rt *rt) 14 | { 15 | t_object *tmp; 16 | int count; 17 | 18 | count = 0; 19 | tmp = rt->first_object; 20 | while (tmp != NULL) 21 | { 22 | if (tmp->object_nb == EYES_NB) 23 | count++; 24 | tmp = tmp->next; 25 | } 26 | if (count == 0) 27 | { 28 | my_puterror(NO_EYES); 29 | return (EXIT_FAILURE); 30 | } 31 | if (count > 1) 32 | { 33 | my_puterror(TOO_MANY_EYES); 34 | return (EXIT_FAILURE); 35 | } 36 | return (EXIT_SUCCESS); 37 | } 38 | -------------------------------------------------------------------------------- /src/get_window_size.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** get_window_size.c for get_window_size.c in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Wed May 15 15:50:50 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:42:18 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int get_window_size(t_rt *rt, char *size_x, char *size_y) 14 | { 15 | if (my_str_isnum(size_x, 0) == 1) 16 | return (my_puterror(BAD_ARG_S)); 17 | if (my_str_isnum(size_y, 0) == 1) 18 | return (my_puterror(BAD_ARG_S)); 19 | rt->size.size_y = atoi(size_y); 20 | rt->size.size_x = atoi(size_x); 21 | if (rt->size.size_x <= 1 || rt->size.size_y <= 1) 22 | return (my_puterror(SIZE_ZERO)); 23 | if (rt->size.size_y > 1080) 24 | return (EXIT_FAILURE); 25 | if (rt->size.size_x > 1920) 26 | return (EXIT_FAILURE); 27 | return (EXIT_SUCCESS); 28 | } 29 | -------------------------------------------------------------------------------- /src/get_wolf_param.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** get_wolf_param.c<2> for rt in /home/domois_a//MERGE/src 3 | ** 4 | ** Made by adrien domoison 5 | ** Login 6 | ** 7 | ** Started on Sun Jun 9 18:16:59 2013 adrien domoison 8 | ** Last update Sun Jun 9 18:17:06 2013 adrien domoison 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int get_wolf_param(t_rt *rt, char *nb_img, char *speed) 14 | { 15 | if (my_str_isnum(nb_img, 0) == 1) 16 | return (my_puterror(BAD_ARG_S)); 17 | if (my_str_isnum(speed, 0) == 1) 18 | return (my_puterror(BAD_ARG_S)); 19 | rt->general_param.speed = atoi(speed); 20 | rt->general_param.nb_img = atoi(nb_img); 21 | if (rt->general_param.nb_img <= 1 || rt->general_param.speed <= 1) 22 | return (my_puterror(SIZE_ZERO)); 23 | if (rt->general_param.speed > 1080) 24 | return (EXIT_FAILURE); 25 | if (rt->general_param.nb_img > 1920) 26 | return (EXIT_FAILURE); 27 | return (EXIT_SUCCESS); 28 | } 29 | -------------------------------------------------------------------------------- /src/lib/epur_line.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** epur_tmp.c for in /home/domois_a//Projets/tmp/Raytracer/src 3 | ** 4 | ** Made by adrien domoison 5 | ** Login 6 | ** 7 | ** Started on Mon Apr 29 20:53:08 2013 adrien domoison 8 | ** Last update Mon Apr 29 21:37:22 2013 adrien domoison 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | char *epur_line(char *str) 14 | { 15 | int pos_cur; 16 | int pos_dest; 17 | 18 | pos_cur = 0; 19 | pos_dest = 0; 20 | while (str[pos_cur] != '\0' && (str[pos_cur] == ' ' || str[pos_cur] == '\t')) 21 | ++pos_cur; 22 | while (str[pos_cur] != '\0') 23 | { 24 | if (str[pos_cur] == ' ' || str[pos_cur] == '\t') 25 | ++pos_cur; 26 | else 27 | { 28 | if (str[pos_cur] == '\t') 29 | str[pos_cur] = ' '; 30 | if (str[pos_cur] == '\n') 31 | str[pos_cur] = '\0'; 32 | str[pos_dest++] = str[pos_cur++]; 33 | } 34 | } 35 | str[pos_dest] = '\0'; 36 | return (str); 37 | } 38 | -------------------------------------------------------------------------------- /src/lib/my_strcat.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** my_strcat.c for my_strcat.c in /home/loeb_t//projets/corewar/asm/source 3 | ** 4 | ** Made by thomas loeb 5 | ** Login 6 | ** 7 | ** Started on Wed Jan 30 11:35:41 2013 thomas loeb 8 | ** Last update Sun Jun 9 16:43:39 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | char *my_strcat(char *s1, char *s2, 14 | int free1, int free2) 15 | { 16 | char *tmp; 17 | int i; 18 | int j; 19 | 20 | if (s1 == NULL || s2 == NULL) 21 | return (""); 22 | if ((tmp = malloc(my_strlen(s1) + my_strlen(s2) + 1)) == NULL) 23 | { 24 | my_puterror(MALLOC_ERROR); 25 | return (NULL); 26 | } 27 | i = 0; 28 | j = 0; 29 | while (s1[i] != '\0') 30 | tmp[j++] = s1[i++]; 31 | if (free1 == 1) 32 | free(s1); 33 | i = 0; 34 | while (s2[i] != '\0') 35 | tmp[j++] = s2[i++]; 36 | if (free2 == 1) 37 | free(s2); 38 | tmp[j] = '\0'; 39 | return (tmp); 40 | } 41 | -------------------------------------------------------------------------------- /src/lib/my_putnbr.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** my_putnbr.c for in /home/domois_a//Projets/tmp/Raytracer/src/lib 3 | ** 4 | ** Made by adrien domoison 5 | ** Login 6 | ** 7 | ** Started on Mon Apr 29 21:14:59 2013 adrien domoison 8 | ** Last update Sun Jun 9 18:17:23 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void my_putchar_error(char c) 14 | { 15 | write(2, &c, 1); 16 | } 17 | 18 | void my_putnbr(int nb) 19 | { 20 | int multip; 21 | int count; 22 | 23 | multip = 1; 24 | count = 0; 25 | if (nb < 0) 26 | { 27 | my_putchar('-'); 28 | count = 1; 29 | nb = (nb + 1) * (-1); 30 | } 31 | while ((nb / multip) >= 10) 32 | multip = multip * 10; 33 | while (multip != 1) 34 | { 35 | my_putchar((nb / multip) % 10 + '0'); 36 | multip = multip / 10; 37 | } 38 | if (count == 0) 39 | my_putchar_error((nb / multip) % 10 + '0'); 40 | else 41 | my_putchar_error((nb / multip) % 10 + '0' + 1); 42 | my_putchar_error('\n'); 43 | } 44 | -------------------------------------------------------------------------------- /src/pixel_put_to_image.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** pixel_put_to_image.c for pixel_put_to_image.c in /home/abgral_f//Projets/RTV1/source 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Fri Feb 15 19:16:53 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:02:16 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void masc_bin(t_object *tmp, t_rtv *rtv) 14 | { 15 | rtv->pix->data_one = (tmp->color & 0xFF0000) >> 16; 16 | rtv->pix->data_two = (tmp->color & 0x00FF00) >> 8; 17 | rtv->pix->data_three = (tmp->color & 0x0000FF); 18 | } 19 | 20 | void my_pixel_put_to_image(t_rtv *rtv) 21 | { 22 | int i; 23 | 24 | if (rtv->pix->x >= 0 && rtv->pix->x <= WINX 25 | && rtv->pix->y >= 0 && rtv->pix->y <= WINY) 26 | { 27 | i = rtv->pix->x * 4 + rtv->pix->y * rtv->init->size_line; 28 | rtv->init->data[i] = rtv->pix->data_three; 29 | rtv->init->data[i + 1] = rtv->pix->data_two; 30 | rtv->init->data[i + 2] = rtv->pix->data_one; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/redirect_appropriate_function.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** redirect_appropriate_function.c for redirect_appropriate_function.c in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Sat May 11 15:37:06 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:14:03 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | static int (*pointer_tab[])(t_list *, int, t_rt *) = 14 | { 15 | &get_sphere_specs, 16 | &get_cylinder_specs, 17 | &get_plan_specs, 18 | &get_cone_specs, 19 | &get_light_specs, 20 | &get_eyes_specs, 21 | &get_parabole_specs, 22 | &get_hyperbole_specs 23 | }; 24 | 25 | int redirect_appropriate_function(int object_nb, t_list *list, t_rt *rt) 26 | { 27 | int count; 28 | 29 | count = 0; 30 | while (count != NB_OBJECT) 31 | { 32 | if (pointer_tab[count](list, object_nb, rt) == EXIT_FAILURE) 33 | return (EXIT_FAILURE); 34 | count++; 35 | } 36 | return (EXIT_SUCCESS); 37 | } 38 | -------------------------------------------------------------------------------- /src/damier.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** damier.c for rt in /home/chauch_a//damier 3 | ** 4 | ** Made by alan chauchet 5 | ** Login 6 | ** 7 | ** Started on Tue Jun 4 21:18:23 2013 alan chauchet 8 | ** Last update Tue Jun 4 21:18:36 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void damier(t_rt *rt, t_object *object, 14 | t_coord *vector, t_eye *eye) 15 | { 16 | int freq; 17 | 18 | freq = (rt->general_param.anti_aliasing 19 | * object->effects.check_frequency) / 2; 20 | if (freq == 0) 21 | freq = 1; 22 | if ((sin(M_PI / freq) 23 | * sin((M_PI / freq) * (eye->coord.y + rt->k * vector->y)) >= 0 24 | && sin(M_PI / freq) * sin((M_PI / freq) 25 | * (eye->coord.x + rt->k * vector->x)) >= 0) 26 | || (sin(M_PI / freq) 27 | * sin((M_PI / freq) * (eye->coord.y + rt->k * vector->y)) < 0 28 | && sin(M_PI / freq) * sin((M_PI / freq) 29 | * (eye->coord.x + rt->k * vector->x)) < 0)) 30 | rt->color = 0xFFFFFF - object->color; 31 | else 32 | rt->color = object->color; 33 | } 34 | -------------------------------------------------------------------------------- /src/raytracing.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** raytracing.c for rt in /home/chauch_a//Dropbox/Raytracer/raytracer-2017-chanut_g 3 | ** 4 | ** Made by alan chauchet 5 | ** Login 6 | ** 7 | ** Started on Wed May 15 14:50:24 2013 alan chauchet 8 | ** Last update Sun Jun 9 18:26:13 2013 adrien domoison 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void *raytracing(void *rt) 14 | { 15 | int max; 16 | int pos; 17 | 18 | load_cos_and_sin((t_rt *)rt); 19 | max = ((t_rt *)rt)->pix_calc.nb_pixel - ((t_rt *)rt)->pix_calc.pixel_pos; 20 | while (((t_rt *)rt)->pix_calc.pixel_pos <= ((t_rt *)rt)->pix_calc.nb_pixel) 21 | { 22 | if (((t_rt *)rt)->thread_nb == ((t_rt *)rt)->general_param.threads) 23 | { 24 | pos = max - (((t_rt *)rt)->pix_calc.nb_pixel - 25 | ((t_rt *)rt)->pix_calc.pixel_pos); 26 | aff_loading((t_rt *)rt, pos, max, 0x00D111); 27 | } 28 | search_inter((t_rt *)rt, ((t_rt *)rt)->pix_calc.pixel_pos 29 | % ((t_rt *)rt)->size.size_x, 30 | ((t_rt *)rt)->pix_calc.pixel_pos 31 | / ((t_rt *)rt)->size.size_x); 32 | ((t_rt *)rt)->pix_calc.pixel_pos++; 33 | } 34 | return (NULL); 35 | } 36 | -------------------------------------------------------------------------------- /src/calc_matrice.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** calc_matrice.c for calc_matrice.c in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Fri May 17 00:58:59 2013 franck abgrall 8 | ** Last update Fri May 31 18:08:38 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void calc_matrice_vector(t_rt *rt, t_object *object, 14 | t_coord *vector, t_coord *new_vector) 15 | { 16 | new_vector->x = matrice_rotate_x(rt, vector, object, -1); 17 | new_vector->y = matrice_rotate_y(rt, vector, object, -1); 18 | new_vector->z = matrice_rotate_z(rt, vector, object, -1); 19 | } 20 | 21 | void calc_matrice_eye(t_rt *rt, t_object *object, 22 | t_eye *eye, t_eye *new_eye) 23 | { 24 | t_coord coord; 25 | 26 | coord.x = (eye->coord.x - object->coord.x); 27 | coord.y = (eye->coord.y - object->coord.y); 28 | coord.z = (eye->coord.z - object->coord.z); 29 | new_eye->coord.x = matrice_rotate_x(rt, &coord, object, -1); 30 | new_eye->coord.y = matrice_rotate_y(rt, &coord, object, -1); 31 | new_eye->coord.z = matrice_rotate_z(rt, &coord, object, -1); 32 | } 33 | -------------------------------------------------------------------------------- /src/thread_create.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** thread_create.c for thread_create.c in /home/abgral_f//Projetsave/rt3/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Mon May 27 13:29:25 2013 franck abgrall 8 | ** Last update Sat Jun 8 06:49:50 2013 franck abgrall 9 | */ 10 | 11 | #include 12 | #include "raytracer.h" 13 | 14 | int thread_creation(t_rt *rt) 15 | { 16 | int count; 17 | int repart; 18 | pthread_t thread[4]; 19 | void *ret; 20 | 21 | count = 0; 22 | repart = rt->size.size_x * rt->size.size_y / rt->general_param.threads; 23 | rt->pix_calc.nb_pixel = repart; 24 | rt->pix_calc.pixel_pos = 0; 25 | rt->thread_nb = 1; 26 | while (count != rt->general_param.threads) 27 | { 28 | if (pthread_create(&(thread[count]), NULL, 29 | raytracing, cpy_general_struct(rt)) == -1) 30 | return (my_puterror(THREAD_ERROR)); 31 | rt->pix_calc.nb_pixel += repart; 32 | rt->pix_calc.pixel_pos += repart; 33 | rt->thread_nb++; 34 | count++; 35 | } 36 | count = 0; 37 | while (count != rt->general_param.threads) 38 | pthread_join(thread[count++], &ret); 39 | return (EXIT_SUCCESS); 40 | } 41 | -------------------------------------------------------------------------------- /src/normal_perturbation.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** normal_perturbation.c for rt in /home/chauch_a//Dropbox/Raytracer/transparence 3 | ** 4 | ** Made by alan chauchet 5 | ** Login 6 | ** 7 | ** Started on Mon Jun 3 18:00:24 2013 alan chauchet 8 | ** Last update Sun Jun 9 16:14:40 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void normal_perturbation(t_rt *rt, t_object *object, 14 | t_vision *vision, t_coord *norm) 15 | { 16 | t_coord prov; 17 | int frequency; 18 | 19 | prov.x = norm->x; 20 | prov.y = norm->y; 21 | prov.z = norm->z; 22 | frequency = object->effects.disturb_x * rt->general_param.anti_aliasing; 23 | if (object->effects.disturb_x > 1) 24 | norm->y = prov.y + cos((int)((vision->eye->coord.y 25 | + rt->k * vision->vector->y) / frequency)) 26 | * (sqrt(pow(prov.x, 2) + pow(prov.y, 2) + pow(prov.z, 2)) / frequency); 27 | frequency = object->effects.disturb_y * rt->general_param.anti_aliasing; 28 | if (object->effects.disturb_y > 1) 29 | norm->x = prov.x + cos((int)((vision->eye->coord.x 30 | + rt->k * vision->vector->x) / frequency)) 31 | * (sqrt(pow(prov.x, 2) + pow(prov.y, 2) + pow(prov.z, 2)) / frequency); 32 | } 33 | -------------------------------------------------------------------------------- /src/plan.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** plan.c for rt in /home/acca_b/Dropbox/EPITECH/Tek1/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by baptiste acca 5 | ** Login 6 | ** 7 | ** Started on Thu May 16 15:23:59 2013 baptiste acca 8 | ** Last update Sun Jun 9 16:02:08 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void plan_luminosity(t_rt *rt, t_vision *vision, 14 | t_object *object, t_coord *norm) 15 | { 16 | t_coord coord; 17 | 18 | if (rt->negative == 0) 19 | { 20 | coord.x = 0; 21 | coord.y = 0; 22 | coord.z = 100; 23 | } 24 | norm->x = matrice_rotate_x(rt, &coord, object, 1); 25 | norm->y = matrice_rotate_y(rt, &coord, object, 1); 26 | norm->z = matrice_rotate_z(rt, &coord, object, 1); 27 | if (object->effects.disturb_x > 1 || object->effects.disturb_y > 1) 28 | normal_perturbation(rt, object, vision, norm); 29 | } 30 | 31 | double inter_plan(t_rt *rt, 32 | t_negative *negative) 33 | { 34 | double ret; 35 | 36 | if (negative->vector->z != 0) 37 | { 38 | ret = - (negative->eye->coord.z / negative->vector->z); 39 | return (negative_object(rt, ret, -2, negative)); 40 | } 41 | return (-1); 42 | } 43 | -------------------------------------------------------------------------------- /src/check_separator_number.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** check_separator_number.c for check_separator_number.c in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Tue Apr 30 22:59:19 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:28:20 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int check_if_empty_box(t_list *list) 14 | { 15 | int count; 16 | 17 | count = 0; 18 | while (list->line[count] != '\0') 19 | { 20 | if (list->line[count] == SEPARATOR 21 | && list->line[count + 1] == SEPARATOR) 22 | { 23 | my_puterror(EMPTY_BOX); 24 | my_putnbr(list->line_nb); 25 | return (EXIT_FAILURE); 26 | } 27 | count++; 28 | } 29 | return (EXIT_SUCCESS); 30 | } 31 | 32 | int check_separator_number(t_list *list) 33 | { 34 | int count; 35 | int count_separator; 36 | 37 | count = 0; 38 | count_separator = 0; 39 | while (list->line[count] != '\0') 40 | { 41 | if (list->line[count] == SEPARATOR) 42 | count_separator++; 43 | count++; 44 | } 45 | if (count_separator != NB_SEPARATOR) 46 | return (my_puterror(BAD_SEPARATOR_NB)); 47 | return (EXIT_SUCCESS); 48 | } 49 | -------------------------------------------------------------------------------- /src/lib/my_strcmp.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** my_strcmp.c for in /home/domois_a//Projets/tmp/Raytracer/src/lib 3 | ** 4 | ** Made by adrien domoison 5 | ** Login 6 | ** 7 | ** Started on Mon Apr 29 21:16:08 2013 adrien domoison 8 | ** Last update Fri Jun 7 15:25:02 2013 alan chauchet 9 | */ 10 | 11 | #include 12 | #include "raytracer.h" 13 | 14 | int my_strncmp(char *s1, char *s2, unsigned int size) 15 | { 16 | unsigned int count; 17 | 18 | count = 0; 19 | while (s1[count] != '\0' && count < size) 20 | { 21 | if (s1[count] != s2[count]) 22 | return (1); 23 | ++count; 24 | } 25 | return (0); 26 | } 27 | 28 | int my_strcmp(char *s1, char *s2) 29 | { 30 | unsigned int count; 31 | 32 | count = 0; 33 | if (my_strlen(s1) != my_strlen(s2)) 34 | return (1); 35 | while (s1[count] != '\0') 36 | { 37 | if (s1[count] != s2[count]) 38 | return (1); 39 | ++count; 40 | } 41 | return (0); 42 | } 43 | 44 | int my_strcmp_parser(char *s1, char *s2) 45 | { 46 | unsigned int count; 47 | 48 | count = 0; 49 | while (s1[count] != SEPARATOR && s1[count] != '\0') 50 | { 51 | if (s1[count] != s2[count]) 52 | return (1); 53 | count++; 54 | } 55 | return (0); 56 | } 57 | -------------------------------------------------------------------------------- /src/object_list_two.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** object_list_two.c for object_list_two.c in /home/abgral_f//Dropbox/Raytracer/transparence/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Sat Jun 8 06:40:15 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:03:53 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int get_cone_specs(t_list *list, int object_nb, t_rt *rt) 14 | { 15 | if (object_nb == CONE_NB) 16 | { 17 | if (add_object(rt, object_nb) == EXIT_FAILURE) 18 | return (EXIT_FAILURE); 19 | if (get_coord(list, rt) == EXIT_FAILURE) 20 | return (EXIT_FAILURE); 21 | if (get_rotate(list, rt) == EXIT_FAILURE) 22 | return (EXIT_FAILURE); 23 | if ((rt->last_object->color = 24 | get_color(list, rt, COLOR_NB)) == EXIT_FAILURE) 25 | return (EXIT_FAILURE); 26 | if (get_effects(list, rt) == -1) 27 | return (EXIT_FAILURE); 28 | if ((rt->last_object->param = get_specs(list, rt, ANGLE_NB)) 29 | == -1) 30 | return (EXIT_FAILURE); 31 | if ((rt->last_object->limit = get_specs(list, rt, LIMIT_NB)) 32 | == -1) 33 | return (EXIT_FAILURE); 34 | } 35 | return (EXIT_SUCCESS); 36 | } 37 | -------------------------------------------------------------------------------- /src/add_light.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** add_light.c for rt in /home/acca_b/Dropbox/EPITECH/Tek1/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by baptiste acca 5 | ** Login 6 | ** 7 | ** Started on Thu May 16 14:39:33 2013 baptiste acca 8 | ** Last update Sun Jun 9 16:13:36 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int add_first_light(t_rt *rt) 14 | { 15 | t_light *new; 16 | 17 | if ((new = malloc(sizeof(*new))) == NULL) 18 | return (my_puterror(MALLOC_ERROR)); 19 | rt->first_light = new; 20 | rt->last_light = new; 21 | new->next = NULL; 22 | return (EXIT_SUCCESS); 23 | } 24 | 25 | int add_other_light(t_rt *rt) 26 | { 27 | t_light *new; 28 | t_light *tmp; 29 | 30 | if ((new = malloc(sizeof(*new))) == NULL) 31 | return (my_puterror(MALLOC_ERROR)); 32 | tmp = rt->first_light; 33 | while (tmp->next != NULL) 34 | tmp = tmp->next; 35 | rt->last_light = new; 36 | tmp->next = new; 37 | new->next = NULL; 38 | return (EXIT_SUCCESS); 39 | } 40 | 41 | int add_light(t_rt *rt) 42 | { 43 | if (rt->first_light == NULL) 44 | { 45 | if (add_first_light(rt) == EXIT_FAILURE) 46 | return (EXIT_FAILURE); 47 | } 48 | else 49 | if (add_other_light(rt) == EXIT_FAILURE) 50 | return (EXIT_FAILURE); 51 | return (EXIT_SUCCESS); 52 | } 53 | -------------------------------------------------------------------------------- /src/get_light_specs.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** get_light_specs.c for get_light_specs.c in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Thu May 16 15:03:57 2013 franck abgrall 8 | ** Last update Tue Jun 4 19:32:26 2013 franck abgrall 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int get_coord_light(t_list *list, t_rt *rt) 14 | { 15 | if ((rt->last_light->coord.x = 16 | get_specs(list, rt, POSX_NB)) == -1) 17 | return (EXIT_FAILURE); 18 | if ((rt->last_light->coord.y = 19 | get_specs(list, rt, POSY_NB)) == -1) 20 | return (EXIT_FAILURE); 21 | if ((rt->last_light->coord.z = 22 | get_specs(list, rt, POSZ_NB)) == -1) 23 | return (EXIT_FAILURE); 24 | return (EXIT_SUCCESS); 25 | } 26 | 27 | int get_light_specs(t_list *list, int object_nb, t_rt *rt) 28 | { 29 | if (object_nb == LIGHT_NB) 30 | { 31 | (void)object_nb; 32 | if (add_light(rt) == EXIT_FAILURE) 33 | return (EXIT_FAILURE); 34 | if (get_coord_light(list, rt) == EXIT_FAILURE) 35 | return (EXIT_FAILURE); 36 | if ((rt->last_light->color = 37 | get_color(list, rt, COLOR_NB)) == EXIT_FAILURE) 38 | return (EXIT_FAILURE); 39 | } 40 | return (EXIT_SUCCESS); 41 | } 42 | -------------------------------------------------------------------------------- /src/pars_first_line.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** pars_first_line.c for pars_first_line.c in /home/abgral_f//Depots/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Tue Apr 30 15:42:42 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:14:17 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void mem_set_ref_tab(int ref_tab[SIZE_TAB]) 14 | { 15 | int count; 16 | 17 | count = 0; 18 | while (count < SIZE_TAB) 19 | { 20 | ref_tab[count] = 0; 21 | count++; 22 | } 23 | } 24 | 25 | int init_rt_pars(t_rt *rt, int ref_tab[SIZE_TAB]) 26 | { 27 | rt->first_object = NULL; 28 | rt->ref_tab = &(ref_tab[0]); 29 | return (EXIT_SUCCESS); 30 | } 31 | 32 | int pars_first_line(t_list *list, t_rt *rt) 33 | { 34 | int ref_tab[SIZE_TAB]; 35 | 36 | init_rt_pars(rt, ref_tab); 37 | mem_set_ref_tab(ref_tab); 38 | if (check_separator_number(list) == EXIT_FAILURE) 39 | return (EXIT_FAILURE); 40 | if (check_if_empty_box(list) == EXIT_FAILURE) 41 | return (EXIT_FAILURE); 42 | if (check_right_name(list->line, ref_tab) == EXIT_FAILURE) 43 | return (EXIT_FAILURE); 44 | if (fill_struct_tab(list, rt) == EXIT_FAILURE) 45 | { 46 | free_object_list(rt); 47 | return (EXIT_FAILURE); 48 | } 49 | return (EXIT_SUCCESS); 50 | } 51 | -------------------------------------------------------------------------------- /src/read_file.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** read_file.c for in /home/domois_a//Projets/tmp/Raytracer 3 | ** 4 | ** Made by adrien domoison 5 | ** Login 6 | ** 7 | ** Started on Tue Apr 30 14:13:07 2013 adrien domoison 8 | ** Last update Sun Jun 9 16:14:08 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int check_valid_line(char *line) 14 | { 15 | int count; 16 | int ret; 17 | 18 | count = 0; 19 | ret = 0; 20 | while (line[count] != '\0') 21 | { 22 | if (line[count] == SEPARATOR) 23 | ret++; 24 | count++; 25 | } 26 | if (ret != NB_SEPARATOR) 27 | return (EXIT_FAILURE); 28 | return (EXIT_SUCCESS); 29 | } 30 | 31 | int read_file(FILE *fd, t_list **list, t_rt *rt) 32 | { 33 | char *line; 34 | size_t len; 35 | int count; 36 | 37 | count = 0; 38 | len = 0; 39 | line = NULL; 40 | while (getline(&line, &len, fd) != -1) 41 | { 42 | epur_line(line); 43 | if (get_general_params(line, count, rt) == EXIT_FAILURE) 44 | return (EXIT_FAILURE); 45 | if (check_valid_line(line) == EXIT_SUCCESS) 46 | { 47 | if (line[0] != COMMENT && add_elem(list, line, count) == EXIT_FAILURE) 48 | return (EXIT_FAILURE); 49 | } 50 | else 51 | if (count == 0) 52 | return (my_puterror(BAD_SEPARATOR_NB)); 53 | count++; 54 | } 55 | my_rev_list(list); 56 | free(line); 57 | return (EXIT_SUCCESS); 58 | } 59 | -------------------------------------------------------------------------------- /src/lib/my_str_isnum.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** my_str_isnum.c for in /home/domois_a//Projets/tmp/Raytracer/src/lib 3 | ** 4 | ** Made by adrien domoison 5 | ** Login 6 | ** 7 | ** Started on Tue Apr 30 10:39:36 2013 adrien domoison 8 | ** Last update Sun Jun 9 16:33:55 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int my_str_isnum(char *str, int do_neg) 14 | { 15 | int i; 16 | 17 | i = 0; 18 | while (str[i] != '\0') 19 | { 20 | if ((str[i] < '0' || str[i] > '9') && str[i] != '+') 21 | { 22 | if (str[i] == '-' && do_neg == 0) 23 | return (1); 24 | else if (str[i] != '-') 25 | return (1); 26 | } 27 | i++; 28 | } 29 | return (0); 30 | } 31 | 32 | int check_isnum(char *str, t_list *list) 33 | { 34 | int count; 35 | 36 | count = 0; 37 | if (str[count] == SEPARATOR) 38 | { 39 | my_puterror(EMPTY_BOX); 40 | my_putnbr(list->line_nb); 41 | return (-1); 42 | } 43 | if ((str[count] < '0' || str[count] > '9') && str[count] != '-') 44 | { 45 | my_puterror(WRONG_COLUMN); 46 | return (-1); 47 | } 48 | while (str[count] != SEPARATOR && str[count] != '\0') 49 | { 50 | if ((str[count] < '0' || str[count] > '9') && count != 0 51 | && str[count] != '.') 52 | { 53 | my_puterror(WRONG_COLUMN); 54 | return (-1); 55 | } 56 | count++; 57 | } 58 | return (0); 59 | } 60 | -------------------------------------------------------------------------------- /src/open_file.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** open_file.c for in /home/domois_a//Projets/tmp/Raytracer/src 3 | ** 4 | ** Made by adrien domoison 5 | ** Login 6 | ** 7 | ** Started on Mon Apr 29 21:07:16 2013 adrien domoison 8 | ** Last update Sun Jun 9 16:43:10 2013 alan chauchet 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include "raytracer.h" 15 | 16 | int check_extension(char *file_name) 17 | { 18 | int count; 19 | int count_extension; 20 | 21 | count = 0; 22 | while (file_name[count] != '\0') 23 | count++; 24 | count_extension = 0; 25 | while (EXTENSION[count_extension] != '\0') 26 | count_extension++; 27 | while ((EXTENSION[count_extension] == file_name[count]) 28 | && count > 0 && count_extension > 0) 29 | { 30 | if (count_extension == 1) 31 | return (EXIT_SUCCESS); 32 | count--; 33 | count_extension--; 34 | } 35 | my_puterror(BAD_EXTENSION); 36 | return (EXIT_FAILURE); 37 | } 38 | 39 | int open_file(char *file_name, t_list **list, t_rt *rt) 40 | { 41 | FILE *fd; 42 | 43 | if (check_extension(file_name) == EXIT_FAILURE) 44 | return (EXIT_FAILURE); 45 | if ((fd = fopen(file_name, FOPEN_MODE)) == NULL) 46 | return (my_puterror(FOPEN_ERROR)); 47 | if (read_file(fd, list, rt) == EXIT_FAILURE) 48 | { 49 | fclose(fd); 50 | return (EXIT_FAILURE); 51 | } 52 | fclose(fd); 53 | return (EXIT_SUCCESS); 54 | } 55 | -------------------------------------------------------------------------------- /src/key_hook.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** key_hook.c for rt in /home/chauch_a//Dropbox/Raytracer/raytracer-2017-chanut_g 3 | ** 4 | ** Made by alan chauchet 5 | ** Login 6 | ** 7 | ** Started on Thu May 16 11:50:54 2013 alan chauchet 8 | ** Last update Sun Jun 9 18:30:18 2013 adrien domoison 9 | */ 10 | 11 | #include 12 | #include "raytracer.h" 13 | 14 | int key_wolf(int keycode, t_rt *rt) 15 | { 16 | if (keycode == UP_KEY) 17 | { 18 | if (rt->pos < rt->general_param.nb_img - 1) 19 | rt->pos++; 20 | mlx_put_image_to_window(rt->mlx_init.mlx_ptr, 21 | rt->mlx_init.win_ptr, 22 | rt->img_tab[rt->pos].img_ptr, 0, 0); 23 | } 24 | else 25 | if (keycode == DOWN_KEY) 26 | { 27 | if (rt->pos > 0) 28 | rt->pos--; 29 | mlx_put_image_to_window(rt->mlx_init.mlx_ptr, 30 | rt->mlx_init.win_ptr, 31 | rt->img_tab[rt->pos].img_ptr, 0, 0); 32 | } 33 | return (EXIT_SUCCESS); 34 | } 35 | 36 | int key_hook(int keycode, t_rt *rt) 37 | { 38 | if (keycode == ESC_KEY) 39 | { 40 | mlx_destroy_window(rt->mlx_init.mlx_ptr, rt->mlx_init.win_ptr); 41 | exit(EXIT_SUCCESS); 42 | } 43 | else 44 | if (keycode == S_KEY) 45 | { 46 | if (bmp(rt) == EXIT_FAILURE) 47 | return (EXIT_FAILURE); 48 | my_putstr(IMG_SAVED); 49 | if (rt->scene_name != NULL) 50 | my_putstr(rt->scene_name); 51 | my_putchar('\n'); 52 | } 53 | key_wolf(keycode, rt); 54 | return (EXIT_SUCCESS); 55 | } 56 | -------------------------------------------------------------------------------- /src/add_object.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** add_object.c for add_object.c in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Mon May 13 17:53:07 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:13:24 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int add_first_object(t_rt *rt, int object_nb) 14 | { 15 | t_object *new; 16 | 17 | if ((new = malloc(sizeof(*new))) == NULL) 18 | return (my_puterror(MALLOC_ERROR)); 19 | rt->first_object = new; 20 | rt->last_object = new; 21 | new->next = NULL; 22 | new->object_nb = object_nb; 23 | return (EXIT_SUCCESS); 24 | } 25 | 26 | int add_other_object(t_rt *rt, int object_nb) 27 | { 28 | t_object *new; 29 | t_object *tmp; 30 | 31 | if ((new = malloc(sizeof(*new))) == NULL) 32 | return (my_puterror(MALLOC_ERROR)); 33 | tmp = rt->first_object; 34 | while (tmp->next != NULL) 35 | tmp = tmp->next; 36 | rt->last_object = new; 37 | tmp->next = new; 38 | new->next = NULL; 39 | new->object_nb = object_nb; 40 | return (EXIT_SUCCESS); 41 | } 42 | 43 | int add_object(t_rt *rt, int object_nb) 44 | { 45 | if (rt->first_object == NULL) 46 | { 47 | if (add_first_object(rt, object_nb) == EXIT_FAILURE) 48 | return (EXIT_FAILURE); 49 | } 50 | else 51 | if (add_other_object(rt, object_nb) == EXIT_FAILURE) 52 | return (EXIT_FAILURE); 53 | return (EXIT_SUCCESS); 54 | } 55 | -------------------------------------------------------------------------------- /src/pixel_backscreen.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** pixel_backscreen.c for rt in /home/chauch_a//texture 3 | ** 4 | ** Made by alan chauchet 5 | ** Login 6 | ** 7 | ** Started on Fri Jun 7 15:52:40 2013 alan chauchet 8 | ** Last update Sun Jun 9 20:48:14 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int pixel_backscreen(t_rt *rt, int x, int y) 14 | { 15 | int color; 16 | double mult_x; 17 | double mult_y; 18 | int pos_x; 19 | int pos_y; 20 | int pos; 21 | 22 | color = 0; 23 | x = x / rt->general_param.anti_aliasing * rt->general_param.aliasing; 24 | y = y / rt->general_param.anti_aliasing * rt->general_param.aliasing; 25 | mult_x = ((double)rt->general_param.backscreen.a) 26 | / ((double)rt->size.size_x / ((double)rt->general_param.anti_aliasing) 27 | * ((double)rt->general_param.aliasing)); 28 | mult_y = ((double)rt->general_param.backscreen.b) 29 | / ((double)rt->size.size_y / ((double)rt->general_param.anti_aliasing) 30 | * ((double)rt->general_param.aliasing)); 31 | pos_x = ((int)(((double)x) * mult_x)); 32 | pos_y = ((int)(((double)y) * mult_y)); 33 | pos = (pos_x + pos_y * rt->general_param.backscreen.a) * 4; 34 | if (pos < rt->general_param.backscreen.a 35 | * rt->general_param.backscreen.b * 4) 36 | color = (rt->general_param.backscreen.data[pos + 2] << 16) 37 | + (rt->general_param.backscreen.data[pos + 1] << 8) 38 | + (rt->general_param.backscreen.data[pos]); 39 | return (color); 40 | } 41 | -------------------------------------------------------------------------------- /src/check_color_syntax.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** check_color_syntax.c for check_clor_syntax in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Mon May 13 22:40:49 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:39:58 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int error_color_syntax(t_list *list) 14 | { 15 | my_puterror(COLOR_SYNTAX); 16 | my_putnbr(list->line_nb); 17 | return (EXIT_FAILURE); 18 | } 19 | 20 | int my_strlen_column(char *str, t_list *list) 21 | { 22 | int count; 23 | 24 | count = 0; 25 | while (str[count] != '\0' && str[count] != SEPARATOR) 26 | count++; 27 | if (count != 8) 28 | return (error_color_syntax(list)); 29 | return (EXIT_SUCCESS); 30 | } 31 | 32 | int check_color_syntax(char *str, t_list *list) 33 | { 34 | int count; 35 | 36 | if (my_strlen_column(str, list) == EXIT_FAILURE) 37 | return (EXIT_FAILURE); 38 | count = 0; 39 | while (str[count] != '\0' && str[count] != SEPARATOR) 40 | { 41 | if (count == 0) 42 | if (str[count] != '0') 43 | return (error_color_syntax(list)); 44 | if (count == 1) 45 | if (str[count] != 'x') 46 | return (error_color_syntax(list)); 47 | if (count > 1 && (str[count] < '0' || 48 | (str[count] > '9' && 49 | str[count] < 'A') 50 | || str[count] > 'F')) 51 | return (error_color_syntax(list)); 52 | count++; 53 | } 54 | return (EXIT_SUCCESS); 55 | } 56 | -------------------------------------------------------------------------------- /src/check_option.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** check_option.c for check_option.c in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Wed May 15 16:05:13 2013 franck abgrall 8 | ** Last update Sun Jun 9 18:19:03 2013 adrien domoison 9 | */ 10 | 11 | #include 12 | #include "raytracer.h" 13 | 14 | int check_s_option(t_rt *rt, char **av, int count) 15 | { 16 | if (strcmp(OPT_S, av[count]) == 0) 17 | { 18 | if (av[count + 1] == NULL || av[count + 2] == NULL) 19 | return (my_puterror(USAGE_S)); 20 | if (get_window_size(rt, av[count + 1], av[count + 2]) == EXIT_FAILURE) 21 | return (EXIT_FAILURE); 22 | } 23 | return (EXIT_SUCCESS); 24 | } 25 | 26 | int check_w_option(t_rt *rt, char **av, int count) 27 | { 28 | if (strcmp(OPT_W, av[count]) == 0) 29 | { 30 | if (av[count + 1] == NULL || av[count + 2] == NULL) 31 | return (my_puterror(USAGE_W)); 32 | if (get_wolf_param(rt, av[count + 1], av[count + 2]) == EXIT_FAILURE) 33 | return (EXIT_FAILURE); 34 | } 35 | return (EXIT_SUCCESS); 36 | } 37 | 38 | int check_option(char **av, t_rt *rt) 39 | { 40 | int count; 41 | 42 | count = 2; 43 | while (av[count] != NULL) 44 | { 45 | if (check_s_option(rt, av, count) == EXIT_FAILURE) 46 | return (EXIT_FAILURE); 47 | if (check_w_option(rt, av, count) == EXIT_FAILURE) 48 | return (EXIT_FAILURE); 49 | count++; 50 | } 51 | return (EXIT_SUCCESS); 52 | } 53 | -------------------------------------------------------------------------------- /src/get_general_params.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** get_general_params.c for get_general_params.c in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Tue May 21 16:30:24 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:16:08 2013 alan chauchet 9 | */ 10 | 11 | #include 12 | #include "raytracer.h" 13 | 14 | int get_general_params(char *line, int line_nb, t_rt *rt) 15 | { 16 | if (strncmp(line, THREADS, strlen(THREADS)) == 0 && 17 | get_threads(&(line[strlen(THREADS)]), line_nb, rt) == EXIT_FAILURE) 18 | return (EXIT_FAILURE); 19 | if (strncmp(line, ALIASING, strlen(ALIASING)) == 0 && 20 | get_aliasing(&(line[strlen(ALIASING)]), line_nb, rt) == EXIT_FAILURE) 21 | return (EXIT_FAILURE); 22 | if (strncmp(line, AMBIANCE, strlen(AMBIANCE)) == 0 && 23 | get_ambiance(&(line[strlen(AMBIANCE)]), line_nb, rt) == EXIT_FAILURE) 24 | return (EXIT_FAILURE); 25 | if (strncmp(line, FILTER, strlen(FILTER)) == 0 && 26 | get_filtre(&(line[strlen(FILTER)]), line_nb, rt) == EXIT_FAILURE) 27 | return (EXIT_FAILURE); 28 | if (strncmp(line, BACKSCREEN, strlen(BACKSCREEN)) == 0 && 29 | get_backscreen(&(line[strlen(BACKSCREEN)]), 30 | line_nb, rt) == EXIT_FAILURE) 31 | return (EXIT_FAILURE); 32 | if (strncmp(line, N_ALIASING, strlen(N_ALIASING)) == 0 && 33 | get_anti_aliasing(&(line[strlen(N_ALIASING)]), 34 | line_nb, rt) == EXIT_FAILURE) 35 | return (EXIT_FAILURE); 36 | return (EXIT_SUCCESS); 37 | } 38 | -------------------------------------------------------------------------------- /src/get_eyes_spec.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** object_list_two.c for object_list_two.c in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Sun May 12 14:16:08 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:07:59 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int get_rotate_eyes(t_list *list, t_rt *rt) 14 | { 15 | if ((rt->eye.rotate.rx = 16 | get_specs(list, rt, ROTX_NB)) == -1) 17 | return (EXIT_FAILURE); 18 | if ((rt->eye.rotate.ry = 19 | get_specs(list, rt, ROTY_NB)) == -1) 20 | return (EXIT_FAILURE); 21 | if ((rt->eye.rotate.rz = 22 | get_specs(list, rt, ROTZ_NB)) == -1) 23 | return (EXIT_FAILURE); 24 | return (EXIT_SUCCESS); 25 | } 26 | 27 | int get_coord_eyes(t_list *list, t_rt *rt) 28 | { 29 | if ((rt->eye.coord.x = 30 | get_specs(list, rt, POSX_NB)) == -1) 31 | return (EXIT_FAILURE); 32 | if ((rt->eye.coord.y = 33 | get_specs(list, rt, POSY_NB)) == -1) 34 | return (EXIT_FAILURE); 35 | if ((rt->eye.coord.z = 36 | get_specs(list, rt, POSZ_NB)) == -1) 37 | return (EXIT_FAILURE); 38 | return (EXIT_SUCCESS); 39 | } 40 | 41 | int get_eyes_specs(t_list *list, int object_nb, t_rt *rt) 42 | { 43 | if (object_nb == EYES_NB) 44 | { 45 | (void)object_nb; 46 | rt->eye.check = TRUE; 47 | if (get_coord_eyes(list, rt) == EXIT_FAILURE) 48 | return (EXIT_FAILURE); 49 | if (get_rotate_eyes(list, rt) == EXIT_FAILURE) 50 | return (EXIT_FAILURE); 51 | } 52 | return (EXIT_SUCCESS); 53 | } 54 | -------------------------------------------------------------------------------- /src/search_inter.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** search_inter.c for rt in /home/chauch_a//Dropbox/Raytracer/raytracer-2017-chanut_g 3 | ** 4 | ** Made by alan chauchet 5 | ** Login 6 | ** 7 | ** Started on Wed May 15 18:16:32 2013 alan chauchet 8 | ** Last update Sun Jun 9 17:05:34 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void apply_transparency(t_rt *rt, int *color) 14 | { 15 | if (rt->inter == TRUE && rt->final_obj != NULL 16 | && rt->final_obj->effects.opacity > 0.00001) 17 | { 18 | rt->transp.size_tab = 1; 19 | if ((rt->transp.inter = malloc(sizeof(t_object*) * 2)) == NULL) 20 | exit(my_puterror(MALLOC_ERROR)); 21 | rt->transp.inter[0] = rt->final_obj; 22 | rt->transp.inter[1] = NULL; 23 | transparency(rt, color, &(rt->vector), &(rt->eye)); 24 | } 25 | } 26 | 27 | void search_inter(t_rt *rt, int pos_x, int pos_y) 28 | { 29 | t_object *obj; 30 | double dist; 31 | int color; 32 | bool inter; 33 | 34 | rt->pos_x = pos_x; 35 | rt->pos_y = pos_y; 36 | calc_rot_eye(rt, pos_x, pos_y); 37 | color = object_loop(rt, &(rt->vector), &(rt->eye), NULL); 38 | obj = rt->final_obj; 39 | dist = rt->k; 40 | inter = rt->inter; 41 | apply_transparency(rt, &color); 42 | rt->final_obj = obj; 43 | rt->k = dist; 44 | rt->inter = inter; 45 | if (rt->inter == TRUE && rt->final_obj != NULL 46 | && rt->final_obj->effects.reflexion >= 0.00001) 47 | { 48 | rt->stop_reflexion = 0; 49 | reflexion(rt, &color, &(rt->vector), &(rt->eye)); 50 | } 51 | filter_color(rt, &color); 52 | my_pixel_put(rt, pos_x, pos_y, color); 53 | } 54 | -------------------------------------------------------------------------------- /src/resize_window_aliasing.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** resize_window_aliasin.c for resize_window_aliasing in /home/abgral_f//Dropbox/Raytracer/transparence/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Fri Jun 7 15:38:12 2013 franck abgrall 8 | ** Last update Fri Jun 7 15:40:41 2013 franck abgrall 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void resize_light_aliasing(t_light *tmp, t_rt *rt) 14 | { 15 | tmp->coord.x /= rt->general_param.aliasing; 16 | tmp->coord.y /= rt->general_param.aliasing; 17 | tmp->coord.z /= rt->general_param.aliasing; 18 | } 19 | 20 | void resize_obj_aliasing(t_object *tmp, t_rt *rt) 21 | { 22 | tmp->coord.x /= rt->general_param.aliasing; 23 | tmp->coord.y /= rt->general_param.aliasing; 24 | tmp->coord.z /= rt->general_param.aliasing; 25 | if (tmp->object_nb != 3) 26 | tmp->param /= rt->general_param.aliasing; 27 | } 28 | 29 | void resize_window_aliasing(t_rt *rt) 30 | { 31 | t_object *tmp_obj; 32 | t_light *tmp_light; 33 | 34 | rt->eye.coord.x /= rt->general_param.aliasing; 35 | rt->eye.coord.y /= rt->general_param.aliasing; 36 | rt->eye.coord.z /= rt->general_param.aliasing; 37 | rt->size.size_x /= rt->general_param.aliasing; 38 | rt->size.size_y /= rt->general_param.aliasing; 39 | tmp_obj = rt->first_object; 40 | while (tmp_obj != NULL) 41 | { 42 | resize_obj_aliasing(tmp_obj, rt); 43 | tmp_obj = tmp_obj->next; 44 | } 45 | tmp_light = rt->first_light; 46 | while (tmp_light != NULL) 47 | { 48 | resize_light_aliasing(tmp_light, rt); 49 | tmp_light = tmp_light->next; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /scenes_obligatoires/scene_1.conf: -------------------------------------------------------------------------------- 1 | |object | pos_x | pos_y | pos_z | rot_x | rot_y | rot_z | color | reflexion | opacity | brightness | radius | angle | limit | disturb_x | disturb_y | check_frequency | 2 | |*************************************************************************************************************************************************************************| 3 | |eyes |-1000 |0 |0 |0 |0 |0 | |0 |0 |0 |0 |0 |0 |0 |0 |0 | 4 | |light | -50 |0 | 300 |0 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 5 | |light | -50 |-250 | 0 |0 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 6 | |sphere | 0 |-50 | 0 |0 |0 |0 |0xFF0000 |0 |0 |0 |100 |0 | 0 |0 |0 |0 | 7 | |*************************************************************************************************************************************************************************| 8 | 9 | ############################################# 10 | * threads => 4 * 11 | * anti-aliasing => 1 * 12 | * ambiance_light => 0 * 13 | * filter => 0 * 14 | ############################################# 15 | -------------------------------------------------------------------------------- /scenes_obligatoires/scene_2.conf: -------------------------------------------------------------------------------- 1 | |object | pos_x | pos_y | pos_z | rot_x | rot_y | rot_z | color | reflexion | opacity | brightness | radius | angle | limit | disturb_x | disturb_y | check_frequency | 2 | |*************************************************************************************************************************************************************************| 3 | |eyes |-1000 |0 |10 |0 |0 |0 | |0 |0 |0 |0 |0 |0 |0 |0 |0 | 4 | |light | -550 |50 | -40 |0 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 5 | |light | -500 | -200 | -40 |0 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 6 | |plan | 0 | 0 | -80 |10 |0 |0 |0x33CC00 |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 7 | |*************************************************************************************************************************************************************************| 8 | 9 | ############################################# 10 | * threads => 4 * 11 | * anti-aliasing => 1 * 12 | * ambiance_light => 0 * 13 | * filter => 0 * 14 | ############################################# 15 | -------------------------------------------------------------------------------- /src/lib/my_atoi_base.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** my_atoi_base.c for my_atoi_base.c in /home/abgral_f//Projets/RTV1/source 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Thu Feb 28 17:39:03 2013 franck abgrall 8 | ** Last update Wed May 15 00:34:24 2013 franck abgrall 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int my_pow(int nb, int pw) 14 | { 15 | int result; 16 | 17 | result = 1; 18 | while (pw > 0) 19 | { 20 | result = result * nb; 21 | pw--; 22 | } 23 | return (result); 24 | } 25 | 26 | int is_in_base(char c, char *base) 27 | { 28 | int i; 29 | 30 | i = 0; 31 | while (base[i] != '\0') 32 | { 33 | if (base[i] == c) 34 | return (1); 35 | i++; 36 | } 37 | return (0); 38 | } 39 | 40 | int is_neg(char *nb, char *base) 41 | { 42 | if (nb[0] == '-' && is_in_base('-', base) == 0) 43 | return (1); 44 | else 45 | return (0); 46 | } 47 | 48 | int my_atoi_base(char *nb, char *base) 49 | { 50 | int result; 51 | int i; 52 | int a; 53 | int neg; 54 | 55 | neg = is_neg(nb, base); 56 | if (my_strlen(base) < 1) 57 | return (1); 58 | result = 0; 59 | i = my_strlen(nb) - 1; 60 | while (i >= 0) 61 | { 62 | a = 0; 63 | while (base[a] != nb[i] && base[a] != '\0') 64 | a++; 65 | if (base[a] == '\0' && !(neg == 1 && i == 0)) 66 | return (1); 67 | if (!(neg == 1 && i == 0)) 68 | result = result + a * my_pow(my_strlen(base), (my_strlen(nb) - i - 1)); 69 | i--; 70 | } 71 | if (neg == 1) 72 | result = result * (-1); 73 | return (result); 74 | } 75 | -------------------------------------------------------------------------------- /scenes_obligatoires/scene_6.conf: -------------------------------------------------------------------------------- 1 | |object | pos_x | pos_y | pos_z | rot_x | rot_y | rot_z | color | reflexion | opacity | brightness | radius | angle | limit | disturb_x | disturb_y | check_frequency | 2 | |*************************************************************************************************************************************************************************| 3 | |eyes |-1000 |0 |5 |0 |0 |0 | |0 |0 |0 |0 |0 |0 |0 |0 |0 | 4 | |light |-930 | -70 | 90 |0 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 5 | |plan | 0 | 0 | 0 |0 |0 |0 |0xC0C0C0 |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 6 | |sphere | -985 | -3 | 2 |0 | 0 |0 |0xFF0000 |0 |0 |0 |3 |0 | 0 |0 |0 |0 | 7 | |cone | -980 | -4 | 0 |0 | 0 |0 |0x3333FF |0 |0 |0 |0 |20 | 0 |0 |0 |0 | 8 | |*************************************************************************************************************************************************************************| 9 | 10 | ############################################# 11 | * threads => 4 * 12 | * anti-aliasing => 1 * 13 | * ambiance_light => 0 * 14 | * filter => 0 * 15 | ############################################# 16 | -------------------------------------------------------------------------------- /src/resize_window_anti_aliasing.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** resize_window_aliasing.c for resize_window_aliasing.c in /home/abgral_f//Dropbox/Raytracer/transparence/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Sat Jun 1 18:23:27 2013 franck abgrall 8 | ** Last update Sun Jun 9 15:59:05 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void resize_light_anti_aliasing(t_light *tmp, t_rt *rt) 14 | { 15 | tmp->coord.x *= rt->general_param.anti_aliasing; 16 | tmp->coord.y *= rt->general_param.anti_aliasing; 17 | tmp->coord.z *= rt->general_param.anti_aliasing; 18 | } 19 | 20 | void resize_obj_anti_aliasing(t_object *tmp, t_rt *rt) 21 | { 22 | tmp->coord.x *= rt->general_param.anti_aliasing; 23 | tmp->coord.y *= rt->general_param.anti_aliasing; 24 | tmp->coord.z *= rt->general_param.anti_aliasing; 25 | if (tmp->object_nb != CONE_NB && tmp->object_nb != PARABOLE_NB && 26 | tmp->object_nb != HYPERBOLE_NB) 27 | tmp->param *= rt->general_param.anti_aliasing; 28 | } 29 | 30 | void resize_window_anti_aliasing(t_rt *rt) 31 | { 32 | t_object *tmp_obj; 33 | t_light *tmp_light; 34 | 35 | rt->eye.coord.x *= rt->general_param.anti_aliasing; 36 | rt->eye.coord.y *= rt->general_param.anti_aliasing; 37 | rt->eye.coord.z *= rt->general_param.anti_aliasing; 38 | rt->size.size_x *= rt->general_param.anti_aliasing; 39 | rt->size.size_y *= rt->general_param.anti_aliasing; 40 | tmp_obj = rt->first_object; 41 | while (tmp_obj != NULL) 42 | { 43 | resize_obj_anti_aliasing(tmp_obj, rt); 44 | tmp_obj = tmp_obj->next; 45 | } 46 | tmp_light = rt->first_light; 47 | while (tmp_light != NULL) 48 | { 49 | resize_light_anti_aliasing(tmp_light, rt); 50 | tmp_light = tmp_light->next; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /scene/abgral.conf: -------------------------------------------------------------------------------- 1 | | object | pos_x | pos_y | pos_z | rot_x | rot_y | rot_z | color | reflexion | opacity | brightness | radius | angle | limit | 2 | |*******************************************************************************************************************************| 3 | | eyes |-1000 |0 |0 |0 |0 |0 | |0 |0 |0 |0 |0 |0 | 4 | | light |-500 |250 |500 |0 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 | 5 | | light | 500 |200 |0 |0 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 | 6 | | plan |0 |0 |-200 |0 |0 |0 |0xFF9B0F |0 |0 |0 |0 |0 | 0 | 7 | | sphere |200 |-250 |0 |0 |0 |0 |0x0FCBFF |0.3 |0 |0 |200 |0 | 0 | 8 | | sphere |-150 |0 |-125 |0 |0 |0 |0x3BFF2D |0.7 |0 |0 |75 |0 | 0 | 9 | | sphere |-300 |100 |-175 |0 |0 |0 |0xFF23E5 |0.2 |0 |0 |25 |0 | 0 | 10 | | cylinder| 0 | 300 |0 |25 |15 |15 |0xFF0000 |0.5 |0 |0 |25 |0 | 0 | 11 | |*******************************************************************************************************************************| 12 | 13 | ############################################# 14 | * threads => 4 * 15 | * ambiance_light => 0.3 16 | * anti-aliasing => 4 * 17 | ############################################# -------------------------------------------------------------------------------- /scenes_obligatoires/scene_3.conf: -------------------------------------------------------------------------------- 1 | |object | pos_x | pos_y | pos_z | rot_x | rot_y | rot_z | color | reflexion | opacity | brightness | radius | angle | limit | disturb_x | disturb_y | check_frequency | 2 | |*************************************************************************************************************************************************************************| 3 | |eyes |-1000 |0 |10 |0 |0 |0 | |0 |0 |0 |0 |0 |0 |0 |0 |0 | 4 | |light |-1000 |50 | -40 |0 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 5 | |light |100 |50 | 400 |0 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 6 | |sphere | 0 | -100 | -80 |0 |0 |0 |0xFFFF33 |0 |0 |0 |100 |0 | 0 |0 |0 |0 | 7 | |cylinder | 0 | -100 | -80 |0 |70 |5 |0xCC33CC |0 |0 |0 |70 |0 | 0 |0 |0 |0 | 8 | |*************************************************************************************************************************************************************************| 9 | 10 | ############################################# 11 | * threads => 4 * 12 | * anti-aliasing => 1 * 13 | * ambiance_light => 0 * 14 | * filter => 0 * 15 | ############################################# 16 | -------------------------------------------------------------------------------- /scenes_obligatoires/scene_4.conf: -------------------------------------------------------------------------------- 1 | |object | pos_x | pos_y | pos_z | rot_x | rot_y | rot_z | color | reflexion | opacity | brightness | radius | angle | limit | disturb_x | disturb_y | check_frequency | 2 | |*************************************************************************************************************************************************************************| 3 | |eyes |-1000 |0 |30 |0 |0 |0 | |0 |0 |0 |0 |0 |0 |0 |0 |0 | 4 | |light |-900 | -200 | 40 |0 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 5 | |light |-1000 | 2 | 36 |0 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 6 | |plan | 0 | 0 | 0 |0 |0 |0 |0xFF6600 |0 |0 |0 |100 |0 | 0 |0 |0 |0 | 7 | |cone | -900 | -20 | 30 |-10 | 0 |0 |0xCC33CC |0 |0 |0 |0 |25 | 0 |0 |0 |0 | 8 | |*************************************************************************************************************************************************************************| 9 | 10 | ############################################# 11 | * threads => 4 * 12 | * anti-aliasing => 1 * 13 | * ambiance_light => 0 * 14 | * filter => 0 * 15 | ############################################# 16 | -------------------------------------------------------------------------------- /src/aliasing.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** aliasing.c for aliasing.c in /home/abgral_f//Dropbox/Raytracer/transparence/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Fri Jun 7 15:42:34 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:13:16 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int fill_resize_window(t_rt *rt, int x, 14 | int y, t_color *color) 15 | { 16 | int count_x; 17 | int count_y; 18 | int pos; 19 | 20 | count_y = 0; 21 | while (count_y != rt->general_param.aliasing) 22 | { 23 | count_x = 0; 24 | while (count_x != rt->general_param.aliasing) 25 | { 26 | pos = x * 4 * rt->general_param.aliasing + count_x * 4 + y 27 | * rt->size.size_x 28 | * rt->general_param.aliasing * rt->general_param.aliasing 29 | * 4 + count_y * rt->size.size_x * rt->general_param.aliasing * 4; 30 | rt->mlx_init.data_resize[pos] = color->red; 31 | rt->mlx_init.data_resize[pos + 1] = color->green; 32 | rt->mlx_init.data_resize[pos + 2] = color->blue; 33 | count_x++; 34 | } 35 | count_y++; 36 | } 37 | return (EXIT_SUCCESS); 38 | } 39 | 40 | int aliasing(t_rt *rt) 41 | { 42 | int x; 43 | int y; 44 | t_color color; 45 | 46 | y = 0; 47 | while (y < rt->size.size_y) 48 | { 49 | x = 0; 50 | while (x < rt->size.size_x) 51 | { 52 | color.red = rt->mlx_init.data_aliasing 53 | [x * 4 + y * rt->size.size_x * 4]; 54 | color.green = rt->mlx_init.data_aliasing 55 | [x * 4 + y * rt->size.size_x * 4 + 1]; 56 | color.blue = rt->mlx_init.data_aliasing 57 | [x * 4 + y * rt->size.size_x * 4 + 2]; 58 | fill_resize_window(rt, x, y, &color); 59 | x++; 60 | } 61 | y++; 62 | } 63 | return (EXIT_SUCCESS); 64 | } 65 | -------------------------------------------------------------------------------- /src/apply_color.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** apply_color.c for rt in /home/acca_b/Dropbox/EPITECH/Tek1/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by baptiste acca 5 | ** Login 6 | ** 7 | ** Started on Thu May 16 16:45:53 2013 baptiste acca 8 | ** Last update Sat Jun 8 06:00:17 2013 franck abgrall 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void color_no_spot(t_rt *rt) 14 | { 15 | if (rt->first_light == NULL) 16 | { 17 | rt->light_var.cos_a = rt->general_param.ambiance_light; 18 | rt->light_var.brightness = 0; 19 | rt->light_var.color.red = 255 * rt->general_param.ambiance_light; 20 | rt->light_var.color.green = 255 * rt->general_param.ambiance_light; 21 | rt->light_var.color.blue = 255 * rt->general_param.ambiance_light; 22 | } 23 | } 24 | 25 | int apply_color(t_rt *rt) 26 | { 27 | int color[3]; 28 | 29 | color_no_spot(rt); 30 | if (rt->light_var.cos_a < rt->general_param.ambiance_light) 31 | rt->light_var.cos_a = rt->general_param.ambiance_light; 32 | if (rt->light_var.shadow < 0.1) 33 | rt->light_var.shadow = rt->general_param.ambiance_light; 34 | color[0] = (int)((rt->color & 0xFF0000) >> 16) * rt->light_var.cos_a 35 | * rt->light_var.shadow + rt->light_var.color.red 36 | * rt->light_var.brightness * rt->light_var.cos_a * rt->light_var.shadow; 37 | if (color[0] > 255) 38 | color[0] = 255; 39 | color[1] = (int)((rt->color & 0x00FF00) >> 8) 40 | * rt->light_var.cos_a * rt->light_var.shadow 41 | + rt->light_var.color.green * rt->light_var.brightness 42 | * rt->light_var.cos_a * rt->light_var.shadow; 43 | if (color[1] > 255) 44 | color[1] = 255; 45 | color[2] = (int)(rt->color & 0x0000FF) 46 | * rt->light_var.cos_a * rt->light_var.shadow 47 | + rt->light_var.color.blue * rt->light_var.brightness 48 | * rt->light_var.cos_a * rt->light_var.shadow; 49 | if (color[2] > 255) 50 | color[2] = 255; 51 | return ((color[0] << 16) + (color[1] << 8) + color[2]); 52 | } 53 | -------------------------------------------------------------------------------- /src/apply_filter2.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** apply_filter2.c for apply_filter2.c in /home/acca_b/Dropbox/EPITECH/Tek1/Raytracer/transparence 3 | ** 4 | ** Made by baptiste acca 5 | ** Login 6 | ** 7 | ** Started on Sat Jun 8 14:31:26 2013 baptiste acca 8 | ** Last update Sat Jun 8 14:35:45 2013 baptiste acca 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int green_filter(int color) 14 | { 15 | int color_tmp[3]; 16 | 17 | color_tmp[0] = (int)((color & 0xFF0000) >> 16) * 0.2; 18 | color_tmp[1] = (int)((color & 0x00FF00) >> 8); 19 | color_tmp[2] = (int)(color & 0x0000FF) * 0.2; 20 | return (((color_tmp[0] << 16) 21 | + (color_tmp[1] << 8) + color_tmp[2])); 22 | } 23 | 24 | int blue_filter(int color) 25 | { 26 | int color_tmp[3]; 27 | 28 | color_tmp[0] = (int)((color & 0xFF0000) >> 16) * 0.2; 29 | color_tmp[1] = (int)((color & 0x00FF00) >> 8) * 0.2; 30 | color_tmp[2] = (int)(color & 0x0000FF); 31 | return (((color_tmp[0] << 16) 32 | + (color_tmp[1] << 8) + color_tmp[2])); 33 | } 34 | 35 | int purple_filter(int color) 36 | { 37 | int color_tmp[3]; 38 | 39 | color_tmp[0] = (int)((color & 0xFF0000) >> 16); 40 | color_tmp[1] = (int)((color & 0x00FF00) >> 8) * 0.2; 41 | color_tmp[2] = (int)(color & 0x0000FF); 42 | return (((color_tmp[0] << 16) 43 | + (color_tmp[1] << 8) + color_tmp[2])); 44 | } 45 | 46 | int cyan_filter(int color) 47 | { 48 | int color_tmp[3]; 49 | 50 | color_tmp[0] = (int)((color & 0xFF0000) >> 16) * 0.2; 51 | color_tmp[1] = (int)((color & 0x00FF00) >> 8); 52 | color_tmp[2] = (int)(color & 0x0000FF); 53 | return (((color_tmp[0] << 16) 54 | + (color_tmp[1] << 8) + color_tmp[2])); 55 | } 56 | 57 | int grey_filter(int color) 58 | { 59 | int color_tmp[3]; 60 | 61 | color_tmp[0] = (int)((color & 0xFF0000) >> 16) * 0.2; 62 | color_tmp[1] = (int)((color & 0x00FF00) >> 8) * 0.2; 63 | color_tmp[2] = (int)(color & 0x0000FF) * 0.2; 64 | return (((color_tmp[0] << 16) 65 | + (color_tmp[1] << 8) + color_tmp[2])); 66 | } 67 | -------------------------------------------------------------------------------- /scene/domois_a.conf~: -------------------------------------------------------------------------------- 1 | |object | pos_x | pos_y | pos_z | rot_x | rot_y | rot_z | color | reflexion | opacity | brightness | radius | angle | limit | disturb_x | disturb_y | check_frequency | 2 | |************************************************************************************************************************************************************************| 3 | |eyes |-1000 |0 |0 |0 |0 |0 | |0 |0 |0 |0 |0 |0 |0 |0 |0 | 4 | |light |-1000 | 0 |0 |0 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 5 | |plan | 0 | 0 | 400 |0 |180 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 6 | |cylinder | 0 | 0 | -800 |0 |90 |0 |0xFF0000 |0.7 |0.5 |0 |500 |0 | 0 |0 |0 |0 | 7 | |plan | 0 | 400 | 0 |90 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 8 | |plan | 0 |-400 | 0 |270 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 9 | |************************************************************************************************************************************************************************| 10 | 11 | ############################################# 12 | * threads => 4 * 13 | * anti-aliasing => 1 * 14 | * aliasing => 1 * 15 | * ambiance_light => 0 * 16 | * filter => 0 * 17 | ############################################# 18 | -------------------------------------------------------------------------------- /src/reflexion_calc.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** reflexion_calc.c for reflexion_calc.c in /home/acca_b/Dropbox/EPITECH/Tek1/Raytracer/transparence 3 | ** 4 | ** Made by baptiste acca 5 | ** Login 6 | ** 7 | ** Started on Sat Jun 8 17:12:00 2013 baptiste acca 8 | ** Last update Sun Jun 9 15:57:09 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | static t_object_tab g_object_tab[6] = 14 | { 15 | {CONE_NB, &cone_luminosity}, 16 | {CYLINDER_NB, &cylinder_luminosity}, 17 | {SPHERE_NB, &sphere_luminosity}, 18 | {PLAN_NB, &plan_luminosity}, 19 | {PARABOLE_NB, ¶bole_luminosity}, 20 | {HYPERBOLE_NB, &hyperbole_luminosity}, 21 | }; 22 | 23 | void calc_norm_reflexion(t_rt *rt, t_vision *vision, 24 | t_coord *norm, t_object *inter) 25 | { 26 | int count; 27 | 28 | count = 0; 29 | while (count < 6 && 30 | inter->object_nb != g_object_tab[count].object_nb) 31 | count++; 32 | if (count < 6) 33 | g_object_tab[count].fct_lum(rt, vision, inter, norm); 34 | } 35 | 36 | void calc_next_eye_reflexion(t_rt *rt, t_vision *vision, 37 | t_eye *next_eye) 38 | { 39 | next_eye->coord.x = rt->k * vision->vector->x + vision->eye->coord.x; 40 | next_eye->coord.y = rt->k * vision->vector->y + vision->eye->coord.y; 41 | next_eye->coord.z = rt->k * vision->vector->z + vision->eye->coord.z; 42 | } 43 | 44 | void calc_reflected_vector(t_coord *vector_r, t_coord *norm, 45 | t_vision *vision) 46 | { 47 | double scal; 48 | 49 | scal = vision->vector->x * norm->x 50 | + vision->vector->y * norm->y + vision->vector->z * norm->z; 51 | vector_r->x = (-2 * norm->x * scal) + vision->vector->x; 52 | vector_r->y = (-2 * norm->y * scal) + vision->vector->y; 53 | vector_r->z = (-2 * norm->z * scal) + vision->vector->z; 54 | } 55 | 56 | t_vision assign_vision(t_coord *new_vector, t_eye *new_eye, 57 | t_coord *vector, t_eye *eye) 58 | { 59 | t_vision vision; 60 | 61 | vision.new_eye = new_eye; 62 | vision.new_vector = new_vector; 63 | vision.vector = vector; 64 | vision.eye = eye; 65 | return (vision); 66 | } 67 | -------------------------------------------------------------------------------- /src/get_backscreen.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** get_backscreen.c for rt in /home/chauch_a//texture 3 | ** 4 | ** Made by alan chauchet 5 | ** Login 6 | ** 7 | ** Started on Fri Jun 7 14:42:06 2013 alan chauchet 8 | ** Last update Fri Jun 7 23:09:39 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void recup_backscreen(t_rt *rt) 14 | { 15 | if (((rt->general_param.backscreen.img = mlx_xpm_file_to_image 16 | (rt->mlx_init.mlx_ptr, rt->general_param.backscreen.name, 17 | &(rt->general_param.backscreen.a), 18 | &(rt->general_param.backscreen.b))) == NULL) 19 | || ((rt->general_param.backscreen.data 20 | = (unsigned char *)mlx_get_data_addr 21 | (rt->general_param.backscreen.img, 22 | &(rt->general_param.backscreen.bpp), 23 | &(rt->general_param.backscreen.size_line), 24 | &(rt->general_param.backscreen.endian))) == NULL)) 25 | { 26 | rt->general_param.backscreen.name = NULL; 27 | my_puterror(BAD_SCREEN); 28 | } 29 | } 30 | 31 | void verif_if_xpm(t_rt *rt) 32 | { 33 | int count; 34 | int found; 35 | 36 | count = 0; 37 | found = 0; 38 | while (rt->general_param.backscreen.name[count] != '\0') 39 | { 40 | if (my_strncmp(&(rt->general_param.backscreen.name[count]), ".xpm", 4) 41 | == 0 && rt->general_param.backscreen.name[count + 4] == '\0') 42 | found = 1; 43 | count++; 44 | } 45 | if (found == 0) 46 | { 47 | rt->general_param.backscreen.name = NULL; 48 | my_puterror(BAD_SCREEN); 49 | } 50 | } 51 | 52 | int get_backscreen(char *nb, int line_nb, t_rt *rt) 53 | { 54 | (void)line_nb; 55 | rt->general_param.backscreen.name = my_strdup(nb, FALSE); 56 | if (rt->general_param.backscreen.name 57 | [my_strlen(rt->general_param.backscreen.name) - 1] == '*') 58 | rt->general_param.backscreen.name 59 | [my_strlen(rt->general_param.backscreen.name) - 1] = '\0'; 60 | if (my_strncmp(rt->general_param.backscreen.name, "NULL", 4) == 0) 61 | { 62 | rt->general_param.backscreen.name = NULL; 63 | return (EXIT_SUCCESS); 64 | } 65 | verif_if_xpm(rt); 66 | return (EXIT_SUCCESS); 67 | } 68 | -------------------------------------------------------------------------------- /scenes_obligatoires/scene_5.conf: -------------------------------------------------------------------------------- 1 | |object | pos_x | pos_y | pos_z | rot_x | rot_y | rot_z | color | reflexion | opacity | brightness | radius | angle | limit | disturb_x | disturb_y | check_frequency | 2 | |*************************************************************************************************************************************************************************| 3 | |eyes |-1000 |0 |5 |0 |0 |0 | |0 |0 |0 |0 |0 |0 |0 |0 |0 | 4 | |light |-960 | 0 | 40 |0 |0 |0 |0x000000 |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 5 | |light |-950 | 15 | 40 |0 |0 |0 |0x000000 |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 6 | |light |-980 | 15 | 40 |0 |0 |0 |0x000000 |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 7 | |light | -960 | -20 | 5 |0 |0 |0 |0x000000 |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 8 | |plan | 0 | 0 | 0 |0 |0 |0 |0x226622 |0 |0 |0 |100 |0 | 0 |0 |0 |0 | 9 | |sphere | -970 | -3 | 7 |0 | 0 |0 |0x553333 |0 |0 |0 |3 |0 | 0 |0 |0 |0 | 10 | |*************************************************************************************************************************************************************************| 11 | 12 | ############################################# 13 | * threads => 4 * 14 | * anti-aliasing => 1 * 15 | * ambiance_light => 0 * 16 | * filter => 0 * 17 | ############################################# 18 | -------------------------------------------------------------------------------- /src/antialiasing.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** antialiasing.c for antialiasing.c in /home/loeb_t/Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by thomas loeb 5 | ** Login 6 | ** 7 | ** Started on Mon May 27 14:06:08 2013 thomas loeb 8 | ** Last update Sat Jun 8 05:57:43 2013 franck abgrall 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | char calc_average(t_rt *rt, int x, int y, int nb) 14 | { 15 | double average; 16 | int count_x; 17 | int count_y; 18 | 19 | average = 0; 20 | count_y = 0; 21 | while (count_y != rt->general_param.anti_aliasing) 22 | { 23 | count_x = 0; 24 | while (count_x != rt->general_param.anti_aliasing) 25 | { 26 | if (x * 4 * rt->general_param.anti_aliasing + count_x * 4 + y 27 | * rt->size.size_x * 4 * rt->general_param.anti_aliasing 28 | + count_y * rt->size.size_x * 4 29 | + nb < rt->size.size_x * rt->size.size_y * 4) 30 | average += rt->mlx_init.data[x * 4 * rt->general_param.anti_aliasing 31 | + count_x * 4 + y * rt->size.size_x * 32 | 4 * rt->general_param.anti_aliasing 33 | + count_y * rt->size.size_x * 4 + nb]; 34 | count_x++; 35 | } 36 | count_y++; 37 | } 38 | average /= rt->general_param.anti_aliasing * rt->general_param.anti_aliasing; 39 | return ((unsigned char)average); 40 | } 41 | 42 | int antialiasing(t_rt *rt) 43 | { 44 | int real_size_x; 45 | int real_size_y; 46 | int x; 47 | int y; 48 | 49 | real_size_x = rt->size.size_x / rt->general_param.anti_aliasing; 50 | real_size_y = rt->size.size_y / rt->general_param.anti_aliasing; 51 | y = 0; 52 | while (y < real_size_y) 53 | { 54 | x = 0; 55 | while (x < real_size_x) 56 | { 57 | rt->mlx_init.data_resize[x * 4 + y * real_size_x 58 | * 4] = calc_average(rt, x, y, 0); 59 | rt->mlx_init.data_resize[x * 4 + y * real_size_x 60 | * 4 + 1] = calc_average(rt, x, y, 1); 61 | rt->mlx_init.data_resize[x * 4 + y * real_size_x 62 | * 4 + 2] = calc_average(rt, x, y, 2); 63 | x++; 64 | } 65 | y++; 66 | } 67 | return (EXIT_SUCCESS); 68 | } 69 | -------------------------------------------------------------------------------- /src/cylinder.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** cylinder.c for rt in /home/acca_b/Dropbox/EPITECH/Tek1/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by baptiste acca 5 | ** Login 6 | ** 7 | ** Started on Thu May 16 15:05:43 2013 baptiste acca 8 | 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void cylinder_luminosity(t_rt *rt, 14 | t_vision *vision, 15 | t_object *object, 16 | t_coord *norm) 17 | { 18 | t_coord coord; 19 | 20 | if (rt->negative == 0) 21 | { 22 | coord.x = (rt->k * vision->new_vector->x 23 | + vision->new_eye->coord.x); 24 | coord.y = (rt->k * vision->new_vector->y 25 | + vision->new_eye->coord.y); 26 | } 27 | else 28 | { 29 | coord.x = - (rt->k * vision->new_vector->x 30 | + vision->new_eye->coord.x); 31 | coord.y = - (rt->k * vision->new_vector->y 32 | + vision->new_eye->coord.y); 33 | } 34 | coord.z = 0; 35 | norm->x = matrice_rotate_x(rt, &coord, object, 1); 36 | norm->y = matrice_rotate_y(rt, &coord, object, 1); 37 | norm->z = matrice_rotate_z(rt, &coord, object, 1); 38 | if (object->effects.disturb_x > 1 || object->effects.disturb_y > 1) 39 | normal_perturbation(rt, object, vision, norm); 40 | } 41 | 42 | double inter_cylinder(t_rt *rt, 43 | t_negative *negative) 44 | { 45 | double a; 46 | double b; 47 | double c; 48 | double delta; 49 | double ret; 50 | 51 | a = pow(negative->vector->x, 2) + pow(negative->vector->y, 2); 52 | b = 2 * (negative->eye->coord.x * negative->vector->x 53 | + negative->eye->coord.y * negative->vector->y); 54 | c = pow(negative->eye->coord.x, 2) + pow(negative->eye->coord.y, 2) 55 | - pow(negative->object->param, 2); 56 | if ((delta = pow(b, 2) - (4 * a * c)) >= 0) 57 | { 58 | ret = (- b - sqrt(delta)) / (2 * a); 59 | if (rt->negative == 2) 60 | ret = (- b + sqrt(delta)) / (2 * a); 61 | if (rt->negative == 0) 62 | return (negative_object(rt, ret, (- b + sqrt(delta)) / (2 * a), 63 | negative)); 64 | return (ret); 65 | } 66 | return (-1); 67 | } 68 | -------------------------------------------------------------------------------- /src/parabole.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** parabole.c for parabole.c in /home/loeb_t/Dropbox/Raytracer/transparence/src 3 | ** 4 | ** Made by thomas loeb 5 | ** Login 6 | ** 7 | ** Started on Fri Jun 7 11:35:30 2013 thomas loeb 8 | ** Last update Sun Jun 9 16:02:51 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void parabole_luminosity(t_rt *rt, t_vision *vision, 14 | t_object *object, t_coord *norm) 15 | { 16 | t_coord coord; 17 | 18 | if (rt->negative == 0) 19 | { 20 | coord.x = (rt->k * vision->new_vector->x + vision->new_eye->coord.x); 21 | coord.y = (rt->k * vision->new_vector->y + vision->new_eye->coord.y); 22 | coord.z = (- object->param); 23 | } 24 | else 25 | { 26 | coord.x = - (rt->k * vision->new_vector->x + vision->new_eye->coord.x); 27 | coord.y = - (rt->k * vision->new_vector->y + vision->new_eye->coord.y); 28 | coord.z = - (- object->param); 29 | } 30 | norm->x = matrice_rotate_x(rt, &coord, object, 1); 31 | norm->y = matrice_rotate_y(rt, &coord, object, 1); 32 | norm->z = matrice_rotate_z(rt, &coord, object, 1); 33 | if (object->effects.disturb_x > 1 || object->effects.disturb_y > 1) 34 | normal_perturbation(rt, object, vision, norm); 35 | } 36 | 37 | double inter_parabole(t_rt *rt, 38 | t_negative *negative) 39 | { 40 | double a; 41 | double b; 42 | double c; 43 | double delta; 44 | double ret; 45 | 46 | a = pow(negative->vector->x, 2) + pow(negative->vector->y, 2); 47 | b = 2 * (negative->eye->coord.x * negative->vector->x 48 | + negative->eye->coord.y * negative->vector->y) 49 | - negative->object->param * negative->vector->z; 50 | c = pow(negative->eye->coord.x, 2) + pow(negative->eye->coord.y, 2) 51 | - negative->object->param * negative->eye->coord.z; 52 | if ((delta = pow(b, 2) - (4 * a * c)) >= 0) 53 | { 54 | ret = (- b - sqrt(delta)) / (2 * a); 55 | if (rt->negative == 2) 56 | ret = (- b + sqrt(delta)) / (2 * a); 57 | if (rt->negative == 0) 58 | return (negative_object(rt, ret, (- b + sqrt(delta)) / (2 * a), 59 | negative)); 60 | return (ret); 61 | } 62 | return (-1); 63 | } 64 | -------------------------------------------------------------------------------- /src/cpy_light_list.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** cpy_light_list.c for cpy_light_list.c in /home/abgral_f//Projetsave/rt3/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Mon May 27 13:16:54 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:09:42 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | static void fill_light_cpy(t_light *cpy, t_light *ref) 14 | { 15 | cpy->coord.x = ref->coord.x; 16 | cpy->coord.y = ref->coord.y; 17 | cpy->coord.z = ref->coord.z; 18 | cpy->intensity = ref->intensity; 19 | cpy->color = ref->color; 20 | } 21 | 22 | static int add_first_light_cpy(t_rt *cpy, t_rt *rt) 23 | { 24 | t_light *new; 25 | 26 | if ((new = malloc(sizeof(*new))) == NULL) 27 | return (my_puterror(MALLOC_ERROR)); 28 | cpy->first_light = new; 29 | cpy->last_light = new; 30 | new->next = NULL; 31 | fill_light_cpy(new, rt->first_light); 32 | return (EXIT_SUCCESS); 33 | } 34 | 35 | static int add_other_light_cpy(t_rt *cpy, t_rt *rt) 36 | { 37 | t_light *new; 38 | t_light *tmp_cpy; 39 | t_light *tmp; 40 | 41 | if ((new = malloc(sizeof(*new))) == NULL) 42 | return (my_puterror(MALLOC_ERROR)); 43 | tmp = rt->first_light; 44 | tmp_cpy = cpy->first_light; 45 | while (tmp_cpy->next != NULL) 46 | { 47 | tmp_cpy = tmp_cpy->next; 48 | tmp = tmp->next; 49 | } 50 | tmp = tmp->next; 51 | cpy->last_light = new; 52 | tmp_cpy->next = new; 53 | new->next = NULL; 54 | fill_light_cpy(new, tmp); 55 | return (EXIT_SUCCESS); 56 | } 57 | 58 | static int add_light_cpy(t_rt *cpy, t_rt *rt) 59 | { 60 | if (cpy->first_light == NULL) 61 | { 62 | if (add_first_light_cpy(cpy, rt) == EXIT_FAILURE) 63 | return (EXIT_FAILURE); 64 | } 65 | else 66 | if (add_other_light_cpy(cpy, rt) == EXIT_FAILURE) 67 | return (EXIT_FAILURE); 68 | return (EXIT_SUCCESS); 69 | } 70 | 71 | int cpy_light_list(t_rt *cpy, t_rt *rt) 72 | { 73 | t_light *tmp; 74 | 75 | tmp = rt->first_light; 76 | while (tmp != NULL) 77 | { 78 | if (add_light_cpy(cpy, rt) == EXIT_FAILURE) 79 | return (EXIT_FAILURE); 80 | tmp = tmp->next; 81 | } 82 | return (EXIT_SUCCESS); 83 | } 84 | -------------------------------------------------------------------------------- /src/sphere.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** sphere.c for rt in /home/acca_b/Dropbox/EPITECH/Tek1/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by baptiste acca 5 | ** Login 6 | ** 7 | ** Started on Thu May 16 14:50:22 2013 baptiste acca 8 | ** Last update Sun Jun 9 14:28:47 2013 thomas loeb 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void sphere_luminosity(t_rt *rt, t_vision *vision, 14 | t_object *object, t_coord *norm) 15 | { 16 | if (rt->negative == 0) 17 | { 18 | norm->x = ((rt->k * vision->vector->x + vision->eye->coord.x) 19 | - object->coord.x); 20 | norm->y = ((rt->k * vision->vector->y + vision->eye->coord.y) 21 | - object->coord.y); 22 | norm->z = ((rt->k * vision->vector->z + vision->eye->coord.z) 23 | - object->coord.z); 24 | } 25 | else 26 | { 27 | norm->x = - ((rt->k * vision->vector->x + vision->eye->coord.x) 28 | - object->coord.x); 29 | norm->y = - ((rt->k * vision->vector->y + vision->eye->coord.y) 30 | - object->coord.y); 31 | norm->z = - ((rt->k * vision->vector->z + vision->eye->coord.z) 32 | - object->coord.z); 33 | } 34 | if (object->effects.disturb_x > 1 || object->effects.disturb_y > 1) 35 | normal_perturbation(rt, object, vision, norm); 36 | } 37 | 38 | double inter_sphere(t_rt *rt, t_negative *negative) 39 | { 40 | double a; 41 | double b; 42 | double c; 43 | double delta; 44 | double ret; 45 | 46 | a = pow(negative->vector->x, 2) 47 | + pow(negative->vector->y, 2) + pow(negative->vector->z, 2); 48 | b = 2 * (negative->eye->coord.x * negative->vector->x 49 | + negative->eye->coord.y * negative->vector->y 50 | + negative->eye->coord.z * negative->vector->z); 51 | c = (pow(negative->eye->coord.x, 2) + pow(negative->eye->coord.y, 2) 52 | + pow(negative->eye->coord.z, 2) - pow(negative->object->param, 2)); 53 | if ((delta = pow(b, 2) - (4 * a * c)) >= 0) 54 | { 55 | ret = (- b - sqrt(delta)) / (2 * a); 56 | if (rt->negative == 2) 57 | ret = (- b + sqrt(delta)) / (2 * a); 58 | if (rt->negative == 0) 59 | return (negative_object(rt, ret, (- b + sqrt(delta)) / (2 * a), 60 | negative)); 61 | return (ret); 62 | } 63 | return (-1); 64 | } 65 | -------------------------------------------------------------------------------- /src/fill_struct_tab.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** fill_struct_tab.c for fill_strcut_tab.c in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Wed May 1 13:57:49 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:29:08 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | static t_cmp struct_tab[] = 14 | { 15 | {EYES, FALSE, EYES_NB}, 16 | {LIGHT, FALSE, LIGHT_NB}, 17 | {CONE, FALSE, CONE_NB}, 18 | {PLAN, FALSE, PLAN_NB}, 19 | {CYLINDER, FALSE, CYLINDER_NB}, 20 | {SPHERE, FALSE, SPHERE_NB}, 21 | {PARABOLE, FALSE, PARABOLE_NB}, 22 | {HYPERBOLE, FALSE, HYPERBOLE_NB}, 23 | {NULL, FALSE, 0} 24 | }; 25 | 26 | int get_object_column_number(int *ref_tab) 27 | { 28 | int count; 29 | 30 | count = 0; 31 | while (count < SIZE_TAB) 32 | { 33 | if (ref_tab[count] == OBJECT_NB) 34 | return (count + 1); 35 | count++; 36 | } 37 | return (EXIT_SUCCESS); 38 | } 39 | 40 | int check_object_name_existence(t_list *list, int column_nb) 41 | { 42 | int count; 43 | int count_char; 44 | int count_tab; 45 | 46 | count = 0; 47 | count_char = -1; 48 | while (count != column_nb && list->line[++count_char] != '\0') 49 | if (list->line[count_char] == SEPARATOR) 50 | { 51 | count++; 52 | if (count == column_nb) 53 | { 54 | count_tab = -1; 55 | while (++count_tab != SIZE_STRUCT_TAB) 56 | if (my_strcmp_parser(&(list->line[count_char + 1]), 57 | struct_tab[count_tab].name) == 0) 58 | return (struct_tab[count_tab].nb_ref); 59 | my_puterror(WRONG_OBJECT); 60 | my_putnbr(list->line_nb); 61 | return (-1); 62 | } 63 | } 64 | return (-1); 65 | } 66 | 67 | int fill_struct_tab(t_list *list, t_rt *rt) 68 | { 69 | int column_nb; 70 | int object_nb; 71 | 72 | if (list->next != NULL) 73 | list = list->next; 74 | rt->first_line = list; 75 | column_nb = get_object_column_number(rt->ref_tab); 76 | while (list != NULL) 77 | { 78 | if ((object_nb = check_object_name_existence(list, column_nb)) 79 | == -1) 80 | return (EXIT_FAILURE); 81 | if (redirect_appropriate_function(object_nb, list, rt) == EXIT_FAILURE) 82 | return (EXIT_FAILURE); 83 | list = list->next; 84 | } 85 | return (EXIT_SUCCESS); 86 | } 87 | -------------------------------------------------------------------------------- /src/apply_filter1.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** apply_filter1.c for apply_filter1.c in /home/acca_b/Dropbox/EPITECH/Tek1/Raytracer/transparence 3 | ** 4 | ** Made by baptiste acca 5 | ** Login 6 | ** 7 | ** Started on Sat Jun 8 14:22:57 2013 baptiste acca 8 | ** Last update Sat Jun 8 14:33:11 2013 baptiste acca 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int negativ_filter(int color) 14 | { 15 | return (0xFFFFFF - color); 16 | } 17 | 18 | int mix_filter(int color) 19 | { 20 | if (0xFFFFFF - color > 0x000000 - color) 21 | return (color * 0.2); 22 | else 23 | return (color * 0.8); 24 | } 25 | 26 | int sepia_filter(int color) 27 | { 28 | int color_tmp[3]; 29 | int final_color[3]; 30 | 31 | color_tmp[0] = (int)((color & 0xFF0000) >> 16); 32 | color_tmp[1] = (int)((color & 0x00FF00) >> 8); 33 | color_tmp[2] = (int)(color & 0x0000FF); 34 | final_color[0] = (int)(((double)color_tmp[0] * 0.393) 35 | + ((double)color_tmp[1] * 0.769) 36 | + ((double)color_tmp[2] * 0.189)); 37 | final_color[1] = (int)(((double)color_tmp[0] * 0.349) 38 | + ((double)color_tmp[1] * 0.686) 39 | + ((double)color_tmp[2] * 0.168)); 40 | final_color[2] = (int)(((double)color_tmp[0] * 0.272) 41 | + ((double)color_tmp[1] * 0.534) 42 | + ((double)color_tmp[2] * 0.131)); 43 | if (final_color[0] > 255) 44 | final_color[0] = 255; 45 | if (final_color[1] > 255) 46 | final_color[1] = 255; 47 | if (final_color[2] > 255) 48 | final_color[2] = 255; 49 | return (((final_color[0] << 16) 50 | + (final_color[1] << 8) + final_color[2])); 51 | } 52 | 53 | int black_white_filter(int color) 54 | { 55 | int grey_color; 56 | int color_tmp[3]; 57 | 58 | color_tmp[0] = (int)((color & 0xFF0000) >> 16); 59 | color_tmp[1] = (int)((color & 0x00FF00) >> 8); 60 | color_tmp[2] = (int)(color & 0x0000FF); 61 | grey_color = (int)(((double)color_tmp[0]) 62 | + ((double)color_tmp[1]) 63 | + ((double)color_tmp[2])); 64 | if (grey_color > 255) 65 | grey_color = 255; 66 | return (((grey_color << 16) 67 | + (grey_color << 8) + grey_color)); 68 | } 69 | 70 | int red_filter(int color) 71 | { 72 | int color_tmp[3]; 73 | 74 | color_tmp[0] = (int)((color & 0xFF0000) >> 16); 75 | color_tmp[1] = (int)((color & 0x00FF00) >> 8) * 0.2; 76 | color_tmp[2] = (int)(color & 0x0000FF) * 0.2; 77 | return (((color_tmp[0] << 16) 78 | + (color_tmp[1] << 8) + color_tmp[2])); 79 | } 80 | -------------------------------------------------------------------------------- /src/cone.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** cone.c for rt in /home/acca_b/Dropbox/EPITECH/Tek1/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by baptiste acca 5 | ** Login 6 | ** 7 | ** Started on Thu May 16 15:26:14 2013 baptiste acca 8 | ** Last update Sun Jun 9 14:29:23 2013 thomas loeb 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void cone_luminosity(t_rt *rt, t_vision *vision, 14 | t_object *object, t_coord *norm) 15 | { 16 | t_coord coord; 17 | 18 | if (rt->negative == 0) 19 | { 20 | coord.x = (rt->k * vision->new_vector->x + vision->new_eye->coord.x); 21 | coord.y = (rt->k * vision->new_vector->y + vision->new_eye->coord.y); 22 | coord.z = ((- RAD(object->param)) * 23 | (rt->k * vision->new_vector->z + vision->new_eye->coord.z)); 24 | } 25 | else 26 | { 27 | coord.x = - (rt->k * vision->new_vector->x + vision->new_eye->coord.x); 28 | coord.y = - (rt->k * vision->new_vector->y + vision->new_eye->coord.y); 29 | coord.z = - ((- RAD(object->param)) * 30 | (rt->k * vision->new_vector->z + vision->new_eye->coord.z)); 31 | } 32 | norm->x = matrice_rotate_x(rt, &coord, object, 1); 33 | norm->y = matrice_rotate_y(rt, &coord, object, 1); 34 | norm->z = matrice_rotate_z(rt, &coord, object, 1); 35 | if (object->effects.disturb_x > 1 || object->effects.disturb_y > 1) 36 | normal_perturbation(rt, object, vision, norm); 37 | } 38 | 39 | double inter_cone(t_rt *rt, 40 | t_negative *neg) 41 | { 42 | double a; 43 | double b; 44 | double c; 45 | double delta; 46 | double ret; 47 | 48 | a = pow(neg->vector->x, 2) + pow(neg->vector->y, 2) 49 | - pow(tan(RAD(neg->object->param)), 2) * pow(neg->vector->z, 2); 50 | b = 2 * (neg->eye->coord.x * neg->vector->x 51 | + neg->eye->coord.y * neg->vector->y 52 | - pow(tan(RAD(neg->object->param)), 2) 53 | * (neg->eye->coord.z * neg->vector->z)); 54 | c = pow(neg->eye->coord.x, 2) + pow(neg->eye->coord.y, 2) 55 | - pow(tan(RAD(neg->object->param)), 2) * pow(neg->eye->coord.z, 2); 56 | if ((delta = pow(b, 2) - (4 * a * c)) >= 0) 57 | { 58 | ret = (- b - sqrt(delta)) / (2 * a); 59 | if (rt->negative == 2) 60 | ret = (- b + sqrt(delta)) / (2 * a); 61 | if (rt->negative == 0) 62 | return (negative_object(rt, ret, (- b + sqrt(delta)) / (2 * a), neg)); 63 | return (ret); 64 | } 65 | return (-1); 66 | } 67 | -------------------------------------------------------------------------------- /src/aff_loading.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** aff_loading.c<2> for rt in /home/acca_b/Dropbox/EPITECH/Tek1/rtv1/src/raytracing 3 | ** 4 | ** Made by baptiste acca 5 | ** Login 6 | ** 7 | ** Started on Thu May 16 11:06:50 2013 baptiste acca 8 | ** Last update Sun Jun 9 18:15:22 2013 adrien domoison 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void aff_text(t_rt *rt) 14 | { 15 | mlx_string_put(rt->mlx_init.mlx_ptr, rt->mlx_init.win_ptr, 16 | rt->size.win_x / 2 - 50, 17 | rt->size.win_y / 2 - 50, 18 | 0xFFFFFF, "Loading, please wait"); 19 | mlx_string_put(rt->mlx_init.mlx_ptr, rt->mlx_init.win_ptr, 20 | rt->size.win_x - 400, 21 | rt->size.win_y - 50, 22 | 0xFFFFFF, 23 | "abgral_f - acca_b - chanut_g - chauch_a - domois_a - loeb_t"); 24 | } 25 | 26 | void aff_vertical_bar(t_rt *rt) 27 | { 28 | int x; 29 | int y; 30 | 31 | y = -6; 32 | while (y <= 6) 33 | { 34 | x = (rt->size.win_x / 4) - 1; 35 | while (x <= (rt->size.win_x / 4) + 1) 36 | { 37 | mlx_pixel_put(rt->mlx_init.mlx_ptr, rt->mlx_init.win_ptr, 38 | x, rt->size.win_y / 2 - y, 39 | 0x00820F); 40 | mlx_pixel_put(rt->mlx_init.mlx_ptr, rt->mlx_init.win_ptr, 41 | x + (rt->size.win_x / 4 * 2), rt->size.win_y / 2 - y, 42 | 0x00820F); 43 | x++; 44 | } 45 | y++; 46 | } 47 | } 48 | 49 | void aff_horizontal_bar(t_rt *rt) 50 | { 51 | int x; 52 | int y; 53 | 54 | x = (rt->size.win_x / 4); 55 | while (x <= rt->size.win_x / 4 * 3) 56 | { 57 | y = -1; 58 | while (y <= 1) 59 | { 60 | mlx_pixel_put(rt->mlx_init.mlx_ptr, rt->mlx_init.win_ptr, 61 | x, rt->size.win_y / 2 - 6 - y, 0x00820F); 62 | mlx_pixel_put(rt->mlx_init.mlx_ptr, rt->mlx_init.win_ptr, 63 | x, rt->size.win_y / 2 + 6 - y, 0x00820F); 64 | y++; 65 | } 66 | x++; 67 | } 68 | } 69 | 70 | void aff_load_bar(t_rt *rt) 71 | { 72 | clear_img(rt); 73 | aff_text(rt); 74 | aff_vertical_bar(rt); 75 | aff_horizontal_bar(rt); 76 | } 77 | 78 | void aff_loading(t_rt *rt, int pos, int max, int color) 79 | { 80 | int coef; 81 | 82 | coef = ((rt->size.win_x / 4 * 3) - 3) - ((rt->size.win_x / 4) + 3); 83 | if ((coef * pos / max) + ((rt->size.win_x / 4) + 3) > 84 | (coef * (pos - 1) / max) + ((rt->size.win_x / 4) + 3)) 85 | mlx_pixel_put(rt->mlx_init.mlx_ptr, 86 | rt->mlx_init.win_ptr, 87 | (coef * pos / max) + ((rt->size.win_x / 4) + 3), 88 | rt->size.win_y / 2, color); 89 | } 90 | -------------------------------------------------------------------------------- /src/matrice_rotate.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** matrice_rotate.c for rt in /home/chauch_a//Dropbox/Raytracer/raytracer-2017-chanut_g 3 | ** 4 | ** Made by alan chauchet 5 | ** Login 6 | ** 7 | ** Started on Thu May 16 15:18:15 2013 alan chauchet 8 | ** Last update Fri May 31 17:19:44 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | double matrice_rotate_x(t_rt *rt, t_coord *coord, 14 | t_object *object, int mat_val) 15 | { 16 | return (rt->cosinus[ANG(mat_val * object->rotate.rz)] 17 | * rt->cosinus[ANG(mat_val * object->rotate.ry)] 18 | * coord->x 19 | - rt->sinus[ANG(mat_val * object->rotate.rz)] 20 | * coord->y 21 | + rt->cosinus[ANG(mat_val * object->rotate.rz)] 22 | * rt->sinus[ANG(mat_val * object->rotate.ry)] 23 | * coord->z); 24 | } 25 | 26 | double matrice_rotate_y(t_rt *rt, t_coord *coord, 27 | t_object *object, int mat_val) 28 | { 29 | return ((rt->cosinus[ANG(mat_val * object->rotate.rx)] 30 | * rt->sinus[ANG(mat_val * object->rotate.rz)] 31 | * rt->cosinus[ANG(mat_val * object->rotate.ry)] 32 | + rt->sinus[ANG(mat_val * object->rotate.rx)] 33 | * rt->sinus[ANG(mat_val * object->rotate.ry)]) 34 | * coord->x 35 | + rt->cosinus[ANG(mat_val * object->rotate.rx)] 36 | * rt->cosinus[ANG(mat_val * object->rotate.rz)] 37 | * coord->y 38 | + (rt->cosinus[ANG(mat_val * object->rotate.rx)] 39 | * rt->sinus[ANG(mat_val * object->rotate.rz)] 40 | * rt->sinus[ANG(mat_val * object->rotate.ry)] 41 | - rt->sinus[ANG(mat_val * object->rotate.rx)] 42 | * rt->cosinus[ANG(mat_val * object->rotate.ry)]) 43 | * coord->z); 44 | } 45 | 46 | double matrice_rotate_z(t_rt *rt, t_coord *coord, 47 | t_object *object, int mat_val) 48 | { 49 | return ((rt->sinus[ANG(mat_val * object->rotate.rx)] 50 | * rt->sinus[ANG(mat_val * object->rotate.rz)] 51 | * rt->cosinus[ANG(mat_val * object->rotate.ry)] 52 | - rt->cosinus[ANG(mat_val * object->rotate.rx)] 53 | * rt->sinus[ANG(mat_val * object->rotate.ry)]) 54 | * coord->x 55 | + rt->sinus[ANG(mat_val * object->rotate.rx)] 56 | * rt->cosinus[ANG(mat_val * object->rotate.rz)] 57 | * coord->y 58 | + (rt->sinus[ANG(mat_val * object->rotate.rx)] 59 | * rt->sinus[ANG(mat_val * object->rotate.rz)] 60 | * rt->sinus[ANG(mat_val * object->rotate.ry)] 61 | + rt->cosinus[ANG(mat_val * object->rotate.rx)] 62 | * rt->cosinus[ANG(mat_val * object->rotate.ry)]) 63 | * coord->z); 64 | } 65 | -------------------------------------------------------------------------------- /src/check_right_name.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** check_right_name.c for check_right_name.c in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Tue Apr 30 23:00:20 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:10:33 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | static t_cmp struct_tab[] = 14 | { 15 | {OBJECT, FALSE, OBJECT_NB}, 16 | {POSX, FALSE, POSX_NB}, 17 | {POSY, FALSE, POSY_NB}, 18 | {POSZ, FALSE, POSZ_NB}, 19 | {ROTX, FALSE, ROTX_NB}, 20 | {ROTY, FALSE, ROTY_NB}, 21 | {ROTZ, FALSE, ROTZ_NB}, 22 | {COLOR, FALSE, COLOR_NB}, 23 | {REFLEXION, FALSE, REFLEXION_NB}, 24 | {OPACITY, FALSE, OPACITY_NB}, 25 | {BRIGHTNESS, FALSE, BRIGHTNESS_NB}, 26 | {RADIUS, FALSE, RADIUS_NB}, 27 | {ANGLE, FALSE, ANGLE_NB}, 28 | {LIMIT, FALSE, LIMIT_NB}, 29 | {DISTURB_X, FALSE, DISTURB_X_NB}, 30 | {DISTURB_Y, FALSE, DISTURB_Y_NB}, 31 | {CHECK_FREQUENCY, FALSE, CHECK_FREQUENCY_NB}, 32 | {NULL, FALSE, 0} 33 | }; 34 | 35 | int compare_name(char *str, int ref_tab[SIZE_TAB]) 36 | { 37 | int count; 38 | int count_two; 39 | 40 | count = 0; 41 | while (struct_tab[count].name != NULL) 42 | { 43 | if (my_strcmp_parser(str, struct_tab[count].name) == 0 44 | && struct_tab[count].visited == FALSE) 45 | { 46 | count_two = 0; 47 | while (ref_tab[count_two] != 0) 48 | count_two++; 49 | ref_tab[count_two] = struct_tab[count].nb_ref; 50 | struct_tab[count].visited = TRUE; 51 | return (EXIT_SUCCESS); 52 | } 53 | if (my_strcmp_parser(str, struct_tab[count].name) == 0 54 | && struct_tab[count].visited == TRUE) 55 | return (my_puterror(TWICE_NAME_USE)); 56 | count++; 57 | } 58 | return (my_puterror(BAD_NAME)); 59 | } 60 | 61 | int check_right_name(char *line, int ref_tab[SIZE_TAB]) 62 | { 63 | int count; 64 | 65 | count = 0; 66 | while (line[count] != '\0') 67 | { 68 | if (line[count] != SEPARATOR) 69 | { 70 | if (compare_name(&line[count], ref_tab) == EXIT_FAILURE) 71 | return (EXIT_FAILURE); 72 | else 73 | { 74 | while (line[count] != SEPARATOR && line[count] != '\0') 75 | count++; 76 | if (line[count] == '\0') 77 | count--; 78 | } 79 | } 80 | count++; 81 | } 82 | return (EXIT_SUCCESS); 83 | } 84 | -------------------------------------------------------------------------------- /src/hyperbole.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** hyperbole.c for hyperbole.c in /home/loeb_t/Dropbox/Raytracer/transparence/src 3 | ** 4 | ** Made by thomas loeb 5 | ** Login 6 | ** 7 | ** Started on Fri Jun 7 16:33:05 2013 thomas loeb 8 | ** Last update Sun Jun 9 14:27:34 2013 thomas loeb 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void hyperbole_luminosity(t_rt *rt, t_vision *vision, 14 | t_object *object, t_coord *norm) 15 | { 16 | t_coord coord; 17 | 18 | if (rt->negative == 0) 19 | { 20 | coord.x = (rt->k * vision->new_vector->x + vision->new_eye->coord.x); 21 | coord.y = (rt->k * vision->new_vector->y + vision->new_eye->coord.y); 22 | coord.z = ((- RAD(object->param)) * 23 | (rt->k * vision->new_vector->z + vision->new_eye->coord.z)); 24 | } 25 | else 26 | { 27 | coord.x = - (rt->k * vision->new_vector->x + vision->new_eye->coord.x); 28 | coord.y = - (rt->k * vision->new_vector->y + vision->new_eye->coord.y); 29 | coord.z = - ((- RAD(object->param)) * 30 | (rt->k * vision->new_vector->z + vision->new_eye->coord.z)); 31 | } 32 | norm->x = matrice_rotate_x(rt, &coord, object, 1); 33 | norm->y = matrice_rotate_y(rt, &coord, object, 1); 34 | norm->z = matrice_rotate_z(rt, &coord, object, 1); 35 | if (object->effects.disturb_x > 1 || object->effects.disturb_y > 1) 36 | normal_perturbation(rt, object, vision, norm); 37 | } 38 | 39 | double inter_hyperbole(t_rt *rt, 40 | t_negative *neg) 41 | { 42 | double a; 43 | double b; 44 | double c; 45 | double delta; 46 | double ret; 47 | 48 | a = pow(neg->vector->x, 2) + pow(neg->vector->y, 2) 49 | - pow(tan(RAD(neg->object->param)), 2) * pow(neg->vector->z, 2); 50 | b = 2 * (neg->eye->coord.x * neg->vector->x 51 | + neg->eye->coord.y * neg->vector->y 52 | - pow(tan(RAD(neg->object->param)), 2) 53 | * (neg->eye->coord.z * neg->vector->z)); 54 | c = pow(neg->eye->coord.x, 2) + pow(neg->eye->coord.y, 2) 55 | - pow(tan(RAD(neg->object->param)), 2) 56 | * pow(neg->eye->coord.z, 2) - neg->object->radius; 57 | if ((delta = pow(b, 2) - (4 * a * c)) >= 0) 58 | { 59 | ret = (- b - sqrt(delta)) / (2 * a); 60 | if (rt->negative == 2) 61 | ret = (- b + sqrt(delta)) / (2 * a); 62 | if (rt->negative == 0) 63 | return (negative_object(rt, ret, (- b + sqrt(delta)) / (2 * a), neg)); 64 | return (ret); 65 | } 66 | return (-1); 67 | } 68 | -------------------------------------------------------------------------------- /src/transparency.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** transparency.c for transparency.c in /home/acca_b/Dropbox/EPITECH/Tek1/Raytracer/transparence/src 3 | ** 4 | ** Made by baptiste acca 5 | ** Login 6 | ** 7 | ** Started on Mon May 27 16:51:41 2013 baptiste acca 8 | ** Last update Sun Jun 9 18:25:48 2013 franck abgrall 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void add_transp_tab(t_rt *rt, t_object *object) 14 | { 15 | int count; 16 | t_object **new_tab; 17 | 18 | if ((new_tab = malloc(sizeof(t_object*) * 19 | (rt->transp.size_tab + 1))) == NULL) 20 | exit(my_puterror(MALLOC_ERROR)); 21 | count = 0; 22 | while (count < rt->transp.size_tab - 1) 23 | { 24 | new_tab[count] = rt->transp.inter[count]; 25 | count++; 26 | } 27 | new_tab[count] = object; 28 | new_tab[count + 1] = NULL; 29 | free(rt->transp.inter); 30 | rt->transp.inter = new_tab; 31 | } 32 | 33 | void transparency_color(int first_color[3], int new_color[3], 34 | int new_obj, t_object *inter) 35 | { 36 | new_color[0] = (int)((new_obj & 0xFF0000) >> 16); 37 | new_color[1] = (int)((new_obj & 0x00FF00) >> 8); 38 | new_color[2] = (int)(new_obj & 0x0000FF); 39 | first_color[0] = new_color[0] * inter->effects.opacity 40 | + first_color[0] * (1 - inter->effects.opacity); 41 | if (first_color[0] > 255) 42 | first_color[0] = 255; 43 | first_color[1] = new_color[1] * inter->effects.opacity 44 | + first_color[1] * (1 - inter->effects.opacity); 45 | if (first_color[1] > 255) 46 | first_color[1] = 255; 47 | first_color[2] = new_color[2] * inter->effects.opacity 48 | + first_color[2] * (1 - inter->effects.opacity); 49 | if (first_color[2] > 255) 50 | first_color[2] = 255; 51 | } 52 | 53 | void transparency(t_rt *rt, int *color, 54 | t_coord *vector, t_eye *eye) 55 | { 56 | int first_color[3]; 57 | int new_color[3]; 58 | int new_obj; 59 | t_object *inter; 60 | 61 | inter = rt->final_obj; 62 | first_color[0] = (int)((*color & 0xFF0000) >> 16); 63 | first_color[1] = (int)((*color & 0x00FF00) >> 8); 64 | first_color[2] = (int)(*color & 0x0000FF); 65 | new_obj = object_loop(rt, vector, eye, rt->transp.inter); 66 | if (rt->inter == TRUE && rt->final_obj != NULL 67 | && rt->final_obj->effects.opacity >= 0.1) 68 | { 69 | rt->transp.size_tab++; 70 | add_transp_tab(rt, rt->final_obj); 71 | transparency(rt, &new_obj, vector, eye); 72 | } 73 | transparency_color(first_color, new_color, new_obj, inter); 74 | *color = ((first_color[0] << 16) + (first_color[1] << 8) + first_color[2]); 75 | } 76 | -------------------------------------------------------------------------------- /src/cpy_object_list.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** cpy_object_list.c for cpy_object_list.c in /home/abgral_f//Projetsave/rt3/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Mon May 27 13:10:26 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:09:29 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | static void fill_object_cpy(t_object *cpy, t_object *ref) 14 | { 15 | cpy->effects.reflexion = ref->effects.reflexion; 16 | cpy->effects.opacity = ref->effects.opacity; 17 | cpy->effects.brightness = ref->effects.brightness; 18 | cpy->effects.disturb_x = ref->effects.disturb_x; 19 | cpy->effects.disturb_y = ref->effects.disturb_y; 20 | cpy->effects.check_frequency = ref->effects.check_frequency; 21 | cpy->rotate.rx = ref->rotate.rx; 22 | cpy->rotate.ry = ref->rotate.ry; 23 | cpy->rotate.rz = ref->rotate.rz; 24 | cpy->coord.x = ref->coord.x; 25 | cpy->coord.y = ref->coord.y; 26 | cpy->coord.z = ref->coord.z; 27 | cpy->param = ref->param; 28 | cpy->radius = ref->radius; 29 | cpy->limit = ref->limit; 30 | cpy->object_nb = ref->object_nb; 31 | cpy->color = ref->color; 32 | } 33 | 34 | static int add_first_object_cpy(t_rt *cpy, t_rt *rt) 35 | { 36 | t_object *new; 37 | 38 | if ((new = malloc(sizeof(*new))) == NULL) 39 | return (my_puterror(MALLOC_ERROR)); 40 | cpy->first_object = new; 41 | cpy->last_object = new; 42 | new->next = NULL; 43 | fill_object_cpy(new, rt->first_object); 44 | return (EXIT_SUCCESS); 45 | } 46 | 47 | static int add_other_object_cpy(t_rt *cpy, t_rt *rt) 48 | { 49 | t_object *new; 50 | t_object *tmp_cpy; 51 | t_object *tmp; 52 | 53 | if ((new = malloc(sizeof(*new))) == NULL) 54 | return (my_puterror(MALLOC_ERROR)); 55 | tmp = rt->first_object; 56 | tmp_cpy = cpy->first_object; 57 | while (tmp_cpy->next != NULL) 58 | { 59 | tmp_cpy = tmp_cpy->next; 60 | tmp = tmp->next; 61 | } 62 | tmp = tmp->next; 63 | cpy->last_object = new; 64 | tmp_cpy->next = new; 65 | new->next = NULL; 66 | fill_object_cpy(new, tmp); 67 | return (EXIT_SUCCESS); 68 | } 69 | 70 | static int add_object_cpy(t_rt *cpy, t_rt *rt) 71 | { 72 | if (cpy->first_object == NULL) 73 | { 74 | if (add_first_object_cpy(cpy, rt) == EXIT_FAILURE) 75 | return (EXIT_FAILURE); 76 | } 77 | else 78 | if (add_other_object_cpy(cpy, rt) == EXIT_FAILURE) 79 | return (EXIT_FAILURE); 80 | return (EXIT_SUCCESS); 81 | } 82 | 83 | int cpy_object_list(t_rt *cpy, t_rt *rt) 84 | { 85 | t_object *tmp; 86 | 87 | tmp = rt->first_object; 88 | while (tmp != NULL) 89 | { 90 | if (add_object_cpy(cpy, rt) == EXIT_FAILURE) 91 | return (EXIT_FAILURE); 92 | tmp = tmp->next; 93 | } 94 | return (EXIT_SUCCESS); 95 | } 96 | -------------------------------------------------------------------------------- /scene/chauch.conf: -------------------------------------------------------------------------------- 1 | |object | pos_x | pos_y | pos_z | rot_x | rot_y | rot_z | color | reflexion | opacity | brightness | radius | angle | limit | disturb_x | disturb_y | check_frequency | 2 | |*************************************************************************************************************************************************************************| 3 | |eyes |-1000 |0 |10 |0 |20 |20 | |0 |0 |0 |0 |0 |0 |0 |0 |0 | 4 | |light |-1000 | 0 |40 |0 | 0 |0 |0xAAAAAA |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 5 | |light | 0 | 0 |40 |0 | 0 |0 |0xAAAAAA |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 6 | |plan |0 |0 | 0 |0 | 0 |0 |0xFFFFFF |0.5 |0 |0.5 |0 |0 | 0 |0 |0 |7 | 7 | |sphere |-970 |0 | 5 |0 | 0 |0 |0x0000FF |0.3 |0.1 |0.5 |6 | 0 |0 |0 |0 |0 | 8 | |sphere |-972 |7 | 5 |0 | 0 |0 |0xCCFF00 |0.3 |0.2 |0.2 |3 | 0 |0 |0 |0 |0 | 9 | |cylinder |-970 |15 | 0 |40 | 0 |0 |0xFF1111 |0.2 |0 |0.2 |4 | 0 |0 |0 |0 |0 | 10 | |hyperbole|-979 |16 | 10 |-20 | 0 |0 |0x339900 |0.2 |0.3 |0.2 | -2 | 22 |0 |0 |0 |0 | 11 | |parabole | -970 | 42 | 3 | -20 | 62 | 0 |0x6600CC | 0.4 | 0.2 | 0 | 0 | 3 | 0 | 0 | 0 | 0 | 12 | |*************************************************************************************************************************************************************************| 13 | 14 | ############################################# 15 | * threads => 4 * 16 | * anti-aliasing => 1 * 17 | * ambiance_light => 0.3 * 18 | * filter => 0 * 19 | * backscreen => NULL * 20 | ############################################# 21 | 22 | #***************************************************************************************************************# 23 | # Filters: 1.negativ 2.mix 3.sepia 4.black and white 5.red 6.green 7.blue 8.purple 9.cyan 10.grey # 24 | # # 25 | # # 26 | # # 27 | #***************************************************************************************************************# 28 | -------------------------------------------------------------------------------- /scenes_obligatoires/scene_7.conf: -------------------------------------------------------------------------------- 1 | |object | pos_x | pos_y | pos_z | rot_x | rot_y | rot_z | color | reflexion | opacity | brightness | radius | angle | limit | disturb_x | disturb_y | check_frequency | 2 | |*************************************************************************************************************************************************************************| 3 | |eyes |-992 |0 |5 |0 |0 |0 | |0 |0 |0 |0 |0 |0 |0 |0 |0 | 4 | |light |-985 | -14 | 15 |0 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 5 | |light |-985 | 14 | 22 |0 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 6 | |plan | 0 | 0 | 30 | 180 |0 | 0 |0xC0C0C0 |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 7 | |plan | 0 | 0 | 0 |0 |0 |0 |0xC0C0C0 |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 8 | |sphere | -975 | 0 | 2 |0 | 0 |0 |0xFF99FF |0 |0 |0 |1 |0 | 0 |0 |0 |0 | 9 | |sphere | -965 | -9 | 6 |0 | 0 |0 |0xFF0000 |0 |0 |0 |2 |0 | 0 |0 |0 |0 | 10 | |sphere | -965 | 9 | 13 |0 | 0 |0 |0xFF0000 |0 |0 |0 |2 |0 | 0 |0 |0 |0 | 11 | |cylinder | -980 | -5 | 0 |0 | 0 |0 |0x3333FF |0 |0 |0 |1 |0 | 0 |0 |0 |0 | 12 | |cylinder | -980 | 5 | 0 |0 | 0 |0 |0x3333FF |0 |0 |0 |1 |0 | 0 |0 |0 |0 | 13 | |cylinder | -940 | 7 | 0 |0 | 0 |0 |0x3333FF |0 |0 |0 |2 |0 | 0 |0 |0 |0 | 14 | |cylinder | -940 | -7 | 0 |0 | 0 |0 |0x3333FF |0 |0 |0 |2 |0 | 0 |0 |0 |0 | 15 | |*************************************************************************************************************************************************************************| 16 | 17 | ############################################# 18 | * threads => 4 * 19 | * anti-aliasing => 1 * 20 | * ambiance_light => 0 * 21 | * filter => 0 * 22 | ############################################# 23 | -------------------------------------------------------------------------------- /scene/test.conf: -------------------------------------------------------------------------------- 1 | |object | pos_x | pos_y | pos_z | rot_x | rot_y | rot_z | color | reflexion | opacity | brightness | radius | angle | limit | disturb_x | disturb_y | check_frequency | 2 | |*************************************************************************************************************************************************************************| 3 | |eyes |-1000 |0 |10 |0 |20 |20 | |0 |0 |0 |0 |0 |0 |0 |0 |0 | 4 | |light |-1000 | 0 |40 |0 | 0 |0 |0xAAAAAA |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 5 | |sphere |0 | 0 |40 |0 | 0 |0 |0xAAAAAA |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 6 | |*************************************************************************************************************************************************************************| 7 | 8 | ############################################# 9 | * threads => 4 * 10 | * anti-aliasing => 1 * 11 | * ambiance_light => 0.3 * 12 | * filter => 0 * 13 | * backscreen => NULL * 14 | ############################################# 15 | 16 | #***************************************************************************************************************# 17 | # Filters: 1.negativ 2.mix 3.sepia 4.black and white 5.red 6.green 7.blue 8.purple 9.cyan 10.grey # 18 | # # 19 | # # 20 | # # 21 | #***************************************************************************************************************# -------------------------------------------------------------------------------- /src/general_params.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** general_params.c for general_params.c in /home/abgral_f//Dropbox/Raytracer/transparence/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Sat Jun 8 06:32:58 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:27:07 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int get_threads(char *nb, int line_nb, t_rt *rt) 14 | { 15 | if (nb[0] < '0' || nb[0] > '9') 16 | { 17 | my_puterror(THREAD_BAD_ARG); 18 | my_putnbr(line_nb); 19 | return (EXIT_FAILURE); 20 | } 21 | rt->general_param.threads = atoi(nb); 22 | if (rt->general_param.threads > 4 || rt->general_param.threads < 1) 23 | { 24 | my_puterror(THREAD_BAD_ARG); 25 | my_putnbr(line_nb); 26 | return (EXIT_FAILURE); 27 | } 28 | return (EXIT_SUCCESS); 29 | } 30 | 31 | int get_anti_aliasing(char *nb, int line_nb, t_rt *rt) 32 | { 33 | if (nb[0] < '0' || nb[0] > '9') 34 | { 35 | my_puterror(ANTI_ALIASING_BAD_ARG); 36 | my_putnbr(line_nb); 37 | return (EXIT_FAILURE); 38 | } 39 | rt->general_param.anti_aliasing = atoi(nb); 40 | if (rt->general_param.anti_aliasing < 1 41 | || rt->general_param.anti_aliasing > 16) 42 | { 43 | my_puterror(ANTI_ALIASING_BAD_ARG); 44 | my_putnbr(line_nb); 45 | return (EXIT_FAILURE); 46 | } 47 | return (EXIT_SUCCESS); 48 | } 49 | 50 | int get_aliasing(char *nb, int line_nb, t_rt *rt) 51 | { 52 | if (nb[0] < '0' || nb[0] > '9') 53 | { 54 | my_puterror(ALIASING_BAD_ARG); 55 | my_putnbr(line_nb); 56 | return (EXIT_FAILURE); 57 | } 58 | rt->general_param.aliasing = atoi(nb); 59 | if (rt->general_param.aliasing < 1 || rt->general_param.aliasing > 30) 60 | { 61 | my_puterror(ALIASING_BAD_ARG); 62 | my_putnbr(line_nb); 63 | return (EXIT_FAILURE); 64 | } 65 | return (EXIT_SUCCESS); 66 | } 67 | 68 | int get_filtre(char *nb, int line_nb, t_rt *rt) 69 | { 70 | if (nb[0] < '0' || nb[0] > '9') 71 | { 72 | my_puterror(FILTER_BAD_ARG); 73 | my_putnbr(line_nb); 74 | return (EXIT_FAILURE); 75 | } 76 | rt->general_param.filter = atoi(nb); 77 | if (rt->general_param.filter < 0 || rt->general_param.filter > 10) 78 | { 79 | my_puterror(FILTER_BAD_ARG); 80 | my_putnbr(line_nb); 81 | return (EXIT_FAILURE); 82 | } 83 | return (EXIT_SUCCESS); 84 | } 85 | 86 | int get_ambiance(char *nb, int line_nb, t_rt *rt) 87 | { 88 | if (nb[0] < '0' || nb[0] > '9') 89 | { 90 | my_puterror(AMBIANCE_BAD_ARG); 91 | my_putnbr(line_nb); 92 | return (EXIT_FAILURE); 93 | } 94 | rt->general_param.ambiance_light = atof(nb); 95 | if (rt->general_param.ambiance_light < 0 96 | || rt->general_param.ambiance_light > 1) 97 | { 98 | my_puterror(AMBIANCE_BAD_ARG); 99 | my_putnbr(line_nb); 100 | return (EXIT_FAILURE); 101 | } 102 | return (EXIT_SUCCESS); 103 | } 104 | -------------------------------------------------------------------------------- /src/calc_rot_eye.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** calc_rot_eye.c for rt in /home/chauch_a//Dropbox/Raytracer/raytracer-2017-chanut_g 3 | ** 4 | ** Made by alan chauchet 5 | ** Login 6 | ** 7 | ** Started on Thu May 16 12:12:09 2013 alan chauchet 8 | ** Last update Sat Jun 8 06:38:44 2013 franck abgrall 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | void rot_x_eye(t_rt *rt, int x, int y) 14 | { 15 | int resize_view; 16 | 17 | if (rt->general_param.aliasing > 1) 18 | resize_view = DIST / rt->general_param.aliasing; 19 | else 20 | resize_view = DIST * rt->general_param.anti_aliasing; 21 | rt->vector.x = (rt->cosinus[ANG(rt->eye.rotate.rz % 360)] 22 | * rt->cosinus[ANG(rt->eye.rotate.ry % 360)] 23 | * resize_view 24 | - rt->sinus[ANG(rt->eye.rotate.rz % 360)] 25 | * ((rt->size.size_x / 2) - x) 26 | + rt->cosinus[ANG(rt->eye.rotate.rz % 360)] 27 | * rt->sinus[ANG(rt->eye.rotate.ry % 360)] 28 | * ((rt->size.size_y / 2) - y)); 29 | } 30 | 31 | void rot_y_eye(t_rt *rt, int x, int y) 32 | { 33 | int resize_view; 34 | 35 | if (rt->general_param.aliasing > 1) 36 | resize_view = DIST / rt->general_param.aliasing; 37 | else 38 | resize_view = DIST * rt->general_param.anti_aliasing; 39 | rt->vector.y = ((rt->cosinus[ANG(rt->eye.rotate.rx % 360)] 40 | * rt->sinus[ANG(rt->eye.rotate.rz % 360)] 41 | * rt->cosinus[ANG(rt->eye.rotate.ry % 360)] 42 | + rt->sinus[ANG(rt->eye.rotate.rx % 360)] 43 | * rt->sinus[ANG(rt->eye.rotate.ry % 360)]) 44 | * resize_view 45 | + rt->cosinus[ANG(rt->eye.rotate.rx % 360)] 46 | * rt->cosinus[ANG(rt->eye.rotate.rz % 360)] 47 | * ((rt->size.size_x / 2) - x) 48 | + (rt->cosinus[ANG(rt->eye.rotate.rx % 360)] 49 | * rt->sinus[ANG(rt->eye.rotate.rz % 360)] 50 | * rt->sinus[ANG(rt->eye.rotate.ry % 360)] 51 | - rt->sinus[ANG(rt->eye.rotate.rx % 360)] 52 | * rt->cosinus[ANG(rt->eye.rotate.ry % 360)]) 53 | * ((rt->size.size_y / 2) - y)); 54 | } 55 | 56 | void rot_z_eye(t_rt *rt, int x, int y) 57 | { 58 | int resize_view; 59 | 60 | if (rt->general_param.aliasing > 1) 61 | resize_view = DIST / rt->general_param.aliasing; 62 | else 63 | resize_view = DIST * rt->general_param.anti_aliasing; 64 | rt->vector.z = ((rt->sinus[ANG(rt->eye.rotate.rx % 360)] 65 | * rt->sinus[ANG(rt->eye.rotate.rz % 360)] 66 | * rt->cosinus[ANG(rt->eye.rotate.ry % 360)] 67 | - rt->cosinus[ANG(rt->eye.rotate.rx % 360)] 68 | * rt->sinus[ANG(rt->eye.rotate.ry % 360)]) 69 | * resize_view 70 | + rt->sinus[ANG(rt->eye.rotate.rx % 360)] 71 | * rt->cosinus[ANG(rt->eye.rotate.rz % 360)] 72 | * ((rt->size.size_x / 2) - x) 73 | + (rt->sinus[ANG(rt->eye.rotate.rx % 360)] 74 | * rt->sinus[ANG(rt->eye.rotate.rz % 360)] 75 | * rt->sinus[ANG(rt->eye.rotate.ry % 360)] 76 | + rt->cosinus[ANG(rt->eye.rotate.rx % 360)] 77 | * rt->cosinus[ANG(rt->eye.rotate.ry % 360)]) 78 | * ((rt->size.size_y / 2) - y)); 79 | } 80 | 81 | void calc_rot_eye(t_rt *rt, int x, int y) 82 | { 83 | rot_x_eye(rt, x, y); 84 | rot_y_eye(rt, x, y); 85 | rot_z_eye(rt, x, y); 86 | } 87 | -------------------------------------------------------------------------------- /src/loop_light.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** loop_light.c for rt in /home/acca_b/Dropbox/EPITECH/Tek1/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by baptiste acca 5 | ** Login 6 | ** 7 | ** Started on Fri May 17 17:29:43 2013 baptiste acca 8 | ** Last update Sun Jun 9 15:56:48 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | static t_object_tab g_object_tab[6] = 14 | { 15 | {CONE_NB, &cone_luminosity}, 16 | {CYLINDER_NB, &cylinder_luminosity}, 17 | {SPHERE_NB, &sphere_luminosity}, 18 | {PLAN_NB, &plan_luminosity}, 19 | {PARABOLE_NB, ¶bole_luminosity}, 20 | {HYPERBOLE_NB, &hyperbole_luminosity}, 21 | }; 22 | 23 | void change_var(t_rt *rt, double cos_atmp, 24 | t_light *light, t_object *object) 25 | { 26 | rt->light_var.cos_a += cos_atmp; 27 | rt->light_var.color.red += ((light->color & 0xFF0000) >> 16); 28 | rt->light_var.color.green += ((light->color & 0x00FF00) >> 8); 29 | rt->light_var.color.blue += ((light->color & 0x0000FF)); 30 | rt->light_var.brightness = object->effects.brightness; 31 | } 32 | 33 | void calc_light_var(t_rt *rt, t_light *light, 34 | t_vision *vision) 35 | { 36 | rt->light_var.vector.x = light->coord.x 37 | - (rt->k * vision->vector->x + vision->eye->coord.x); 38 | rt->light_var.vector.y = light->coord.y 39 | - (rt->k * vision->vector->y + vision->eye->coord.y); 40 | rt->light_var.vector.z = light->coord.z 41 | - (rt->k * vision->vector->z + vision->eye->coord.z); 42 | rt->light_var.norme_l = sqrt(pow(rt->light_var.vector.x, 2) 43 | + pow(rt->light_var.vector.y, 2) 44 | + pow(rt->light_var.vector.z, 2)); 45 | } 46 | 47 | void check_light(t_rt *rt, t_light *light, 48 | t_object *object, t_vision *vision) 49 | { 50 | double cos_atmp; 51 | int count; 52 | 53 | calc_light_var(rt, light, vision); 54 | count = 0; 55 | while (count < 6 && 56 | object->object_nb != g_object_tab[count].object_nb) 57 | count++; 58 | if (count < 6) 59 | g_object_tab[count].fct_lum(rt, vision, 60 | object, &rt->light_var.norm); 61 | rt->light_var.norme_n = sqrt(pow(rt->light_var.norm.x, 2) 62 | + pow(rt->light_var.norm.y, 2) 63 | + pow(rt->light_var.norm.z, 2)); 64 | rt->light_var.shadow += check_shadow(rt, light, vision); 65 | cos_atmp = ((rt->light_var.vector.x * rt->light_var.norm.x) 66 | + (rt->light_var.vector.y * rt->light_var.norm.y) 67 | + (rt->light_var.vector.z * rt->light_var.norm.z)) 68 | / (rt->light_var.norme_n * rt->light_var.norme_l); 69 | if (cos_atmp > 0.000001) 70 | change_var(rt, cos_atmp, light, object); 71 | } 72 | 73 | void loop_light(t_rt *rt, t_object *object, t_vision *vision) 74 | { 75 | t_light *light; 76 | int count; 77 | 78 | rt->light_var.shadow = 0; 79 | rt->light_var.cos_a = 0; 80 | rt->light_var.color.red = 0; 81 | rt->light_var.color.blue = 0; 82 | rt->light_var.color.green = 0; 83 | light = rt->first_light; 84 | count = 0; 85 | while (light != NULL) 86 | { 87 | count++; 88 | check_light(rt, light, object, vision); 89 | light = light->next; 90 | } 91 | rt->light_var.shadow /= count; 92 | } 93 | -------------------------------------------------------------------------------- /src/object_loop.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** object_loop.c for rt in /home/chauch_a//Dropbox/Raytracer/raytracer-2017-chanut_g 3 | ** 4 | ** Made by alan chauchet 5 | ** Login 6 | ** 7 | ** Started on Thu May 16 14:42:52 2013 alan chauchet 8 | ** Last update Sun Jun 9 17:04:56 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | static t_inter_obj g_inter_obj[6] = 14 | { 15 | {CONE_NB, &inter_cone}, 16 | {CYLINDER_NB, &inter_cylinder}, 17 | {SPHERE_NB, &inter_sphere}, 18 | {PLAN_NB, &inter_plan}, 19 | {PARABOLE_NB, &inter_parabole}, 20 | {HYPERBOLE_NB, &inter_hyperbole} 21 | }; 22 | 23 | void check_if_inter(t_rt *rt, t_object *object, 24 | t_vision *vision, t_negative *negative) 25 | { 26 | int count; 27 | double prov_k; 28 | 29 | prov_k = -1; 30 | count = 0; 31 | while (count < 6 && object->object_nb != g_inter_obj[count].nb) 32 | count++; 33 | if (count != 6) 34 | prov_k = g_inter_obj[count].inter_obj(rt, negative); 35 | if (prov_k > 0 && (rt->inter == FALSE || prov_k < rt->k)) 36 | { 37 | rt->k = prov_k; 38 | if (object->effects.check_frequency > 0) 39 | damier(rt, object, vision->vector, vision->eye); 40 | else 41 | rt->color = object->color; 42 | rt->inter = TRUE; 43 | rt->final_obj = object; 44 | if (rt->first_light != NULL) 45 | loop_light(rt, rt->final_obj, vision); 46 | } 47 | } 48 | 49 | void check_object(t_rt *rt, t_object *object, 50 | t_coord *vector, t_eye *eye) 51 | { 52 | t_negative negative; 53 | t_vision vision; 54 | t_coord new_vector; 55 | t_eye new_eye; 56 | 57 | calc_matrice_eye(rt, object, eye, &new_eye); 58 | calc_matrice_vector(rt, object, vector, &new_vector); 59 | vision.eye = eye; 60 | vision.vector = vector; 61 | vision.new_eye = &new_eye; 62 | vision.new_vector = &new_vector; 63 | rt->shadow = FALSE; 64 | rt->negative = 0; 65 | negative.object = object; 66 | negative.eye = &new_eye; 67 | negative.vector = &new_vector; 68 | negative.light = NULL; 69 | negative.vision = &vision; 70 | check_if_inter(rt, object, &vision, &negative); 71 | } 72 | 73 | int no_check_obj(t_rt *rt, t_object **no_obj, 74 | t_object *object) 75 | { 76 | int count; 77 | 78 | count = 0; 79 | while (count < rt->transp.size_tab) 80 | { 81 | if (no_obj[count] == object) 82 | return (0); 83 | count++; 84 | } 85 | return (1); 86 | } 87 | 88 | int object_loop(t_rt *rt, t_coord *vector, 89 | t_eye *eye, t_object **no_obj) 90 | { 91 | t_object *object; 92 | 93 | object = rt->first_object; 94 | rt->final_obj = NULL; 95 | rt->inter = FALSE; 96 | rt->inside = FALSE; 97 | while (object != NULL) 98 | { 99 | if (object->limit == 0 && 100 | (no_obj == NULL || no_check_obj(rt, no_obj, object) == 1)) 101 | check_object(rt, object, vector, eye); 102 | object = object->next; 103 | } 104 | if (rt->inter == FALSE) 105 | { 106 | if (rt->general_param.backscreen.name != NULL) 107 | return (pixel_backscreen(rt, rt->pos_x, rt->pos_y)); 108 | return (0x000000); 109 | } 110 | else 111 | return (apply_color(rt)); 112 | } 113 | -------------------------------------------------------------------------------- /src/reflexion.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** transparency.c for transparency.c in /home/acca_b/Dropbox/EPITECH/Tek1/Raytracer/transparence/src 3 | ** 4 | ** Made by baptiste acca 5 | ** Login 6 | ** 7 | ** Started on Mon May 27 16:51:41 2013 baptiste acca 8 | ** Last update Sat Jun 8 17:15:39 2013 baptiste acca 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int sign(double nb) 14 | { 15 | if (nb < 0) 16 | return (-1); 17 | return (1); 18 | } 19 | 20 | void reflexion_color(int *color, t_object *inter, 21 | int new_obj) 22 | { 23 | int first_color[3]; 24 | int new_color[3]; 25 | 26 | first_color[0] = (int)((*color & 0xFF0000) >> 16); 27 | first_color[1] = (int)((*color & 0x00FF00) >> 8); 28 | first_color[2] = (int)(*color & 0x0000FF); 29 | new_color[0] = (int)((new_obj & 0xFF0000) >> 16); 30 | new_color[1] = (int)((new_obj & 0x00FF00) >> 8); 31 | new_color[2] = (int)(new_obj & 0x0000FF); 32 | first_color[0] = new_color[0] * inter->effects.reflexion 33 | + first_color[0] * (1 - inter->effects.reflexion); 34 | if (first_color[0] > 255) 35 | first_color[0] = 255; 36 | first_color[1] = new_color[1] * inter->effects.reflexion 37 | + first_color[1] * (1 - inter->effects.reflexion); 38 | if (first_color[1] > 255) 39 | first_color[1] = 255; 40 | first_color[2] = new_color[2] * inter->effects.reflexion 41 | + first_color[2] * (1 - inter->effects.reflexion); 42 | if (first_color[2] > 255) 43 | first_color[2] = 255; 44 | *color = ((first_color[0] << 16) + (first_color[1] << 8) + first_color[2]); 45 | } 46 | 47 | void reflexion_plan(t_coord *vector_r, t_coord *vector, 48 | t_coord norm, t_eye *next_eye) 49 | { 50 | vector_r->x = vector->x; 51 | vector_r->y = vector->y; 52 | vector_r->z = vector->z; 53 | if (norm.x > 0.000001 || norm.x < -0.999999) 54 | vector_r->x = ((-100) / norm.x) * vector->x; 55 | if (norm.y > 0.000001 || norm.y < -0.999999) 56 | vector_r->y = ((-100) / norm.y) * vector->y; 57 | if (norm.z > 0.000001 || norm.z < -0.999999) 58 | vector_r->z = ((-100) / norm.z) * vector->z; 59 | next_eye->coord.x += sign(norm.x); 60 | next_eye->coord.y += sign(norm.y); 61 | next_eye->coord.z += sign(norm.z); 62 | } 63 | 64 | void reflexion(t_rt *rt, int *color, 65 | t_coord *vector, t_eye *eye) 66 | { 67 | int new_obj; 68 | t_object *inter; 69 | t_vision vision; 70 | t_coord new_vector; 71 | t_eye new_eye; 72 | t_coord vector_r; 73 | t_eye next_eye; 74 | t_coord norm; 75 | 76 | rt->stop_reflexion++; 77 | inter = rt->final_obj; 78 | calc_matrice_eye(rt, rt->final_obj, eye, &new_eye); 79 | calc_matrice_vector(rt, rt->final_obj, vector, &new_vector); 80 | vision = assign_vision(&new_vector, &new_eye, vector, eye); 81 | calc_norm_reflexion(rt, &vision, &norm, inter); 82 | calc_next_eye_reflexion(rt, &vision, &next_eye); 83 | if (inter->object_nb == PLAN_NB) 84 | reflexion_plan(&vector_r, vision.vector, norm, &next_eye); 85 | else 86 | calc_reflected_vector(&vector_r, &norm, &vision); 87 | new_obj = object_loop(rt, &vector_r, &next_eye, NULL); 88 | if (rt->inter == TRUE && rt->final_obj->effects.reflexion > 0.000001 && 89 | rt->stop_reflexion < 200) 90 | reflexion(rt, &new_obj, &vector_r, &next_eye); 91 | reflexion_color(color, inter, new_obj); 92 | } 93 | -------------------------------------------------------------------------------- /src/bsc.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** bsc.c for rt in /home/acca_b/Dropbox/EPITECH/Tek1/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by baptiste acca 5 | ** Login 6 | ** 7 | ** Started on Wed May 15 14:18:22 2013 baptiste acca 8 | ** Last update Sun Jun 9 20:47:25 2013 alan chauchet 9 | */ 10 | 11 | #include 12 | #include "raytracer.h" 13 | 14 | int parse_arg_file(t_rt *rt, char **av) 15 | { 16 | init_rt(rt); 17 | default_size_window(rt); 18 | if (get_file(av[1], rt) == EXIT_FAILURE) 19 | return (EXIT_FAILURE); 20 | if (rt->eye.check == FALSE) 21 | return (my_puterror(NO_EYES)); 22 | if (check_option(av, rt) == EXIT_FAILURE) 23 | return (EXIT_FAILURE); 24 | if (resize_aliasing(rt) == EXIT_FAILURE) 25 | return (EXIT_FAILURE); 26 | if (init_param(rt) == EXIT_FAILURE) 27 | return (EXIT_FAILURE); 28 | return (EXIT_SUCCESS); 29 | } 30 | 31 | int copy_img(t_rt *rt) 32 | { 33 | int count; 34 | 35 | if ((rt->img_tab[rt->pos].img_ptr = 36 | mlx_new_image(rt->mlx_init.mlx_ptr, 37 | rt->size.win_x, 38 | rt->size.win_y)) == NULL) 39 | return (my_puterror(CONNECT_ERROR)); 40 | rt->img_tab[rt->pos].data = (unsigned char *)mlx_get_data_addr 41 | (rt->img_tab[rt->pos].img_ptr, 42 | &rt->img_tab[rt->pos].bits_per_pixel, 43 | &rt->img_tab[rt->pos].size_line, 44 | &rt->img_tab[rt->pos].endian); 45 | count = 0; 46 | while (count <= ((rt->size.win_x) * (rt->size.win_y) * 4)) 47 | { 48 | rt->img_tab[rt->pos].data[count] = rt->mlx_init.data_resize[count]; 49 | count++; 50 | } 51 | return (EXIT_SUCCESS); 52 | } 53 | 54 | int fill_imgs(t_rt *rt) 55 | { 56 | if ((rt->img_tab = malloc(sizeof(*rt->img_tab) 57 | * rt->general_param.nb_img)) == NULL) 58 | return (EXIT_FAILURE); 59 | rt->pos = 0; 60 | while (rt->pos < rt->general_param.nb_img) 61 | { 62 | aff_load_bar(rt); 63 | if (thread_creation(rt) == EXIT_FAILURE) 64 | return (EXIT_FAILURE); 65 | if (rt->general_param.anti_aliasing >= 1) 66 | antialiasing(rt); 67 | if (rt->general_param.aliasing > 1) 68 | aliasing(rt); 69 | if (copy_img(rt) == EXIT_FAILURE) 70 | return (EXIT_FAILURE); 71 | rt->pos++; 72 | rt->eye.coord.x += rt->general_param.speed; 73 | } 74 | rt->pos = 0; 75 | return (EXIT_SUCCESS); 76 | } 77 | 78 | int bsc(char **av) 79 | { 80 | t_rt rt; 81 | 82 | if (parse_arg_file(&rt, av) == EXIT_FAILURE) 83 | return (EXIT_FAILURE); 84 | if (rt.general_param.aliasing >= 1) 85 | { 86 | rt.size.win_x = rt.size.size_x * rt.general_param.aliasing; 87 | rt.size.win_y = rt.size.size_y * rt.general_param.aliasing; 88 | } 89 | if (rt.general_param.anti_aliasing > 1) 90 | { 91 | rt.size.win_x = rt.size.size_x / rt.general_param.anti_aliasing; 92 | rt.size.win_y = rt.size.size_y / rt.general_param.anti_aliasing; 93 | } 94 | if (rt.general_param.backscreen.name != NULL) 95 | recup_backscreen(&rt); 96 | if (fill_imgs(&rt) == EXIT_FAILURE) 97 | return (EXIT_FAILURE); 98 | mlx_hook(rt.mlx_init.win_ptr, KeyPress, KeyPressMask, &key_hook, &rt); 99 | mlx_expose_hook(rt.mlx_init.win_ptr, &expose_hook, &rt); 100 | mlx_loop(rt.mlx_init.mlx_ptr); 101 | return (EXIT_SUCCESS); 102 | } 103 | -------------------------------------------------------------------------------- /src/bmp.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** main.c for main.c in /home/acca_b/Dropbox/EPITECH/Tek1/Raytracer/bmp 3 | ** 4 | ** Made by baptiste acca 5 | ** Login 6 | ** 7 | ** Started on Mon Jun 3 13:15:14 2013 baptiste acca 8 | ** Last update Sun Jun 9 21:19:47 2013 baptiste acca 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include "raytracer.h" 15 | 16 | void make_img_header(t_bitmapinfoheader *i_header, t_rt *rt) 17 | { 18 | i_header->biSize = sizeof(*i_header); 19 | if (rt->general_param.anti_aliasing >= 1) 20 | { 21 | i_header->biWidth = rt->size.size_x / rt->general_param.anti_aliasing; 22 | i_header->biHeight = rt->size.size_y / rt->general_param.anti_aliasing; 23 | } 24 | if (rt->general_param.aliasing > 1) 25 | { 26 | i_header->biWidth = rt->size.size_x * rt->general_param.aliasing; 27 | i_header->biHeight = rt->size.size_y * rt->general_param.aliasing; 28 | } 29 | i_header->biPlanes = 1; 30 | i_header->biBitCount = 32; 31 | i_header->biCompression = 0; 32 | i_header->biSizeImage = i_header->biWidth * i_header->biHeight * 4; 33 | i_header->biXPelsPerMeter = 0; 34 | i_header->biYPelsPerMeter = 0; 35 | i_header->biClrUsed = 0; 36 | i_header->biClrImportant = 0; 37 | } 38 | 39 | void make_file_header(t_bitmapfileheader *f_header, 40 | t_bitmapinfoheader *i_header) 41 | { 42 | f_header->bftype = 0x4D42; 43 | f_header->bfReserved1 = 0; 44 | f_header->bfReserved2 = 0; 45 | f_header->bfOffBits = sizeof(*f_header) + sizeof(*i_header); 46 | f_header->bfSize = f_header->bfOffBits + i_header->biSizeImage; 47 | } 48 | 49 | char *get_save_name(t_rt *rt) 50 | { 51 | char *file_name; 52 | int ret; 53 | 54 | my_putstr(BMP_FILE); 55 | file_name = malloc(sizeof(*file_name) * 512); 56 | if (file_name == NULL) 57 | { 58 | my_puterror(MALLOC_ERROR); 59 | return (NULL); 60 | } 61 | if ((ret = read(0, file_name, 511)) == -1) 62 | { 63 | my_puterror(READ_ERROR); 64 | return (NULL); 65 | } 66 | file_name[ret - 1] = '\0'; 67 | file_name = my_strcat(file_name, ".bmp", 1, 0); 68 | if (file_name == NULL || my_strlen(file_name) <= 4) 69 | { 70 | my_putstr(BMP_ERROR); 71 | return (get_save_name(rt)); 72 | } 73 | if ((rt->scene_name = my_strdup(file_name, 1)) == NULL) 74 | return (NULL); 75 | return (file_name); 76 | } 77 | 78 | int bmp(t_rt *rt) 79 | { 80 | t_bitmapfileheader f_header; 81 | t_bitmapinfoheader i_header; 82 | int fd; 83 | int i; 84 | char *file_name; 85 | 86 | make_img_header(&i_header, rt); 87 | make_file_header(&f_header, &i_header); 88 | if ((file_name = get_save_name(rt)) == NULL) 89 | return (EXIT_FAILURE); 90 | if ((fd = open(file_name, O_CREAT | O_TRUNC | O_WRONLY, 0644)) == -1) 91 | { 92 | my_puterror(FOPEN_ERROR); 93 | return (EXIT_FAILURE); 94 | } 95 | write(fd, &f_header, sizeof(f_header)); 96 | write(fd, &i_header, sizeof(i_header)); 97 | i = i_header.biSizeImage - i_header.biWidth * 4; 98 | while (i >= 0) 99 | { 100 | write(fd, &rt->img_tab[rt->pos].data[i], i_header.biWidth * 4); 101 | i -= (i_header.biWidth * 4); 102 | } 103 | close(fd); 104 | return (EXIT_SUCCESS); 105 | } 106 | -------------------------------------------------------------------------------- /src/cpy_general_struct.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** cpy_general_struct.c for cpy_general_struct.c in /home/abgral_f//Projetsave/rt3/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Sat May 25 14:51:12 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:09:52 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | static void cpy_light_var(t_rt *cpy, t_rt *rt) 14 | { 15 | cpy->light_var.color.red = rt->light_var.color.red; 16 | cpy->light_var.color.green = rt->light_var.color.green; 17 | cpy->light_var.color.blue = rt->light_var.color.blue; 18 | cpy->light_var.norm.x = rt->light_var.norm.x; 19 | cpy->light_var.norm.y = rt->light_var.norm.y; 20 | cpy->light_var.norm.z = rt->light_var.norm.z; 21 | cpy->light_var.vector.x = rt->light_var.vector.x; 22 | cpy->light_var.vector.y = rt->light_var.vector.y; 23 | cpy->light_var.vector.z = rt->light_var.vector.z; 24 | cpy->light_var.norme_n = rt->light_var.norme_n; 25 | cpy->light_var.norme_l = rt->light_var.norme_l; 26 | cpy->light_var.brightness = rt->light_var.brightness; 27 | cpy->light_var.shadow = rt->light_var.shadow; 28 | cpy->light_var.cos_a = rt->light_var.cos_a; 29 | } 30 | 31 | static void cpy_calc_param(t_rt *cpy, t_rt *rt) 32 | { 33 | cpy->eye.coord.x = rt->eye.coord.x; 34 | cpy->eye.coord.y = rt->eye.coord.y; 35 | cpy->eye.coord.z = rt->eye.coord.z; 36 | cpy->eye.rotate.rx = rt->eye.rotate.rx; 37 | cpy->eye.rotate.ry = rt->eye.rotate.ry; 38 | cpy->eye.rotate.rz = rt->eye.rotate.rz; 39 | cpy->eye.check = rt->eye.check; 40 | cpy->vector.x = rt->vector.x; 41 | cpy->vector.y = rt->vector.y; 42 | cpy->vector.z = rt->vector.z; 43 | cpy->color = rt->color; 44 | cpy->k = rt->k; 45 | cpy->inter = rt->inter; 46 | cpy->count_pixel = rt->count_pixel; 47 | } 48 | 49 | static void cpy_general_param(t_rt *cpy, t_rt *rt) 50 | { 51 | cpy->mlx_init.mlx_ptr = rt->mlx_init.mlx_ptr; 52 | cpy->mlx_init.win_ptr = rt->mlx_init.win_ptr; 53 | cpy->mlx_init.img_ptr = rt->mlx_init.img_ptr; 54 | cpy->mlx_init.data = rt->mlx_init.data; 55 | cpy->mlx_init.bits_per_pixel = rt->mlx_init.bits_per_pixel; 56 | cpy->mlx_init.size_line = rt->mlx_init.size_line; 57 | cpy->mlx_init.endian = rt->mlx_init.endian; 58 | cpy->size.size_x = rt->size.size_x; 59 | cpy->size.size_y = rt->size.size_y; 60 | cpy->size.win_x = rt->size.win_x; 61 | cpy->size.win_y = rt->size.win_y; 62 | cpy->general_param.anti_aliasing = rt->general_param.anti_aliasing; 63 | cpy->general_param.aliasing = rt->general_param.aliasing; 64 | cpy->general_param.threads = rt->general_param.threads; 65 | cpy->general_param.filter = rt->general_param.filter; 66 | cpy->general_param.ambiance_light = rt->general_param.ambiance_light; 67 | cpy->general_param.backscreen = rt->general_param.backscreen; 68 | cpy->pix_calc.nb_pixel = rt->pix_calc.nb_pixel; 69 | cpy->pix_calc.pixel_pos = rt->pix_calc.pixel_pos; 70 | cpy->thread_nb = rt->thread_nb; 71 | } 72 | 73 | t_rt *cpy_general_struct(t_rt *rt) 74 | { 75 | t_rt *cpy; 76 | 77 | if ((cpy = malloc(sizeof(*cpy))) == NULL) 78 | return (NULL); 79 | init_rt(cpy); 80 | if (cpy_object_list(cpy, rt) == EXIT_FAILURE) 81 | return (NULL); 82 | if (cpy_light_list(cpy, rt) == EXIT_FAILURE) 83 | return (NULL); 84 | cpy_general_param(cpy, rt); 85 | cpy_calc_param(cpy, rt); 86 | cpy_light_var(cpy, rt); 87 | return (cpy); 88 | } 89 | -------------------------------------------------------------------------------- /src/get_specs.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** get_specs.c for get_specs.c in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Mon May 13 18:31:47 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:05:33 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int get_color(t_list *list, t_rt *rt, int specs_nb) 14 | { 15 | int column_nb; 16 | int adress_specs; 17 | int result; 18 | char *color_hex; 19 | 20 | if ((column_nb = get_column_number(specs_nb, rt)) == EXIT_FAILURE) 21 | return (EXIT_FAILURE); 22 | if ((adress_specs = get_adress_specs(list, column_nb)) == EXIT_FAILURE) 23 | return (EXIT_FAILURE); 24 | if (check_color_syntax(&(list->line[adress_specs]), list) == EXIT_FAILURE) 25 | return (EXIT_FAILURE); 26 | if (get_color_hex_str(&color_hex, 27 | &(list->line[adress_specs + 2])) == EXIT_FAILURE) 28 | return (EXIT_FAILURE); 29 | result = my_atoi_base(color_hex, "0123456789ABCDEF"); 30 | free(color_hex); 31 | return (result); 32 | } 33 | 34 | int get_effects(t_list *list, t_rt *rt) 35 | { 36 | if ((rt->last_object->effects.reflexion = 37 | get_specs(list, rt, REFLEXION_NB)) == -1) 38 | return (EXIT_FAILURE); 39 | if ((rt->last_object->effects.opacity = 40 | get_specs(list, rt, OPACITY_NB)) == -1) 41 | return (EXIT_FAILURE); 42 | if ((rt->last_object->effects.brightness = 43 | get_specs(list, rt, BRIGHTNESS_NB)) == -1) 44 | return (EXIT_FAILURE); 45 | if ((rt->last_object->effects.disturb_x = 46 | get_specs(list, rt, DISTURB_X_NB)) == -1) 47 | return (EXIT_FAILURE); 48 | if ((rt->last_object->effects.disturb_y = 49 | get_specs(list, rt, DISTURB_Y_NB)) == -1) 50 | return (EXIT_FAILURE); 51 | if ((rt->last_object->effects.check_frequency = 52 | get_specs(list, rt, CHECK_FREQUENCY_NB)) == -1) 53 | return (EXIT_FAILURE); 54 | return (EXIT_SUCCESS); 55 | } 56 | 57 | int get_rotate(t_list *list, t_rt *rt) 58 | { 59 | if ((rt->last_object->rotate.rx = 60 | get_specs(list, rt, ROTX_NB)) == -1) 61 | return (EXIT_FAILURE); 62 | if ((rt->last_object->rotate.ry = 63 | get_specs(list, rt, ROTY_NB)) == -1) 64 | return (EXIT_FAILURE); 65 | if ((rt->last_object->rotate.rz = 66 | get_specs(list, rt, ROTZ_NB)) == -1) 67 | return (EXIT_FAILURE); 68 | return (EXIT_SUCCESS); 69 | } 70 | 71 | int get_coord(t_list *list, t_rt *rt) 72 | { 73 | if ((rt->last_object->coord.x = 74 | get_specs(list, rt, POSX_NB)) == -1) 75 | return (EXIT_FAILURE); 76 | if ((rt->last_object->coord.y = 77 | get_specs(list, rt, POSY_NB)) == -1) 78 | return (EXIT_FAILURE); 79 | if ((rt->last_object->coord.z = 80 | get_specs(list, rt, POSZ_NB)) == -1) 81 | return (EXIT_FAILURE); 82 | return (EXIT_SUCCESS); 83 | } 84 | 85 | double get_specs(t_list *list, t_rt *rt, int specs_nb) 86 | { 87 | int column_nb; 88 | int adress_specs; 89 | double result; 90 | 91 | if ((column_nb = get_column_number(specs_nb, rt)) == EXIT_FAILURE) 92 | return (-1); 93 | if ((adress_specs = get_adress_specs(list, column_nb)) == EXIT_FAILURE) 94 | return (-1); 95 | if (check_isnum(&(list->line[adress_specs]), list) == -1) 96 | return (-1); 97 | result = atof(&(list->line[adress_specs])); 98 | return (result); 99 | } 100 | -------------------------------------------------------------------------------- /src/init_param.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** init_param.c for init_param.c in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Wed May 15 16:53:27 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:05:04 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int init_param_aliasing(t_rt *rt) 14 | { 15 | if ((rt->mlx_init.img_ptr_aliasing = 16 | mlx_new_image(rt->mlx_init.mlx_ptr, rt->size.size_x 17 | / rt->general_param.anti_aliasing 18 | / rt->general_param.aliasing, 19 | rt->size.size_y / rt->general_param.anti_aliasing 20 | / rt->general_param.aliasing)) == NULL) 21 | return (my_puterror(CONNECT_ERROR)); 22 | rt->mlx_init.data_aliasing = (unsigned char *)mlx_get_data_addr 23 | (rt->mlx_init.img_ptr, 24 | &rt->mlx_init.bits_per_pixel_aliasing, 25 | &rt->mlx_init.size_line_aliasing, 26 | &rt->mlx_init.endian_aliasing); 27 | return (EXIT_SUCCESS); 28 | } 29 | 30 | int init_param_cpy_anti_alias(t_rt *rt) 31 | { 32 | if ((rt->mlx_init.img_ptr_resize = 33 | mlx_new_image(rt->mlx_init.mlx_ptr, rt->size.size_x 34 | / rt->general_param.anti_aliasing, rt->size.size_y 35 | / rt->general_param.anti_aliasing)) == NULL) 36 | return (my_puterror(CONNECT_ERROR)); 37 | if ((rt->mlx_init.win_ptr = 38 | mlx_new_window(rt->mlx_init.mlx_ptr, rt->size.size_x 39 | / rt->general_param.anti_aliasing, rt->size.size_y 40 | / rt->general_param.anti_aliasing, WINDOW_NAME)) 41 | == NULL) 42 | return (my_puterror(CONNECT_ERROR)); 43 | rt->mlx_init.data_resize = (unsigned char *)mlx_get_data_addr 44 | (rt->mlx_init.img_ptr_resize, 45 | &rt->mlx_init.bits_per_pixel_resize, 46 | &rt->mlx_init.size_line_resize, 47 | &rt->mlx_init.endian_resize); 48 | return (EXIT_SUCCESS); 49 | } 50 | 51 | int init_param_cpy_alias(t_rt *rt) 52 | { 53 | if ((rt->mlx_init.img_ptr_resize = 54 | mlx_new_image(rt->mlx_init.mlx_ptr, 55 | rt->size.size_x * rt->general_param.aliasing, 56 | rt->size.size_y * rt->general_param.aliasing)) == NULL) 57 | return (my_puterror(CONNECT_ERROR)); 58 | if ((rt->mlx_init.win_ptr = 59 | mlx_new_window(rt->mlx_init.mlx_ptr, rt->size.size_x 60 | * rt->general_param.aliasing, rt->size.size_y 61 | * rt->general_param.aliasing, WINDOW_NAME)) 62 | == NULL) 63 | return (my_puterror(CONNECT_ERROR)); 64 | rt->mlx_init.data_resize = (unsigned char *)mlx_get_data_addr 65 | (rt->mlx_init.img_ptr_resize, 66 | &rt->mlx_init.bits_per_pixel_resize, 67 | &rt->mlx_init.size_line_resize, 68 | &rt->mlx_init.endian_resize); 69 | return (EXIT_SUCCESS); 70 | } 71 | 72 | int init_param(t_rt *rt) 73 | { 74 | if ((rt->mlx_init.mlx_ptr = mlx_init()) == NULL) 75 | return (my_puterror(CONNECT_ERROR)); 76 | if ((rt->mlx_init.img_ptr = 77 | mlx_new_image(rt->mlx_init.mlx_ptr, 78 | rt->size.size_x, 79 | rt->size.size_y)) == NULL) 80 | return (my_puterror(CONNECT_ERROR)); 81 | rt->mlx_init.data = (unsigned char *)mlx_get_data_addr 82 | (rt->mlx_init.img_ptr, 83 | &rt->mlx_init.bits_per_pixel, 84 | &rt->mlx_init.size_line, 85 | &rt->mlx_init.endian); 86 | if (rt->general_param.anti_aliasing >= 1) 87 | if (init_param_cpy_anti_alias(rt) == EXIT_FAILURE) 88 | return (EXIT_FAILURE); 89 | if (rt->general_param.aliasing > 1) 90 | if (init_param_cpy_alias(rt) == EXIT_FAILURE) 91 | return (EXIT_FAILURE); 92 | if (rt->general_param.aliasing > 1) 93 | if (init_param_aliasing(rt) == EXIT_FAILURE) 94 | return (EXIT_FAILURE); 95 | return (EXIT_SUCCESS); 96 | } 97 | -------------------------------------------------------------------------------- /scene/abgral3.conf: -------------------------------------------------------------------------------- 1 | |object | pos_x | pos_y | pos_z | rot_x | rot_y | rot_z | color | reflexion | opacity | brightness | radius | angle | limit | disturb_x | disturb_y | check_frequency | 2 | |************************************************************************************************************************************************************************| 3 | | eyes |-1000 |0 |0 |0 |0 |0 | |0 |0 |0 |0 |0 |0 |0 |0 |0 | 4 | | light |-500 | 0 |500 |0 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 5 | 6 | |cylinder |0 |0 |-200 |0 |90 |0 |0xFF6600 |0.3 |0 |0 |50 |0 | 0 |0 |0 |0 | 7 | |cylinder |0 |-100 |-200 |0 |90 |0 |0x3333FF |0.3 |0 | 0 |50 |0 | 0 |0 |0 |0 | 8 | |cylinder |0 |-200 |-200 |0 |90 |0 |0xFF6600 |0.3 |0 | 0 |50 |0 | 0 |0 |0 |0 | 9 | |cylinder |0 |100 |-200 |0 |90 |0 |0x3333FF |0.3 |0 | 0 |50 |0 | 0 |0 |0 |0 | 10 | |cylinder |0 |200 |-200 |0 |90 |0 |0xFF6600 |0.3 |0 |0 |50 |0 | 0 |0 |0 |0 | 11 | |cylinder |0 |-300 |-200 |0 |90 |0 |0x3333FF |0.3 |0 | 0 |50 |0 | 0 |0 |0 |0 | 12 | |cylinder |0 |-400 |-200 |0 |90 |0 |0xFF6600 |0.3 |0 | 0 |50 |0 | 0 |0 |0 |0 | 13 | |cylinder |0 |300 |-200 |0 |90 |0 |0x3333FF |0.3 |0 | 0 |50 |0 | 0 |0 |0 |0 | 14 | |cylinder |0 |400 |-200 |0 |90 |0 |0xFF6600 |0.3 |0 | 0 |50 |0 | 0 |0 |0 |0 | 15 | 16 | #|cylinder |100 |0 |400 |90 |0 |0 |0xFF6600 |0.5 |0 |25 |50 |0 | 0 |0 |0 |0 | 17 | 18 | | sphere |200 |0 |0 |0 |0 |0 |0xFFFFFF |1 |0 |10 |2000 |0 | 0 |0 |0 |0 | 19 | | sphere |200 |-250 |0 |0 |0 |0 |0xFFFFFF |1 |0.5 |10 |200 |0 | 0 |0 |0 |0 | 20 | | sphere |200 | 250 |0 |0 |0 |0 |0xFFFFFF |1 |0.5 |10 |200 |0 | 0 |0 |0 |0 | 21 | | sphere |600 | 0 |0 |0 |0 |0 |0xFFFFFF |1 |0.5 |10 |200 |0 | 0 |0 |0 |0 | 22 | |*************************************************************************************************************************************************************************| 23 | 24 | ############################################# 25 | * threads => 4 * 26 | * anti-aliasing => 2 * 27 | * ambiance_light => 0 * 28 | * filter => 0 * 29 | ############################################# -------------------------------------------------------------------------------- /scene/acca.conf: -------------------------------------------------------------------------------- 1 | |object | pos_x | pos_y | pos_z | rot_x | rot_y | rot_z | color | reflexion | opacity | brightness | radius | angle | limit | disturb_x | disturb_y | check_frequency | 2 | |*************************************************************************************************************************************************************************| 3 | |eyes |-300 | 100 |100 |0 | 5 | 0 | |0 |0 |0 |0 |0 |0 |0 |0 |0 | 4 | |sphere | 38 | 20 |10 |0 |0 |0 |0xCCE1FF |0 |0 |0 |20 |0 |0 |0 |0 |0 | 5 | |sphere | 0 | 0 |10 |0 |0 |0 |0xCCE1FF |0 |0 |0 |20 |0 |0 |0 |0 |0 | 6 | |sphere | 38 | -20 |10 |0 |0 |0 |0xCCE1FF |0 |0 |0 |20 |0 |0 |0 |0 |0 | 7 | |sphere | 58 | 0 |10 |0 |0 |0 |0xCCE1FF |0 |0 |0 |20 |0 |0 |0 |0 |0 | 8 | |sphere | 20 | 0 |40 |0 |0 |0 |0x8CFF7C |0 |0 |0 |20 |0 |0 |0 |3 |0 | 9 | |sphere | 200 | 0|30 |0 |0 |0 |0xFFFFFF |0.3 |0 |0 |30 |0 |0 |0 |0 | 50 | 10 | # |parabole | 100 | 0 | 0 |0 |0 |0 |0x8CFF7C |0 |0 |0 |20 |20 |0 |0 |3 |0 | 11 | |sphere | 400 | 0 | 300 |0 |0 |0 |0x8CFF7C |0 |0 |0 |150 |0 | 2 |0 |3 |0 | 12 | |sphere | 20 | 0 | 60 | 00 | 0 | 0 |0x3333FF |0 | 0 | 0 |10 | 0 | 2 | 0 | 0 | 0 | 13 | |sphere | 10 | 15 | 40 | 0 | 0 | 00 |0x3333FF |0 | 0 | 0 |10 | 0 | 2 | 0 | 0 | 0 | 14 | |sphere | 10 | -15| 40 | 0 | 0 | 00 |0x3333FF |0 | 0 | 0 |10 | 0 | 2 | 0 | 0 | 0 | 15 | |plan | 0 | 0 |-10 |0 |0 |0 |0xEEEEEE |0.2 |0.5 |0 | 0 |0 |0 |0 |0 |500 | 16 | |light | -1000 | 0 | 5000 |0 |0 |0 |0xFF0000 |0 |0 |0 | 0 |0 |0 |0 |0 |0 | 17 | |light | 20 | -10 | 40 |0 |0 |0 |0xFF0000 |0 |0 |0 | 0 |0 |0 |0 |0 |0 | 18 | |*************************************************************************************************************************************************************************| 19 | 20 | ############################################# 21 | * threads => 4 * 22 | * anti-aliasing => 1 * 23 | * ambiance_light => 0.3 * 24 | * filter => 0 * 25 | * backscreen => xpm/osx_lion.xpm * 26 | ############################################# 27 | 28 | #***************************************************************************************************************# 29 | # Filters: 1.negativ 2.mix 3.sepia 4.black and white 5.red 6.green 7.blue 8.purple 9.cyan 10.grey # 30 | # # 31 | # # 32 | # # 33 | #***************************************************************************************************************# 34 | -------------------------------------------------------------------------------- /src/check_shadow.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** check_shadow.c for rt in /home/acca_b/Dropbox/EPITECH/Tek1/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by baptiste acca 5 | ** Login 6 | ** 7 | ** Started on Fri May 17 17:57:44 2013 baptiste acca 8 | ** Last update Sun Jun 9 16:10:11 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | static t_inter_obj g_inter_obj[6] = 14 | { 15 | {CONE_NB, &inter_cone}, 16 | {CYLINDER_NB, &inter_cylinder}, 17 | {SPHERE_NB, &inter_sphere}, 18 | {PLAN_NB, &inter_plan}, 19 | {PARABOLE_NB, &inter_parabole}, 20 | {HYPERBOLE_NB, &inter_hyperbole} 21 | }; 22 | 23 | void calc_prov_eye(t_rt *rt, t_object *object, 24 | t_vision *vision) 25 | { 26 | t_coord coord; 27 | 28 | coord.x = (rt->k * vision->vector->x 29 | + vision->eye->coord.x) - object->coord.x; 30 | coord.y = (rt->k * vision->vector->y 31 | + vision->eye->coord.y) - object->coord.y; 32 | coord.z = (rt->k * vision->vector->z 33 | + vision->eye->coord.z) - object->coord.z; 34 | vision->new_eye->coord.x = matrice_rotate_x(rt, &coord, object, -1); 35 | vision->new_eye->coord.y = matrice_rotate_y(rt, &coord, object, -1); 36 | vision->new_eye->coord.z = matrice_rotate_z(rt, &coord, object, -1); 37 | } 38 | 39 | void calc_prov_vector(t_rt *rt, t_light *light, 40 | t_object *object, t_vision *vision) 41 | { 42 | t_coord coord; 43 | 44 | coord.x = light->coord.x - (rt->k * vision->vector->x 45 | + vision->eye->coord.x); 46 | coord.y = light->coord.y - (rt->k * vision->vector->y 47 | + vision->eye->coord.y); 48 | coord.z = light->coord.z - (rt->k * vision->vector->z 49 | + vision->eye->coord.z); 50 | vision->new_vector->x = matrice_rotate_x(rt, &coord, object, -1); 51 | vision->new_vector->y = matrice_rotate_y(rt, &coord, object, -1); 52 | vision->new_vector->z = matrice_rotate_z(rt, &coord, object, -1); 53 | } 54 | 55 | double shadow_object(t_rt *rt, t_object *object, 56 | t_vision *vision, t_light *light) 57 | { 58 | t_negative negative; 59 | double ktmp; 60 | int count; 61 | 62 | rt->shadow = TRUE; 63 | negative.object = object; 64 | negative.eye = vision->new_eye; 65 | negative.vector = vision->new_vector; 66 | negative.light = light; 67 | negative.vision = vision; 68 | ktmp = rt->k; 69 | count = 0; 70 | while (count < 6 && object->object_nb != g_inter_obj[count].nb) 71 | count++; 72 | if (count != 6) 73 | ktmp = g_inter_obj[count].inter_obj(rt, &negative); 74 | return (ktmp); 75 | } 76 | 77 | void shadow_save_restore_eye(double (*tmp)[6], 78 | t_vision *vision, 79 | char status) 80 | { 81 | if (status == 0) 82 | { 83 | (*tmp)[0] = vision->new_vector->x; 84 | (*tmp)[1] = vision->new_vector->y; 85 | (*tmp)[2] = vision->new_vector->z; 86 | (*tmp)[3] = vision->new_eye->coord.x; 87 | (*tmp)[4] = vision->new_eye->coord.y; 88 | (*tmp)[5] = vision->new_eye->coord.z; 89 | } 90 | else 91 | { 92 | vision->new_vector->x = (*tmp)[0]; 93 | vision->new_vector->y = (*tmp)[1]; 94 | vision->new_vector->z = (*tmp)[2]; 95 | vision->new_eye->coord.x = (*tmp)[3]; 96 | vision->new_eye->coord.y = (*tmp)[4]; 97 | vision->new_eye->coord.z = (*tmp)[5]; 98 | } 99 | } 100 | 101 | char check_shadow(t_rt *rt, t_light *light, 102 | t_vision *vision) 103 | { 104 | t_object *object_tmp; 105 | double ktmp; 106 | char ret; 107 | double tmp[6]; 108 | 109 | ret = 1; 110 | object_tmp = rt->first_object; 111 | shadow_save_restore_eye(&tmp, vision, 0); 112 | while (object_tmp != NULL) 113 | { 114 | if (object_tmp->limit == 0) 115 | { 116 | calc_prov_eye(rt, object_tmp, vision); 117 | calc_prov_vector(rt, light, object_tmp, vision); 118 | ktmp = shadow_object(rt, object_tmp, vision, light); 119 | if (ktmp > 0.00001 && ktmp < 1) 120 | ret = 0; 121 | } 122 | object_tmp = object_tmp->next; 123 | } 124 | shadow_save_restore_eye(&tmp, vision, 1); 125 | return (ret); 126 | } 127 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ## 2 | ## Makefile for rt in /home/chauch_a//raytracer-2017-chanut_g 3 | ## 4 | ## Made by alan chauchet 5 | ## Login 6 | ## 7 | ## Started on Wed Apr 3 11:32:46 2013 alan chauchet 8 | ## Last update Sun Jun 9 18:27:00 2013 adrien domoison 9 | ## 10 | 11 | NAME = rt 12 | 13 | PATH1 = include/ 14 | 15 | PATH2 = src/ 16 | 17 | PATH3 = src/lib/ 18 | 19 | SCENE = scene/ 20 | 21 | SRC = $(PATH2)main.c \ 22 | $(PATH2)bsc.c \ 23 | $(PATH2)general_params.c \ 24 | $(PATH2)bmp.c \ 25 | $(PATH2)resize_aliasing.c \ 26 | $(PATH2)init_rt.c \ 27 | $(PATH2)object_list_two.c \ 28 | $(PATH2)get_file.c \ 29 | $(PATH2)read_file.c \ 30 | $(PATH2)open_file.c \ 31 | $(PATH2)add_elem.c \ 32 | $(PATH2)my_rev_list.c \ 33 | $(PATH2)show_list.c \ 34 | $(PATH2)pars_first_line.c \ 35 | $(PATH2)my_linked_list_len.c \ 36 | $(PATH2)my_free_list.c \ 37 | $(PATH2)check_right_name.c \ 38 | $(PATH2)check_separator_number.c \ 39 | $(PATH2)fill_struct_tab.c \ 40 | $(PATH2)redirect_appropriate_function.c \ 41 | $(PATH2)object_list_one.c \ 42 | $(PATH2)get_eyes_spec.c \ 43 | $(PATH2)get_light_specs.c \ 44 | $(PATH2)get_column_number.c \ 45 | $(PATH2)get_specs.c \ 46 | $(PATH2)add_object.c \ 47 | $(PATH2)get_adress_specs.c \ 48 | $(PATH2)check_color_syntax.c \ 49 | $(PATH2)check_eyes_number.c \ 50 | $(PATH2)free_object_list.c \ 51 | $(PATH2)get_color_hex_str.c \ 52 | $(PATH2)check_option.c \ 53 | $(PATH2)get_wolf_param.c \ 54 | $(PATH2)default_size_window.c \ 55 | $(PATH2)get_window_size.c \ 56 | $(PATH2)init_param.c \ 57 | $(PATH2)raytracing.c \ 58 | $(PATH2)search_inter.c \ 59 | $(PATH2)load_cos_and_sin.c \ 60 | $(PATH2)aff_loading.c \ 61 | $(PATH2)clear_img.c \ 62 | $(PATH2)key_hook.c \ 63 | $(PATH2)calc_rot_eye.c \ 64 | $(PATH2)object_loop.c \ 65 | $(PATH2)matrice_rotate.c \ 66 | $(PATH2)calc_matrice.c \ 67 | $(PATH2)add_light.c \ 68 | $(PATH2)sphere.c \ 69 | $(PATH2)cylinder.c \ 70 | $(PATH2)plan.c \ 71 | $(PATH2)cone.c \ 72 | $(PATH2)parabole.c \ 73 | $(PATH2)hyperbole.c \ 74 | $(PATH2)apply_color.c \ 75 | $(PATH2)free_light_list.c \ 76 | $(PATH2)my_pixel_put.c \ 77 | $(PATH2)get_general_params.c \ 78 | $(PATH2)expose_hook.c \ 79 | $(PATH2)loop_light.c \ 80 | $(PATH2)check_shadow.c \ 81 | $(PATH2)cpy_general_struct.c \ 82 | $(PATH2)cpy_object_list.c \ 83 | $(PATH2)cpy_light_list.c \ 84 | $(PATH2)thread_create.c \ 85 | $(PATH2)transparency.c \ 86 | $(PATH2)reflexion.c \ 87 | $(PATH2)reflexion_calc.c \ 88 | $(PATH2)resize_window_aliasing.c \ 89 | $(PATH2)resize_window_anti_aliasing.c \ 90 | $(PATH2)antialiasing.c \ 91 | $(PATH2)aliasing.c \ 92 | $(PATH2)negative_object.c \ 93 | $(PATH2)normal_perturbation.c \ 94 | $(PATH2)filter_color.c \ 95 | $(PATH2)apply_filter1.c \ 96 | $(PATH2)apply_filter2.c \ 97 | $(PATH2)damier.c \ 98 | $(PATH2)get_backscreen.c \ 99 | $(PATH2)pixel_backscreen.c \ 100 | $(PATH3)epur_line.c \ 101 | $(PATH3)my_puterror.c \ 102 | $(PATH3)my_putstr.c \ 103 | $(PATH3)my_strcat.c \ 104 | $(PATH3)my_strlen.c \ 105 | $(PATH3)my_strcmp.c \ 106 | $(PATH3)my_memset.c \ 107 | $(PATH3)my_strdup.c \ 108 | $(PATH3)my_str_isnum.c \ 109 | $(PATH3)my_putchar.c \ 110 | $(PATH3)my_putnbr.c \ 111 | $(PATH3)my_atoi_base.c \ 112 | 113 | OBJ = $(SRC:.c=.o) 114 | 115 | CFLAGS = -W -Wall -Werror -Wextra -Wshadow -I$(PATH1) 116 | 117 | LIB = -L/usr/X11/lib -lmlx -lXext -lX11 -lm -lpthread 118 | 119 | all: $(NAME) 120 | 121 | $(NAME): $(OBJ) 122 | cc -o $(NAME) $(OBJ) $(LIB) 123 | @echo -en "\t\033[32m> " $(NAME) " compiled\033[0m\n" 124 | 125 | clean: 126 | clean 127 | rm -f $(OBJ) 128 | @echo -en "\t\033[35m> " $(NAME) " cleaned\033[0m\n" 129 | 130 | fclean: clean 131 | rm -f $(NAME) 132 | @echo -en "\t\033[31m> " $(NAME) " executable removed\033[0m\n" 133 | 134 | re: fclean all 135 | -------------------------------------------------------------------------------- /scene/abgral2.conf: -------------------------------------------------------------------------------- 1 | |object | pos_x | pos_y | pos_z | rot_x | rot_y | rot_z | color | reflexion | opacity | brightness | radius | angle | limit | disturb_x | disturb_y | check_frequency | 2 | |*************************************************************************************************************************************************************************| 3 | |eyes |-1000 |0 |0 |0 |0 |0 | |0 |0 |0 |0 |0 |0 |0 |0 |0 | 4 | |light |-300 | 0 |500 |0 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 5 | |cylinder |0 |0 |-200 |0 |90 |0 |0xFF6600 |0.5 |0 |0 |50 |0 | 0 |0 |0 |0 | 6 | |cylinder |0 |-100 |-200 |0 |90 |0 |0x3333FF |0.5 |0 | 0 |50 |0 | 0 |0 |0 |0 | 7 | |cylinder |0 |-200 |-200 |0 |90 |0 |0xFF6600 |0.5 |0 | 0 |50 |0 | 0 |0 |0 |0 | 8 | |cylinder |0 |100 |-200 |0 |90 |0 |0x3333FF |0.5 |0 | 0 |50 |0 | 0 |0 |0 |0 | 9 | |cylinder |0 |200 |-200 |0 |90 |0 |0xFF6600 |0.5 |0 |0 |50 |0 | 0 |0 |0 |0 | 10 | |cylinder |0 |-300 |-200 |0 |90 |0 |0x3333FF |0.5 |0 | 0 |50 |0 | 0 |0 |0 |0 | 11 | |cylinder |0 |-400 |-200 |0 |90 |0 |0xFF6600 |0.5 |0 | 0 |50 |0 | 0 |0 |0 |0 | 12 | |cylinder |0 |300 |-200 |0 |90 |0 |0x3333FF |0.5 |0 | 0 |50 |0 | 0 |0 |0 |0 | 13 | |cylinder |0 |400 |-200 |0 |90 |0 |0xFF6600 |0.5 |0 | 0 |50 |0 | 0 |0 |0 |0 | 14 | |cylinder |0 |400 |-200 |0 |90 |0 |0xFF6600 |0.5 |0 | 0 |50 |0 | 0 |0 |0 |0 | 15 | |sphere |200 |-250 |0 |0 |0 |0 |0xFFFFFF |1 |0 |10 |200 |0 | 0 |0 |0 |0 | 16 | |sphere |200 | 250 |0 |0 |0 |0 |0xFFFFFF |1 |0 |10 |200 |0 | 0 |0 |0 |0 | 17 | |sphere |-100 | -600 |350 |0 |0 |0 |0xFFFFFF |1 |0 |10 |150 |0 | 0 |0 |0 |0 | 18 | |sphere |-100 | 600 |350 |0 |0 |0 |0xFFFFFF |1 |0 |10 |150 |0 | 0 |0 |0 |0 | 19 | |sphere |600 | 0 |0 |0 |0 |0 |0xFFFFFF |1 |0 |10 |200 |0 | 0 |0 |0 |0 | 20 | |sphere | 200 |0 |400 |0 |0 |0 |0x3333FF |0.3 |0 |0 |200 |0 | 0 |0 |0 |0 | 21 | |cylinder |200 |-375 |200 |-45 |0 |0 |0xFF6600 |0.3 |0 |0 |50 |0 | 0 |0 |0 |0 | 22 | |cylinder |200 |375 |200 |45 |0 |0 |0xFF6600 |0.3 |0 |0 |50 |0 | 0 |0 |0 |0 | 23 | |*************************************************************************************************************************************************************************| 24 | 25 | ############################################# 26 | * threads => 4 * 27 | * anti-aliasing => 8 * 28 | * aliasing => 1 * 29 | * ambiance_light => 0 * 30 | * filter => 0 * 31 | * backscreen => xpm/osx_lion.xpm * 32 | ############################################# 33 | -------------------------------------------------------------------------------- /scene/abgral2.conf~: -------------------------------------------------------------------------------- 1 | |object | pos_x | pos_y | pos_z | rot_x | rot_y | rot_z | color | reflexion | opacity | brightness | radius | angle | limit | disturb_x | disturb_y | check_frequency | 2 | |*************************************************************************************************************************************************************************| 3 | |eyes |-1000 |0 |0 |0 |0 |0 | |0 |0 |0 |0 |0 |0 |0 |0 |0 | 4 | |light |-300 | 0 |500 |0 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 5 | |cylinder |0 |0 |-200 |0 |90 |0 |0xFF6600 |0.5 |0 |0 |50 |0 | 0 |0 |0 |0 | 6 | |cylinder |0 |-100 |-200 |0 |90 |0 |0x3333FF |0.5 |0 | 0 |50 |0 | 0 |0 |0 |0 | 7 | |cylinder |0 |-200 |-200 |0 |90 |0 |0xFF6600 |0.5 |0 | 0 |50 |0 | 0 |0 |0 |0 | 8 | |cylinder |0 |100 |-200 |0 |90 |0 |0x3333FF |0.5 |0 | 0 |50 |0 | 0 |0 |0 |0 | 9 | |cylinder |0 |200 |-200 |0 |90 |0 |0xFF6600 |0.5 |0 |0 |50 |0 | 0 |0 |0 |0 | 10 | |cylinder |0 |-300 |-200 |0 |90 |0 |0x3333FF |0.5 |0 | 0 |50 |0 | 0 |0 |0 |0 | 11 | |cylinder |0 |-400 |-200 |0 |90 |0 |0xFF6600 |0.5 |0 | 0 |50 |0 | 0 |0 |0 |0 | 12 | |cylinder |0 |300 |-200 |0 |90 |0 |0x3333FF |0.5 |0 | 0 |50 |0 | 0 |0 |0 |0 | 13 | |cylinder |0 |400 |-200 |0 |90 |0 |0xFF6600 |0.5 |0 | 0 |50 |0 | 0 |0 |0 |0 | 14 | |cylinder |0 |400 |-200 |0 |90 |0 |0xFF6600 |0.5 |0 | 0 |50 |0 | 0 |0 |0 |0 | 15 | |sphere |200 |-250 |0 |0 |0 |0 |0xFFFFFF |1 |0 |10 |200 |0 | 0 |0 |0 |0 | 16 | |sphere |200 | 250 |0 |0 |0 |0 |0xFFFFFF |1 |0 |10 |200 |0 | 0 |0 |0 |0 | 17 | |sphere |-100 | -600 |350 |0 |0 |0 |0xFFFFFF |1 |0 |10 |150 |0 | 0 |0 |0 |0 | 18 | |sphere |-100 | 600 |350 |0 |0 |0 |0xFFFFFF |1 |0 |10 |150 |0 | 0 |0 |0 |0 | 19 | |sphere |600 | 0 |0 |0 |0 |0 |0xFFFFFF |1 |0 |10 |200 |0 | 0 |0 |0 |0 | 20 | |sphere | 200 |0 |400 |0 |0 |0 |0x3333FF |0.3 |0 |0 |200 |0 | 0 |0 |0 |0 | 21 | |cylinder |200 |-375 |200 |-45 |0 |0 |0xFF6600 |0.3 |0 |0 |50 |0 | 0 |0 |0 |0 | 22 | |cylinder |200 |375 |200 |45 |0 |0 |0xFF6600 |0.3 |0 |0 |50 |0 | 0 |0 |0 |0 | 23 | |*************************************************************************************************************************************************************************| 24 | 25 | ############################################# 26 | * threads => 4 * 27 | * anti-aliasing => 8 * 28 | * aliasing => 1 * 29 | * ambiance_light => 0 * 30 | * filter => 0 * 31 | * backscreen => xpm/osx_lion.xpm * 32 | ############################################# 33 | -------------------------------------------------------------------------------- /src/object_list_one.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** object_list_one.c for objecy_list_one.c in /home/abgral_f//Dropbox/Raytracer/raytracer-2017-chanut_g/src 3 | ** 4 | ** Made by franck abgrall 5 | ** Login 6 | ** 7 | ** Started on Sat May 11 19:44:11 2013 franck abgrall 8 | ** Last update Sun Jun 9 16:03:56 2013 alan chauchet 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | int get_sphere_specs(t_list *list, int object_nb, t_rt *rt) 14 | { 15 | if (object_nb == SPHERE_NB) 16 | { 17 | if (add_object(rt, object_nb) == EXIT_FAILURE) 18 | return (EXIT_FAILURE); 19 | if (get_coord(list, rt) == EXIT_FAILURE) 20 | return (EXIT_FAILURE); 21 | if (get_rotate(list, rt) == EXIT_FAILURE) 22 | return (EXIT_FAILURE); 23 | if ((rt->last_object->color = 24 | get_color(list, rt, COLOR_NB)) == EXIT_FAILURE) 25 | return (EXIT_FAILURE); 26 | if (get_effects(list, rt) == EXIT_FAILURE) 27 | return (EXIT_FAILURE); 28 | if ((rt->last_object->param = 29 | get_specs(list, rt, RADIUS_NB)) == -1) 30 | return (EXIT_FAILURE); 31 | if ((rt->last_object->limit = get_specs(list, rt, LIMIT_NB)) 32 | == -1) 33 | return (EXIT_FAILURE); 34 | } 35 | return (EXIT_SUCCESS); 36 | } 37 | 38 | int get_cylinder_specs(t_list *list, int object_nb, t_rt *rt) 39 | { 40 | if (object_nb == CYLINDER_NB) 41 | { 42 | if (add_object(rt, object_nb) == EXIT_FAILURE) 43 | return (EXIT_FAILURE); 44 | if (get_coord(list, rt) == EXIT_FAILURE) 45 | return (EXIT_FAILURE); 46 | if ((rt->last_object->color = 47 | get_color(list, rt, COLOR_NB)) == EXIT_FAILURE) 48 | return (EXIT_FAILURE); 49 | if (get_rotate(list, rt) == EXIT_FAILURE) 50 | return (EXIT_FAILURE); 51 | if (get_effects(list, rt) == EXIT_FAILURE) 52 | return (EXIT_FAILURE); 53 | if ((rt->last_object->param = 54 | get_specs(list, rt, RADIUS_NB)) == -1) 55 | return (EXIT_FAILURE); 56 | if ((rt->last_object->limit = get_specs(list, rt, LIMIT_NB)) 57 | == -1) 58 | return (EXIT_FAILURE); 59 | } 60 | return (EXIT_SUCCESS); 61 | } 62 | 63 | int get_plan_specs(t_list *list, int object_nb, t_rt *rt) 64 | { 65 | if (object_nb == PLAN_NB) 66 | { 67 | if (add_object(rt, object_nb) == EXIT_FAILURE) 68 | return (EXIT_FAILURE); 69 | if (get_coord(list, rt) == EXIT_FAILURE) 70 | return (EXIT_FAILURE); 71 | if ((rt->last_object->color = 72 | get_color(list, rt, COLOR_NB)) == EXIT_FAILURE) 73 | return (EXIT_FAILURE); 74 | if (get_rotate(list, rt) == EXIT_FAILURE) 75 | return (EXIT_FAILURE); 76 | if (get_effects(list, rt) == -1) 77 | return (EXIT_FAILURE); 78 | if ((rt->last_object->limit = get_specs(list, rt, LIMIT_NB)) 79 | == -1) 80 | return (EXIT_FAILURE); 81 | } 82 | return (EXIT_SUCCESS); 83 | } 84 | 85 | int get_parabole_specs(t_list *list, int object_nb, t_rt *rt) 86 | { 87 | if (object_nb == PARABOLE_NB) 88 | { 89 | if (add_object(rt, object_nb) == EXIT_FAILURE) 90 | return (EXIT_FAILURE); 91 | if (get_coord(list, rt) == EXIT_FAILURE) 92 | return (EXIT_FAILURE); 93 | if (get_rotate(list, rt) == EXIT_FAILURE) 94 | return (EXIT_FAILURE); 95 | if ((rt->last_object->color = 96 | get_color(list, rt, COLOR_NB)) == EXIT_FAILURE) 97 | return (EXIT_FAILURE); 98 | if (get_effects(list, rt) == -1) 99 | return (EXIT_FAILURE); 100 | if ((rt->last_object->param = get_specs(list, rt, ANGLE_NB)) 101 | == -1) 102 | return (EXIT_FAILURE); 103 | if ((rt->last_object->limit = get_specs(list, rt, LIMIT_NB)) 104 | == -1) 105 | return (EXIT_FAILURE); 106 | } 107 | return (EXIT_SUCCESS); 108 | } 109 | 110 | int get_hyperbole_specs(t_list *list, int object_nb, t_rt *rt) 111 | { 112 | if (object_nb == HYPERBOLE_NB) 113 | { 114 | if (add_object(rt, object_nb) == EXIT_FAILURE) 115 | return (EXIT_FAILURE); 116 | if (get_coord(list, rt) == EXIT_FAILURE) 117 | return (EXIT_FAILURE); 118 | if (get_rotate(list, rt) == EXIT_FAILURE) 119 | return (EXIT_FAILURE); 120 | if ((rt->last_object->color = 121 | get_color(list, rt, COLOR_NB)) == EXIT_FAILURE) 122 | return (EXIT_FAILURE); 123 | if (get_effects(list, rt) == -1) 124 | return (EXIT_FAILURE); 125 | if ((rt->last_object->radius = 126 | get_specs(list, rt, RADIUS_NB)) == -1) 127 | return (EXIT_FAILURE); 128 | if ((rt->last_object->param = get_specs(list, rt, ANGLE_NB)) 129 | == -1) 130 | return (EXIT_FAILURE); 131 | if ((rt->last_object->limit = get_specs(list, rt, LIMIT_NB)) 132 | == -1) 133 | return (EXIT_FAILURE); 134 | } 135 | return (EXIT_SUCCESS); 136 | } 137 | -------------------------------------------------------------------------------- /src/negative_object.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** negative_object.c for negative_object.c in /home/loeb_t/Dropbox/Raytracer/transparence/src 3 | ** 4 | ** Made by thomas loeb 5 | ** Login 6 | ** 7 | ** Started on Sun Jun 2 15:19:22 2013 thomas loeb 8 | ** Last update Sun Jun 9 14:43:17 2013 thomas loeb 9 | */ 10 | 11 | #include "raytracer.h" 12 | 13 | static t_inter_obj g_inter_obj[5] = 14 | { 15 | {CONE_NB, &inter_cone}, 16 | {CYLINDER_NB, &inter_cylinder}, 17 | {SPHERE_NB, &inter_sphere}, 18 | {PARABOLE_NB, &inter_parabole}, 19 | {HYPERBOLE_NB, &inter_hyperbole} 20 | }; 21 | 22 | double negative_inter(t_rt *rt, t_negative *neg, 23 | char negative, t_object *object) 24 | { 25 | double ktmp; 26 | int count; 27 | 28 | rt->negative = negative; 29 | count = 0; 30 | ktmp = -1; 31 | while (count < 5 && object->object_nb != g_inter_obj[count].nb) 32 | count++; 33 | if (count < 5) 34 | ktmp = g_inter_obj[count].inter_obj(rt, neg); 35 | return (ktmp); 36 | } 37 | 38 | void negative_modify(t_rt *rt, t_negative *tmp, 39 | t_object *object, t_negative *neg) 40 | { 41 | tmp->object = object; 42 | tmp->light = neg->light; 43 | tmp->vision = neg->vision; 44 | rt->inter_neg.neg_forward = negative_inter(rt, tmp, 1, object); 45 | rt->inter_neg.neg_backward = negative_inter(rt, tmp, 2, object); 46 | if (rt->inter_neg.neg_forward < rt->inter_neg.obj_forward && 47 | rt->inter_neg.neg_backward > rt->inter_neg.obj_forward) 48 | { 49 | if (rt->inter_neg.obj_backward == -2) 50 | rt->inter_neg.obj_forward = -1; 51 | else 52 | { 53 | if (rt->inter_neg.obj_backward > rt->inter_neg.neg_backward) 54 | { 55 | rt->inter_neg.obj_forward = rt->inter_neg.obj_backward; 56 | rt->inside = TRUE; 57 | } 58 | else 59 | rt->inter_neg.obj_forward = -1; 60 | } 61 | } 62 | } 63 | 64 | void negative_shadow(t_rt *rt, t_negative *neg, 65 | t_object *prov, t_negative *negative) 66 | { 67 | t_coord coord; 68 | 69 | coord.x = (rt->k * neg->vision->vector->x 70 | + neg->vision->eye->coord.x) - prov->coord.x; 71 | coord.y = (rt->k * neg->vision->vector->y 72 | + neg->vision->eye->coord.y) - prov->coord.y; 73 | coord.z = (rt->k * neg->vision->vector->z 74 | + neg->vision->eye->coord.z) - prov->coord.z; 75 | negative->prov_eye.coord.x = matrice_rotate_x(rt, &coord, prov, -1); 76 | negative->prov_eye.coord.y = matrice_rotate_y(rt, &coord, prov, -1); 77 | negative->prov_eye.coord.z = matrice_rotate_z(rt, &coord, prov, -1); 78 | coord.x = neg->light->coord.x - (rt->k * neg->vision->vector->x 79 | + neg->vision->eye->coord.x); 80 | coord.y = neg->light->coord.y - (rt->k * neg->vision->vector->y 81 | + neg->vision->eye->coord.y); 82 | coord.z = neg->light->coord.z - (rt->k * neg->vision->vector->z 83 | + neg->vision->eye->coord.z); 84 | negative->prov_vector.x = matrice_rotate_x(rt, &coord, prov, -1); 85 | negative->prov_vector.y = matrice_rotate_y(rt, &coord, prov, -1); 86 | negative->prov_vector.z = matrice_rotate_z(rt, &coord, prov, -1); 87 | } 88 | 89 | void negative_matrice(t_rt *rt, t_negative *neg, 90 | t_object *prov, t_negative *negative) 91 | { 92 | t_coord coord; 93 | 94 | if (rt->shadow == FALSE) 95 | { 96 | coord.x = (neg->vision->eye->coord.x - prov->coord.x); 97 | coord.y = (neg->vision->eye->coord.y - prov->coord.y); 98 | coord.z = (neg->vision->eye->coord.z - prov->coord.z); 99 | negative->prov_eye.coord.x = matrice_rotate_x(rt, &coord, prov, -1); 100 | negative->prov_eye.coord.y = matrice_rotate_y(rt, &coord, prov, -1); 101 | negative->prov_eye.coord.z = matrice_rotate_z(rt, &coord, prov, -1); 102 | negative->prov_vector.x = 103 | matrice_rotate_x(rt, neg->vision->vector, prov, -1); 104 | negative->prov_vector.y = 105 | matrice_rotate_y(rt, neg->vision->vector, prov, -1); 106 | negative->prov_vector.z = 107 | matrice_rotate_z(rt, neg->vision->vector, prov, -1); 108 | } 109 | else 110 | negative_shadow(rt, neg, prov, negative); 111 | } 112 | 113 | double negative_object(t_rt *rt, double k_obj, 114 | double behind, t_negative *neg) 115 | { 116 | t_object *prov; 117 | t_negative negative; 118 | 119 | prov = rt->first_object; 120 | rt->inter_neg.neg_forward = -1; 121 | rt->inter_neg.obj_forward = k_obj; 122 | rt->inter_neg.obj_backward = behind; 123 | while (prov != NULL) 124 | { 125 | if (prov->limit != 0) 126 | { 127 | negative_matrice(rt, neg, prov, &negative); 128 | negative.eye = &negative.prov_eye; 129 | negative.vector = &negative.prov_vector; 130 | negative_modify(rt, &negative, prov, neg); 131 | } 132 | prov = prov->next; 133 | } 134 | rt->negative = 1; 135 | if (rt->inter_neg.obj_forward != rt->inter_neg.obj_backward || 136 | rt->shadow == TRUE) 137 | rt->negative = 0; 138 | return (rt->inter_neg.obj_forward); 139 | } 140 | -------------------------------------------------------------------------------- /scene/domois_a.conf: -------------------------------------------------------------------------------- 1 | |object | pos_x | pos_y | pos_z | rot_x | rot_y | rot_z | color | reflexion | opacity | brightness | radius | angle | limit | disturb_x | disturb_y | check_frequency | 2 | |************************************************************************************************************************************************************************| 3 | |eyes |-1000 |0 |0 |0 |0 |0 | |0 |0 |0 |0 |0 |0 |0 |0 |0 | 4 | |light |-1000 | 0 |0 |0 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 5 | |plan | 0 | 0 | 400 |0 |180 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 6 | |plan | 0 | 400 | 0 |90 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 7 | |plan | 0 |-400 | 0 |270 |0 |0 |0xFFFFFF |0 |0 |0 |0 |0 | 0 |0 |0 |0 | 8 | |cylinder | 0 | 0 | -800 |0 |90 |0 |0xFF0000 |0.7 |0.5 |0 |500 |0 | 0 |0 |0 |0 | 9 | |sphere | 50 | -100 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 10 | |sphere | 10 | -20 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 11 | |sphere | 100 | 50 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 12 | |sphere | 200 | -80 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 13 | |sphere | 300 | 100 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 14 | |sphere | 400 | -200 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 15 | |sphere | 600 | 50 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 16 | |sphere | 800 | -80 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 17 | |sphere | 900 | 100 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 18 | |sphere | 1000 | -200 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 19 | |sphere | 1200 | 50 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 20 | |sphere | 1300 | -80 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 21 | |sphere | 1400 | 100 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 22 | |sphere | 2000 | -200 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 23 | |sphere | 2500 | -100 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 24 | |sphere | 3000 | -20 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 25 | |sphere | 4500 | 50 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 26 | |sphere | 5000 | -80 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 27 | |sphere | 5400 | 100 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 28 | |sphere | 5900 | -200 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 29 | |sphere | 6100 | 50 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 30 | |sphere | 6230 | -80 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 31 | |sphere | 6480 | 100 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 32 | |sphere | 6980 | -200 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 33 | |sphere | 7000 | 50 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 34 | |sphere | 7510 | -80 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 35 | |sphere | 8000 | 100 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 36 | |sphere | 1000 | -200 | -400 |0 |90 |0 |0xFF0000 |0 |0 |0 |50 |0 | 0 |0 |0 |0 | 37 | |************************************************************************************************************************************************************************| 38 | 39 | ############################################# 40 | * threads => 4 * 41 | * anti-aliasing => 1 * 42 | * aliasing => 1 * 43 | * ambiance_light => 0 * 44 | * filter => 0 * 45 | ############################################# 46 | --------------------------------------------------------------------------------