Class representing a single particle instance.
        public override void InitParticle(Particle particle)
        {
            float alpha, a, b, x, y, z;

            // create a random angle from 0 .. PI*2
            alpha = MathUtil.RangeRandom(0,MathUtil.TWO_PI);

            // create two random radius values that are bigger than the inner size
            a = MathUtil.RangeRandom(InnerX,1.0f);
            b = MathUtil.RangeRandom(InnerY,1.0f);

            // with a and b we have defined a random ellipse inside the inner
            // ellipse and the outer circle (radius 1.0)
            // with alpha, and a and b we select a random point on this ellipse
            // and calculate it's coordinates
            x = a * MathUtil.Sin(alpha);
            y = b * MathUtil.Cos(alpha);
            // the height is simple running from 0 to 1
            z = MathUtil.UnitRandom();     // 0..1

            // scale the found point to the ring's size and move it
            // relatively to the center of the emitter point

            particle.Position = position + x * xRange + y * yRange + z * zRange;

            // Generate complex data by reference
            GenerateEmissionColor(particle.Color);
            GenerateEmissionDirection(ref particle.Direction);
            GenerateEmissionVelocity(ref particle.Direction);

            // Generate simpler data
            particle.timeToLive = GenerateEmissionTTL();
        }
Пример #2
0
		/// <see cref="ParticleAffector.InitParticle"/>
		public override void InitParticle( ref Particle particle )
		{
			if ( !this.colorImageLoaded )
			{
				loadImage();
			}

			particle.Color = this.colorImage.GetColorAt( 0, 0, 0 );
		}
Пример #3
0
		public override void InitParticle( Particle particle )
		{
			base.InitParticle( particle );

			// point emitter emits starting from its own position
			particle.Position = Position;

			GenerateEmissionColor( ref particle.Color );
			GenerateEmissionDirection( ref particle.Direction );
			GenerateEmissionVelocity( ref particle.Direction );

			// generate time to live
			particle.timeToLive = particle.totalTimeToLive = GenerateEmissionTTL();
		}
Пример #4
0
		public override void InitParticle( Particle particle )
		{
			Vector3 xOff, yOff, zOff;

			xOff = Utility.SymmetricRandom() * xRange;
			yOff = Utility.SymmetricRandom() * yRange;
			zOff = Utility.SymmetricRandom() * zRange;

			particle.Position = position + xOff + yOff + zOff;

			// Generate complex data by reference
			GenerateEmissionColor( ref particle.Color );
			GenerateEmissionDirection( ref particle.Direction );
			GenerateEmissionVelocity( ref particle.Direction );

			// Generate simpler data
			particle.timeToLive = particle.totalTimeToLive = GenerateEmissionTTL();
		}
        public override void InitParticle(Particle particle)
        {
            base.InitParticle(particle);

            Vector3 pos = new Vector3();

            pos.x = MathUtil.SymmetricRandom() * distance;
            pos.y = MathUtil.SymmetricRandom() * distance;
            pos.z = MathUtil.SymmetricRandom() * distance;

            // point emitter emits starting from its own position
            particle.Position = pos + particle.ParentSet.WorldPosition;

            GenerateEmissionColor(particle.Color);
            particle.Direction = particle.ParentSet.WorldPosition - particle.Position;
            GenerateEmissionVelocity(ref particle.Direction);

            // generate time to live
            particle.timeToLive = GenerateEmissionTTL();
        }
Пример #6
0
		public override void InitParticle( Particle particle )
		{
			float xOff, yOff, zOff;

			// First we create a random point inside a bounding cylinder with a
			// radius and height of 1 (this is easy to do). The distance of the
			// point from 0,0,0 must be <= 1 (== 1 means on the surface and we
			// count this as inside, too).

			while ( true )
			{
				// three random values for one random point in 3D space
				xOff = Utility.SymmetricRandom();
				yOff = Utility.SymmetricRandom();
				zOff = Utility.SymmetricRandom();

				// the distance of x,y from 0,0 is sqrt(x*x+y*y), but
				// as usual we can omit the sqrt(), since sqrt(1) == 1 and we
				// use the 1 as boundary. z is not taken into account, since
				// all values in the z-direction are inside the cylinder:
				if ( xOff*xOff + yOff*yOff <= 1 )
				{
					// found one valid point inside
					break;
				}
			}

			// scale the found point to the cylinder's size and move it
			// relatively to the center of the emitter point

			particle.Position = Position + xOff*xRange + yOff*yRange*zOff*zRange;

			// Generate complex data by reference
			GenerateEmissionColor( ref particle.Color );
			GenerateEmissionDirection( ref particle.Direction );
			GenerateEmissionVelocity( ref particle.Direction );

			// Generate simpler data
			particle.timeToLive = GenerateEmissionTTL();
		}
Пример #7
0
		public override void InitParticle( ref Particle particle )
		{
		}
Пример #8
0
		public override void InitParticle( ref Particle particle )
		{
			particle.Rotation = rotationRangeStart + ( Utility.UnitRandom() * ( rotationRangeEnd - rotationRangeStart ) );
			particle.RotationSpeed = rotationSpeedRangeStart + ( Utility.UnitRandom() * ( rotationSpeedRangeEnd - rotationSpeedRangeStart ) );
		}
 /// <summary>
 ///		Initializes a particle based on the emitter's approach and parameters.
 ///	</summary>
 ///	<remarks>
 ///		See the GetEmissionCount method for details of why there is a separation between
 ///		'requested' emissions and actual initialized particles.
 /// </remarks>
 /// <param name="particle">Reference to a particle which must be initialized based on how this emitter starts particles</param>
 public virtual void InitParticle(Particle particle)
 {
     particle.ResetDimensions();
 }
        public override void InitParticle(ref Particle particle)
        {
            const float div_255 = 1.0f / 255.0f;

            particle.Color.r = colorImage.Data[0] * div_255;
            particle.Color.g = colorImage.Data[1] * div_255;
            particle.Color.b = colorImage.Data[2] * div_255;
            particle.Color.a = colorImage.Data[3] * div_255;
        }
Пример #11
0
		/// <summary>
		///		Method called to allow the affector to 'do it's stuff' on all active particles in the system.
		/// </summary>
		/// <remarks>
		///		This is where the affector gets the chance to apply it's effects to the particles of a system.
		///		The affector is expected to apply it's effect to some or all of the particles in the system
		///		passed to it, depending on the affector's approach.
		/// </remarks>
        /// <param name="particle">Reference to a ParticleSystem to affect.</param>
		public virtual void InitParticle( ref Particle particle )
		{
			// do nothing by default
		}
        public override void InitParticle(Particle particle)
        {
            float alpha, beta, a, b, c, x, y, z;

            particle.ResetDimensions();

            // create two random angles alpha and beta
            // with these two angles, we are able to select any point on an
            // ellipsoid's surface
            MathUtil.RangeRandom(durationMin, durationMax);

            alpha = MathUtil.RangeRandom(0,MathUtil.TWO_PI);
            beta  = MathUtil.RangeRandom(0,MathUtil.PI);

            // create three random radius values that are bigger than the inner
            // size, but smaller/equal than/to the outer size 1.0 (inner size is
            // between 0 and 1)
            a = MathUtil.RangeRandom(InnerX,1.0f);
            b = MathUtil.RangeRandom(InnerY,1.0f);
            c = MathUtil.RangeRandom(InnerZ,1.0f);

            // with a,b,c we have defined a random ellipsoid between the inner
            // ellipsoid and the outer sphere (radius 1.0)
            // with alpha and beta we select on point on this random ellipsoid
            // and calculate the 3D coordinates of this point
            x = a * MathUtil.Cos(alpha) * MathUtil.Sin(beta);
            y = b * MathUtil.Sin(alpha) * MathUtil.Sin(beta);
            z = c * MathUtil.Cos(beta);

            // scale the found point to the ellipsoid's size and move it
            // relatively to the center of the emitter point

            particle.Position = position + x * xRange + y * yRange * z * zRange;

            // Generate complex data by reference
            GenerateEmissionColor(particle.Color);
            GenerateEmissionDirection(ref particle.Direction);
            GenerateEmissionVelocity(ref particle.Direction);

            // Generate simpler data
            particle.timeToLive = GenerateEmissionTTL();
        }