private void AddCollada(AffineMesh a, XElement COLLADA, AffinePoint Offset)
        {

            var q = COLLADA
                .Elements("library_geometries")
                .Elements("geometry")
                .Elements("mesh")
                .Elements("triangles")
                .Elements("p");


            q.WithEach(
                 p =>
                 {
                     var mesh = p.Parent.Parent;

                     var triangles_input = p.Parent.Elements("input").Single(k => k.Attribute("semantic").Value == "VERTEX");
                     var vertices_POSITION = mesh.Elements("vertices").Elements("input").Single(k => k.Attribute("semantic").Value == "POSITION");

                     var source_float_array = mesh.Elements("source")
                         .Where(k => vertices_POSITION.Attribute("source").Value == ("#" + k.Attribute("id").Value))
                         .Elements("float_array").Single();

                     var VERTEX = p.Value.ParseToInt32Array();
                     var POSITION = source_float_array.Value.ParseToDoubleArray();


                     for (int i = 0; i < VERTEX.Length; i += 3)
                     {
                         var j = new[]
                         {
                             VERTEX[i + 0],
                             VERTEX[i + 1],
                             VERTEX[i + 2],
                         };

                         var B = new AffinePoint(
                             X: POSITION[j[0] * 3 + 0],
                             Y: POSITION[j[0] * 3 + 1],
                             Z: POSITION[j[0] * 3 + 2]
                         );

                         var C = new AffinePoint(
                             X: POSITION[j[1] * 3 + 0],
                             Y: POSITION[j[1] * 3 + 1],
                             Z: POSITION[j[1] * 3 + 2]
                         );

                         var A = new AffinePoint(
                             X: POSITION[j[2] * 3 + 0],
                             Y: POSITION[j[2] * 3 + 1],
                             Z: POSITION[j[2] * 3 + 2]
                         );

                         var v1 =
                             new AffineVertex
                             {
                                 A = A + Offset,
                                 B = B + Offset,
                                 C = C + Offset,

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

                         a.Add(v1);
                     }
                 }
            );
        }
        private void AddCubeFace(AffineMesh a, string t, AffinePoint A, AffinePoint B, AffinePoint C, AffinePoint D, AffinePoint Offset = null)
        {
            if (Offset == null)
                Offset = new AffinePoint();

            var v1 =
               new AffineVertex
               {
                   A = A + Offset,
                   B = B + Offset,
                   C = C + Offset,

                   Element = new Avalon.Images._17
                   {
                       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 + Offset,
                    B = C + Offset,
                    C = B + Offset,

                    Element = new Avalon.Images._19g
                    {
                        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);

        }
Exemplo n.º 3
0
        public void Add(AffineVertex v)
        {
            Vertecies.Add(v);

        }