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


C# MeshData.Init方法代码示例

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


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

示例1: LoadMesh

    public static BC2Mesh LoadMesh(string loc)
    {
        BC2Mesh bc2mesh = new BC2Mesh ();
        List<Mesh> subsetMesh = new List<Mesh> ();
        List<string> subsetNames = new List<string> ();

        var s_Data = File.ReadAllBytes (loc);
        using (var s_Reader = new BinaryReader(new MemoryStream(s_Data))) {
            MeshData md = new MeshData();

            stream = s_Reader;
            //md.useFloat = float32;
            md.Init ();
            int i = 0;

            List<Vector3> v3 = new List<Vector3>();
            v3 = md.subset[0].GetV3(0);

            int v3int = 0;
            float v3float = 0;
            while(v3int < v3.Count()) {
                v3float += v3[v3int].x;
                v3int ++;
            }

            //hacky, but mostly works
            //Try creating something that detects corrupt mesh.
            //Perhaps overall distance or size?
            //Like, how tall the mesh is compared to how long it is.
            string name = loc.ToLower();
            float avg = (v3float / v3.Count);

            if (name.Contains ("sub_pen_outdoor") || name.Contains ("com_bridge_old/com_bridge_old") || name.Contains("sewer") || name.Contains("pickuppoint") ||
                name.Contains("com_bridge_small") || name.Contains("buffalo_dead" ) ) {

                md = new MeshData ();
                s_Reader.BaseStream.Seek (0, 0);
                md.useFloat = true;
                md.Init ();

                Debug.Log (loc + " is using 32 bit float | " + avg + " | " + v3float);
            }

            if ((name.Contains ("com_bridge_old/") || name.Contains("pickuppoint") || name.Contains("sewer"))){
                bc2mesh.inverted = true;
            }

            while (i < md.subset.Count) {

                if(!md.subset[i].name.Contains("ZOnly")) {
                    Mesh me = new Mesh ();
                    Vector3[] verts  = null;
                    verts = md.subset[i].GetV3(0).ToArray();
                    int[] tris = md.subset[i].GetIndices().ToArray();

                    if(bc2mesh.inverted == true) {
                        tris = tris.Reverse().ToArray();
                        Util.Log ("Inverted: " + loc);
                         //verts = md.subset[i].GetV3Inverted(0).ToArray();

                    }

                    ;
                    Vector2[] uv = null;
                    if(uvOffset != 0) {
                        md.subset[i].uvOffset = uvOffset;
                    } else {
                        md.subset[i].getV2offfsets();
                    }

                    List<Vector2> tempv2 = new List<Vector2>();
                    tempv2 = md.subset[i].getV2();
                    if(tempv2.Count != 0) {

                        uv = tempv2.ToArray();
                    }
                    me.vertices = verts;
                    me.triangles = tris;
                    me.uv = uv;
                    subsetNames.Add(md.subset[i].name);
                    subsetMesh.Add(me);
                }
                i++;
            }

        }
        bc2mesh.path = loc;
        bc2mesh.subMesh = subsetMesh;
        bc2mesh.subMeshNames = subsetNames;
        return bc2mesh;
    }
开发者ID:Powback,项目名称:Bad-Company-2-Map-Editor,代码行数:91,代码来源:MeshdataImporter.cs

示例2: LoadMeshRaw

    public static BC2Mesh LoadMeshRaw(string loc, int uvOffset, bool bigFloat, bool inverted)
    {
        BC2Mesh bc2mesh = new BC2Mesh ();
        List<Mesh> subsetMesh = new List<Mesh> ();
        List<string> subsetNames = new List<string> ();

        var s_Data = File.ReadAllBytes (loc);
        using (var s_Reader = new BinaryReader(new MemoryStream(s_Data))) {
            MeshData md = new MeshData();

            stream = s_Reader;
            //md.useFloat = float32;
            md.Init ();

            string name = loc.ToLower();

            md = new MeshData ();
            s_Reader.BaseStream.Seek (0, 0);
            md.useFloat = bigFloat;
            md.Init ();

            bc2mesh.inverted = inverted;

            int i = 0;
            while (i < md.subset.Count) {

                if(!md.subset[i].name.Contains("ZOnly")) {
                    Mesh me = new Mesh ();
                    Vector3[] verts  = null;
                    verts = md.subset[i].GetV3(0).ToArray();
                    int[] tris = md.subset[i].GetIndices().ToArray();

                    if(bc2mesh.inverted == true) {
                        tris = tris.Reverse().ToArray();
                        Util.Log ("Inverted: " + loc);
                        //verts = md.subset[i].GetV3Inverted(0).ToArray();

                    }

                    ;
                    Vector2[] uv = null;

                    md.subset[i].uvOffset = uvOffset;

                    List<Vector2> tempv2 = new List<Vector2>();
                    tempv2 = md.subset[i].getV2();
                    if(tempv2.Count != 0) {

                        uv = tempv2.ToArray();
                    }
                    me.vertices = verts;
                    me.triangles = tris;
                    me.uv = uv;
                    subsetNames.Add(md.subset[i].name);
                    subsetMesh.Add(me);
                }
                i++;
            }

        }
        bc2mesh.path = loc;
        bc2mesh.subMesh = subsetMesh;
        bc2mesh.subMeshNames = subsetNames;
        return bc2mesh;
    }
开发者ID:Powback,项目名称:Bad-Company-2-Map-Editor,代码行数:65,代码来源:MeshdataImporter.cs


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