void GenerateRemapIndices(Mesh mesh, MeshBuffer mbuf)
            {
                mbuf.Capture(mesh, false, false, false, false);
                var weights4 = new PinnedList <BoneWeight>();

                weights4.LockList(l => { mesh.GetBoneWeights(l); });

                remap.Resize(mbuf.points.Count);
                numRemappedVertices = aeGenerateRemapIndices(remap, mbuf.points, weights4, mbuf.points.Count);
            }
            public void Capture(Mesh mesh,
                                bool captureNormals, bool captureUV0, bool captureUV1, bool captureColors)
            {
                if (mesh == null)
                {
                    Clear();
                    return;
                }

                points.LockList(ls => mesh.GetVertices(ls));

                if (captureNormals)
                {
                    normals.LockList(ls => mesh.GetNormals(ls));
                }
                else
                {
                    normals.Clear();
                }

                if (captureUV0)
                {
                    uv0.LockList(ls => mesh.GetUVs(0, ls));
                }
                else
                {
                    uv0.Clear();
                }

                if (captureUV1)
                {
                    uv1.LockList(ls => mesh.GetUVs(1, ls));
                }
                else
                {
                    uv1.Clear();
                }

                if (captureColors)
                {
                    colors.LockList(ls => mesh.GetColors(ls));
                }
                else
                {
                    colors.Clear();
                }


                int submeshCount = mesh.subMeshCount;

                submeshData.Resize(submeshCount);
                if (submeshIndices.Count > submeshCount)
                {
                    submeshIndices.RemoveRange(submeshCount, submeshIndices.Count - submeshCount);
                }
                while (submeshIndices.Count < submeshCount)
                {
                    submeshIndices.Add(new PinnedList <int>());
                }
                for (int smi = 0; smi < submeshCount; ++smi)
                {
                    var indices = submeshIndices[smi];
                    indices.LockList(l => { mesh.GetIndices(l, smi); });

                    aeSubmeshData smd;
                    switch (mesh.GetTopology(smi))
                    {
                    case MeshTopology.Triangles: smd.topology = aeTopology.Triangles; break;

                    case MeshTopology.Lines: smd.topology = aeTopology.Lines; break;

                    case MeshTopology.Quads: smd.topology = aeTopology.Quads; break;

                    default: smd.topology = aeTopology.Points; break;
                    }
                    smd.indices      = indices;
                    smd.indexCount   = indices.Count;
                    submeshData[smi] = smd;
                }
            }
예제 #3
0
            public void Capture(Mesh mesh,
                                bool captureNormals, bool captureUV0, bool captureUV1, bool captureColors)
            {
                points.LockList(ls => mesh.GetVertices(ls));

                if (captureNormals)
                {
                    normals.LockList(ls => mesh.GetNormals(ls));
                }
                else
                {
                    normals.Clear();
                }

                if (captureUV0)
                {
                    uv0.LockList(ls => mesh.GetUVs(0, ls));
                }
                else
                {
                    uv0.Clear();
                }

                if (captureUV1)
                {
                    uv1.LockList(ls => mesh.GetUVs(1, ls));
                }
                else
                {
                    uv1.Clear();
                }

                if (captureColors)
                {
                    colors.LockList(ls => mesh.GetColors(ls));
                }
                else
                {
                    colors.Clear();
                }

                {
                    int submeshCount = mesh.subMeshCount;
                    if (submeshCount == 1)
                    {
                        indices.LockList(ls => mesh.GetTriangles(ls, 0));
                    }
                    else
                    {
                        indices.Assign(mesh.triangles);

                        while (facesets.Count < submeshCount)
                        {
                            facesets.Add(new PinnedList <int>());
                        }

                        int offsetTriangle = 0;
                        for (int smi = 0; smi < submeshCount; ++smi)
                        {
                            tmpIndices.LockList(ls => { mesh.GetTriangles(ls, smi); });
                            int numTriangles = tmpIndices.Count / 3;
                            facesets[smi].ResizeDiscard(numTriangles);
                            for (int ti = 0; ti < numTriangles; ++ti)
                            {
                                facesets[smi][ti] = ti + offsetTriangle;
                            }
                            offsetTriangle += numTriangles;
                        }
                    }
                }
            }