-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_file7.c
62 lines (56 loc) · 1.76 KB
/
ft_file7.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_file7.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ymoukhli <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/07/11 20:43:39 by ymoukhli #+# #+# */
/* Updated: 2019/08/08 20:13:16 by ymoukhli ### ########.fr */
/* */
/* ************************************************************************** */
#include "./rtparse.h"
#include "rtv1.h"
void objects_translation(t_vect *pos, t_vect *trans)
{
pos->x += trans->x;
pos->y += trans->y;
pos->z += trans->z;
}
void ft_change_param(t_params *init)
{
t_obj *obj;
t_cam cam;
float f;
cam.pos = ft_get_position(init);
obj = init->obj;
while (obj)
{
objects_translation(&obj->pos, &obj->trs);
if (obj->type == plane)
{
obj->nor = vec_normalise(obj->nor);
f = vec_dot(obj->nor, vec_normalise(vec_sub(cam.pos, obj->pos)));
if (f < 0)
obj->nor = vec_mult(-1, obj->nor);
rot(&obj->nor, &obj->rot);
}
else
{
obj->dir = vec_normalise(obj->dir);
rot(&obj->dir, &obj->rot);
}
obj = obj->next;
}
}
int config_check(char *file_name, t_params *init)
{
t_config data;
data = ft_parse_file(file_name);
init->sce = &(data.scene);
init->obj = data.obj;
ft_change_param(init);
ft_init(init);
ft_calcule(init);
return (1);
}