コード例 #1
0
ファイル: evidence_sl.c プロジェクト: vcwseas/CMSC15200
int main()
{
  printf("%s\n", "testing sl_cons");
  sphere *s1 = sphere_new(vec_new(0.0, 0.0, 0.0), 10.0, rgb_new(0.5, 0.5, 0.5));
  sphere *s2 = sphere_new(vec_new(1.0, 1.0, 1.0), 5.0, rgb_new(0.1, 0.1, 0.1));
  sphere *s3 = sphere_new(vec_new(100.0, 100.0, 100.0), 100.0, rgb_new(0, 0, 0));

  sphere_list *sl = sl_cons(s1, sl_cons(s2, sl_cons(s3, NULL)));
  sl_print(sl);
  printf("%s\n", "testing sl_singleton");
  sphere_list *sl2 = sl_singleton(sphere_dup(s1));
  sl_print(sl2);
  sphere_list *sl3 = sl_cons(sphere_dup(s2), sl_singleton(sphere_dup(s1)));
  sl_print(sl3);

  printf("%s\n", "testing sl_dup");
  sphere_list *sl4 = sl_dup(sl);
  sl_print(sl4);


  printf("%s\n", "FOR VALGRIND TESTING");
  sl_free(sl);
  sl_free(sl2);
  sl_free(sl3);
  sl_free(sl4);
}
コード例 #2
0
ファイル: parse_material.c プロジェクト: Entrivax/RT
void		init_material(t_material *mat)
{
	mat->color = rgb_new(1, 1, 1);
	mat->shine = 1;
	mat->k_ambiant = 1;
	mat->k_spec = 1;
	mat->k_diffuse = 1;
	mat->refle = 0;
	mat->name = NULL;
}
コード例 #3
0
ファイル: evidence_sphere.c プロジェクト: vcwseas/CMSC15200
int main()
{
  printf("%s\n", "testing sphere_new");
  sphere *s1 = sphere_new(vec_new(0.0, 0.0, 0.0), 10.0, rgb_new(0.5, 0.5, 0.5));
  sphere *s2 = sphere_new(vec_new(1.0, 1.0, 1.0), 10.0, rgb_new(0.2, 0.3, 0.4));
  sphere_print(s1);
  sphere_print(s2);
  printf("%s\n", "testing sphere_dup");
  sphere *s3 = sphere_dup(s1);
  sphere *s4 = sphere_dup(s2);
  sphere_free(s1);
  sphere_free(s2);
  sphere_print(s3);
  sphere_print(s4);
  s1 = sphere_dup(s3);
  s2 = sphere_dup(s4);
  printf("%s\n", "testing sphere_tos");
  char *p = sphere_tos(s3);
  char *p2 = sphere_tos(s4);
  printf("%s\n", p);
  printf("%s\n", p2);
}
コード例 #4
0
ファイル: compute_light.c プロジェクト: Entrivax/RT
static void	set_ambiant_light(t_phpa *ph, t_scene *scene, t_ray *ray,
								t_color *color)
{
	double	dot;
	t_mtx	n;

	n = mtx_negate(ray->dir);
	dot = ft_fclamp((dot_vect(&n, &ph->normal) + scene->ambbaseimpact)
		* scene->ambcoefimpact, 0, 1);
	*color = rgb_new(
		ft_min(scene->i_ambiant.r, ray->closest->mat->color.r) * dot
		* ray->closest->mat->k_ambiant,
		ft_min(scene->i_ambiant.g, ray->closest->mat->color.g) * dot
		* ray->closest->mat->k_ambiant,
		ft_min(scene->i_ambiant.b, ray->closest->mat->color.b) * dot
		* ray->closest->mat->k_ambiant);
	ph->color = color;
	ph->diffuse = &color[1];
	ph->specular = &color[2];
	*ph->diffuse = rgb_new(0, 0, 0);
	*ph->specular = rgb_new(0, 0, 0);
}