示例#1
0
        public static World GetBlackHoleWorld(int width, int height)
        {
            World world = new World(width, height, Rgba32.Black);
            // initialize light source
            Vector      lightPos = Vector.Build.DenseOfArray(new float[] { -15.0f, 0f, 130.0f });
            LightSource l1       = new LightSource(lightPos, Rgba32.White, 150.0f);

            world.AddLightSource(l1);

            Vector      lightPos2 = Vector.Build.DenseOfArray(new float[] { 15.0f, 0f, 130.0f });
            LightSource l2        = new LightSource(lightPos2, Rgba32.White, 150.0f);

            world.AddLightSource(l2);

            // initialize camera
            Vector cameraPos    = Vector.Build.DenseOfArray(new float[] { 0.0f, 0.0f, 0.0f });
            Vector cameraUp     = Vector.Build.DenseOfArray(new float[] { 0.0f, -1.0f, 0.0f });
            Vector cameraLookAt = Vector.Build.DenseOfArray(new float[] { 0f, 0.0f, 15.0f });

            world.cameras.Add(new Camera(cameraPos, cameraLookAt, cameraUp, world));

            PhongIlluminationModel illuminationModel = new PhongIlluminationModel(world);

            var   max_z1_c = Vector.Build.DenseOfArray(new float[] { -50.0f, 0.0f, 150.0f });
            var   max_z1_n = Vector.Build.DenseOfArray(new float[] { 0.0f, 0.0f, -1.0f });
            var   mat1     = PhongMaterial.Red(illuminationModel);
            Plane max_z1   = new Plane(max_z1_c, max_z1_n, 100.0f, 100.0f, mat1);

            var   max_z2_c = Vector.Build.DenseOfArray(new float[] { 50.0f, 0.0f, 150.0f });
            var   max_z2_n = Vector.Build.DenseOfArray(new float[] { 0.0f, 0.0f, -1.0f });
            var   mat2     = PhongMaterial.Blue(illuminationModel);
            Plane max_z2   = new Plane(max_z2_c, max_z2_n, 100.0f, 100.0f, mat2);

            var       bh_c  = Vector.Build.DenseOfArray(new float[] { 0.0f, 0.0f, 50.0f });
            var       bh_sr = 1.5f;
            BlackHole bh    = new BlackHole(bh_c, 3.0f, bh_sr);

            bh.material = new LenseMaterial(illuminationModel);
            world.AddObject(bh);
            world.AddObject(max_z1);
            world.AddObject(max_z2);
            return(world);
        }
示例#2
0
 public BlackHoleMaterial(BlackHole bh, World w)
 {
     world     = w;
     blackHole = bh;
 }