Example #1
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 1;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new RayCast(this);

            Ambient a = new Ambient();

            a.ScaleRadiance = 1.0f;
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(0.0, 0.0, 20),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          3600);

            Camera = pinhole;

            Directional l = new Directional();

            l.SetDirection(-10, 20, 20);
            l.ScaleRadiance = 3.0f;
            l.Shadows       = false;
            AddLight(l);

            int numSpheres = 1000000;

            double volume = 0.1 / numSpheres;
            double radius = Math.Pow(0.75 * volume / Math.PI, 0.333333);

            Grid grid = new Grid();

            Rnd.SetRandSeed(15);

            for (int j = 0; j < numSpheres; j++)
            {
                Matte matte = new Matte();
                matte.SetKa(0.25f);
                matte.SetKd(0.75f);
                matte.SetColor(new Vec3(Rnd.RandDouble(),
                                        Rnd.RandDouble(),
                                        Rnd.RandDouble()));

                Sphere sphere = new Sphere();
                sphere.Radius = radius;
                sphere.SetCenter(1.0f - 2.0f * (float)Rnd.RandDouble(),
                                 1.0f - 2.0f * (float)Rnd.RandDouble(),
                                 1.0f - 2.0f * (float)Rnd.RandDouble());
                sphere.Material = matte;
                grid.AddObject(sphere);
            }

            grid.SetupCells();

            AddObject(grid);
        }
Example #2
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 25;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new RayCast(this);

            Ambient a = new Ambient();

            a.ScaleRadiance = 1.0f;
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(0, 0, 65),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          9000 /**24*/);

            Camera = pinhole;

            Directional light = new Directional();

            light.SetDirection(-0.25f, 0.4f, 1.0f);
            light.ScaleRadiance = 2.5f;
            AddLight(light);

            //image
            Image image = new Image();

            image.Load(PATH + "ppm/EarthLowRes.ppm");

            //mapping
            SphericalMap sphericalMap = new SphericalMap();

            //image based texture
            ImageTexture texture = new ImageTexture(image, sphericalMap);

            //textured material
            SV_Matte svMatte = new SV_Matte();

            svMatte.SetKa(0.45f);
            svMatte.SetKd(0.65f);
            svMatte.SetCd(texture);

            Sphere s = new Sphere();

            s.Material = svMatte;

            Instance earth = new Instance(s);

            earth.Material = svMatte;
            earth.RotateY(-72);
            earth.RotateX(40);
            earth.RotateZ(20);
            AddObject(earth);
        }
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 1;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new RayCast(this);

            Ambient a = new Ambient();

            a.ScaleRadiance = 1.0f;
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(),
                                          new Vec3(-100, 0, 0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          400);

            Camera = pinhole;

            Directional l1 = new Directional();

            l1.SetDirection(1, 0, 0);
            l1.ScaleRadiance = 1.0f;
            l1.Shadows       = true;

            Directional l2 = new Directional();

            l2.SetDirection(0, 1, 0);
            l2.ScaleRadiance = 2.0f;
            l2.Shadows       = true;

            Directional l3 = new Directional();

            l3.SetDirection(0, 0, 1);
            l3.ScaleRadiance = 1.5f;
            l3.Shadows       = true;

            Directional l4 = new Directional();

            l4.SetDirection(-1, 0, 0);
            l4.ScaleRadiance = 1.0f;
            l4.Shadows       = true;

            Directional l5 = new Directional();

            l5.SetDirection(0, -1, 0);
            l5.ScaleRadiance = 1.5f;
            l5.Shadows       = true;

            Directional l6 = new Directional();

            l6.SetDirection(0, 0, -1);
            l6.ScaleRadiance = 1.5f;
            l6.Shadows       = true;

            AddLight(l1);
            AddLight(l2);
            AddLight(l3);
            AddLight(l4);
            AddLight(l5);
            AddLight(l6);

            int numSpheres = 25;

            double volume = 0.1 / numSpheres;
            float  radius = (float)(2.5 * Math.Pow(0.75 * volume / Math.PI, 0.333333));

            Grid grid = new Grid();

            Rnd.SetRandSeed(14);

            for (int j = 0; j < numSpheres; j++)
            {
                Matte matte = new Matte();
                matte.SetKa(0.25f);
                matte.SetKd(0.85f);
                matte.SetColor(new Vec3(Rnd.RandDouble(),
                                        Rnd.RandDouble(),
                                        Rnd.RandDouble()));

                Sphere sphere = new Sphere();
                sphere.Material = matte;

                Instance instance = new Instance(sphere);
                instance.Scale(radius, radius, radius);
                instance.Translate(new Vec3(1.0 - 2.0 * Rnd.RandDouble(),
                                            1.0 - 2.0 * Rnd.RandDouble(),
                                            1.0 - 2.0 * Rnd.RandDouble()));
                instance.ComputeBoundingBox();

                grid.AddObject(instance);
            }

            grid.SetupCells();

            AddObject(grid);
        }