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


C# Mesh.Init方法代码示例

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


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

示例1: Load

        public static Mesh Load(string path)
        {
            try
            {
                string line;
                using (StreamReader sr = new StreamReader(path))
                {
                    line = sr.ReadLine();
                    int vcnt, icnt;
                    {
                        string[] t = Split(line);
                        if (t.Length != 2) throw new Exception("failed to read vcnt & icnt");
                        if (!int.TryParse(t[0], out vcnt)) throw new Exception("failed to read vcnt");
                        if (!int.TryParse(t[1], out icnt)) throw new Exception("failed to read icnt");
                    }

                    Mesh mesh = new Mesh();
                    if (icnt > 0)
                        mesh.Init(icnt, vcnt);
                    else
                        mesh.Init(vcnt);

                    line = sr.ReadLine();

                    do
                    {
                        if (string.Compare(line, "index") == 0)
                            line = Load(sr, mesh.Indices);

                        else if (string.Compare(line, "faceprop") == 0)
                            line = Load(sr, mesh.FaceProps);

                        else if (string.Compare(line, "position") == 0)
                            line = Load(sr, mesh.Positions.Raw);

                        else if (string.Compare(line, "normal") == 0)
                            line = Load(sr, mesh.Normals.Raw);

                        else if (string.Compare(line, "texcrd0") == 0)
                            line = Load(sr, mesh.Texcrds0.Raw);

                        else if (string.Compare(line, "texcrd1") == 0)
                            line = Load(sr, mesh.Texcrds1.Raw);

                        else
                            throw new Exception(string.Format("failed to read {0}", line));

                    } while (null != line);

                    return mesh;
                }
            }
            catch (Exception err)
            {
                Console.WriteLine(err.Message);
                return null;
            }
        }
开发者ID:ming4883,项目名称:MJ-app,代码行数:58,代码来源:MeshUtil.cs

示例2: ToMesh

        public virtual Mesh ToMesh()
        {
            Mesh mesh = new Mesh();
            mesh.Init(positions.Count);

            mesh.FaceProps.Clear();
            mesh.FaceProps.AddRange(faceProps);

            mesh.Positions.Raw.Clear();
            mesh.Positions.Raw.AddRange(positions);

            mesh.Normals.Raw.Clear();
            mesh.Normals.Raw.AddRange(normals);

            mesh.Texcrds0.Raw.Clear();
            mesh.Texcrds0.Raw.AddRange(texcrds0);

            mesh.Texcrds1.Raw.Clear();
            mesh.Texcrds1.Raw.AddRange(texcrds1);

            return mesh;
        }
开发者ID:ming4883,项目名称:MJ-app,代码行数:22,代码来源:MeshBuilder.cs

示例3: Unwrap


//.........这里部分代码省略.........
                    Console.Write("gp{0}: ", i);
                    GroupedFaceUV.Dump(faceuvs, i);
                }
            }

            EndEvent("Prepare pack inputs");

            BeginEvent();

            bool ok = false;

            do
            {
                packSettings.Size.Width = packSize;
                packSettings.Size.Height = packSize;
                packSettings.Border = Border;

                packOutputs.Clear();

                JimScottPacker packer = new JimScottPacker();
                packer.debug = debug;
                packer.Pack(packSettings, packInputs, packOutputs);

                if (SingleMeshOutput)
                {
                    ok = packOutputs.Count == 1;
                    if (!ok) packSize = packSize * 2;
                }

            } while (SingleMeshOutput && !ok);

            EndEvent("Packing");

            BeginEvent();

            Vector2 scale = new Vector2(1.0f / packSize, 1.0f / packSize);

            // convert pack outputs back to faceuv
            foreach (PackOutputList polist in packOutputs)
            {
                foreach (PackOutput po in polist)
                {
                    Group gp = groups[po.Input];

                    foreach (GroupedFaceUV fuv in faceuvs)
                    {
                        if (fuv.GroupId != po.Input) continue;

                        fuv.Translate(new Vector2(po.X, po.Y) - gp.Min);
                        fuv.Scale(scale);
                    }
                }
            }

            // create output meshes
            List<Mesh> output = new List<Mesh>();

            foreach (PackOutputList polist in packOutputs)
            {
                Mesh omesh = new Mesh();

                int ofcnt = 0;
                for (int i = 0; i < polist.Count; ++i)
                    ofcnt += groups[polist[i].Input].Count;

                omesh.Init(ofcnt * 3);

                int dst = 0;

                for (int i = 0; i < polist.Count; ++i)
                {
                    for (int src = 0; src < fcnt; ++src)
                    {
                        GroupedFaceUV fuv = faceuvs[src];

                        if (fuv.GroupId != polist[i].Input) continue;

                        mesh.Positions.CopyFaceTo(omesh.Positions, src, dst);
                        mesh.Normals.CopyFaceTo(omesh.Normals, src, dst);
                        mesh.Texcrds0.CopyFaceTo(omesh.Texcrds0, src, dst);

                        omesh.Texcrds1.SetFace(dst, fuv.Texcrd[0], fuv.Texcrd[1], fuv.Texcrd[2]);

                        if(debug)
                            omesh.FaceProps[dst] = src;
                        else
                            omesh.FaceProps[dst] = mesh.FaceProps[src];

                        ++dst;
                    }
                }
                output.Add(omesh);
            }

            OutputSize = packSize;

            EndEvent("Prepare pack outputs");

            return output;
        }
开发者ID:ming4883,项目名称:MJ-app,代码行数:101,代码来源:GroupedFaceUnwrapper.cs


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