Exemplo n.º 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)));
        }
Exemplo n.º 2
0
        public static Sphere GeodesicOffset(Sphere s, double offset, bool ball = true)
        {
            Sphere offsetSphere;

            if (ball)
            {
                // Geodesic offset (ball).

                {                       // Hyperbolic honeycomb
                    double mag = s.Center.Abs() - s.Radius;
                    mag = s.IsPlane ? DonHatch.h2eNorm(offset) :
                          DonHatch.h2eNorm(DonHatch.e2hNorm(mag) - offset);

                    Vector3D closestPointToOrigin = s.IsPlane ? s.Normal : s.Center;
                    closestPointToOrigin.Normalize();
                    closestPointToOrigin *= mag;
                    offsetSphere          = H3Models.Ball.OrthogonalSphereInterior(closestPointToOrigin);

                    // There are multiple ultraparallel spheres.
                    // This experiments with picking others.
                    Mobius m = new Mobius();
                    m.Isometry(Geometry.Hyperbolic, 0, new Vector3D(0, -0.2));
                    //H3Models.TransformInBall2( offsetSphere, m );
                }

                {                       // Spherical honeycomb
                                        //offset *= -1;
                    double mag = -s.Center.Abs() + s.Radius;
                    Spherical2D.s2eNorm(Spherical2D.e2sNorm(mag) + offset);

                    offsetSphere         = s.Clone();
                    offsetSphere.Radius += offset * 10;
                }
            }
            else
            {
                // Geodesic offset (UHS).
                // XXX - not scaled right.
                offsetSphere         = s.Clone();
                offsetSphere.Radius += offset;
            }

            return(offsetSphere);
        }
Exemplo n.º 3
0
        public void Sphere_CloneYieldsSameScript()
        {
            var sphere = new Sphere()
            {
                Diameter            = 10,
                MinimumAngle        = 5,
                MinimumFragmentSize = 5,
                Resolution          = 30
            };

            var clone = sphere.Clone();

            Assert.IsTrue(sphere.IsSameAs(clone));
        }
Exemplo n.º 4
0
        public static void  makeGreatSword()
        {
            double referenceWidth = Inches.Eigth;
            double overallLength  = Inches.One * 1.5;

            var tang = new Cylinder(referenceWidth, overallLength, true)
            {
                Resolution = 6
            }.Scale(.5, 2, 1);
            var pommel = new Sphere(referenceWidth * 1.2)
            {
                Resolution = 11
            }.Translate(0, 0, -Inches.Half - Inches.Eigth).Color("Gold");
            var hilt = new Cylinder(referenceWidth, Inches.Half * .75, true)
            {
                Resolution = 10
            }
            .Rotate(90, 0, 0)
            .Translate(0, 0, -Inches.Quarter).Color("Gold");
            var hiltRight = new Sphere(referenceWidth * 1.1)
            {
                Resolution = 8
            }
            .Scale(1, 1, 1.2).Color("Gold")
            .Translate(0, hilt.Bounds().YMin, hilt.Position().Z);
            var hiltLeft   = hiltRight.Clone().Mirror(0, 1, 0);
            var hiltCenter = new Cylinder(referenceWidth * .9, Inches.Half * .8, true)
            {
                Resolution = 8
            }
            .Translate(0, 0, -Inches.Quarter - Inches.Quarter * .75).Color("Gold");

            hilt = hilt + hiltLeft + hiltRight + hiltCenter;

            var blade = tang.Translate(0, 0, Inches.Half);
            var tip   = new Cylinder(referenceWidth, Inches.Quarter, true)
            {
                Resolution = 6, Diameter2 = .1
            }.Scale(.5, 2, 1).Translate(0, 0, blade.Bounds().ZMax + Inches.Eigth);

            blade = blade + tip;
            blade = blade.Color("Silver");

            var whole = (blade + pommel + hilt).Scale(.5, .5, .5);

            whole.ToFile("greatsword").Open();
        }
Exemplo n.º 5
0
        public static void makepaddleHandle()
        {
            double holeSize    = Inches.One + Inches.Eigth;
            double holeHeight  = Inches.One;
            double shaftSize   = holeSize + Inches.Quarter;
            double totalLength = Inches.One * 8;
            double totalWidth  = Inches.One * 5;

            var blade = new Sphere()
            {
                Resolution = 80
            }.Resize(totalLength, totalWidth, Inches.One * 2);
            var copy = blade.Clone().Translate(0, 0, -Inches.One).Scale(1.4, 1.4, 1.1);

            blade = blade - copy;

            //var gap = new Cube(Inches.One, Inches.One * 8, Inches.One*8, true).Translate(blade.Bounds().XMin, 0, 0);
            //blade = blade - gap;

            OSCADObject shaft = new Cylinder(shaftSize, totalLength / 4, true)
            {
                Resolution = 80
            }.Rotate(0, 90, 0);
            var hole = new Cylinder(holeSize, holeHeight * 2, true)
            {
                Resolution = 80
            }.Rotate(0, 90, 0).Translate(shaft.Bounds().XMin, 0, 0);

            blade = blade - hole.Translate(blade.Bounds().XMin + Inches.Half, 0, +Inches.Quarter);
            shaft = shaft - hole;
            shaft = shaft.Translate(blade.Bounds().XMin + Inches.Half, 0, +Inches.Quarter);

            var top = new Cylinder(shaftSize, Inches.One * 3, true)
            {
                Resolution = 80
            }.Rotate(90, 0, 0).Translate(shaft.Bounds().XMax, 0, shaft.Bounds().ZMax - shaftSize / 2);
            var gapCloserLeft = new Sphere(shaftSize)
            {
                Resolution = 80
            }.Translate(top.Bounds().XMax - shaftSize / 2, top.Bounds().YMax, +Inches.Quarter);
            var gapCloserRight = gapCloserLeft.Mirror(0, 1, 0);

            var whole = shaft + top + gapCloserLeft + gapCloserRight;

            whole.ToFile("paddleHandle").Open();
        }
Exemplo n.º 6
0
        private void boxingButton_Click(object sender, EventArgs e)
        {
            boxingListBox.Items.Add("Creating box...");
            Box box = new Box(5, 10, 15);
            boxingListBox.Items.Add("Cloning box as newBox...");
            Box newBox = box.Clone();
            boxingListBox.Items.Add("Do box and newBox reference same object? " + ReferenceEquals(box, newBox));
            boxingListBox.Items.Add("Setting box to null...");
            box = null;
            boxingListBox.Items.Add("Is box null? " + (box == null));
            boxingListBox.Items.Add("Is newBox null? " + (newBox == null));
            boxingListBox.Items.Add("Volume : " + newBox.Volume());

            boxingListBox.Items.Add("");
            boxingListBox.Items.Add("Creating squareBox...");
            SquareBox squareBox = new SquareBox(20);

            // Additional Project code
            squareBox.Dimension = 25;
            int numberOfDimensions = SquareBox.Dimensions;
            string volumeCalculation = SquareBox.VolumeCalcuation();
            // end
            SquareBox newSquareBox = squareBox.Reference();
            boxingListBox.Items.Add("Do squareBox and newSquareBox reference same object? " + ReferenceEquals(squareBox, newSquareBox));
            boxingListBox.Items.Add("Setting squareBox to null...");
            squareBox = null;
            boxingListBox.Items.Add("Is squarebox null? " + (squareBox == null));
            boxingListBox.Items.Add("Is newSquareBox null? " + (newSquareBox == null));
            // Additional Project code
            boxingListBox.Items.Add("Are the dimensions equal to 25? " + (numberOfDimensions == 25) + " Actual: " + numberOfDimensions);
            boxingListBox.Items.Add("What is the formula used for volume? " + volumeCalculation);
            // End
            boxingListBox.Items.Add("");
            //Sphere code
            boxingListBox.Items.Add("Creating sphere...");
            Sphere sphere = new Sphere(5);
            boxingListBox.Items.Add("Cloning sphere as newSphere...");
            Sphere newSphere = sphere.Clone();
            boxingListBox.Items.Add("do sphere and newSphere reference same object? " + ReferenceEquals(sphere, newSphere));
            boxingListBox.Items.Add("Setting sphere to null...");
            sphere = null;
            boxingListBox.Items.Add("Is sphere null? " + (sphere == null));
            boxingListBox.Items.Add("Is newSphere null? " + (newSphere == null));
            boxingListBox.Items.Add("Volume: " + newSphere.Volume());
            boxingListBox.Items.Add("What formula is used for sphere volume calculation? " + Sphere.SphereVolumeCalcuation());
        }
Exemplo n.º 7
0
        public static void GenImage()
        {
            int        size  = 1000;
            Bitmap     image = new Bitmap(size, size);
            ImageSpace i     = new ImageSpace(size, size);
            double     b     = 1.1;

            i.XMin = -b; i.XMax = b;
            i.YMin = -b; i.YMax = b;

            Vector3D cen = HoneycombPaper.InteriorPointBall;

            cen = H3Models.BallToUHS(cen);
            Sphere[] simplex = Simplex(ref cen);

            Sphere inSphere = InSphere(simplex);

            using (Graphics g = Graphics.FromImage(image))
                foreach (int[] reflections in AllCells())
                {
                    Sphere clone = inSphere.Clone();
                    foreach (int r in reflections)
                    {
                        clone.Reflect(simplex[r]);
                    }


                    Sphere   ball = new Sphere();
                    Circle3D inSphereIdealBall = ball.Intersection(clone);
                    Circle3D inSphereIdealUHS  = H3Models.BallToUHS(inSphereIdealBall);
                    Circle   inSphereIdeal     = new Circle {
                        Center = inSphereIdealUHS.Center, Radius = inSphereIdealUHS.Radius
                    };

                    using (Brush brush = new SolidBrush(Color.Blue))
                        DrawUtils.DrawFilledCircle(inSphereIdeal, g, i, brush);
                }

            image.Save("threefifty.png", ImageFormat.Png);
        }
        public override void Build()
        {
            vp                = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples     = 64;
            vp.ShowOutOfGamut = 2;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new AreaLighting(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;

            Emissive emissive = new Emissive();

            emissive.ScaleRadiance = 40.0f;
            emissive.Ce            = ColorUtils.WHITE;

            MultiJittered sampler = new MultiJittered(256);

            sampler.Generate();

            Rectangle rectangle = new Rectangle(new Vec3(100.0, 100.0, 200.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, emissive);

            lamp.Sampler = sampler;
            AddObject(lamp);

            AreaLight areaLight = new AreaLight();

            areaLight.Object  = lamp;
            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);

            Matte m = new Matte();

            //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);
        }
Exemplo n.º 9
0
 public static bool TestOBBSphere(OBB obb, Sphere sphere)
 {
     sphere        = sphere.Clone <Sphere>();
     sphere.center = obb.RTMatrix * MathUtil.Vector4(sphere.center, 1);
     return(TestAABBSphere(obb.GetAABB(), sphere));
 }
        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);
        }
Exemplo n.º 11
0
        /// <summary>
        ///  Creates a runtime object and adds the LoadedFile to the element.
        /// </summary>
        /// <param name="objectToLoad"></param>
        /// <param name="container"></param>
        /// <param name="elementRuntime"></param>
        /// <param name="objectType"></param>
        /// <param name="objectJustLoaded"></param>
        /// <param name="newElementRuntime"></param>
        /// <param name="toAddTo"></param>
        /// <param name="layerToAddTo"></param>
        /// <param name="rfs"></param>
        /// <param name="pullsFromEntireNamedObject"></param>
        /// <returns></returns>
        private static LoadedFile CreateRuntimeObjectForNamedObject(NamedObjectSave objectToLoad,
                                                                    IElement container, ElementRuntime elementRuntime, string objectType,
                                                                    LoadedFile objectJustLoaded,
                                                                    ElementRuntime newElementRuntime,
                                                                    object toAddTo,
                                                                    Layer layerToAddTo, ReferencedFileSave rfs, bool pullsFromEntireNamedObject)
        {
            var fileName = ElementRuntime.ContentDirectory + objectToLoad.SourceFile;


            bool       shouldClone = rfs != null && (rfs.IsSharedStatic && !(container is ScreenSave)) && !pullsFromEntireNamedObject;
            LoadedFile toReturn    = null;

            // This could have a ( in the name in a file like .scnx, so use the last (
            //int indexOfType = objectToLoad.SourceName.IndexOf("(");
            int indexOfType = objectToLoad.SourceName.LastIndexOf("(");

            string objectName = objectToLoad.SourceName.Substring(0, indexOfType - 1);

            switch (objectType)
            {
            case "Scene":
            {
                Scene scene = objectJustLoaded.RuntimeObject as Scene;

                foreach (Text text in scene.Texts)
                {
                    text.AdjustPositionForPixelPerfectDrawing = true;
                    if (ObjectFinder.Self.GlueProject.UsesTranslation)
                    {
                        text.DisplayText = LocalizationManager.Translate(text.DisplayText);
                    }
                }

                if (shouldClone)
                {
                    scene = scene.Clone();
                    elementRuntime.EntireScenes.Add(objectToLoad.SourceFile, scene);

                    var loadedFile = new LoadedFile();
                    loadedFile.RuntimeObject      = scene;
                    loadedFile.FilePath           = objectToLoad.SourceFile;
                    loadedFile.ReferencedFileSave = rfs;
                    toReturn = loadedFile;

                    newElementRuntime.ReferencedFileRuntimeList.Add(loadedFile);

                    scene.AddToManagers(layerToAddTo);
                }
            }
            break;


            case "Sprite":
            {
                Sprite loadedSprite = null;
                Scene  scene        = objectJustLoaded.RuntimeObject as Scene;
                if (scene != null)
                {
                    loadedSprite = scene.Sprites.FindByName(objectName);
                }

                if (loadedSprite == null)
                {
                    System.Windows.Forms.MessageBox.Show("There is a missing Sprite called\n\n" + objectName + "\n\n" +
                                                         "in the object\n\n" + elementRuntime.Name + "\n\n" +
                                                         "This probably happened if someone changed the name of a Sprite in a .scnx file but didn't update " +
                                                         "the associated object in Glue", "Missing Sprite");
                }
                else
                {
                    if (shouldClone)
                    {
                        loadedSprite = loadedSprite.Clone();
                        (toAddTo as Scene).Sprites.Add(loadedSprite);
                        SpriteManager.AddToLayer(loadedSprite, layerToAddTo);

                        var loadedFile = new LoadedFile();

                        loadedFile.RuntimeObject      = loadedSprite;
                        loadedFile.FilePath           = objectJustLoaded.FilePath;
                        loadedFile.DataModel          = objectJustLoaded.DataModel;
                        loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;

                        toReturn = loadedFile;
                    }
                }
            }
            break;


            case "SpriteFrame":
            {
                Scene       scene             = objectJustLoaded.RuntimeObject as Scene;
                SpriteFrame loadedSpriteFrame = scene.SpriteFrames.FindByName(objectName);
                if (loadedSpriteFrame != null)
                {
                    if (shouldClone)
                    {
                        loadedSpriteFrame = loadedSpriteFrame.Clone();
                        (toAddTo as Scene).SpriteFrames.Add(loadedSpriteFrame);
                        SpriteManager.AddToLayer(loadedSpriteFrame, layerToAddTo);

                        var loadedFile = new LoadedFile();

                        loadedFile.RuntimeObject      = loadedSpriteFrame;
                        loadedFile.FilePath           = objectJustLoaded.FilePath;
                        loadedFile.DataModel          = objectJustLoaded.DataModel;
                        loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                        toReturn = loadedFile;
                    }
                }
            }
            break;

            case "SpriteGrid":
            {
                Scene      scene      = objectJustLoaded.RuntimeObject as Scene;
                SpriteGrid spriteGrid = null;
                for (int i = 0; i < scene.SpriteGrids.Count; i++)
                {
                    if (scene.SpriteGrids[i].Name == objectName)
                    {
                        spriteGrid = scene.SpriteGrids[i];
                        break;
                    }
                }
                if (spriteGrid != null)
                {
                    if (shouldClone)
                    {
                        spriteGrid = spriteGrid.Clone();
                        (toAddTo as Scene).SpriteGrids.Add(spriteGrid);
                        spriteGrid.Layer = layerToAddTo;
                        spriteGrid.PopulateGrid();
                        spriteGrid.RefreshPaint();
                        spriteGrid.Manage();

                        var loadedFile = new LoadedFile();

                        loadedFile.RuntimeObject      = spriteGrid;
                        loadedFile.FilePath           = objectJustLoaded.FilePath;
                        loadedFile.DataModel          = objectJustLoaded.DataModel;
                        loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                        toReturn = loadedFile;
                    }
                }
            }
            break;

            case "Text":
            {
                Scene scene = objectJustLoaded.RuntimeObject as Scene;

                Text loadedText = scene.Texts.FindByName(objectName);
                if (loadedText != null)
                {
                    if (shouldClone)
                    {
                        loadedText = loadedText.Clone();
                        (toAddTo as Scene).Texts.Add(loadedText);

                        TextManager.AddToLayer(loadedText, layerToAddTo);

                        var loadedFile = new LoadedFile();

                        loadedFile.RuntimeObject      = loadedText;
                        loadedFile.FilePath           = objectJustLoaded.FilePath;
                        loadedFile.DataModel          = objectJustLoaded.DataModel;
                        loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                        toReturn = loadedFile;
                    }
                    loadedText.AdjustPositionForPixelPerfectDrawing = true;
                    if (LocalizationManager.HasDatabase)
                    {
                        loadedText.DisplayText = LocalizationManager.Translate(loadedText.DisplayText);
                    }
                }
            }
            break;

            case "ShapeCollection":
            {
                ShapeCollection shapeCollection = objectJustLoaded.RuntimeObject as ShapeCollection;

                if (shouldClone)
                {
                    shapeCollection = shapeCollection.Clone();
                    elementRuntime.EntireShapeCollections.Add(objectToLoad.SourceFile, shapeCollection);

                    newElementRuntime.ReferencedFileRuntimeList.LoadedShapeCollections.Add(shapeCollection);

                    shapeCollection.AddToManagers(layerToAddTo);

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = shapeCollection;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
                // Most cases are handled below in an AttachTo method, but
                // ShapeCollection isn't a PositionedObject so we have to do it manually here
                if (objectToLoad.AttachToContainer)
                {
                    shapeCollection.AttachTo(elementRuntime, true);
                }
            }
            break;

            case "AxisAlignedCube":
            {
                ShapeCollection shapeCollection       = objectJustLoaded.RuntimeObject as ShapeCollection;
                AxisAlignedCube loadedAxisAlignedCube = shapeCollection.AxisAlignedCubes.FindByName(objectName);


                if (shouldClone)
                {
                    loadedAxisAlignedCube = loadedAxisAlignedCube.Clone();
                    (toAddTo as ShapeCollection).AxisAlignedCubes.Add(loadedAxisAlignedCube);
                    ShapeManager.AddToLayer(loadedAxisAlignedCube, layerToAddTo);

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = loadedAxisAlignedCube;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
            }
            break;


            case "AxisAlignedRectangle":
            {
                ShapeCollection      shapeCollection            = objectJustLoaded.RuntimeObject as ShapeCollection;
                AxisAlignedRectangle loadedAxisAlignedRectangle = shapeCollection.AxisAlignedRectangles.FindByName(objectName);


                if (shouldClone)
                {
                    loadedAxisAlignedRectangle = loadedAxisAlignedRectangle.Clone();
                    (toAddTo as ShapeCollection).AxisAlignedRectangles.Add(loadedAxisAlignedRectangle);
                    ShapeManager.AddToLayer(loadedAxisAlignedRectangle, layerToAddTo);

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = loadedAxisAlignedRectangle;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
            }
            break;

            case "Circle":
            {
                ShapeCollection shapeCollection = objectJustLoaded.RuntimeObject as ShapeCollection;
                Circle          loadedCircle    = shapeCollection.Circles.FindByName(objectName);


                if (shouldClone)
                {
                    loadedCircle = loadedCircle.Clone();
                    (toAddTo as ShapeCollection).Circles.Add(loadedCircle);
                    ShapeManager.AddToLayer(loadedCircle, layerToAddTo);

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = loadedCircle;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
            }
            break;

            case "Polygon":
            {
                ShapeCollection shapeCollection = objectJustLoaded.RuntimeObject as ShapeCollection;
                Polygon         loadedPolygon   = shapeCollection.Polygons.FindByName(objectName);


                if (shouldClone)
                {
                    loadedPolygon = loadedPolygon.Clone();
                    (toAddTo as ShapeCollection).Polygons.Add(loadedPolygon);
                    ShapeManager.AddToLayer(loadedPolygon, layerToAddTo);

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = loadedPolygon;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
            }
            break;

            case "Sphere":
            {
                ShapeCollection shapeCollection = objectJustLoaded.RuntimeObject as ShapeCollection;
                Sphere          loadedSphere    = shapeCollection.Spheres.FindByName(objectName);


                if (shouldClone)
                {
                    loadedSphere = loadedSphere.Clone();
                    (toAddTo as ShapeCollection).Spheres.Add(loadedSphere);
                    ShapeManager.AddToLayer(loadedSphere, layerToAddTo);

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = loadedSphere;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
            }
            break;

            case "Capsule2D":
            {
                ShapeCollection shapeCollection = objectJustLoaded.RuntimeObject as ShapeCollection;
                Capsule2D       loadedCapsule2D = shapeCollection.Capsule2Ds.FindByName(objectName);


                if (shouldClone)
                {
                    loadedCapsule2D = loadedCapsule2D.Clone();
                    (toAddTo as ShapeCollection).Capsule2Ds.Add(loadedCapsule2D);
                    ShapeManager.AddToLayer(loadedCapsule2D, layerToAddTo);

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = loadedCapsule2D;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
            }
            break;

            case "Emitter":
            {
                EmitterList emitterList   = objectJustLoaded.RuntimeObject as EmitterList;
                Emitter     loadedEmitter = emitterList.FindByName(objectName);

                if (shouldClone && loadedEmitter != null)
                {
                    loadedEmitter = loadedEmitter.Clone();
                    (toAddTo as EmitterList).Add(loadedEmitter);
                    SpriteManager.AddEmitter(loadedEmitter, layerToAddTo);

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = loadedEmitter;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
            }
            break;

            case "EmitterList":
            {
                EmitterList emitterList = objectJustLoaded.RuntimeObject as EmitterList;

                if (shouldClone && emitterList != null)
                {
                    emitterList = emitterList.Clone();

                    foreach (var item in emitterList)
                    {
                        SpriteManager.AddEmitter(item);
                    }

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = emitterList;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
            }
            break;

            case "NodeNetwork":
            {
                NodeNetwork nodeNetwork = objectJustLoaded.RuntimeObject as NodeNetwork;

                if (shouldClone)
                {
                    nodeNetwork = nodeNetwork.Clone();

                    elementRuntime.EntireNodeNetworks.Add(objectToLoad.SourceFile, nodeNetwork);

                    newElementRuntime.ReferencedFileRuntimeList.LoadedNodeNetworks.Add(nodeNetwork);

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = nodeNetwork;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
            }
            break;

            case "SplineList":
            {
                SplineList splineList = objectJustLoaded.RuntimeObject as SplineList;

                if (shouldClone)
                {
                    splineList = splineList.Clone();

                    elementRuntime.EntireSplineLists.Add(splineList.Name, splineList);

                    foreach (var spline in splineList)
                    {
                        spline.CalculateVelocities();
                        spline.CalculateAccelerations();
                    }

                    splineList.AddToManagers();


                    splineList[0].UpdateShapes();

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = splineList;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
            }
            break;

            case "Spline":
            {
                SplineList splineList = objectJustLoaded.RuntimeObject as SplineList;
                Spline     spline     = splineList.FirstOrDefault(item => item.Name == objectName);


                if (shouldClone && spline != null)
                {
                    spline = spline.Clone();
                    (toAddTo as SplineList).Add(spline);

                    // Eventually support layers?
                    //ShapeManager.AddToLayer(spline, layerToAddTo);

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = spline;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
                spline.CalculateVelocities();
                spline.CalculateAccelerations();
            }
            break;
            }

            if (toReturn == null)
            {
                foreach (var manager in ReferencedFileRuntimeList.FileManagers)
                {
                    var objectFromFile = manager.TryGetObjectFromFile(elementRuntime.ReferencedFileRuntimeList.LoadedRfses, rfs, objectType, objectName);

                    if (objectFromFile != null)
                    {
                        var runtimeObject = objectFromFile;

                        var loadedFile = new LoadedFile();

                        loadedFile.RuntimeObject      = runtimeObject;
                        loadedFile.FilePath           = objectJustLoaded.FilePath;
                        loadedFile.DataModel          = objectJustLoaded.DataModel;
                        loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                        toReturn = loadedFile;


                        break;
                    }
                }
            }


            if (toReturn != null && objectToLoad.AttachToContainer)
            {
                if (toReturn.RuntimeObject is PositionedObject)
                {
                    // If the object is already attached to something, that means it
                    // came from a file, so we don't want to re-attach it.
                    PositionedObject asPositionedObject = toReturn.RuntimeObject as PositionedObject;
                    if (asPositionedObject.Parent == null)
                    {
                        asPositionedObject.AttachTo(elementRuntime, true);
                    }
                }
                else if (toReturn.RuntimeObject is Scene)
                {
                    ((Scene)toReturn.RuntimeObject).AttachAllDetachedTo(elementRuntime, true);
                }
                else if (toReturn.RuntimeObject is ShapeCollection)
                {
                    ((ShapeCollection)toReturn.RuntimeObject).AttachAllDetachedTo(elementRuntime, true);
                }
            }


            return(toReturn);
        }
Exemplo n.º 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);
        }