コード例 #1
0
        public static Scene Lighting1()
        {
            Scene scene = new Scene(new Color(255, 255, 255));

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

            lightGroup.addLight(sun);

            SurfaceMaterial diffuseRed   = new SurfaceDiffuse(new Color(255, 50, 50), lightGroup);
            SurfaceMaterial diffuseGreen = new SurfaceDiffuse(new Color(50, 255, 50), lightGroup);
            SurfaceMaterial diffuseBlue  = new SurfaceDiffuse(new Color(50, 50, 255), lightGroup);
            SurfaceMaterial diffuseWhite = new SurfaceDiffuse(new Color(255, 255, 255), lightGroup);

            SurfaceMaterial specular = new SurfaceSpecular(new Color(100, 100, 100), 50, lightGroup);

            SurfaceMaterial red   = new SurfaceMaterialSum(specular, diffuseRed);
            SurfaceMaterial blue  = new SurfaceMaterialSum(specular, diffuseBlue);
            SurfaceMaterial green = new SurfaceMaterialSum(specular, diffuseGreen);
            SurfaceMaterial white = new SurfaceMaterialSum(specular, diffuseWhite);

            scene.addSurface(new Surface(new SurfacePlane(-25 * Vector3.Up, Vector3.Forward, Vector3.Right), white));
            scene.addSurface(new Surface(new SurfaceSphere(new Vector3(-40, 0, 80), 10), red));
            scene.addSurface(new Surface(new SurfaceSphere(new Vector3(0, 0, 80), 10), green));
            scene.addSurface(new Surface(new SurfaceSphere(new Vector3(40, 0, 80), 10), blue));

            return(scene);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public static Scene Lighting2()
        {
            Scene      scene      = new Scene(new Color(255, 255, 255));
            Light      lightRed   = new LightDirectional(new Color(255, 0, 0), new Vector3(1, -3, 0), scene, true);
            Light      lightGreen = new LightDirectional(new Color(0, 255, 0), new Vector3(-1, -3, 0), scene, true);
            Light      lightBlue  = new LightDirectional(new Color(0, 0, 255), new Vector3(0, -3, 1), scene, true);
            LightGroup lightGroup = new LightGroup();

            lightGroup.addLight(lightRed);
            lightGroup.addLight(lightGreen);
            lightGroup.addLight(lightBlue);

            SurfaceMaterial diffuseWhite = new SurfaceDiffuse(new Color(255, 255, 255), lightGroup);
            SurfaceMaterial specular     = new SurfaceSpecular(new Color(100, 100, 100), 50, lightGroup);
            SurfaceMaterial material     = new SurfaceMaterialSum(specular, diffuseWhite);

            scene.addSurface(new Surface(new SurfacePlane(-25 * Vector3.Up, Vector3.Forward, Vector3.Right), diffuseWhite));
            scene.addSurface(new Surface(new SurfaceSphere(new Vector3(0, 0, 80), 10), material));

            return(scene);
        }
コード例 #4
0
        public static Scene Mesh()
        {
            Scene scene = new Scene(new Color(200, 200, 255));

            Mesh mesh = OBJ.ParseFile(@"..\..\monkey.obj");

            LightGroup lightGroup = new LightGroup();

            lightGroup.addLight(new LightDirectional(new Color(255, 255, 255), new Vector3(0.2, -0.2, 1), scene));

            SurfaceGeometry geometry = new SurfaceMesh(mesh, Vector3.Forward * 10, new Vector3(0, Math.PI, 0), SurfaceMesh.NormalMode.PER_VERTEX);

            SurfaceMaterial diffuse  = new SurfaceDiffuse(new Color(200, 212, 180), lightGroup);
            SurfaceMaterial specular = new SurfaceSpecular(new Color(255, 255, 255), 150, lightGroup);
            SurfaceMaterial material = new SurfaceMaterialSum(diffuse, specular);

            Surface monkey = new Surface(geometry, material);
            //We enclose the monkey in a bounding sphere, which speeds up the rendering over 7 times
            Surface boundedMonkey = new Surface(new SurfaceBoundingVolume(new SurfaceSphere(Vector3.Forward * 10, 2.5), monkey), null);

            scene.addSurface(boundedMonkey);

            return(scene);
        }