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


C# TriMesh.TrimExcess方法代码示例

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


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

示例1: Clone

        public static TriMesh Clone(TriMesh mesh)
        {
            TriMesh newMesh = new TriMesh();
            for (int i = 0; i < mesh.Vertices.Count; i++)
            {
                VertexTraits traits = new VertexTraits(mesh.Vertices[i].Traits.Position.x,
                                                       mesh.Vertices[i].Traits.Position.y,
                                                       mesh.Vertices[i].Traits.Position.z);
                newMesh.Vertices.Add(traits);
            }

            TriMesh.Vertex[] faceVetices = new TriMesh.Vertex[3];
            for (int i = 0; i < mesh.Faces.Count; i++)
            {
                int faceVertexIndex1 = mesh.Faces[i].GetVertex(0).Index;
                int faceVertexIndex2 = mesh.Faces[i].GetVertex(1).Index;
                int faceVertexIndex3 = mesh.Faces[i].GetVertex(2).Index;

                faceVetices[0] = newMesh.Vertices[faceVertexIndex1];
                faceVetices[1] = newMesh.Vertices[faceVertexIndex2];
                faceVetices[2] = newMesh.Vertices[faceVertexIndex3];
                newMesh.Faces.AddTriangles(faceVetices);
            }
            newMesh.TrimExcess();
            return newMesh;
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:26,代码来源:TriMeshIO.cs

示例2: LoadPlyStream

        private static TriMesh LoadPlyStream(Stream stream)
        {
            TriMesh mesh = new TriMesh();
            mesh.Traits.HasFaceVertexNormals = true;
            mesh.Traits.HasTextureCoordinates = true;

            StreamReader sr = new StreamReader(stream);
            PlyFileProcessorState state = new PlyFileProcessorState();
            string line;
            while ((line = sr.ReadLine()) != null)
            {
                ProcessPlyLine(mesh, line, state);
            }

            mesh.TrimExcess();
            return mesh;
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:17,代码来源:TriMeshIOply.cs

示例3: LoadOffStream

        private static TriMesh LoadOffStream(Stream stream)
        {
            TriMesh mesh = new TriMesh();
            mesh.Traits.HasFaceVertexNormals = true;
            mesh.Traits.HasTextureCoordinates = true;

            StreamReader sr = new StreamReader(stream);
            OffFileProcessorState state = new OffFileProcessorState();
            string line;
            bool ignoreFirstThreeNum = true;


            while ((line = sr.ReadLine()) != null)
            {
                ProcessOffLine(mesh, line, state, ref ignoreFirstThreeNum);
            }

            mesh.TrimExcess();
            return mesh;
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:20,代码来源:TriMeshIOoff.cs

示例4: LoadObjStream

        /// <summary>
        /// Loads an OBJ file from a stream.
        /// </summary>
        /// <param name="stream">A stream with OBJ file data.</param>
        private static TriMesh LoadObjStream(Stream stream)
        {
            TriMesh mesh = new TriMesh();
            mesh.Traits.HasFaceVertexNormals = true;
            mesh.Traits.HasTextureCoordinates = true;

            StreamReader sr = new StreamReader(stream);
            ObjFileProcessorState state = new ObjFileProcessorState();
            string line;

            while ((line = sr.ReadLine()) != null)
            {

                ProcessObjLine(mesh, line, state);

            }

            if (state.VertexTextureCoords.Count == mesh.Vertices.Count)
            {
                for (int i = 0; i < mesh.Vertices.Count; i++)
                {
                    mesh.Vertices[i].Traits.UV = state.VertexTextureCoords[i];
                }
            }
            mesh.TrimExcess();
            return mesh;
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:31,代码来源:TriMeshIOobj.cs

示例5: BulidSphere

        public static TriMesh BulidSphere()//建立球星Trimesh
        {
            TriMesh sphere = new TriMesh();

            sphere.Vertices.Add(new VertexTraits(-0.9972, 19.7347, -0.3015));
            sphere.Vertices.Add(new VertexTraits(-0.9972, 13.8535, -15.6699));
            sphere.Vertices.Add(new VertexTraits(-14.3067, 13.8535, -7.98572));
            sphere.Vertices.Add(new VertexTraits(-14.3067, 13.8535, 7.3828));
            sphere.Vertices.Add(new VertexTraits(-0.9972, 13.8535, 15.0670));
            sphere.Vertices.Add(new VertexTraits(12.3122, 13.8535, 7.3828));
            sphere.Vertices.Add(new VertexTraits(12.3122, 13.8535, -7.9857));
            sphere.Vertices.Add(new VertexTraits(-0.9972, -3.8925, -15.6699));
            sphere.Vertices.Add(new VertexTraits(-14.3067, -3.8925, -7.9857));
            sphere.Vertices.Add(new VertexTraits(-14.3067, -3.8925, 7.3828));
            sphere.Vertices.Add(new VertexTraits(-0.9972, -3.8925, 15.0670));
            sphere.Vertices.Add(new VertexTraits(12.3122, -3.8925, 7.3828));
            sphere.Vertices.Add(new VertexTraits(12.3122, -3.8925, -7.9857));
            sphere.Vertices.Add(new VertexTraits(-0.9972, -9.7738, -0.3015));


            BulidSphereFace(0, 1, 2,sphere);
            BulidSphereFace(0, 2, 3,sphere);
            BulidSphereFace(0, 3, 4, sphere);
            BulidSphereFace(0, 4, 5, sphere);
            BulidSphereFace(0, 5, 6, sphere);
            BulidSphereFace(0, 6, 1, sphere);
            BulidSphereFace(1, 7, 8, sphere);
            BulidSphereFace(1, 8, 2, sphere);
            BulidSphereFace(2, 8, 9, sphere);
            BulidSphereFace(2, 9, 3, sphere);
            BulidSphereFace(3, 9, 10, sphere);
            BulidSphereFace(3, 10, 4, sphere);
            BulidSphereFace(4, 10, 11, sphere);
            BulidSphereFace(4, 11, 5, sphere);
            BulidSphereFace(5, 11, 12, sphere);
            BulidSphereFace(5, 12, 6, sphere);
            BulidSphereFace(6, 12, 7, sphere);
            BulidSphereFace(6, 7, 1, sphere);
            BulidSphereFace(13, 8, 7, sphere);
            BulidSphereFace(13, 9, 8, sphere);
            BulidSphereFace(13, 10, 9, sphere);
            BulidSphereFace(13, 11, 10, sphere);
            BulidSphereFace(13, 12, 11, sphere);
            BulidSphereFace(13, 7, 12, sphere);

            sphere.TrimExcess();

            Matrix4D m = new Matrix4D();
            m[0, 0] = 0.003; m[1, 1] = 0.003; m[2, 2] = 0.003;
            Vector4D v = new Vector4D();
            for (int i = 0; i < sphere.Vertices.Count; i++)//对整个球进行缩放
            {
                v.x = sphere.Vertices[i].Traits.Position.x;
                v.y = sphere.Vertices[i].Traits.Position.y;
                v.z = sphere.Vertices[i].Traits.Position.z;
                v.w = 1;
                v *= m;
                sphere.Vertices[i].Traits.Position.x = v.x;
                sphere.Vertices[i].Traits.Position.y = v.y;
                sphere.Vertices[i].Traits.Position.z = v.z;
             }
            return sphere;

        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:64,代码来源:TrimeshCreateSphere.cs


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