Example #1
0
        public static Hitable my_random_scene()
        {
            int            max_items = 500;
            List <Hitable> list      = new List <Hitable>(max_items + 1);

            list.Add(new Sphere(new Vec3(0.0f, -1000.0f, 0.0f), 1000.0f, new Lambertian(TextureLib.green_white_checker)));

            if (true)
            {
                for (int a = -11; a < 11; a++)
                {
                    for (int b = -11; b < 11; b++)
                    {
                        float choose_mat = Rng.f();
                        Vec3  center     = new Vec3((float)a + 0.8f * Rng.f(), 0.2f, (float)b + 0.8f * Rng.f());
                        if ((center - new Vec3(4.0f, 0.2f, 0.0f)).length() > 1.5f &&
                            (center - new Vec3(0.0f, 0.2f, 0.0f)).length() > 1.5f &&
                            (center - new Vec3(-4.0f, 0.2f, 0.0f)).length() > 1.5f)
                        {
                            if (choose_mat < 0.8f)
                            {
                                list.Add(new Sphere(center, 0.2f, new Lambertian(new ConstantTexture(new Vec3(Rng.f(), Rng.f(), Rng.f())))));
                            }
                            else if (choose_mat < 0.95f)
                            {
                                list.Add(new Sphere(center, 0.2f,
                                                    new Metal(new Vec3(0.5f * (1.0f + Rng.f()), 0.5f * (1.0f + Rng.f()), 0.5f * (1.0f + Rng.f())),
                                                              0.5f * Rng.f())));
                            }
                            else
                            {
                                list.Add(new Sphere(center, 0.2f, new Dielectric(1.5f)));
                            }
                        }
                    }
                }
            }



            list.Add(new Sphere(new Vec3(0.0f, 1.0f, 0.0f), 1.0f, new Dielectric(1.5f, new Vec3(1.0f, 1.0f, 1.0f))));
            list.Add(new Sphere(new Vec3(-4.0f, 1.0f, 0.0f), 1.0f, new Lambertian(TextureLib.burnt_sienna)));
            list.Add(new Sphere(new Vec3(4.0f, 1.0f, 0.0f), 1.0f, new Metal(new Vec3(0.7f, 0.6f, 0.5f), 0.0f)));

            int i = list.Count();

            return(new Hitable_List(list, i));
        }