コード例 #1
0
        private void CreateObjects()
        {
            //esfera de cima da caixa
            Phong m = new Phong();

            m.SetColor(new Vec3(0.6, 0.6, 0.6));
            m.SetKa(0.2f);
            m.SetKd(0.7f);
            m.SetKs(0.8f);
            m.SetExp(20.0f);

            Sphere s = new Sphere(new Vec3(0.168749, 0.099999, 0.449999), 0.4);

            s.Material = m;
            AddObject(s.Clone());

            //esfera grande
            m.SetColor(new Vec3(0.7, 0.7, 1.0));
            m.SetKa(0.2f);
            m.SetKd(0.7f);
            m.SetKs(0.8f);
            m.SetExp(20.0f);

            s.Center.Set(-0.562499, -0.159256, 0.449999);
            s.Radius   = 0.5;
            s.Material = m;
            AddObject(s);

            //AddObjects(new Box(RT::Vec3f(0.0f, -3.0f, 2.5f), RT::Vec3f(3.0f, 1.5f, 3.0f),
            //    new Phong(RT::Vec3f(0.7f, 0.7f, 1.0f),
            //        0.2f, 0.7f, 0.2f, 20.0f)));
        }
コード例 #2
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 16;

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

            Ambient a = new Ambient();

            a.ScaleRadiance = 1.0f;
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(100, 0, 100),
                                          new Vec3(0, 1, 0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          8000);

            Camera = pinhole;

            PointLight l = new PointLight();

            l.Color = ColorUtils.WHITE;
            l.SetLocation(50, 50, 1);
            l.ScaleRadiance = 3.0f;
            l.Shadows       = true;
            AddLight(l);

            Phong m = new Phong();

            m.SetColor(new Vec3(0.75));
            m.SetKa(0.25f);
            m.SetKd(0.8f);
            m.SetKs(0.15f);
            m.SetExp(50.0f);

            Instance ellipsoid = new Instance(new Sphere());

            ellipsoid.Material = m;
            ellipsoid.Scale(2, 3, 1);
            ellipsoid.RotateX(-45);
            ellipsoid.Translate(0, 1, 0);
            AddObject(ellipsoid);

            //Plane p = new Plane(new Vec3(0, -10, 0), new Vec3(0, 1, 0));
            //Matte pm = new Matte();
            //pm.SetKa(0.25f);
            //pm.SetKd(0.75f);
            //pm.SetColor(new Vec3(0.3));
            //p.Material = pm;

            //AddObject(p);
        }
コード例 #3
0
        private void CreateObjects()
        {
            Phong m1 = new Phong();

            m1.SetColor(new Vec3(0.6, 0.6, 0.6));
            m1.SetKa(0.2f);
            m1.SetKd(0.7f);
            m1.SetKs(0.8f);
            m1.SetExp(20.0f);

            Sphere s1 = new Sphere(new Vec3(/*300, 54, -432*/), 216);

            s1.Material = m1;

            Instance i = new Instance(s1);

            i.Scale(1.0f, 2.0f, 0.9f);
            i.RotateX(90);
            i.Translate(300, 54, -432);
            AddObject(i);

            Phong m2 = new Phong();

            m2.SetColor(new Vec3(0.7, 0.7, 1.0));
            m2.SetKa(0.2f);
            m2.SetKd(0.7f);
            m2.SetKs(0.8f);
            m2.SetExp(20.0f);

            Sphere s2 = new Sphere(new Vec3(/*-540, -86, -432*/), 270);

            s2.Material = m2;

            Instance i2 = new Instance(s2);

            i2.Translate(-540, -86, -432);
            AddObject(i2);

            Phong m3 = new Phong();

            m3.SetColor(new Vec3(0.7, 0.7, 1.0));
            m3.SetKa(0.2f);
            m3.SetKd(0.7f);
            m3.SetKs(0.2f);
            m3.SetExp(1.0f);

            Box b = new Box(new Vec3(138, -324, -594),
                            new Vec3(462, -162, -270));

            b.Material = m3;
            AddObject(b);
        }
コード例 #4
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 4;

            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, 80.0, 210),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          500);

            Camera = pinhole;

            PointLight l = new PointLight();

            l.Color = ColorUtils.WHITE;
            l.SetLocation(100, 100, 200);
            l.ScaleRadiance = 3.0f;
            l.Shadows       = true;
            AddLight(l);

            Phong m = new Phong();

            m.SetColor(0.2f, 0.5f, 0.4f);
            m.SetKa(0.25f);
            m.SetKd(0.75f);
            m.SetKs(0.2f);
            m.SetExp(20.0f);

            Grid sphere = new Grid();

            //sphere.TessellateFlatSphere(200, 100);
            sphere.TessellateSmoothSphere(100, 50);
            sphere.Material = m;
            sphere.SetupCells();

            Instance i = new Instance(sphere);

            i.Scale(60.0f);

            AddObject(i);
        }
コード例 #5
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 4;

            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, 80.0, 210),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          500);

            Camera = pinhole;

            PointLight l = new PointLight();

            l.Color = ColorUtils.WHITE;
            l.SetLocation(100, 100, 200);
            l.ScaleRadiance = 3.0f;
            l.Shadows       = true;
            AddLight(l);

            Phong m = new Phong();

            m.SetColor(new Vec3(0.35f));
            m.SetKa(0.2f);
            m.SetKd(0.65f);
            m.SetKs(0.4f);
            m.SetExp(64.0f);

            float t = 20;
            float b = -80;
            float r = 50;

            //BeveledCylinder bc = new BeveledCylinder(b, t, r, 6);
            //bc.Material = m;
            Cylinder c = Cylinder.Create(b, t, r, 3);

            c.Material = m;

            AddObject(c);
        }
コード例 #6
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 4;

            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, 80.0, 210),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          500);

            Camera = pinhole;

            PointLight l = new PointLight();

            l.Color = ColorUtils.WHITE;
            l.SetLocation(100, 100, 200);
            l.ScaleRadiance = 3.0f;
            l.Shadows       = true;
            AddLight(l);

            Phong m = new Phong();

            m.SetColor(ColorUtils.BLUE);
            m.SetKa(0.2f);
            m.SetKd(0.65f);
            m.SetKs(0.4f);
            m.SetExp(64.0f);

            Annulus an = new Annulus(new Vec3(),
                                     new Vec3(0, 1, 0), 55, 80);

            an.Material = m;

            AddObject(an);
        }
コード例 #7
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1920, 1080, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 4;

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

            //Ambient a = new Ambient();
            //a.ScaleRadiance = 1.0f;
            //AmbientLight = a;

            AmbientOccluder a = new AmbientOccluder();

            a.ScaleRadiance = 1.5;
            a.Color         = ColorUtils.WHITE;
            a.MinAmount     = 0.4;
            a.Sampler       = new MultiJittered(vp.NumSamples);
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(-150.0, 80.0, 210),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          800);

            Camera = pinhole;

            PointLight l = new PointLight();

            l.Color = ColorUtils.WHITE;
            l.SetLocation(0, 300, 200);
            l.ScaleRadiance = 3.0f;
            l.Shadows       = true;
            AddLight(l);

            Phong m = new Phong();

            m.SetColor(ColorUtils.BLUE);
            m.SetKa(0.2f);
            m.SetKd(0.65f);
            m.SetKs(0.4f);
            m.SetExp(64.0f);

            Phong m1 = new Phong();

            m1.SetColor(ColorUtils.YELLOW);
            m1.SetKa(0.2f);
            m1.SetKd(0.65f);
            m1.SetKs(0.4f);
            m1.SetExp(64.0f);

            SolidCone sc = new SolidCone(70, 60);

            sc.SetBodyMaterial(m);
            sc.SetBaseMaterial(m1);

            AddObject(sc);

            Sphere s = new Sphere(new Vec3(150, 0, 0), 50);

            s.Material = m;

            Box b = new Box(-200, -70, -50, 50, -100, 0);

            b.Material = m1;

            AddObject(s);
            AddObject(b);
        }
コード例 #8
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 4;

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

            MultiJittered sampler = new MultiJittered(vp.NumSamples);

            sampler.Generate();

            AmbientOccluder occluder = new AmbientOccluder(ColorUtils.WHITE, 0.0);

            occluder.Sampler = sampler;
            //occluder.ScaleRadiance = 1.0;
            //occluder.Color = ColorUtils.WHITE;
            //occluder.SetMinAmount(0.0f);
            AmbientLight = occluder;

            Pinhole pinhole = new Pinhole(new Vec3(0.0, 0.0, 500.0),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          2000.0f);

            Camera = pinhole;

            Emissive emissive = new Emissive(ColorUtils.WHITE, 20.0f);

            //emissive.ScaleRadiance = 1.0f;
            //emissive.Ce = new Vec3(1.0, 1.0, 1.0);

            sampler = new MultiJittered(256);
            sampler.Generate();

            ConcaveSphere sphere = new ConcaveSphere(new Vec3(), 10000.0);

            //sphere.Radius = 10000.0;
            sphere.Sampler          = sampler;
            sphere.Material         = emissive;
            sphere.EmissiveMaterial = emissive;
            sphere.Shadows          = false;
            AddObject(sphere);

            sampler = new MultiJittered(256);
            sampler.Generate();

            EnvironmentLight l = new EnvironmentLight();

            l.Material = emissive;
            l.Sampler  = sampler;
            l.Sampler.MapSamplesToHemisphere(10);
            l.Shadows = true;
            AddLight(l);

            //Rectangle rectangle = new Rectangle(new Vec3(0.0, 100.0, 0.0),
            //                                    new Vec3(216.0, 0.0, 0.0),
            //                                    new Vec3(0.0, 0.0, 216.0));
            //emissive = new Emissive();
            //emissive.ScaleRadiance = 1.0f;
            //emissive.Ce = ColorUtils.WHITE;

            //rectangle.Material = emissive;
            //rectangle.Sampler = sampler;
            //rectangle.Shadows = false;
            //AddObject(rectangle);

            AreaLight areaLight = new AreaLight();

            areaLight.Object  = sphere;
            areaLight.Shadows = true;
            AddLight(areaLight);

            Vec3 lightGreen = new Vec3(0.65f, 1.0f, 0.30f);
            Vec3 green      = new Vec3(0.0f, 0.6f, 0.3f);
            Vec3 darkGreen  = new Vec3(0.0f, 0.41f, 0.41f);

            Vec3 yellow     = new Vec3(1.0f, 1.0f, 0.0f);
            Vec3 darkYellow = new Vec3(0.61f, 0.61f, 0.0f);

            Vec3 lightPurple = new Vec3(0.65f, 0.3f, 1.0f);
            Vec3 darkPurple  = new Vec3(0.5f, 0.0f, 1.0f);

            Vec3 brown  = new Vec3(0.71f, 0.40f, 0.16f);
            Vec3 orange = new Vec3(1.0f, 0.75f, 0.0f);

            Matte matte = new Matte();

            matte.SetKa(0.2f);
            matte.SetKd(0.5f);
            matte.SetColor(ColorUtils.WHITE);

            Plane p = new Plane(new Vec3(0, -85, 0), new Vec3(0, 1, 0));

            p.Material = matte;
            AddObject(p);

            Phong m = new Phong();

            m.SetKa(0.2f);
            m.SetKd(0.65f);
            m.SetKs(0.1f);
            m.SetExp(8.0f);
            m.SetColor(ColorUtils.WHITE);

            Sphere s = new Sphere(new Vec3(5, 3, 0), 30);

            s.Material = m;

            AddObject((Sphere)s.Clone());

            s.SetCenter(45, -7, -60);
            s.Radius = 20;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(40, 43, -100);
            s.Radius = 17;
            m.SetColor(darkGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-20, 28, -15);
            s.Radius = 20;
            m.SetColor(orange);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-25, -7, -35);
            s.Radius = 27;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(20, -27, -35);
            s.Radius = 25;
            m.SetColor(lightGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(35, 18, -35);
            s.Radius = 22;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-57, -17, -50);
            s.Radius = 15;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-47, 16, -80);
            s.Radius = 23;
            m.SetColor(lightGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-15, -32, -60);
            s.Radius = 22;
            m.SetColor(darkGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-35, -37, -80);
            s.Radius = 22;
            m.SetColor(darkYellow);
            AddObject((Sphere)s.Clone());

            s.SetCenter(10, 43, -80);
            s.Radius = 22;
            m.SetColor(darkYellow);
            AddObject((Sphere)s.Clone());

            s.SetCenter(30, -7, -80);
            s.Radius = 10;
            m.SetColor(darkYellow);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-40, 48, -110);
            s.Radius = 18;
            m.SetColor(darkGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-10, 53, -120);
            s.Radius = 18;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-55, -52, -100);
            s.Radius = 10;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(5, -52, -100);
            s.Radius = 15;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-20, -57, -120);
            s.Radius = 15;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(55, -27, -100);
            s.Radius = 17;
            m.SetColor(darkGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(50, -47, -120);
            s.Radius = 15;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(70, -42, -150);
            s.Radius = 10;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(5, 73, -130);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(66, 21, -130);
            s.Radius = 13;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(72, -12, -140);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(64, 5, -160);
            s.Radius = 11;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(55, 38, -160);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-73, -2, -160);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(30, -62, -140);
            s.Radius = 15;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(25, 63, -140);
            s.Radius = 15;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-60, 46, -140);
            s.Radius = 15;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-30, 68, -130);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(58, 56, -180);
            s.Radius = 11;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-63, -39, -180);
            s.Radius = 11;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(46, 68, -200);
            s.Radius = 10;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-3, -72, -130);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject(s);
        }
コード例 #9
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 64;

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

            AmbientOccluder a = new AmbientOccluder(ColorUtils.WHITE,
                                                    0.25, 1.0);

            a.Sampler    = new MultiJittered(vp.NumSamples);
            AmbientLight = a;

            Pinhole pinhole = new Pinhole(new Vec3(0.0, 80.0, 210),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          500);

            Camera = pinhole;

            Emissive e = new Emissive();

            e.ScaleRadiance = 8.0f;
            e.Ce            = ColorUtils.WHITE;

            Rectangle rectangle = new Rectangle(new Vec3(0.0, 200.0, 100.0),
                                                new Vec3(216.0, 0.0, 0.0),
                                                new Vec3(0.0, 0.0, 216.0));

            rectangle.Shadows = false;

            RectangularLamp lamp = new RectangularLamp(rectangle, e);

            lamp.Sampler = new MultiJittered(vp.NumSamples);
            AddObject(lamp);

            AreaLight areaLight = new AreaLight();

            areaLight.Object  = lamp;
            areaLight.Shadows = true;
            AddLight(areaLight);

            //PointLight l = new PointLight();
            //l.Color = ColorUtils.WHITE;
            //l.SetLocation(100, 100, 200);
            //l.ScaleRadiance = 3.0f;
            //l.Shadows = true;
            //AddLight(l);

            Phong m = new Phong();

            m.SetColor(new Vec3(0.6, 0.2, 0.02));
            m.SetKa(0.2f);
            m.SetKd(0.65f);
            m.SetKs(0.4f);
            m.SetExp(64.0f);

            Phong i = new Phong();

            i.SetColor(new Vec3(0.8, 0.4, 0.02));
            i.SetKa(0.2f);
            i.SetKd(0.65f);
            i.SetKs(0.4f);
            i.SetExp(64.0f);

            //Bowl b = Bowl.CreateFlatRimmedBowl(75, 80);
            //Bowl b = Bowl.CreateRoundRimmedBowl(75, 80);
            Bowl b = Bowl.Create(75, 80, true);

            b.SetExternalMaterial(m);
            b.SetInternalMaterial(i);
            b.SetBorderMaterial(i);

            AddObject(b);

            Plane p  = new Plane(new Vec3(0, -80, 0), new Vec3(0, 1, 0));
            Matte pm = new Matte();

            pm.SetColor(new Vec3(0.2, 0.2, 0.2));
            pm.SetKa(0.2f);
            pm.SetKd(0.6f);
            p.Material = pm;

            AddObject(p);
        }
コード例 #10
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 4;

            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, 80.0, 210),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          500);

            Camera = pinhole;

            PointLight l = new PointLight();

            l.Color = ColorUtils.WHITE;
            l.SetLocation(0, 100, 200);
            l.ScaleRadiance = 3.0f;
            l.Shadows       = true;
            AddLight(l);

            Phong m = new Phong();

            m.SetColor(ColorUtils.BLUE);
            m.SetKa(0.2f);
            m.SetKd(0.65f);
            m.SetKs(0.4f);
            m.SetExp(64.0f);

            Phong m1 = new Phong();

            m1.SetColor(ColorUtils.YELLOW);
            m1.SetKa(0.2f);
            m1.SetKd(0.65f);
            m1.SetKs(0.4f);
            m1.SetExp(64.0f);

            Phong m2 = new Phong();

            m2.SetColor(ColorUtils.GREEN);
            m2.SetKa(0.2f);
            m2.SetKd(0.65f);
            m2.SetKs(0.4f);
            m2.SetExp(64.0f);

            float t = 20;
            float b = -80;
            float r = 50;

            ConvexPartSphere cps = new ConvexPartSphere(new Vec3(), 50);

            cps.Material = m;

            SolidCylinder sc = new SolidCylinder(b, t, r);

            sc.SetTopMaterial(m);
            sc.SetWallMaterial(m1);
            sc.SetBottomMaterial(m2);
            sc.BoundingBox = new BBox(-r, r, b, t, -r, r);

            //Disk top = new Disk(new Vec3(0, t, 0), new Vec3(0, 1, 0), r);
            //Disk bottom = new Disk(new Vec3(0, b, 0), new Vec3(0, -1, 0), r);
            //OpenCylinder wall = new OpenCylinder(b, t, r);
            //wall.BoundingBox = new BBox(-r, r, b, t, -r, r);

            //top.Material = m;
            //bottom.Material = m1;
            //wall.Material = m1;
            AddObject(sc);
            //AddObject(top);
            //AddObject(wall);
        }
コード例 #11
0
        private void CreateWalls()
        {
            //chão
            Phong m = new Phong();

            m.SetColor(new Vec3(0.4f, 0.3f, 0.3f));
            m.SetKa(0.2f);
            m.SetKd(0.7f);
            m.SetKs(0.5f);
            m.SetExp(25.0f);

            Plane p = new Plane(new Vec3(0.0, -0.599999, 0.0), new Vec3(0.0, 1.0, 0.0));

            p.Material = m;
            AddObject(p.Clone());

            //parede fundo
            m.SetColor(new Vec3(0.6f, 0.5f, 0.5f));
            m.SetKa(0.2f);
            m.SetKd(1.0f);
            m.SetKs(0.8f);
            m.SetExp(25.0f);

            p.Point.Set(0.0, 0.0, 2.519791);
            p.Normal.Set(0.0, 0.0, -1.0);
            p.Material = m;
            AddObject(p.Clone());

            //parede esquerda
            m.SetColor(new Vec3(0.5f, 0.5f, 0.6f));
            m.SetKa(0.2f);
            m.SetKd(1.0f);
            m.SetKs(0.8f);
            m.SetExp(25.0f);

            p.Point.Set(-1.349999, 0.0, 0.0);
            p.Normal.Set(1.0, 0.0, 0.0);
            p.Material = m;
            AddObject(p.Clone());

            //parede direita
            m.SetColor(new Vec3(0.5f, 0.5f, 0.6f));
            m.SetKa(0.2f);
            m.SetKd(1.0f);
            m.SetKs(0.8f);
            m.SetExp(25.0f);

            p.Point.Set(1.349999, 0.0, 0.0);
            p.Normal.Set(-1.0, 0.0, 0.0);
            p.Material = m;
            AddObject(p.Clone());

            //parede topo
            m.SetColor(new Vec3(0.7f, 0.7f, 0.7f));
            m.SetKa(0.2f);
            m.SetKd(1.0f);
            m.SetKs(0.8f);
            m.SetExp(25.0f);

            p.Point.Set(0.0, 1.518518, 0.0);
            p.Normal.Set(0.0, -1.0, 0.0);
            p.Material = m;
            AddObject(p);
        }
コード例 #12
0
        public override void Build()
        {
            vp                = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples     = 16;
            vp.ShowOutOfGamut = 0;

            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, 500.0),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          2000.0f);

            Camera = pinhole;

            PointLight l = new PointLight();

            l.Color = ColorUtils.WHITE;
            l.SetLocation(100, 100, 200);
            l.ScaleRadiance = 3.0f;
            l.Shadows       = true;
            AddLight(l);

            Vec3 lightGreen = new Vec3(0.65f, 1.0f, 0.30f);
            Vec3 green      = new Vec3(0.0f, 0.6f, 0.3f);
            Vec3 darkGreen  = new Vec3(0.0f, 0.41f, 0.41f);

            Vec3 yellow     = new Vec3(1.0f, 1.0f, 0.0f);
            Vec3 darkYellow = new Vec3(0.61f, 0.61f, 0.0f);

            Vec3 lightPurple = new Vec3(0.65f, 0.3f, 1.0f);
            Vec3 darkPurple  = new Vec3(0.5f, 0.0f, 1.0f);

            Vec3 brown  = new Vec3(0.71f, 0.40f, 0.16f);
            Vec3 orange = new Vec3(1.0f, 0.75f, 0.0f);

            Matte matte = new Matte();

            matte.SetKa(0.2f);
            matte.SetKd(0.5f);
            matte.SetColor(ColorUtils.WHITE);

            Plane p = new Plane(new Vec3(0, -85, 0), new Vec3(0, 1, 0));

            p.Material = matte;
            AddObject(p);

            Phong m = new Phong();

            //Plastic *m = new Plastic();
            m.SetKa(0.2f);
            m.SetKd(0.65f);
            m.SetKs(0.1f);
            m.SetExp(8.0f);
            m.SetColor(ColorUtils.WHITE);

            Sphere s = new Sphere(new Vec3(5, 3, 0), 30);

            s.Material = m;

            AddObject((Sphere)s.Clone());

            s.SetCenter(45, -7, -60);
            s.Radius = 20;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(40, 43, -100);
            s.Radius = 17;
            m.SetColor(darkGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-20, 28, -15);
            s.Radius = 20;
            m.SetColor(orange);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-25, -7, -35);
            s.Radius = 27;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(20, -27, -35);
            s.Radius = 25;
            m.SetColor(lightGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(35, 18, -35);
            s.Radius = 22;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-57, -17, -50);
            s.Radius = 15;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-47, 16, -80);
            s.Radius = 23;
            m.SetColor(lightGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-15, -32, -60);
            s.Radius = 22;
            m.SetColor(darkGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-35, -37, -80);
            s.Radius = 22;
            m.SetColor(darkYellow);
            AddObject((Sphere)s.Clone());

            s.SetCenter(10, 43, -80);
            s.Radius = 22;
            m.SetColor(darkYellow);
            AddObject((Sphere)s.Clone());

            s.SetCenter(30, -7, -80);
            s.Radius = 10;
            m.SetColor(darkYellow);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-40, 48, -110);
            s.Radius = 18;
            m.SetColor(darkGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-10, 53, -120);
            s.Radius = 18;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-55, -52, -100);
            s.Radius = 10;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(5, -52, -100);
            s.Radius = 15;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-20, -57, -120);
            s.Radius = 15;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(55, -27, -100);
            s.Radius = 17;
            m.SetColor(darkGreen);
            AddObject((Sphere)s.Clone());

            s.SetCenter(50, -47, -120);
            s.Radius = 15;
            m.SetColor(brown);
            AddObject((Sphere)s.Clone());

            s.SetCenter(70, -42, -150);
            s.Radius = 10;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(5, 73, -130);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(66, 21, -130);
            s.Radius = 13;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(72, -12, -140);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(64, 5, -160);
            s.Radius = 11;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(55, 38, -160);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-73, -2, -160);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(30, -62, -140);
            s.Radius = 15;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(25, 63, -140);
            s.Radius = 15;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-60, 46, -140);
            s.Radius = 15;
            m.SetColor(darkPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-30, 68, -130);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(58, 56, -180);
            s.Radius = 11;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-63, -39, -180);
            s.Radius = 11;
            m.SetColor(green);
            AddObject((Sphere)s.Clone());

            s.SetCenter(46, 68, -200);
            s.Radius = 10;
            m.SetColor(lightPurple);
            AddObject((Sphere)s.Clone());

            s.SetCenter(-3, -72, -130);
            s.Radius = 12;
            m.SetColor(lightPurple);
            AddObject(s);
        }