예제 #1
0
        private void NestedButton_Click(object sender, RoutedEventArgs e)
        {
            var main = new RTF.Patterns.Checker(RTF.Color.Black, RTF.Color.White);
            var a    = new RTF.Patterns.Stripe(RTF.Color.Black, RTF.Color.Gray);
            var b    = new RTF.Patterns.Stripe(RTF.Color.Red, RTF.Color.Purple)
            {
                Transform = transform.RotationY(Math.PI / 2)
            };

            var ceilling = new RTF.Shapes.Plane()
            {
                Material = new RTF.Material()
                {
                    Pattern  = new RTF.Patterns.Nested(main, 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 + $"\\NestedPattern[{elapsedMs}ms].ppm");
        }
예제 #2
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));
        }