private void AddCube(AffineMesh a, AffinePoint Offset = null)
        {
            // front
            AddCubeFace(a, "front",
                        new AffinePoint(-100, -100, 100) + Offset,
                        new AffinePoint(100, -100, 100) + Offset,
                        new AffinePoint(-100, 100, 100) + Offset,
                        new AffinePoint(100, 100, 100) + Offset
                        );

            // right
            AddCubeFace18(a, "right",
                          new AffinePoint(100, -100, 100) + Offset,
                          new AffinePoint(100, -100, -100) + Offset,
                          new AffinePoint(100, 100, 100) + Offset,
                          new AffinePoint(100, 100, -100) + Offset
                          );

            // left
            AddCubeFace18(a, "left",
                          new AffinePoint(-100, -100, 100) + Offset,
                          new AffinePoint(-100, -100, -100) + Offset,
                          new AffinePoint(-100, 100, 100) + Offset,
                          new AffinePoint(-100, 100, -100) + Offset
                          );

            // back
            AddCubeFace18(a, "back",
                          new AffinePoint(-100, -100, -100) + Offset,
                          new AffinePoint(100, -100, -100) + Offset,
                          new AffinePoint(-100, 100, -100) + Offset,
                          new AffinePoint(100, 100, -100) + Offset
                          );

            // top
            AddCubeFace18(a, "top",
                          new AffinePoint(-100, 100, -100) + Offset,
                          new AffinePoint(100, 100, -100) + Offset,
                          new AffinePoint(-100, 100, 100) + Offset,
                          new AffinePoint(100, 100, 100) + Offset
                          );

            // bottom
            AddCubeFace18(a, "bottom",
                          new AffinePoint(-100, -100, -100) + Offset,
                          new AffinePoint(100, -100, -100) + Offset,
                          new AffinePoint(-100, -100, 100) + Offset,
                          new AffinePoint(100, -100, 100) + Offset
                          );
        }
예제 #2
0
        private void AddCubeFace(AffineMesh a, string t, AffinePoint A, AffinePoint B, AffinePoint C, AffinePoint D)
        {
            var v1 =
                new AffineVertex
            {
                A = A,
                B = B,
                C = C,

                Element = new Avalon.Images._17
                {
                    Width  = 100,
                    Height = 100,
                }.AttachTo(AffineContent),
                ElementWidth  = 100,
                ElementHeight = 100
            };

            a.Vertecies.Add(v1);

            var v2 =
                new AffineVertex
            {
                A = D,
                B = C,
                C = B,

                Element = new Avalon.Images._17g
                {
                    Width  = 100,
                    Height = 100,
                }.AttachTo(AffineContent),
                ElementWidth  = 100,
                ElementHeight = 100
            };



            a.Vertecies.Add(v2);
        }
예제 #3
0
        private void AddCubeFace(AffineMesh a, ImageSource Source, ImageSource Source2, AffinePoint A, AffinePoint B, AffinePoint C, AffinePoint D)
        {
            var v1 =
                new AffineVertex
            {
                A = A,
                B = B,
                C = C,

                Element = new Image
                {
                    Width  = 100,
                    Height = 100,
                    Source = Source
                }.AttachTo(AffineContent),
                ElementWidth  = 100,
                ElementHeight = 100
            };



            a.Vertecies.Add(v1);

            var v2 =
                new AffineVertex
            {
                A = D,
                B = C,
                C = B,

                Element = new Image
                {
                    Width  = 100,
                    Height = 100,
                    Source = Source2
                }.AttachTo(AffineContent),
                ElementWidth  = 100,
                ElementHeight = 100
            };



            a.Vertecies.Add(v2);
        }
예제 #4
0
        private AffineMesh AddCube(AffineMesh context, ImageSource Source, ImageSource Source2, AffinePoint TopLocation)
        {
            var a = new AffineMesh();


            // front
            AddCubeFace(a, Source, Source2,
                        new AffinePoint(-100, -100, 100),
                        new AffinePoint(100, -100, 100),
                        new AffinePoint(-100, 100, 100),
                        new AffinePoint(100, 100, 100)
                        );

            // right
            AddCubeFace(a, Source, Source2,
                        new AffinePoint(100, -100, 100),
                        new AffinePoint(100, -100, -100),
                        new AffinePoint(100, 100, 100),
                        new AffinePoint(100, 100, -100)
                        );

            // left
            AddCubeFace(a, Source, Source2,
                        new AffinePoint(-100, -100, 100),
                        new AffinePoint(-100, -100, -100),
                        new AffinePoint(-100, 100, 100),
                        new AffinePoint(-100, 100, -100)
                        );

            // back
            AddCubeFace(a, Source, Source2,
                        new AffinePoint(-100, -100, -100),
                        new AffinePoint(100, -100, -100),
                        new AffinePoint(-100, 100, -100),
                        new AffinePoint(100, 100, -100)
                        );

            // top
            AddCubeFace(a, Source, Source2,
                        new AffinePoint(-100, 100, -100),
                        new AffinePoint(100, 100, -100),
                        new AffinePoint(-100, 100, 100),
                        new AffinePoint(100, 100, 100)
                        );

            var _a = a.ToTranslation(new AffinePoint(TopLocation.X * 200, TopLocation.Z * 200, TopLocation.Y * 200));

            context.Meshes.Add(
                _a
                );

            return(_a);
        }
        private void AddCubeFace18(
            AffineMesh a, string t, AffinePoint A, AffinePoint B, AffinePoint C, AffinePoint D)
        {
            var v1 =
                new AffineVertex
            {
                A = A,
                B = B,
                C = C,

                Element = new Avalon.Images._18
                {
                    Width  = 100,
                    Height = 100,
                }.AttachTo(AffineContent),
                ElementWidth  = 100,
                ElementHeight = 100
            };

            //var t1 = new TextBox { Text = t, Foreground = Brushes.Blue }.AttachTo(InfoContent);

            //v1.Tag = new Action<AffineVertex>(
            //    k =>
            //    {
            //        t1.Text = t + " " + Convert.ToInt32(k.Center.Z);
            //        t1.MoveTo(k.Center.X + DefaultWidth / 2, k.Center.Y + DefaultHeight / 2);

            //    }
            //);

            a.Add(v1);

            //var v2 =
            //    new AffineVertex
            //    {
            //        A = D,
            //        B = C,
            //        C = B,

            //        Element = new Avalon.Images._18.AffineTriangle2
            //        {
            //            Width = 100,
            //            Height = 100,
            //        }.AttachTo(AffineContent),
            //        ElementWidth = 100,
            //        ElementHeight = 100
            //    };

            ////v2.Element.Opacity = 0.5;

            ////var t2 = new TextBox { Text = t }.AttachTo(InfoContent);

            ////v2.Tag = new Action<AffineVertex>(
            ////    k =>
            ////    {
            ////        t2.Text = t + " " + Convert.ToInt32(k.Center.Z);
            ////        t2.MoveTo(k.Center.X + DefaultWidth / 2, k.Center.Y + DefaultHeight / 2);

            ////    }
            ////);

            //a.Add(v2);
        }
예제 #6
0
        void InitializeContent()
        {
            Colors.Blue.ToGradient(Colors.Red, Convert.ToInt32(Height) / 4).Select(
                (c, i) =>
                new Rectangle
            {
                Fill   = new SolidColorBrush(c),
                Width  = Width,
                Height = 4,
            }.MoveTo(0, i * 4).AttachTo(this)
                ).ToArray();



            //var help = new Image
            //{
            //    Source = (KnownAssets.Path.Assets + "/help.png").ToSource()
            //}.AttachTo(this);

            //help.Opacity = 0;

            var img = new Image
            {
                Source = new Avalon.Images.jsc().Source
            }.MoveTo(Width - 128, Height - 128).AttachTo(this);

            var t = new TextBox
            {
                FontSize        = 10,
                Text            = "powered by jsc",
                BorderThickness = new Thickness(0),
                Foreground      = 0xffffffff.ToSolidColorBrush(),
                Background      = Brushes.Transparent,
                IsReadOnly      = true,
                Width           = Width
            }.MoveTo(8, 8).AttachTo(this);



            //help.Opacity = 1;
            img.Opacity = 0.5;



            // cursor position calculations are not ready
            // for transofrmed elements.
            // we will provide a floor for those events...
            var shadow = new Rectangle
            {
                Width  = Width,
                Height = Height,

                Fill = Brushes.Black,
            }.AttachTo(this);

            var shadowa = shadow.ToAnimatedOpacity();

            shadowa.Opacity = 0;



            var a = new AffineMesh();

            Func <double, double, double, Brush, AffinePoint> a_Add =
                (X, Y, Z, Fill) =>
            {
                var p = new AffinePoint {
                    Z = Z, X = X, Y = Y
                };
                var h = new Rectangle {
                    Fill = Fill, Width = 4, Height = 4
                }.AttachTo(this);
                //var ht = new TextBox { }.AttachTo(this);

                var historysize = 64;
                var history     = new Queue <Rectangle>();

                Action <AffinePoint> p_Update =
                    pp =>
                {
                    if (history.Count > historysize)
                    {
                        history.Dequeue();
                    }

                    // -100 == 0.5
                    // 0 == 1
                    // +100 == 2

                    //var zoom = (pp.Z) / 1000;

                    var zoom = 0.5;

                    var pp_X = Width / 2 - 4 + pp.X * zoom;
                    var pp_Y = Height / 2 - 4 + pp.Y * zoom;
                    // Z is ignored here
                    // but could be used for sorting

                    h.MoveTo(pp_X, pp_Y);

                    //var hh = new Rectangle { Fill = Fill, Width = 4, Height = 4, Opacity = 1 }.MoveTo(pp_X, pp_Y).AttachTo(this);
                    //history.Enqueue(hh);

                    //foreach (var k in history.Select((c, i) => new { c, i }))
                    //{
                    //    k.c.Opacity = ((double)k.i / historysize) * 0.6;
                    //}

                    //ht.MoveTo(
                    //    DefaultWidth / 2 + pp.X - 4,
                    //    DefaultHeight / 2 + pp.Y + 4
                    //);

                    //ht.Text = new { pp.X, pp.Y, pp.Z }.ToString();
                };

                p.Tag = p_Update;

                a.Add(p);

                p_Update(p);

                return(p);
            };


            Enumerable.Range(0, 10).Select(X => a_Add(X * 10, 0, 0, Brushes.Red)).ToArray();
            Enumerable.Range(0, 10).Select(Y => a_Add(0, Y * 10, 0, Brushes.Blue)).ToArray();
            Enumerable.Range(0, 10).Select(Z => a_Add(0, 0, Z * 10, Brushes.GreenYellow)).ToArray();

            Enumerable.Range(0, 10).Select(X => a_Add(X * 10 + 100, 0, 0, Brushes.Red)).ToArray();
            Enumerable.Range(0, 10).Select(Y => a_Add(100, Y * 10, 0, Brushes.Blue)).ToArray();
            Enumerable.Range(0, 10).Select(Z => a_Add(100, 0, Z * 10, Brushes.GreenYellow)).ToArray();


            Enumerable.Range(0, 100).Select(X => a_Add(X * 10 + 200, 0, 0, Brushes.Red)).ToArray();
            Enumerable.Range(0, 10).Select(Y => a_Add(200, Y * 10, 0, Brushes.Blue)).ToArray();
            Enumerable.Range(0, 10).Select(Z => a_Add(200, 0, Z * 10, Brushes.GreenYellow)).ToArray();

            {
                var radius = 100;
                foreach (var i in Enumerable.Range(0, 90).Select(aa => (aa * 4).DegreesToRadians()))
                {
                    a_Add(Math.Cos(i) * radius, Math.Sin(i) * radius, 0, Brushes.GreenYellow);
                    a_Add(Math.Cos(i) * radius, 0, Math.Sin(i) * radius, Brushes.BlueViolet);
                    a_Add(0, Math.Cos(i) * radius, Math.Sin(i) * radius, Brushes.Magenta);
                }
            }

            {
                var radius = 200;
                foreach (var i in Enumerable.Range(0, 90).Select(aa => (aa * 4).DegreesToRadians()))
                {
                    a_Add(Math.Cos(i) * radius, Math.Sin(i) * radius, 0, Brushes.GreenYellow);
                    a_Add(Math.Cos(i) * radius, 0, Math.Sin(i) * radius, Brushes.BlueViolet);
                    a_Add(0, Math.Cos(i) * radius, Math.Sin(i) * radius, Brushes.Magenta);
                }
            }

            {
                var radius = 500;
                foreach (var i in Enumerable.Range(0, 90).Select(aa => (aa * 4).DegreesToRadians()))
                {
                    a_Add(Math.Cos(i) * radius, Math.Sin(i) * radius, 0, Brushes.GreenYellow);
                    a_Add(Math.Cos(i) * radius, 0, Math.Sin(i) * radius, Brushes.BlueViolet);
                    a_Add(0, Math.Cos(i) * radius, Math.Sin(i) * radius, Brushes.Magenta);
                }
            }

            a_Add(200, 0, 0, Brushes.BlueViolet);
            a_Add(0, 200, 0, Brushes.Yellow);
            a_Add(0, 0, 200, Brushes.Red);

            (1000 / 50).AtIntervalWithCounter(
                c =>
            {
                // rotate floor
                var _a = a.ToRotation(
                    new AffineRotation
                {
                    XY = 0.01,
                    YZ = 0.02,
                    XZ = 0.03
                }
                    );

                //var _a = a.ToRotation(0, 0.01);

                a = _a;

                //var _a = a.ToRotation(c * 0.01, c * 0.005);
                //var _a = a.ToRotation(c * 0.01, 0);

                foreach (var p in _a.Points)
                {
                    ((Action <AffinePoint>)p.Tag)(p);
                }
            }
                );
        }