-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap_normal_triangle.c
29 lines (26 loc) · 1.39 KB
/
map_normal_triangle.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* map_normal_triangle.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ajaehaer <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/21 16:34:57 by ajaehaer #+# #+# */
/* Updated: 2019/02/22 17:18:34 by ajaehaer ### ########.fr */
/* */
/* ************************************************************************** */
#include "engine_render.h"
void map_normal_triangle(t_intersection *inter)
{
t_triangle *triangle;
t_vector tangent;
t_4x4matrix new_basis;
t_vector new_normal;
triangle = (t_triangle*)inter->primitive->primitive;
tangent = normalize(vector_sub(triangle->c, triangle->a));
new_basis = change_basis_matrix(
tangent, inter->normal, (t_vector){0, 0, 0, 0});
new_normal = get_normal_uv(inter->primitive, inter->uv);
new_normal = normalize(vector_matrix_mul(new_normal, new_basis));
inter->mapped_normal = new_normal;
}