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


C# Mesh.getVertexCount方法代码示例

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


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

示例1: MG2MeshEqualsTest

        private void MG2MeshEqualsTest(MG2Encoder enc, Mesh orig, Mesh read)
        {
            Assert.AreEqual (orig.getTriangleCount (), read.getTriangleCount (), "Trianglecount differs");
            Assert.AreEqual (orig.getVertexCount (), read.getVertexCount (), "Vertexcount differs");
            Assert.AreEqual (orig.hasNormals (), read.hasNormals (), "Only one has normals");

            Grid grid = enc.setupGrid (orig.vertices);
            SortableVertex[] sorted = enc.sortVertices (grid, orig.vertices);
            int[] indexLUT = new int[sorted.Length];
            for (int i = 0; i < sorted.Length; ++i) {
                indexLUT [sorted [i].originalIndex] = i;
            }

            for (int i=0; i < orig.getVertexCount(); i++) {
                int newIndex = indexLUT [i];

                for (int e = 0; e < Mesh.CTM_POSITION_ELEMENT_COUNT; e++) {
                    Assert.IsTrue (compare (orig.vertices [i * 3 + e], read.vertices [newIndex * 3 + e], enc.vertexPrecision * 2),
                                   "positions not in precision");
                }
                if (orig.hasNormals ()) {
                    for (int e = 0; e < Mesh.CTM_NORMAL_ELEMENT_COUNT; e++) {
                        Assert.IsTrue (compare (orig.normals [i * 3 + e], read.normals [newIndex * 3 + e], enc.normalPrecision * 10),
                                       "normals not in precision");
                    }
                }
            }

            testAttributeArrays (orig.texcoordinates, read.texcoordinates, indexLUT);
            testAttributeArrays (orig.attributs, read.attributs, indexLUT);
        }
开发者ID:archimy,项目名称:OpenCtm-CSharp,代码行数:31,代码来源:ReadTests.cs

示例2: encode

        public virtual void encode(Mesh m, CtmOutputStream output)
        {
            int vc = m.getVertexCount();

            output.writeLittleInt(MeshDecoder.INDX);
            writeIndicies(m.indices, output);

            output.writeLittleInt(MeshDecoder.VERT);
            writeFloatArray(m.vertices, output, vc * 3, 1);

            // Write normals
            if (m.normals != null) {
                output.writeLittleInt(MeshDecoder.NORM);
                writeFloatArray(m.normals, output, vc, 3);
            }

            foreach (AttributeData ad in m.texcoordinates) {
                output.writeLittleInt(MeshDecoder.TEXC);
                output.writeString(ad.name);
                output.writeString(ad.materialName);
                writeFloatArray(ad.values, output, vc, 2);
            }

            foreach (AttributeData ad in m.attributs) {
                output.writeLittleInt(MeshDecoder.ATTR);
                output.writeString(ad.name);
                writeFloatArray(ad.values, output, vc, 4);
            }
        }
开发者ID:archimy,项目名称:OpenCtm-CSharp,代码行数:29,代码来源:RawEncoder.cs

示例3: encode

        public void encode(Mesh m, String comment)
        {
            // Check mesh integrity
            m.checkIntegrity();

            // Determine flags
            int flags = 0;
            if (m.normals != null) {
                flags |= MeshInfo.HAS_NORMAL_BIT;
            }

            // Write header to stream
            output.writeLittleInt(CtmFileReader.OCTM);
            output.writeLittleInt(encoder.getFormatVersion());
            output.writeLittleInt(encoder.getTag());

            output.writeLittleInt(m.getVertexCount());
            output.writeLittleInt(m.getTriangleCount());
            output.writeLittleInt(m.getUVCount());
            output.writeLittleInt(m.getAttrCount());
            output.writeLittleInt(flags);
            output.writeString(comment);

            // Compress to stream
            encoder.encode(m, output);
        }
开发者ID:archimy,项目名称:OpenCtm-CSharp,代码行数:26,代码来源:CtmFileWriter.cs

示例4: encode

        public override void encode(Mesh m, CtmOutputStream output)
        {
            Grid grid = setupGrid (m.vertices);
            SortableVertex[] sorted = sortVertices (grid, m.vertices);
            int[] vdeltas = makeVertexDeltas (m.vertices, sorted, grid);

            int[] gridIndicies = new int[m.getVertexCount ()];
            gridIndicies [0] = sorted [0].gridIndex;
            for (int i = 1; i < m.getVertexCount(); ++i) {
                gridIndicies [i] = sorted [i].gridIndex - sorted [i - 1].gridIndex;
            }

            output.writeLittleInt (MG2Decoder.MG2_HEADER_TAG);

            output.writeLittleFloat (vertexPrecision);
            output.writeLittleFloat (normalPrecision);

            grid.writeToStream (output);

            output.writeLittleInt (MeshDecoder.VERT);
            output.writePackedInts (vdeltas, m.getVertexCount (), Mesh.CTM_POSITION_ELEMENT_COUNT, false);

            output.writeLittleInt (MG2Decoder.GIDX);
            output.writePackedInts (gridIndicies, m.getVertexCount (), 1, false);

            output.writeLittleInt (MeshDecoder.INDX);
            int[] indices = reIndexIndices (sorted, m.indices);
            rearrangeTriangles (indices);

            //write indicies
            {
                int[] deltas = new int[indices.Length];
                Array.Copy(indices, deltas, indices.Length);
                makeIndexDeltas (deltas);
                output.writePackedInts (deltas, m.getTriangleCount (), 3, false);
            }

            if (m.hasNormals ()) {

                for (int i = 1; i < m.getVertexCount(); i++) {
                    gridIndicies [i] += gridIndicies [i - 1];
                }
                float[] restoredv = CommonAlgorithm.restoreVertices (vdeltas, gridIndicies, grid, vertexPrecision);

                output.writeLittleInt (MeshDecoder.NORM);
                int[] intNormals = makeNormalDeltas (restoredv, m.normals, indices, sorted);
                output.writePackedInts (intNormals, m.getVertexCount (), Mesh.CTM_NORMAL_ELEMENT_COUNT, false);
            }

            foreach (AttributeData ad in m.texcoordinates) {
                output.writeLittleInt (MeshDecoder.TEXC);
                output.writeString (ad.name);
                output.writeString (ad.materialName);
                output.writeLittleFloat (ad.precision);
                int[] deltas = makeUVCoordDeltas (ad, sorted);
                output.writePackedInts (deltas, m.getVertexCount (), Mesh.CTM_UV_ELEMENT_COUNT, true);
            }

            foreach (AttributeData ad in m.attributs) {
                output.writeLittleInt (MeshDecoder.ATTR);
                output.writeString (ad.name);
                output.writeLittleFloat (ad.precision);
                int[] deltas = makeAttribDeltas (ad, sorted);
                output.writePackedInts (deltas, m.getVertexCount (), Mesh.CTM_ATTR_ELEMENT_COUNT, true);
            }
        }
开发者ID:archimy,项目名称:OpenCtm-CSharp,代码行数:66,代码来源:MG2Encoder.cs


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