Пример #1
0
        private void BlendedButton_Click(object sender, RoutedEventArgs e)
        {
            var a = new RTF.Patterns.Stripe(RTF.Color.Green, RTF.Color.White);
            var b = new RTF.Patterns.Stripe(RTF.Color.Green, RTF.Color.White)
            {
                Transform = transform.RotationY(Math.PI / 2)
            };

            var ceilling = new RTF.Shapes.Plane()
            {
                Material = new RTF.Material()
                {
                    Pattern  = new RTF.Patterns.Blended(a, b),
                    Color    = RTF.Color.Black,
                    Specular = 0
                }
            };

            var watch  = System.Diagnostics.Stopwatch.StartNew();
            var canvas = CreateCeiling(ceilling);

            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;

            canvas.SaveAsPPMFile(FolderPath.Text + $"\\BlendedPattern[{elapsedMs}ms].ppm");
        }
Пример #2
0
        public RTF.Canvas CreateCircle()
        {
            var ceilling = new RTF.Shapes.Plane()
            {
                Material = new RTF.Material()
                {
                    Color    = new RTF.Color(1, 0.9, 0.9),
                    Specular = 0
                }
            };

            var middle = new RTF.Shapes.Sphere()
            {
                Transform = transform.Translation(-0.5, 1, 0.5),
                Material  = new RTF.Material(RTF.Color.Purple, 0.7, 0.3)
            };
            var right = new RTF.Shapes.Sphere()
            {
                Transform = transform.Translation(1.5, 0.5, -0.5) * transform.Scaling(0.5, 0.5, 0.5),
                Material  = new RTF.Material(RTF.Color.Lime, 0.7, 0.3)
            };
            var left = new RTF.Shapes.Sphere()
            {
                Transform = transform.Translation(-1.5, 0.33, -0.75) * transform.Scaling(0.33, 0.33, 0.33),
                Material  = new RTF.Material(RTF.Color.Cyan, 0.7, 0.3)
            };

            var world = new RTF.World
            {
                Lights = new List <RTF.Light>()
                {
                    new RTF.Light(point.Point(-10, 10, -10), RTF.Color.White)
                },
                Objects = new List <RTF.Shapes.Shape>()
                {
                    ceilling, right, middle, right, left
                }
            };

            var camera = new RTF.Camera(200, 100, Math.PI / 3)
            {
                Transform = transform.ViewTransform(
                    point.Point(0, 1.5, -5),
                    point.Point(0, 1, 0),
                    point.Vector(0, 1, 0))
            };

            return(RTF.Canvas.Render(camera, world));
        }
Пример #3
0
        public RTF.Canvas CreatingPerturbedSphere()
        {
            var p_ceiling = new RTF.Patterns.Checker(RTF.Color.Black, RTF.Color.White);

            var ceilling = new RTF.Shapes.Plane()
            {
                Material = new RTF.Material()
                {
                    Pattern  = new RTF.Patterns.Perturbed(p_ceiling),
                    Color    = RTF.Color.Black,
                    Specular = 0
                }
            };

            var p_sphere = new RTF.Patterns.Ring(RTF.Color.Purple, RTF.Color.Pink);
            var middle   = new RTF.Shapes.Sphere()
            {
                Transform = transform.Translation(-0.5, 1, 0.5),
                Material  = new RTF.Material()
                {
                    Pattern  = new RTF.Patterns.Perturbed(p_sphere),
                    Color    = RTF.Color.Black,
                    Specular = 0
                }
            };

            var world = new RTF.World
            {
                Lights = new List <RTF.Light>()
                {
                    new RTF.Light(point.Point(-10, 10, -10), RTF.Color.White)
                },
                Objects = new List <RTF.Shapes.Shape>()
                {
                    ceilling, middle
                }
            };

            var camera = new RTF.Camera(400, 200, Math.PI / 3)
            {
                Transform = transform.ViewTransform(
                    point.Point(0, 1.5, -5),
                    point.Point(0, 1, 0),
                    point.Vector(0, 1, 0))
            };

            return(RTF.Canvas.Render(camera, world));
        }
Пример #4
0
        public RTF.Canvas CreateWorld()
        {
            var ceilling = new RTF.Shapes.Plane()
            {
                Material = new RTF.Material()
                {
                    Color    = new RTF.Color(1, 0.9, 0.9),
                    Specular = 0
                }
            };

            var middle = new RTF.Shapes.Sphere()
            {
                Transform = transform.Translation(-0.5, 1, 0.5),
                Material  = new RTF.Material()
                {
                    Color        = RTF.Color.Green,
                    Diffuse      = 0.1,
                    Specular     = 1,
                    Transparency = 1,
                    Shininess    = 300,
                    Reflective   = 0.9
                }
            };

            var world = new RTF.World
            {
                Lights = new List <RTF.Light>()
                {
                    new RTF.Light(point.Point(-10, 10, -10), RTF.Color.White)
                },
                Objects = new List <RTF.Shapes.Shape>()
                {
                    ceilling, middle
                }
            };

            var camera = new RTF.Camera(200, 100, Math.PI / 3)
            {
                Transform = transform.ViewTransform(
                    point.Point(0, 1.5, -5),
                    point.Point(0, 1, 0),
                    point.Vector(0, 1, 0))
            };

            return(RTF.Canvas.Render(camera, world));
        }
Пример #5
0
        private void GenerateButton_Click(object sender, RoutedEventArgs e)
        {
            var ceilling = new RTF.Shapes.Plane()
            {
                Material = new RTF.Material()
                {
                    Pattern  = new RTF.Patterns.RadialGradient(RTF.Color.Blue, RTF.Color.White),
                    Color    = RTF.Color.Black,
                    Specular = 0
                }
            };

            var watch  = System.Diagnostics.Stopwatch.StartNew();
            var canvas = CreateCeiling(ceilling);

            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;

            canvas.SaveAsPPMFile(FolderPath.Text + $"\\GradientRadiant[{elapsedMs}ms].ppm");
        }