Пример #1
0
        public static Bowl CreateFlatRimmedBowl(double innerRadius,
                                                double outerRadius,
                                                IMaterial material)
        {
            ConvexPartSphere o = new ConvexPartSphere(new Vec3(),
                                                      outerRadius,
                                                      0, 360, 90, 180);
            ConvexPartSphere i = new ConvexPartSphere(new Vec3(),
                                                      innerRadius,
                                                      0, 360, 90, 180);
            Annulus a = new Annulus(new Vec3(),
                                    new Vec3(0, 1, 0),
                                    innerRadius,
                                    outerRadius);

            Bowl b = new Bowl();

            b.AddObject(o);
            b.AddObject(i);
            b.AddObject(a);

            b.bbox = new BBox(-outerRadius, outerRadius,
                              -outerRadius, outerRadius,
                              -outerRadius, outerRadius);

            b.Material = material;

            return(b);
        }
Пример #2
0
        public static Bowl CreateRoundRimmedBowl(double innerRadius,
                                                 double outerRadius,
                                                 IMaterial material)
        {
            ConvexPartSphere o = new ConvexPartSphere(new Vec3(),
                                                      outerRadius,
                                                      0, 360, 90, 180);
            ConvexPartSphere i = new ConvexPartSphere(new Vec3(),
                                                      innerRadius,
                                                      0, 360, 90, 180);
            Torus t = new Torus((outerRadius + innerRadius) / 2,
                                (outerRadius - innerRadius) / 2);

            Bowl b = new Bowl();

            b.AddObject(o);
            b.AddObject(i);
            b.AddObject(t);

            b.bbox = new BBox(-outerRadius, outerRadius,
                              -outerRadius, outerRadius,
                              -outerRadius, outerRadius);

            b.Material = material;

            return(b);
        }
Пример #3
0
        public static Bowl Create(double innerRadius,
                                  double outerRadius,
                                  bool roundRimmedBowl,
                                  IMaterial material)
        {
            ConvexPartSphere o = new ConvexPartSphere(new Vec3(),
                                                      outerRadius,
                                                      0, 360, 90, 180);
            ConvexPartSphere i = new ConvexPartSphere(new Vec3(),
                                                      innerRadius,
                                                      0, 360, 90, 180);

            Bowl b = new Bowl();

            b.AddObject(o);
            b.AddObject(i);

            if (roundRimmedBowl)
            {
                Torus t = new Torus((outerRadius + innerRadius) / 2,
                                    (outerRadius - innerRadius) / 2);
                b.AddObject(t);
            }
            else
            {
                Annulus a = new Annulus(new Vec3(),
                                        new Vec3(0, 1, 0),
                                        innerRadius,
                                        outerRadius);
                b.AddObject(a);
            }

            b.bbox = new BBox(-outerRadius, outerRadius,
                              -outerRadius, outerRadius,
                              -outerRadius, outerRadius);

            b.Material = material;

            return(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(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);
        }