Exemplo n.º 1
0
/*
** brief : for a cone determine its luminosity
** @scene : our scene
** @cone : our cone
** @point : our vector point P
** return : the color
*/
t_color		*lumi_cone(t_scene *scene, t_cone *cone, t_vector *point)
{
  t_color	*color;
  int		nb_l;
  t_light	*light;

  nb_l = 0;
  light = scene->list_light;
  if (light == NULL)
    return (cone->color);
  color = create_color(0, 0, 0);
  while (light != NULL)
    {
      ++nb_l;
      to_simple(&(light)->coord, cone->coord, cone->rot);
      if (scene->ambiance)
	_normal_cone_amb(light, point, cone, &color);
      else
	_normal_cone(light, point, cone, &color);
      to_real_life(&(light)->coord, cone->coord, cone->rot);
      light = light->next;
    }
  div_color(&color, nb_l);
  return (color);
}
Exemplo n.º 2
0
void		draw(t_tool *t, double x, double y)
{
	t_ray	*ray;
	double	x0;
	double	y0;
	t_color	*final_color;

	final_color = new_color();
	x0 = x;
	while (x0 <= x + 0.5)
	{
		y0 = y;
		while (y0 <= y + 0.5)
		{
			ray = get_ray(t, x0, y0);
			add_color(final_color, draw_suite(ray, t));
			y0 += 0.5;
		}
		x0 += 0.5;
	}
	div_color(final_color, 4);
	normalize_color(final_color);
	pixel_put_to_image(t, x, y, final_color);
}