コード例 #1
0
            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);
            }
コード例 #2
0
ファイル: AlembicExporter.cs プロジェクト: chellingly/Vessel
            public override void Capture()
            {
                if (m_target == null)
                {
                    return;
                }

                // create buffer
#if UNITY_5_5_OR_NEWER
                int count_max = m_target.main.maxParticles;
#else
                int count_max = m_target.maxParticles;
#endif
                if (m_buf_particles == null)
                {
                    m_buf_particles = new ParticleSystem.Particle[count_max];
                    m_buf_positions.Resize(count_max);
                    m_buf_rotations.Resize(count_max);
                }
                else if (m_buf_particles.Length != count_max)
                {
                    Array.Resize(ref m_buf_particles, count_max);
                    m_buf_positions.Resize(count_max);
                    m_buf_rotations.Resize(count_max);
                }

                // copy particle positions & rotations to buffer
                int count = m_target.GetParticles(m_buf_particles);
                for (int i = 0; i < count; ++i)
                {
                    m_buf_positions[i] = m_buf_particles[i].position;
                }
                for (int i = 0; i < count; ++i)
                {
                    var a = m_buf_particles[i].axisOfRotation;
                    m_buf_rotations[i].Set(a.x, a.y, a.z, m_buf_particles[i].rotation);
                }

                // write!
                var data = new AbcAPI.aePointsData();
                data.positions = m_buf_positions;
                data.count     = count;
                AbcAPI.aePointsWriteSample(m_abc, ref data);
                AbcAPI.aePropertyWriteArraySample(m_prop_rotatrions, m_buf_rotations, count);
            }
コード例 #3
0
            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);
            }
コード例 #4
0
            public override void Capture()
            {
                if (m_stopped)
                {
                    return;
                }

                if (m_target == null)
                {
                    m_stopped         = true;
                    m_data.visibility = false;
                }
                else
                {
                    // create buffer
                    int count_max = m_target.main.maxParticles;
                    if (m_buf_particles == null || m_buf_particles.Length != count_max)
                    {
                        m_buf_particles = new ParticleSystem.Particle[count_max];
                        m_buf_points.Resize(count_max);
                        m_buf_rotations.Resize(count_max);
                    }

                    // copy particle positions & rotations to buffer
                    int count = m_target.GetParticles(m_buf_particles);
                    for (int i = 0; i < count; ++i)
                    {
                        m_buf_points[i] = m_buf_particles[i].position;
                    }
                    for (int i = 0; i < count; ++i)
                    {
                        var a = m_buf_particles[i].axisOfRotation;
                        m_buf_rotations[i].Set(a.x, a.y, a.z, m_buf_particles[i].rotation);
                    }

                    // write!
                    m_data.visibility = m_target.gameObject.activeSelf;
                    m_data.positions  = m_buf_points;
                    m_data.count      = count;
                }
                m_abc.WriteSample(ref m_data);
            }
コード例 #5
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;
                    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;
                }
            }