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


C# Vector3.GetLength方法代码示例

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


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

示例1: ConvertMeshToVertList

        /// <summary>
        /// warning: cache thrashes
        /// </summary>
        /// <param name="mesh"></param>
        /// <param name="vertexes"></param>
        public static void ConvertMeshToVertList(Vector3[,] mesh, ref VertexPositionTexture[] vertexes)
        {
            int index = 0;
            for (int x = 0; x < mesh.GetLength(0) - 1; x++) {
                for (int z = 0; z < mesh.GetLength(1) - 1; z++) {
                    vertexes[index].Position = mesh[x, z];
                    vertexes[index + 1].Position = mesh[x, z + 1];
                    vertexes[index + 2].Position = mesh[x + 1, z + 1];
                    vertexes[index + 3].Position = mesh[x + 1, z];

                    index += 4;
                }
            }
        }
开发者ID:bsamuels453,项目名称:With-Fire-and-Iron,代码行数:19,代码来源:MeshHelper.cs

示例2: ConvertMeshToVertList

        public static void ConvertMeshToVertList(Vector3[,] mesh, Vector3[,] normals, ref VertexPositionNormalTexture[] verticies)
        {
            //convert from 2d array to 1d
            int index = 0;
            for (int x = 0; x < mesh.GetLength(0) - 1; x++){
                for (int z = 0; z < mesh.GetLength(1) - 1; z++){
                    verticies[index].Position = mesh[x, z];
                    verticies[index].Normal = normals[x, z];

                    verticies[index + 1].Position = mesh[x, z + 1];
                    verticies[index + 1].Normal = normals[x, z + 1];

                    verticies[index + 2].Position = mesh[x + 1, z + 1];
                    verticies[index + 2].Normal = normals[x + 1, z + 1];

                    verticies[index + 3].Position = mesh[x + 1, z];
                    verticies[index + 3].Normal = normals[x + 1, z];

                    index += 4;
                }
            }
        }
开发者ID:bsamuels453,项目名称:Drydock,代码行数:22,代码来源:MeshHelper.cs

示例3: GenerateMeshNormals

        public static Vector3[,] GenerateMeshNormals(Vector3[,] mesh)
        {
            var normals = new Vector3[mesh.GetLength(0), mesh.GetLength(1)];
            for (int vertX = 0; vertX < mesh.GetLength(0) - 1; vertX++) {
                for (int vertZ = 0; vertZ < mesh.GetLength(1) - 1; vertZ++) {
                    var crossSum = new Vector3();

                    var s1 = mesh[vertX + 1, vertZ] - mesh[vertX, vertZ];
                    var s2 = mesh[vertX, vertZ + 1] - mesh[vertX, vertZ];
                    var s3 = mesh[vertX + 1, vertZ + 1] - mesh[vertX, vertZ];

                    crossSum += Vector3.Cross(s1, s3);
                    crossSum += Vector3.Cross(s3, s2);

                    normals[vertX, vertZ] += crossSum;
                    if (crossSum != Vector3.Zero) {
                        normals[vertX, vertZ].Normalize();
                    }
                }
            }

            for (int vertX = 1; vertX < mesh.GetLength(0); vertX++) {
                for (int vertZ = 1; vertZ < mesh.GetLength(1); vertZ++) {
                    var crossSum = new Vector3();

                    var s1 = mesh[vertX - 1, vertZ] - mesh[vertX, vertZ];
                    var s2 = mesh[vertX, vertZ - 1] - mesh[vertX, vertZ];
                    var s3 = mesh[vertX - 1, vertZ - 1] - mesh[vertX, vertZ];

                    crossSum += Vector3.Cross(s1, s3);
                    crossSum += Vector3.Cross(s3, s2);

                    normals[vertX, vertZ] += crossSum;
                    normals[vertX, vertZ].Normalize();
                }
            }
            return normals;
        }
开发者ID:bsamuels453,项目名称:With-Fire-and-Iron,代码行数:38,代码来源:MeshHelper.cs


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