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 aeAPI.aePointsSampleData(); data.positions = GetArrayPtr(m_buf_positions); data.count = count; aeAPI.aePointsWriteSample(m_abc, ref data); aeAPI.aePropertyWriteArraySample(m_prop_rotatrions, GetArrayPtr(m_buf_rotations), count); }
public override void Capture() { var target = GetComponent<ParticleEngine>(); var positions = target.positionBuffer; if (positions == null) { return; } var data = new aeAPI.aePointsSampleData(); data.count = positions.Length; data.positions = Marshal.UnsafeAddrOfPinnedArrayElement(positions, 0); if(m_captureVelocities) { var velocities = target.velocityBuffer; if (velocities != null) { data.velocities = Marshal.UnsafeAddrOfPinnedArrayElement(velocities, 0); } } aeAPI.aePointsWriteSample(m_abc, ref data); }
public override unsafe void Capture() { var target = GetComponent <MPWorld>(); var ctx = target.GetContext(); var num = MPAPI.mpGetNumParticles(ctx); var particles = MPAPI.mpGetParticles(ctx); var positions = new Vector3[num]; var t = GetComponent <Transform>().worldToLocalMatrix; for (int i = 0; i < num; ++i) { positions[i] = t * new Vector4(particles[i].position.x, particles[i].position.y, particles[i].position.z, 1.0f); } var data = new aeAPI.aePointsSampleData(); data.count = num; data.positions = Marshal.UnsafeAddrOfPinnedArrayElement(positions, 0); aeAPI.aePointsWriteSample(m_abc, ref data); }
public override void Capture() { var target = GetComponent <ParticleEngine>(); var positions = target.positionBuffer; if (positions == null) { return; } var data = new aeAPI.aePointsSampleData(); data.count = positions.Length; data.positions = Marshal.UnsafeAddrOfPinnedArrayElement(positions, 0); if (m_captureVelocities) { var velocities = target.velocityBuffer; if (velocities != null) { data.velocities = Marshal.UnsafeAddrOfPinnedArrayElement(velocities, 0); } } aeAPI.aePointsWriteSample(m_abc, ref data); }