public static Scene Boolean(bool outlines)
        {
            Scene scene = new Scene(new Color(255, 255, 255));

            Light      sun        = new LightDirectional(new Color(255, 255, 255), new Vector3(0, -1, 1), scene, false);
            LightGroup lightGroup = new LightGroup();

            lightGroup.addLight(sun);

            Vector3 center1 = new Vector3(-12, 0, 30);
            Vector3 center2 = new Vector3(-6, 0, 30);
            Vector3 center3 = new Vector3(9, 0, 30);
            Vector3 center4 = new Vector3(9, 1, 27);
            double  radius  = 5;
            double  radius2 = 3;

            SurfaceGeometry surfaceIntersection = new SurfaceIntersection(new VolumeSphere(center1, radius), new VolumeSphere(center2, radius));
            SurfaceGeometry surfaceDifference   = new SurfaceDifference(new VolumeSphere(center3, radius), new VolumeSphere(center4, radius2));

            SurfaceMaterial diffuse    = new SurfaceDiffuse(new Color(255, 255, 255), lightGroup);
            SurfaceMaterial semiopaque = new SurfaceMaterialBlend(new SurfaceTransparent(scene), diffuse, 0.2);

            scene.addSurface(new Surface(surfaceIntersection, diffuse));
            scene.addSurface(new Surface(surfaceDifference, diffuse));
            if (outlines)
            {
                scene.addSurface(new Surface(new SurfaceSphere(center1, radius), semiopaque));
                scene.addSurface(new Surface(new SurfaceSphere(center2, radius), semiopaque));
                scene.addSurface(new Surface(new SurfaceSphere(center3, radius), semiopaque));
                scene.addSurface(new Surface(new SurfaceSphere(center4, radius2), semiopaque));
            }

            return(scene);
        }
Exemplo n.º 2
0
        //Scene presenting a non-euclidean space
        public static Scene MagicWindow()
        {
            Scene mainScene  = new Scene(new Color(255, 255, 255));
            Scene magicScene = new Scene(new Color(255, 255, 255));

            SurfaceMaterial solidRed    = new SurfaceUnlit(new Color(200, 100, 100));
            SurfaceMaterial solidGreen  = new SurfaceUnlit(new Color(100, 200, 100));
            SurfaceMaterial solidBlue   = new SurfaceUnlit(new Color(100, 100, 200));
            SurfaceMaterial solidGray   = new SurfaceUnlit(new Color(100, 100, 100));
            SurfaceMaterial magicWindow = new SurfaceMaterialBlend(solidGray, new SurfaceTransparent(magicScene), 0.9);

            //Objects are added into a different scene
            magicScene.addSurface(new Surface(new SurfaceSphere(new Vector3(-20, 15, 80), 10), solidRed));
            magicScene.addSurface(new Surface(new SurfaceSphere(new Vector3(20, 15, 80), 10), solidGreen));
            magicScene.addSurface(new Surface(new SurfaceSphere(new Vector3(0, -15, 80), 10), solidBlue));

            //Object in main scene
            //We use transparent material, but propagate rays into a different scene
            //Therefore, the objects can be seen only while looking through the sphere
            mainScene.addSurface(new Surface(new SurfaceSphere(new Vector3(0, 2, 40), 10), magicWindow));

            return(mainScene);
        }
Exemplo n.º 3
0
        //Scene presenting different materials
        public static Scene Materials()
        {
            Random random = new Random();
            Scene  scene  = new Scene(new Color(255, 255, 255));

            SurfaceMaterial solid      = new SurfaceUnlit(new Color(128, 128, 128));
            SurfaceMaterial solidRed   = new SurfaceUnlit(new Color(255, 128, 128));
            SurfaceMaterial solidBlue  = new SurfaceUnlit(new Color(128, 128, 255));
            SurfaceMaterial reflective = new SurfaceReflective(scene);
            SurfaceMaterial hybrid     = new SurfaceMaterialBlend(solid, reflective, 0.2); //20% reflective, 80% solid

            //80% transparent, 10% reflective, 10% absorptive
            SurfaceMaterial glass = new SurfaceMaterialBlend(new SurfaceTransparent(scene),
                                                             new SurfaceMaterialBlend(reflective, new SurfaceUnlit(new Color(0, 0, 0)), 0.5), 0.2);

            //Red glass
            SurfaceMaterial redGlass = new SurfaceMaterialBlend(new SurfaceTransparent(scene), new SurfaceUnlit(new Color(0, 0, 0)),
                                                                new Vector3(0, 1, 1)); //We specify that only red channel is affected by transparent material

            scene.addSurface(new Surface(new SurfaceFloor(-10, -500, 500, -500, 500), hybrid));
            scene.addSurface(new Surface(new SurfaceSphere(new Vector3(-20, 0, 50), 10), glass));
            scene.addSurface(new Surface(new SurfaceSphere(new Vector3(20, 0, 50), 10), redGlass));

            //We add 4 random spheres into the scene
            for (int i = 0; i < 4; i++)
            {
                scene.addSurface(new Surface
                                     (new SurfaceSphere
                                         (new Vector3(random.Next(-50, 50), random.Next(5, 25), random.Next(60, 80)), random.Next(4, 14)),
                                     new SurfaceMaterialBlend
                                         (new SurfaceUnlit(new Color((byte)random.Next(256), (byte)random.Next(256), (byte)random.Next(256))),
                                         reflective, 0.25)));
            }

            return(scene);
        }