void ft_init_vectors(t_dt *dt, float aliax, float aliay) { int pix[2]; int x; int y; float *vec_tmp; dt->foc = 1 / tan(PHI / 2); dt->vect = (float ***)malloc(sizeof(float **) * dt->y_max); y = -1; while (++y < dt->y_max) { dt->vect[y] = (float **)malloc(sizeof(float *) * dt->x_max); x = -1; while (++x < dt->x_max) { dt->vect[y][x] = (float *)malloc(sizeof(float) * 3); pix[0] = x; pix[1] = y; vec_tmp = ft_get_vector(dt, pix, aliax, aliay); dt->vect[y][x][0] = vec_tmp[0]; dt->vect[y][x][1] = vec_tmp[1]; dt->vect[y][x][2] = vec_tmp[2]; free(vec_tmp); } } }
void ft_init_ray(t_ray *ray, t_dt *dt) { ray->opt_f = dt->opt_f; ray->delta = dt->delta; ft_get_vector(dt, ray); ft_change_base(dt, ray); ray->rec = 1; ray->d = D_MAX; ray->dneg = 0; ray->refl = NULL; ray->tran = NULL; ray->O[0] = dt->cam_pos[0]; ray->O[1] = dt->cam_pos[1]; ray->O[2] = dt->cam_pos[2]; }
int ft_parse_triangle(char *l, t_object *o, int *i) { if (ft_strc(l, 't')) { o->q1 = ft_get_next_point(l, i); o->q2 = ft_get_next_point(l, i); o->q3 = ft_get_next_point(l, i); o->p = o->q1; } if (ft_strc(l, 'c')) { o->dc[0] = ft_get_next_number(l, i) / 255.0; o->dc[1] = ft_get_next_number(l, i) / 255.0; o->dc[2] = ft_get_next_number(l, i) / 255.0; } o->n = ft_cross_vec(ft_get_vector(&o->q1, &o->q2), ft_get_vector(&o->q1, &o->q3)); ft_get_n_vector(o->n, &o->n, 0); ft_parse_coefficients(l, o, i); ft_parse_noise(l, o, i); if (ft_strc(l, '}')) return (0); return (1); }
void ft_apply_all_matrix(t_scene *scn) { t_matrix a; t_matrix b; t_matrix m; m = ft_init_matrix(); a = ft_scale_matrix(scn->scale); if (scn->projection == 1) scn->rot = ft_get_vector(-1.1, 0.0, 0.80, 1.0); b = ft_rotation_matrix_z(scn->rot); m = ft_muli_matrix(b, a); b = ft_rotation_matrix_y(scn->rot); m = ft_muli_matrix(b, m); b = ft_rotation_matrix_x(scn->rot); m = ft_muli_matrix(b, m); b = ft_translation_matrix(scn->trans); m = ft_muli_matrix(b, m); ft_apply_all_vector(m, scn); }