public void ResetParticlePosition(int index, float offset) { if (emitterShape == null) { Vector3 spawnVelocity = Vector3.Lerp(transform.forward, UnityEngine.Random.onUnitSphere, randomVelocity); Vector3 positionOffset = spawnVelocity * (speed * Time.fixedDeltaTime) * offset; Vector4[] posArray = { transform.position + positionOffset }; Vector4[] velArray = { spawnVelocity *speed }; Oni.SetParticlePositions(solver.OniSolver, posArray, 1, particleIndices[index]); Oni.SetParticleVelocities(solver.OniSolver, velArray, 1, particleIndices[index]); colors[index] = Color.white; } else { ObiEmitterShape.DistributionPoint distributionPoint = emitterShape.GetDistributionPoint(); Vector3 spawnVelocity = Vector3.Lerp(transform.TransformVector(distributionPoint.velocity), UnityEngine.Random.onUnitSphere, randomVelocity); Vector3 positionOffset = spawnVelocity * (speed * Time.fixedDeltaTime) * offset; Vector4[] posArray = { transform.TransformPoint(distributionPoint.position) + positionOffset }; Vector4[] velArray = { spawnVelocity *speed }; Oni.SetParticlePositions(solver.OniSolver, posArray, 1, particleIndices[index]); Oni.SetParticleVelocities(solver.OniSolver, velArray, 1, particleIndices[index]); colors[index] = distributionPoint.color; } }
public void ResetParticlePosition(int index, float offset) { distEnumerator.MoveNext(); ObiEmitterShape.DistributionPoint distributionPoint = distEnumerator.Current; Vector3 spawnVelocity = Vector3.Lerp(distributionPoint.velocity, UnityEngine.Random.onUnitSphere, randomVelocity); Vector3 positionOffset = spawnVelocity * (speed * Time.fixedDeltaTime) * offset; Vector4[] posArray = { distributionPoint.position + positionOffset }; Vector4[] velArray = { spawnVelocity *speed }; Oni.SetParticlePositions(solver.OniSolver, posArray, 1, particleIndices[index]); Oni.SetParticleVelocities(solver.OniSolver, velArray, 1, particleIndices[index]); colors[index] = distributionPoint.color; }
public void ResetParticle(int index, float offset) { distEnumerator.MoveNext(); ObiEmitterShape.DistributionPoint distributionPoint = distEnumerator.Current; Vector3 spawnVelocity = Vector3.Lerp(distributionPoint.velocity, UnityEngine.Random.onUnitSphere, randomVelocity); Vector3 positionOffset = spawnVelocity * (speed * Time.fixedDeltaTime) * offset; m_Solver.startPositions[solverIndices[index]] = m_Solver.positions[solverIndices[index]] = distributionPoint.position + positionOffset; m_Solver.velocities[solverIndices[index]] = spawnVelocity * speed; UpdateParticleMaterial(index); if (useShapeColor) { m_Solver.colors[solverIndices[index]] = distributionPoint.color; } }
public void ResetParticlePosition(int index) { if (emitterShape == null) { Vector4[] posArray = { transform.position }; Vector4[] velArray = { Vector3.Lerp(Vector3.zero, UnityEngine.Random.onUnitSphere, randomVelocity) }; Oni.SetParticlePositions(solver.OniSolver, posArray, 1, particleIndices[index]); Oni.SetParticleVelocities(solver.OniSolver, velArray, 1, particleIndices[index]); Oni.SetParticleVorticities(solver.OniSolver, new Vector4[] { Vector4.zero }, 1, particleIndices[index]); } else { ObiEmitterShape.DistributionPoint distributionPoint = emitterShape.GetDistributionPoint(); Vector3 spawnPosition = transform.TransformPoint(distributionPoint.position); Vector3 spawnVelocity = transform.TransformVector(distributionPoint.velocity); Vector4[] posArray = { spawnPosition }; Vector4[] velArray = { Vector3.Lerp(spawnVelocity, UnityEngine.Random.onUnitSphere, randomVelocity) * initialSpeed }; Oni.SetParticlePositions(solver.OniSolver, posArray, 1, particleIndices[index]); Oni.SetParticleVelocities(solver.OniSolver, velArray, 1, particleIndices[index]); Oni.SetParticleVorticities(solver.OniSolver, new Vector4[] { Vector4.zero }, 1, particleIndices[index]); } }