public override void Capture()
            {
                if (m_target == null)
                {
                    m_data.visibility = false;
                }
                else
                {
                    // create buffer
                    int count_max = m_target.main.maxParticles;
                    if (m_bufParticles == null || m_bufParticles.Length != count_max)
                    {
                        m_bufParticles = new ParticleSystem.Particle[count_max];
                        m_bufPoints.Resize(count_max);
                        m_bufRotations.Resize(count_max);
                    }

                    // copy particle positions & rotations to buffer
                    int count = m_target.GetParticles(m_bufParticles);
                    for (int i = 0; i < count; ++i)
                    {
                        m_bufPoints[i]    = m_bufParticles[i].position;
                        m_bufRotations[i] = Quaternion.AngleAxis(m_bufParticles[i].rotation, m_bufParticles[i].axisOfRotation);
                    }

                    // write!
                    m_data.visibility = m_target.gameObject.activeSelf;
                    m_data.positions  = m_bufPoints;
                    m_data.count      = count;
                }
                abcObject.WriteSample(ref m_data);
            }
            void GenerateRemapIndices(Mesh mesh, MeshBuffer mbuf)
            {
                mbuf.Capture(mesh, Matrix4x4.identity, false, false, false, false);
                var weights4 = new PinnedList <BoneWeight>();

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

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

                if (world2local != Matrix4x4.identity)
                {
                    var verts = new List <Vector3>();
                    mesh.GetVertices(verts);
                    for (var i = 0; i < verts.Count; ++i)
                    {
                        var v = verts[i];
                        verts[i] = world2local.MultiplyPoint(v);
                    }

                    points.Assign(verts);
                }
                else
                {
                    points.LockList(ls => mesh.GetVertices(ls));
                }


                if (captureNormals)
                {
                    if (world2local != Matrix4x4.identity)
                    {
                        var meshNormals = new List <Vector3>();
                        mesh.GetNormals(meshNormals);
                        for (var i = 0; i < meshNormals.Count; ++i)
                        {
                            var n = meshNormals[i];
                            meshNormals[i] = world2local.MultiplyVector(n);
                        }
                        normals.Assign(meshNormals);
                    }
                    else
                    {
                        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 = new aeSubmeshData();
                    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.indexes      = indices;
                    smd.indexCount   = indices.Count;
                    submeshData[smi] = smd;
                }
            }
Esempio n. 4
0
            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 = new aeSubmeshData();
                    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.indexes      = indices;
                    smd.indexCount   = indices.Count;
                    submeshData[smi] = smd;
                }
            }