Ejemplo n.º 1
0
int
refraction_management(t_detail *detail,
		      t_color *color, t_light *light, double *vector)
{
  t_color	tmp[CONST_TRANS + 1];
  double	tv[NB_DIMENSION];
  t_detail	td;
  int		i;

  if (detail == NULL || color == NULL || light == NULL || vector == NULL)
    return (EXIT_FAILURE);
  i = -1;
  while (++i <= CONST_TRANS)
    {
      tmp[i].red = -1.0F;
      tmp[i].green = -1.0F;
      tmp[i].blue = -1.0F;
    }
  cpy_point(vector, tv);
  cpy_point(detail->position, td.position);
  cpy_point(detail->normal, td.normal);
  td.k = detail->k;
  td.object = detail->object;
  cpy_color(color, &tmp[0]);
  calc_refraction(&td, tmp, light, tv);
  cpy_color(&tmp[0], color);
  return (EXIT_SUCCESS);
}
Ejemplo n.º 2
0
void			cpy_reverse_sprite(t_bunny_pixelarray *out,
					   t_sprite_sheet *sp,
					   int col, int row)
{
  t_bunny_position	copying_pos;
  t_bunny_position	actual_pos;
  t_bunny_position	max;

  actual_pos = pos_(col * sp->size.x, row * sp->size.y);
  max = pos_(actual_pos.x + sp->size.x, actual_pos.y + sp->size.y);
  copying_pos.y = 0;
  while (actual_pos.y < max.y)
    {
      copying_pos.x = sp->size.x;
      while (actual_pos.x < max.x)
	{
	  cpy_color(out, sp->pix, copying_pos, actual_pos);
	  actual_pos.x += 1;
	  copying_pos.x -= 1;
	}
      actual_pos.x = col * sp->size.x;
      actual_pos.y += 1;
      copying_pos.y += 1;
    }
}
Ejemplo n.º 3
0
int
light_management(t_detail *detail, t_color *color,
		 t_light *light, double *vector)
{
  t_color	tmp[3];

  if (detail == NULL || color == NULL || light == NULL || vector == NULL)
    return (EXIT_FAILURE);
  cpy_color(color, &tmp[0]);
  restat_color(&tmp[1]);
  restat_color(&tmp[2]);
  light_ambient(detail, tmp, light);
  light_ponctual(detail, tmp, light, vector);
  color->red = ABS(CAST(tmp[1].red + tmp[2].red));
  color->green = ABS(CAST(tmp[1].green + tmp[2].green));
  color->blue = ABS(CAST(tmp[1].blue + tmp[2].blue));
  return (EXIT_SUCCESS);
}
Ejemplo n.º 4
0
void			cpy_sprite(t_bunny_pixelarray *out, t_sprite_sheet *sp,
				   int col, int row)
{
  t_bunny_position	o_pos;
  t_bunny_position	pos;
  t_bunny_position	limit;

  pos = pos_(col * sp->size.x, row * sp->size.y);
  limit = pos_(pos.x + sp->size.x, pos.y + sp->size.y);
  o_pos.y = 0;
  while (pos.y < limit.y)
    {
      o_pos.x = 0;
      while (pos.x < limit.x)
	{
	  cpy_color(out, sp->pix, o_pos, pos);
	  pos.x += 1;
	  o_pos.x++;
	}
      pos.x = col * sp->size.x;
      pos.y += 1;
      o_pos.y++;
    }
}