当前位置: 首页>>代码示例>>C#>>正文


C# Vector3.Concat方法代码示例

本文整理汇总了C#中Vector3.Concat方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.Concat方法的具体用法?C# Vector3.Concat怎么用?C# Vector3.Concat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vector3的用法示例。


在下文中一共展示了Vector3.Concat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateGreenGemModel

        public GemModel CreateGreenGemModel()
        {
            var gemCorners = new Vector3[] {
                //Top back vertex
                new Vector3(0, 0.8F, -0.2F),
                //Middle ring two back vertices
                new Vector3(0.12F, 0.4F, -0.30F),
                new Vector3(-0.12F, 0.4F, -0.30F),
                //Bottom ring two back vertices
                new Vector3(0.08F, -0.8F, -0.20F),
                new Vector3(-0.08F, -0.8F, -0.20F),
            };
            //Now create more by rotating these 120° and 240° around the Y axis
            gemCorners = gemCorners
                .Concat(
                    gemCorners.Select(v => Vector3.Transform(v, Matrix.CreateRotationY(MathHelper.Pi * 2 / 3))).ToArray()
                ).Concat(
                    gemCorners.Select(v => Vector3.Transform(v, Matrix.CreateRotationY(MathHelper.Pi * 4 / 3))).ToArray()
                ).ToArray();

            var faceCorners = new int[][] {
                //Top face
                new int[] { 0, 5, 10 },
                //Upper band
                new int[] { 0, 1, 2 },
                new int[] { 0, 2, 6 },
                new int[] { 0, 6, 5 },
                new int[] { 5, 6, 7 },
                new int[] { 5, 7, 11 },
                new int[] { 5, 11, 10 },
                new int[] { 10, 11, 12 },
                new int[] { 10, 12, 1 },
                new int[] { 10, 1, 0 },
                //Lower band
                new int[] { 1, 3, 4 },
                new int[] { 1, 4, 2 },
                new int[] { 2, 4, 8 },
                new int[] { 2, 8, 6 },
                new int[] { 6, 8, 9 },
                new int[] { 6, 9, 7 },
                new int[] { 7, 9, 13 },
                new int[] { 7, 13, 11 },
                new int[] { 11, 13, 14 },
                new int[] { 11, 14, 12 },
                new int[] { 12, 14, 3 },
                new int[] { 12, 3, 1 },
                //Bottom face
                new int[] { 8, 4, 3 },
                new int[] { 13, 9, 8 },
                new int[] { 3, 14, 13 },
                new int[] { 3, 13, 8 }
            };

            //Just hardcode the list of edges to inset
            var insetEdges = new int[][] {
                new int[] {0, 1},
                new int[] {1, 2},
                new int[] {2, 0},
                new int[] {1, 3},
                new int[] {3, 4},
                new int[] {4, 2},
                new int[] {0, 5},
                new int[] {2, 6},
                new int[] {4, 8}
            };
            //Copy it 3 times
            var insetEdges1 = insetEdges.Select(ii => ii.Select(i => (i + 5) % 15).ToArray()).ToArray();
            var insetEdges2 = insetEdges.Select(ii => ii.Select(i => (i + 10) % 15).ToArray()).ToArray();
            insetEdges = insetEdges.Concat(insetEdges1).Concat(insetEdges2).ToArray();

            var gemVerticesOuterList = new List<VertexPositionNormalTexture>();
            var gemVerticesInnerList = new List<VertexPositionNormalTexture>();

            foreach (int[] corners in faceCorners)
            {
                float edge0 = GreenGemInsetEdge(corners[0], corners[1], insetEdges);
                float edge1 = GreenGemInsetEdge(corners[1], corners[2], insetEdges);
                float edge2 = GreenGemInsetEdge(corners[2], corners[0], insetEdges);

                gemVerticesOuterList.AddRange(MakeTriangle(gemCorners, corners, new float[] { 0.0F, 0.0F, 0.0F }));
                gemVerticesInnerList.AddRange(MakeTriangle(gemCorners, corners, new float[] { edge0, edge1, edge2 }, 0.02F));
            }

            return new GemModel(device, gemVerticesOuterList, gemVerticesInnerList, Color.Green );
        }
开发者ID:noxo,项目名称:SecondRealityponyWinRT,代码行数:85,代码来源:Rarity.cs

示例2: CreateRedGemModel

        public GemModel CreateRedGemModel()
        {
            var gemCorners = new Vector3[] {
                //Front face, 6 corners, counterclockwise from top
                new Vector3(0, 0.5F, 0.2F),
                new Vector3(-0.2F, 0.3F, 0.2F),
                new Vector3(-0.2F, -0.3F, 0.2F),
                new Vector3(0, -0.5F, 0.2F),
                new Vector3(0.2F, -0.3F, 0.2F),
                new Vector3(0.2F, 0.3F, 0.2F),

                //Outer vertices, 6 corners, counterclockwise from top
                new Vector3(0F, 1.0F, 0),
                new Vector3(-0.5F, 0.5F, 0),
                new Vector3(-0.5F, -0.5F, 0),
                new Vector3(0F, -1.0F, 0),
                new Vector3(0.5F, -0.5F, 0),
                new Vector3(0.5F, 0.5F, 0)
            };
            //Copy first 6 vertices to last 6, with inverted Z
            gemCorners = gemCorners.Concat(gemCorners.Take(6).Select(v => new Vector3(v.X, v.Y, -v.Z))).ToArray();

            var faceCorners = new int[][] {
                //Front face
                new int[] { 0, 1, 2 },
                new int[] { 2, 3, 4 },
                new int[] { 4, 5, 0 },
                new int[] { 0, 2, 4 },

                //6 faces, counterclockwise from top, 2 triangles each
                new int[] { 0, 6, 7 },
                new int[] { 7, 1, 0 },
                new int[] { 1, 7, 8 },
                new int[] { 8, 2, 1 },
                new int[] { 2, 8, 9 },
                new int[] { 9, 3, 2 },
                new int[] { 3, 9, 10 },
                new int[] { 10, 4, 3 },
                new int[] { 4, 10, 11 },
                new int[] { 11, 5, 4 },
                new int[] { 5, 11, 6 },
                new int[] { 6, 0, 5 },

                //6 faces, clockwise from top, 2 triangles each
                new int[] { 12, 7, 6 },
                new int[] { 12, 13, 7 },
                new int[] { 13, 8, 7 },
                new int[] { 13, 14, 8 },
                new int[] { 14, 9, 8 },
                new int[] { 14, 15, 9 },
                new int[] { 15, 10, 9 },
                new int[] { 15, 16, 10 },
                new int[] { 16, 11, 10 },
                new int[] { 16, 17, 11 },
                new int[] { 17, 6, 11 },
                new int[] { 17, 12, 6 },

                //Back face
                new int[] { 12, 14, 13 },
                new int[] { 16, 15, 14 },
                new int[] { 12, 17, 16 },
                new int[] { 12, 16, 14 },

            };

            var gemVerticesOuterList = new List<VertexPositionNormalTexture>();
            var gemVerticesInnerList = new List<VertexPositionNormalTexture>();

            foreach (int[] corners in faceCorners)
            {
                float edge0 = RedGemInsetEdge(corners[0], corners[1]);
                float edge1 = RedGemInsetEdge(corners[1], corners[2]);
                float edge2 = RedGemInsetEdge(corners[2], corners[0]);

                gemVerticesOuterList.AddRange(MakeTriangle(gemCorners, corners, new float[] { 0.0F, 0.0F, 0.0F }));
                gemVerticesInnerList.AddRange(MakeTriangle(gemCorners, corners, new float[] { edge0, edge1, edge2 }, 0.02F));
            }

            return new GemModel(device, gemVerticesOuterList, gemVerticesInnerList, Color.Red);
        }
开发者ID:noxo,项目名称:SecondRealityponyWinRT,代码行数:80,代码来源:Rarity.cs

示例3: CreateBlueGemModel

        public GemModel CreateBlueGemModel()
        {
            var gemCorners = new Vector3[] {
                new Vector3(0F, 0.7F, 0.5F),
                new Vector3(0.35F, 0.4F, 0.35F * (float) Math.Sqrt(3))
            };

            //Create 6 rotations of those two vertices
            gemCorners = (from i in Enumerable.Range(0, 6)
                          from v in gemCorners
                         select Vector3.Transform(v, Matrix.CreateRotationY(MathHelper.Pi * i / 3F))).ToArray();

            //Append top-center and bottom-center vertices
            gemCorners = gemCorners.Concat(new Vector3[] {
                new Vector3(0, 0.7F, 0),
                new Vector3(0, -0.7F, 0)
            }).ToArray();

            //Tilt entire gem slightly towards the viewer, so we can see the top face
            gemCorners = gemCorners.Select(v => Vector3.Transform(v, Matrix.CreateRotationX(0.3F))).ToArray();

            //Define 4 triangles, then create 6 rotations of them too
            var faceCorners = new int[][] {
                new int[] {12, 0, 2},
                new int[] {0, 1, 2},
                new int[] {1, 3, 2},
                new int[] {1, 13, 3}
            };
            Func<int, int, int> nextStep = (i, n) => (i >= 12 ? i : (i + n * 2) % 12);
            faceCorners = (from n in Enumerable.Range(0, 6)
                          from ints in faceCorners
                          select ints.Select(i => nextStep(i, n)).ToArray()).ToArray();

            var gemVerticesOuterList = new List<VertexPositionNormalTexture>();
            var gemVerticesInnerList = new List<VertexPositionNormalTexture>();

            foreach (int[] corners in faceCorners)
            {
                //Inset all edges, except edges 0 and 2 when vertex0 is 12 (top center)
                float edge0 = corners[0] != 12 ? 0.03F : 0;
                float edge1 = 0.03F;
                float edge2 = corners[0] != 12 ? 0.03F : 0;

                gemVerticesOuterList.AddRange(MakeTriangle(gemCorners, corners, new float[] { 0.0F, 0.0F, 0.0F }));
                gemVerticesInnerList.AddRange(MakeTriangle(gemCorners, corners, new float[] { edge0, edge1, edge2 }, 0.02F));
            }

            return new GemModel(device, gemVerticesOuterList, gemVerticesInnerList, new Color(48, 48, 255));
        }
开发者ID:noxo,项目名称:SecondRealityponyWinRT,代码行数:49,代码来源:Rarity.cs


注:本文中的Vector3.Concat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。