Ejemplo n.º 1
0
void	ft_impact(t_draw_suite *val, t_ray *ray, t_tool *t)
{
	val->impact->o = vectoradd(ray->o,
	vectorscale(val->curobject->dist, ray->d));
	find_normal(val->impact, val->curobject);
	vectornorm(val->impact->d);
	init_color(t, val->curobject->color, val->final_color);
	val->curlight = t->l_lights;
	while (val->curlight)
	{
		val->lightray->o = vectorcopy(val->curlight->o);
		val->lightray->d = vectorsub(val->impact->o, val->lightray->o);
		vectornorm(val->lightray->d);
		if ((val->curobject2 = intersection(t->l_objects,
						val->lightray)) && val->curobject2 == val->curobject)
			ft_impact2(val);
		val->curlight = val->curlight->next;
	}
}
Ejemplo n.º 2
0
t_ray		*get_ray(t_tool *t, double x, double y)
{
	t_ray	*ray;
	t_pos	*b;

	ray = malloc(sizeof(t_ray));
	ray->o = malloc(sizeof(t_pos));
	b = malloc(sizeof(t_pos));
	ray->o->x = t->cam->pos->x;
	ray->o->y = t->cam->pos->y;
	ray->o->z = t->cam->pos->z;
	b->x = t->cam->upleft->x + t->cam->r_vect->x *
		t->cam->indent * x - t->cam->h_vect->x * t->cam->indent * y;
	b->y = t->cam->upleft->y + t->cam->r_vect->y *
		t->cam->indent * x - t->cam->h_vect->y * t->cam->indent * y;
	b->z = t->cam->upleft->z + t->cam->r_vect->z *
		t->cam->indent * x - t->cam->h_vect->z * t->cam->indent * y;
	ray->d = vectorsub(b, ray->o);
	vectornorm(ray->d);
	free(b);
	return (ray);
}