Example #1
0
int		get_pixel_color(t_pos xyz, t_win *mw)
{
  int		i;
  int		color;
  double	k;
  double	a;
  double	cos;

  i = 0;
  k = 1000000;
  color = 0x000000;
  while (mw->tab_obj[i].obj != 0)
    {
      mw->tab_obj[i].obj == 1 ? a = inter_sphere(xyz, *mw, i) : 0;
      mw->tab_obj[i].obj == 2 ? a = inter_plan(xyz, *mw, i) : 0;
      mw->tab_obj[i].obj == 3 ? a = inter_cone(xyz, *mw, i, &cos) : 0;
      mw->tab_obj[i].obj == 4 ? a = inter_cylindre(xyz, *mw, i) : 0;
      mw->tab_obj[i].obj == 5 ? a = inter_cube(xyz, *mw, i) : 0;
      if (a < k && a > 0.000001)
	{
	  k = a;
	  color = mw->tab_obj[i].color;
	}
      i++;
    }
  color = change_color(color, xyz, *mw, k);
  return (color);
}
Example #2
0
void	spot_calc(t_scene *sc, t_object *obj)
{
  if (obj->type == SPHERE)
    inter_sphere(sc);
  if (obj->type == CONE)
    inter_cone(sc);
  if (obj->type == PLAN)
    inter_plan(sc);
  if (obj->type == CYLIND)
    inter_cylindre(sc);
}
Example #3
0
double	calc_shad(t_objet p, t_utils l, int type)
{
	double	k;

	k = -1.0;
	if (type == PLAN)
		k = inter_plan(l, &p);
	else if (type == SPHERE)
		k = inter_sphere(l, &p);
	else if (type == CYLINDRE)
		k = inter_cylindre(l, &p);
	else if (type == CONE)
		k = inter_cone(l, &p);
	else if (type == PARABOLOIDE)
		k = inter_paraboloide(l, &p);
	else if (type == HYPERBOLOIDE)
		k = inter_hyperboloide(l, &p);
	return (k);
}