コード例 #1
0
            public override void Capture()
            {
                if (m_target == null)
                {
                    return;
                }

                // create buffer
                int count_max = m_target.maxParticles;

                if (m_buf_particles == null)
                {
                    m_buf_particles = new ParticleSystem.Particle[count_max];
                    m_buf_positions = new Vector3[count_max];
                    m_buf_rotations = new Vector4[count_max];
                }
                else if (m_buf_particles.Length != count_max)
                {
                    Array.Resize(ref m_buf_particles, count_max);
                    Array.Resize(ref m_buf_positions, count_max);
                    Array.Resize(ref m_buf_rotations, 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)
                {
                    m_buf_rotations[i]   = m_buf_particles[i].axisOfRotation;
                    m_buf_rotations[i].w = m_buf_particles[i].rotation;
                }

                // write!
                var data = new AbcAPI.aePointsData();

                data.positions = GetArrayPtr(m_buf_positions);
                data.count     = count;
                AbcAPI.aePointsWriteSample(m_abc, ref data);
                AbcAPI.aePropertyWriteArraySample(m_prop_rotatrions, GetArrayPtr(m_buf_rotations), count);
            }