Пример #1
0
        public static World GetManyBallWorld(int width, int height)
        {
            var world = GetDefaultWorld(width, height);
            // world.objects = new List<Shape3D>();
            PhongIlluminationModel illuminationModel = new PhongIlluminationModel(world);
            var r      = new Random();
            var center = Vector.Build.DenseOfArray(new float[] { 0.0f, -0.3f, 3.5f });
            var radius = 0.3f;
            var mir    = Mirror.GetMirror(illuminationModel);
            var glass  = TransmissiveMaterial.GetTransmissiveMaterial(illuminationModel);
            var blue   = PhongMaterial.Blue(illuminationModel);

            for (int i = 0; i < 100; i++)
            {
                var rVec = Vector.Build.DenseOfArray(new float[] {
                    (float)(r.NextDouble() * 2) - 1,
                    (float)(r.NextDouble() * 2) - 1,
                    (float)(r.NextDouble() * 2) - 1
                });
                rVec = rVec.Normalize();
                var rC = center + (rVec * radius);
                // PhongMaterial mat = mir;
                PhongMaterial mat  = (i % 2 == 0) ? mir : blue;//(PhongMaterial)glass;
                Sphere        ball = new Sphere(rC, (float)(r.NextDouble() * 0.01f), mat);
                world.AddObject(ball);
            }
            return(world);
        }
Пример #2
0
        public static TransmissiveMaterial GetTransmissiveMaterial(PhongIlluminationModel model)
        {
            TransmissiveMaterial tm = new TransmissiveMaterial(model);

            return(tm);
        }