/****************************************************************************
        *       Trail functions
        ****************************************************************************/

        /// <summary>
        /// Creates a trail and assigns it to a particle.
        /// </summary>
        /// <param name="particleInfo">Information about the particle.</param>
        public void AddTrail(TrailParticleInfo particleInfo)
        {
            // Check parent object
            if (_parentGameObject == null)
            {
                _parentGameObject = new GameObject("Playground Trails (" + playgroundSystem.name + ")", typeof(PlaygroundTrailParent));
                _parentTransform  = _parentGameObject.transform;
                _parentGameObject.GetComponent <PlaygroundTrailParent>().trailsReference = this;
            }

            ParticlePlaygroundTrail newTrail = new ParticlePlaygroundTrail(maxPoints);

            newTrail.trailGameObject       = new GameObject("Playground Trail " + particleInfo.particleId);
            newTrail.trailTransform        = newTrail.trailGameObject.transform;
            newTrail.trailTransform.parent = _parentTransform;
            newTrail.trailRenderer         = newTrail.trailGameObject.AddComponent <MeshRenderer>();
            newTrail.trailMeshFilter       = newTrail.trailGameObject.AddComponent <MeshFilter>();
            newTrail.trailMesh             = new Mesh();
            newTrail.trailMesh.MarkDynamic();
            newTrail.trailMeshFilter.sharedMesh   = newTrail.trailMesh;
            newTrail.trailRenderer.sharedMaterial = material;

            newTrail.particleId = particleInfo.particleId;

            if (createFirstPointOnParticleBirth)
            {
                newTrail.SetFirstPoint(particleInfo.position, particleInfo.velocity, EvaluateWidth(0), time, _calculationStartTime);
            }

            _trails.Add(newTrail);
        }
Beispiel #2
0
        /****************************************************************************
        *       Trail functions
        ****************************************************************************/

        public void ReuseTrail(int trailIndex, TrailParticleInfo particleInfo)
        {
            trails[trailIndex].DequeueForReuse();
            trails[trailIndex].particleId = particleInfo.particleId;
            trails[trailIndex].ClearTrail();

            if (createFirstPointOnParticleBirth)
            {
                float w = EvaluateWidth(0);
                trails[trailIndex].SetFirstPoint(particleInfo.position, particleInfo.velocity, w, time, _calculationStartTime);

                // Send trail point event to listeners
                if (_hasTrailPointEventListener)
                {
                    _eventTrailPoint.Update(
                        trails.Count,
                        0,
                        particleInfo.position,
                        w,
                        time,
                        _calculationStartTime
                        );
                    trailPointEvent(_eventTrailPoint);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Creates a trail and assigns it to a particle.
        /// </summary>
        /// <param name="particleInfo">Information about the particle.</param>
        public void CreateTrail(TrailParticleInfo particleInfo)
        {
            // Check parent object
            if (_parentGameObject == null)
            {
                _parentGameObject = new GameObject("Playground Trails (" + playgroundSystem.name + ")", typeof(PlaygroundTrailParent));
                _parentTransform  = _parentGameObject.transform;
                _parentGameObject.GetComponent <PlaygroundTrailParent>().trailsReference = this;
            }

            ParticlePlaygroundTrail newTrail = new ParticlePlaygroundTrail(maxPoints);

            newTrail.trailGameObject = new GameObject("Playground Trail " + trails.Count);
            layer = Mathf.Clamp(layer, 0, 32);
            newTrail.trailGameObject.layer = layer;
            newTrail.trailTransform        = newTrail.trailGameObject.transform;
            newTrail.trailTransform.parent = _parentTransform;
            newTrail.trailRenderer         = newTrail.trailGameObject.AddComponent <MeshRenderer>();
            newTrail.trailMeshFilter       = newTrail.trailGameObject.AddComponent <MeshFilter>();
            newTrail.trailMesh             = new Mesh();
            newTrail.trailMesh.MarkDynamic();
            newTrail.trailMeshFilter.sharedMesh   = newTrail.trailMesh;
            newTrail.trailRenderer.sharedMaterial = material;

            newTrail.particleId = particleInfo.particleId;

            if (createFirstPointOnParticleBirth)
            {
                float w = EvaluateWidth(0);
                newTrail.SetFirstPoint(particleInfo.position, particleInfo.velocity, w, time, _calculationStartTime);

                // Send trail point event to listeners
                if (_hasTrailPointEventListener)
                {
                    _eventTrailPoint.Update(
                        trails.Count,
                        0,
                        particleInfo.position,
                        w,
                        time,
                        _calculationStartTime
                        );
                    trailPointEvent(_eventTrailPoint);
                }
            }

            trails.Add(newTrail);
        }
		/****************************************************************************
			Trail functions
		 ****************************************************************************/

		/// <summary>
		/// Creates a trail and assigns it to a particle.
		/// </summary>
		/// <param name="particleInfo">Information about the particle.</param>
		public void AddTrail (TrailParticleInfo particleInfo)
		{
			// Check parent object
			if (_parentGameObject == null)
			{
				_parentGameObject = new GameObject("Playground Trails ("+playgroundSystem.name+")", typeof(PlaygroundTrailParent));
				_parentTransform = _parentGameObject.transform;
				_parentGameObject.GetComponent<PlaygroundTrailParent>().trailsReference = this;
			}

			ParticlePlaygroundTrail newTrail = new ParticlePlaygroundTrail(maxPoints);
			newTrail.trailGameObject = new GameObject("Playground Trail "+particleInfo.particleId);
			newTrail.trailTransform = newTrail.trailGameObject.transform;
			newTrail.trailTransform.parent = _parentTransform;
			newTrail.trailRenderer = newTrail.trailGameObject.AddComponent<MeshRenderer>();
			newTrail.trailMeshFilter = newTrail.trailGameObject.AddComponent<MeshFilter>();
			newTrail.trailMesh = new Mesh();
			newTrail.trailMesh.MarkDynamic();
			newTrail.trailMeshFilter.sharedMesh = newTrail.trailMesh;
			newTrail.trailRenderer.sharedMaterial = material;
			
			newTrail.particleId = particleInfo.particleId;

			if (createFirstPointOnParticleBirth)
				newTrail.SetFirstPoint(particleInfo.position, particleInfo.velocity, EvaluateWidth(0), time, _calculationStartTime);

			_trails.Add (newTrail);
		}