Пример #1
0
        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;
            }
        }
Пример #2
0
        public void ResetParticlePosition(int index)
        {
            if (emitterShape == null)
            {
                solver.positions[particleIndices[index]]          = transform.position;
                solver.predictedPositions[particleIndices[index]] = transform.position;
                solver.previousPositions[particleIndices[index]]  = transform.position;
                solver.velocities[particleIndices[index]]         = transform.TransformVector(initialVelocity);
            }
            else
            {
                Vector3 spawnPosition = transform.TransformPoint(emitterShape.GetDistributionPoint());

                solver.positions[particleIndices[index]]          = spawnPosition;
                solver.predictedPositions[particleIndices[index]] = spawnPosition;
                solver.previousPositions[particleIndices[index]]  = spawnPosition;
                solver.velocities[particleIndices[index]]         = transform.TransformVector(initialVelocity);
            }
        }
Пример #3
0
        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]);
            }
        }