-
Notifications
You must be signed in to change notification settings - Fork 0
/
raytracer.c
43 lines (40 loc) · 1.03 KB
/
raytracer.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
/*
** raytracer.c for raytracer in /home/nicolas/Modules/gfx_raytracer1
**
** Made by menett_a
** Login <[email protected]>
**
** Started on Tue Mar 1 22:02:01 2016 menett_a
** Last update Sat Mar 12 16:42:42 2016 menett_a
*/
#include <lapin.h>
#include <unistd.h>
#include "struct.h"
#include "proto.h"
void check_collision(t_loop *data)
{
sphere_collision(data, &data->info);
plan_collision(data, &data->info);
cone_collision(data, &data->info);
cylinder_collision(data, &data->info);
}
void raytracer(t_loop *data)
{
data->ray.j = 0;
while (data->ray.j < data->pix->clipable.clip_height)
{
data->ray.i = 0;
while (data->ray.i < data->pix->clipable.clip_width)
{
init_values(data);
vec_normalize(&data->ray.vec_x, &data->ray.vec_y,
&data->ray.vec_z);
check_collision(data);
if (data->collision.dist == 0)
data->collision._color.full = BLACK;
tekpixel(data->pix, &data->collision.pos, &data->collision._color);
data->ray.i = data->ray.i + 1;
}
data->ray.j = data->ray.j + 1;
}
}