Beispiel #1
0
        /// <summary>
        /// Example of how to create a Particle Initialization Function
        /// </summary>
        /// <param name="cParticle">The Particle to be Initialized</param>
        public void InitializeParticleProperties(DefaultSprite3DBillboardParticle cParticle)
        {
            //-----------------------------------------------------------
            // TODO: Initialize all of the Particle's properties here.
            // If you plan on simply using the default InitializeParticleUsingInitialProperties
            // Particle Initialization Function (see the LoadParticleSystem() function above),
            // then you may delete this function all together.
            //-----------------------------------------------------------
            // Set the Particle's Lifetime (how long it should exist for)
            cParticle.Lifetime = 0.1f;

            // Set the Particle's initial Position to be wherever the Emitter is
            cParticle.Position = Emitter.PositionData.Position;

            // Set the Particle's Velocity
            Vector3 sVelocityMin = new Vector3(-1.8f, -1.8f, -3f);
            Vector3 sVelocityMax = new Vector3(1.8f, 1.8f, -1.8f);

            cParticle.Velocity = DPSFHelper.RandomVectorBetweenTwoVectors(sVelocityMin, sVelocityMax);

            // Adjust the Particle's Velocity direction according to the Emitter's Orientation
            cParticle.Velocity = Vector3.Transform(cParticle.Velocity, Emitter.OrientationData.Orientation);

            cParticle.Velocity += velocity;
            // Give the Particle a random Size
            // Since we have Size Lerp enabled we must also set the Start and End Size
            cParticle.Width      = cParticle.StartWidth = cParticle.EndWidth = cParticle.EndHeight =
                cParticle.Height = cParticle.StartHeight = 2f * RandomNumber.NextFloat();

            // Give the Particle a random Color
            // Since we have Color Lerp enabled we must also set the Start and End Color
            cParticle.Color    = cParticle.StartColor = Color.Yellow;
            cParticle.EndColor = Color.Red;
        }
Beispiel #2
0
        /// <summary>
        /// Example of how to create a Particle Initialization Function
        /// </summary>
        /// <param name="cParticle">The Particle to be Initialized</param>
        public void InitializeParticleProperties(DefaultSprite3DBillboardParticle cParticle)
        {
            Quaternion cBackup = Emitter.OrientationData.Orientation;

            Emitter.OrientationData.Orientation = Quaternion.Identity;
            InitializeParticleUsingInitialProperties(cParticle);
            Emitter.OrientationData.Orientation = cBackup;

            cParticle.Position  = offSet;
            cParticle.Position  = Vector3.Transform(cParticle.Position, Emitter.OrientationData.Orientation);
            cParticle.Position += Emitter.PositionData.Position;

            cParticle.Velocity = Vector3.Transform(cParticle.Velocity, Emitter.OrientationData.Orientation);
            switch (type)
            {
            case 0:
                cParticle.StartColor = defaultColor[layer];
                cParticle.EndColor   = defaultEnd[layer];
                break;

            case 1:
                cParticle.StartColor = boostColor[layer];
                cParticle.EndColor   = boostFadeEnd[layer];
                break;

            default:
                cParticle.StartColor = defaultColor[layer];
                cParticle.EndColor   = defaultEnd[layer];
                break;
            }
        }
Beispiel #3
0
        public void InitializeParticlePropertiesRespawn(DefaultSprite3DBillboardParticle cParticle)
        {
            //-----------------------------------------------------------
            // TODO: Initialize all of the Particle's properties here.
            // If you plan on simply using the default InitializeParticleUsingInitialProperties
            // Particle Initialization Function (see the LoadParticleSystem() function above),
            // then you may delete this function all together.
            //-----------------------------------------------------------
            // Set the Particle's Lifetime (how long it should exist for)
            cParticle.Lifetime = 1.0f;

            // Set the Particle's initial Position to be wherever the Emitter is
            cParticle.Position = Vector3.Zero;
            cParticle.Position = Vector3.Transform(cParticle.Position, Emitter.OrientationData.Orientation);


            // Set the Particle's Velocity
            cParticle.Velocity = DPSFHelper.PointOnSphere(RandomNumber.Between(0, MathHelper.TwoPi), RandomNumber.Between(0, MathHelper.TwoPi), radius);

            // Adjust the Particle's Velocity direction according to the Emitter's Orientation
            cParticle.Velocity  = Vector3.Transform(cParticle.Velocity, Emitter.OrientationData.Orientation);
            cParticle.Position += Emitter.PositionData.Position;


            // Give the Particle a random Size
            // Since we have Size Lerp enabled we must also set the Start and End Size
            cParticle.Width      = cParticle.StartWidth = cParticle.EndWidth = cParticle.EndHeight =
                cParticle.Height = cParticle.StartHeight = size;

            // Give the Particle a random Color
            // Since we have Color Lerp enabled we must also set the Start and End Color
            cParticle.Color    = cParticle.StartColor = Color.White;
            cParticle.EndColor = Color.Blue;
        }
Beispiel #4
0
        public void RemoveRecent()
        {
            DefaultSprite3DBillboardParticle cparticle = ActiveParticles.Last.Value;

            ActiveParticles.RemoveLast();
            ActiveParticles.RemoveLast();
            ActiveParticles.AddLast(cparticle);
        }
 //===========================================================
 // Particle Update Functions
 //===========================================================
 protected void UpdateParticleDieOnceGroundIsHit(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
 {
     // If the Particle hits the ground
     if (cParticle.Position.Y < -5)
     {
         // Kill it
         cParticle.Lifetime = 1.0f;
     }
 }
 protected void UpdateParticleChangeVelocityAndRotation(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
 {
     if (RandomNumber.Next(0, 100) == 50)
     {
         Vector3 sChange = new Vector3(RandomNumber.Next(-3, 3), RandomNumber.Next(-3, 3), RandomNumber.Next(-3, 3));
         cParticle.Velocity           += sChange;
         cParticle.RotationalVelocity += RandomNumber.Between(-MathHelper.PiOver4, MathHelper.PiOver4);
     }
 }
Beispiel #7
0
        public void InitializeParticleSpiral(DefaultSprite3DBillboardParticle cParticle)
        {
            InitializeParticleUsingInitialProperties(cParticle);

            // Have the new particles' velocities form a circle pattern around position (0, 50, 0)
            mfAngle += 0.1f;
            Vector3 sDirection = DPSFHelper.PointOnSphere(-MathHelper.PiOver2, mfAngle, 70, new Vector3(0, 50, 0));
            cParticle.Velocity = sDirection - cParticle.Position;
        }
 //===========================================================
 // Particle Update Functions
 //===========================================================
 protected void UpdateParticleDieOnceGroundIsHit(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
 {
     // If the Particle hits the ground
     if (cParticle.Position.Y < -5)
     {
         // Kill it
         cParticle.Lifetime = 1.0f;
     }
 }
        public void InitializeParticleChangeColor(DefaultSprite3DBillboardParticle cParticle)
		{
			cParticle.Lifetime = (float)(4.0f);

			cParticle.Position = Emitter.PositionData.Position;
			cParticle.Position += new Vector3(-100, RandomNumber.Next(0, 100), RandomNumber.Next(-50, 50));
			cParticle.Size = RandomNumber.Next(5, 20);
			cParticle.Color = Color.Red;

			cParticle.Velocity = new Vector3(50, 0, 0);
			cParticle.Acceleration = Vector3.Zero;
		}
Beispiel #10
0
		public void InitializeParticleFigure8(DefaultSprite3DBillboardParticle cParticle)
		{
			cParticle.Lifetime = 4.0f;

			cParticle.Position = Emitter.PositionData.Position;
			cParticle.Position += new Vector3(0, 100, 0);
			cParticle.Size = 10.0f;
			cParticle.Color = Color.Red;

			cParticle.Velocity = new Vector3(0, 0, 0);
			cParticle.Acceleration = Vector3.Zero;
		}
Beispiel #11
0
        public void InitializeParticleStar2D(DefaultSprite3DBillboardParticle cParticle)
        {
            InitializeParticleUsingInitialProperties(cParticle);

            // Add 7 more Particles, going in different 2D directions
            DefaultSprite3DBillboardParticle cParticle2 = new DefaultSprite3DBillboardParticle();
            DefaultSprite3DBillboardParticle cParticle3 = new DefaultSprite3DBillboardParticle();
            DefaultSprite3DBillboardParticle cParticle4 = new DefaultSprite3DBillboardParticle();
            DefaultSprite3DBillboardParticle cParticle5 = new DefaultSprite3DBillboardParticle();
            DefaultSprite3DBillboardParticle cParticle6 = new DefaultSprite3DBillboardParticle();
            DefaultSprite3DBillboardParticle cParticle7 = new DefaultSprite3DBillboardParticle();
            DefaultSprite3DBillboardParticle cParticle8 = new DefaultSprite3DBillboardParticle();

            cParticle2.CopyFrom(cParticle);
            cParticle3.CopyFrom(cParticle);
            cParticle4.CopyFrom(cParticle);
            cParticle5.CopyFrom(cParticle);
            cParticle6.CopyFrom(cParticle);
            cParticle7.CopyFrom(cParticle);
            cParticle8.CopyFrom(cParticle);

            cParticle2.Velocity = new Vector3(50, 50, 0);
            cParticle3.Velocity = new Vector3(100, 0, 0);
            cParticle4.Velocity = new Vector3(50, -50, 0);
            cParticle5.Velocity = new Vector3(0, -100, 0);
            cParticle6.Velocity = new Vector3(-50, -50, 0);
            cParticle7.Velocity = new Vector3(-100, 0, 0);
            cParticle8.Velocity = new Vector3(-50, 50, 0);

            cParticle2.Velocity = Vector3.Transform(cParticle2.Velocity, Emitter.OrientationData.Orientation);
            cParticle3.Velocity = Vector3.Transform(cParticle3.Velocity, Emitter.OrientationData.Orientation);
            cParticle4.Velocity = Vector3.Transform(cParticle4.Velocity, Emitter.OrientationData.Orientation);
            cParticle5.Velocity = Vector3.Transform(cParticle5.Velocity, Emitter.OrientationData.Orientation);
            cParticle6.Velocity = Vector3.Transform(cParticle6.Velocity, Emitter.OrientationData.Orientation);
            cParticle7.Velocity = Vector3.Transform(cParticle7.Velocity, Emitter.OrientationData.Orientation);
            cParticle8.Velocity = Vector3.Transform(cParticle8.Velocity, Emitter.OrientationData.Orientation);

            // If the axis should be distinguishable
            if (mbHighlightAxis)
            {
                cParticle.Color = Color.Green;
                cParticle3.Color = Color.Red;
            }

            AddParticle(cParticle2);
            AddParticle(cParticle3);
            AddParticle(cParticle4);
            AddParticle(cParticle5);
            AddParticle(cParticle6);
            AddParticle(cParticle7);
            AddParticle(cParticle8);
        }
		public void InitializeParticleSquarePattern(DefaultSprite3DBillboardParticle cParticle)
		{
			cParticle.Lifetime = (float)(5.0f);

			cParticle.Position = Emitter.PositionData.Position;
			cParticle.Position += new Vector3(RandomNumber.Next(-50, 50), RandomNumber.Next(-50, 50), RandomNumber.Next(-50, 50));
			cParticle.Size = RandomNumber.Next(5, 20);
			cParticle.Color = new Color(0, RandomNumber.NextFloat(), 0);

			// Move Right
			cParticle.Velocity = new Vector3(50, 0, 0);
			cParticle.Acceleration = Vector3.Zero;
		}
        protected void AttractParticleToExternalObject(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
        {
            // Calculate Direction towards the Object and how far the Particle is from the Object
            Vector3 sDirectionTowardsObject = mcExternalObjectPosition - cParticle.Position;
            float   fDistance = sDirectionTowardsObject.Length();

            // If the Particle is close enough to the Object to be affected by it
            if (fDistance < mfAttractRepelRange)
            {
                // Attract the Particle to the Object
                sDirectionTowardsObject.Normalize();
                cParticle.Velocity = sDirectionTowardsObject * (mfAttractRepelRange - fDistance) * mfAttractRepelForce;
            }
        }
Beispiel #14
0
        public void InitializeParticleSmokeTrail(DefaultSprite3DBillboardParticle cParticle)
        {
            cParticle.Lifetime = RandomNumber.Between(1.0f, 7.0f);

            cParticle.Position = Emitter.PositionData.Position;
            cParticle.Size = 5;
            cParticle.Color = smokeColors[currentColor];
            cParticle.Rotation = RandomNumber.Between(0, MathHelper.TwoPi);

            cParticle.Velocity = new Vector3(0, 0, 0);
            cParticle.Acceleration = Vector3.Zero;
            cParticle.RotationalVelocity = RandomNumber.Between(-MathHelper.Pi, MathHelper.Pi);

            cParticle.StartSize = cParticle.Size;
        }
        protected void RepelParticleFromExternalObject(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
        {
            // Calculate Direction away from the Object and how far the Particle is from the Object
            Vector3 sDirectionAwayFromObject = cParticle.Position - mcExternalObjectPosition;
            float   fDistance = sDirectionAwayFromObject.Length();

            // If the Particle is close enough to the Object to be affected by it
            if (fDistance < mfAttractRepelRange)
            {
                // Repel the Particle from the Object
                sDirectionAwayFromObject.Normalize();
                cParticle.Velocity           += sDirectionAwayFromObject * (mfAttractRepelRange - fDistance) * mfAttractRepelForce;
                cParticle.RotationalVelocity += 0.005f;
            }
        }
        // Used to generate random smoke particles around the floor
        public void InitializeParticleFoggySmoke(DefaultSprite3DBillboardParticle cParticle)
        {
            cParticle.Lifetime = RandomNumber.Between(1.0f, 3.0f);

            cParticle.Position  = Emitter.PositionData.Position;
            cParticle.Position += new Vector3(RandomNumber.Next(-500, 500), 0, RandomNumber.Next(-500, 500));
            cParticle.Size      = RandomNumber.Next(10, 25);
            cParticle.Color     = msaColors[miCurrentColor];
            cParticle.Rotation  = RandomNumber.Between(0, MathHelper.TwoPi);

            cParticle.Velocity           = new Vector3(RandomNumber.Next(-30, 30), RandomNumber.Next(0, 10), RandomNumber.Next(-30, 30));
            cParticle.Acceleration       = Vector3.Zero;
            cParticle.RotationalVelocity = RandomNumber.Between(-MathHelper.Pi, MathHelper.Pi);

            cParticle.StartSize = cParticle.Size;

            mfColorBlendAmount = 0.5f;
        }
        // Used to generate random smoke particles around the floor
        public void InitializeParticleFoggySmoke(DefaultSprite3DBillboardParticle cParticle)
        {
            cParticle.Lifetime = RandomNumber.Between(1.0f, 3.0f);

            cParticle.Position = Emitter.PositionData.Position;
            cParticle.Position += new Vector3(RandomNumber.Next(-500, 500), 0, RandomNumber.Next(-500, 500));
            cParticle.Size = RandomNumber.Next(10, 25);
            cParticle.Color = msaColors[miCurrentColor];
            cParticle.Rotation = RandomNumber.Between(0, MathHelper.TwoPi);

            cParticle.Velocity = new Vector3(RandomNumber.Next(-30, 30), RandomNumber.Next(0, 10), RandomNumber.Next(-30, 30));
            cParticle.Acceleration = Vector3.Zero;
            cParticle.RotationalVelocity = RandomNumber.Between(-MathHelper.Pi, MathHelper.Pi);

            cParticle.StartSize = cParticle.Size;

            mfColorBlendAmount = 0.5f;
        }
        public void InitializeParticleSnow(DefaultSprite3DBillboardParticle cParticle)
        {
            // Position the Snow within 500 units of the emitter
            Vector3 sPosition = Emitter.PositionData.Position;
            sPosition.Y = RandomNumber.Next(-500, 500);
            sPosition.X += RandomNumber.Next(-500, 500);
            sPosition.Z += RandomNumber.Next(-50, 50);

            cParticle.Lifetime = 0.0f;

            cParticle.Position = sPosition;
            cParticle.Size = RandomNumber.Next(2, 5);
            cParticle.Color = DPSFHelper.LerpColor(new Color(255, 255, 255, 50), new Color(255, 255, 255, 255), RandomNumber.NextFloat());
            cParticle.Rotation = RandomNumber.Between(0, MathHelper.TwoPi);

            cParticle.Velocity = new Vector3(RandomNumber.Next(-10, 3), RandomNumber.Next(-15, -5), RandomNumber.Next(-10, 10));
            cParticle.Acceleration = Vector3.Zero;
            cParticle.RotationalVelocity = RandomNumber.Between(-MathHelper.PiOver2, MathHelper.PiOver2);
        }
        public void InitializeParticleSnow(DefaultSprite3DBillboardParticle cParticle)
        {
            // Position the Snow within 500 units of the emitter
            Vector3 sPosition = Emitter.PositionData.Position;

            sPosition.Y  = 200;
            sPosition.X += RandomNumber.Next(-500, 500);
            sPosition.Z += RandomNumber.Next(-500, 500);

            cParticle.Lifetime = 0.0f;

            cParticle.Position = sPosition;
            cParticle.Size     = RandomNumber.Next(2, 5);
            cParticle.Color    = DPSFHelper.LerpColor(new Color(255, 255, 255, 50), new Color(255, 255, 255, 255), RandomNumber.NextFloat());
            cParticle.Rotation = RandomNumber.Between(0, MathHelper.TwoPi);

            cParticle.Velocity           = new Vector3(RandomNumber.Next(-10, 3), RandomNumber.Next(-15, -5), RandomNumber.Next(-10, 10));
            cParticle.Acceleration       = Vector3.Zero;
            cParticle.RotationalVelocity = RandomNumber.Between(-MathHelper.PiOver2, MathHelper.PiOver2);
        }
 protected void UpdateParticleAddWindForce(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
 {
     cParticle.ExternalForce = Vector3.Lerp(Vector3.Zero, mcMaxWindForce, RandomNumber.Between(0.1f, 1.0f));
 }
        protected void UpdateParticleChangeDirection3(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
		{
			// Move Down
			cParticle.Velocity = new Vector3(0, -50, 0);
		}
 protected void UpdateColor(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
 {
     cParticle.Color = msaColors[miCurrentColor];
 }
        protected void RepelParticleFromExternalObject(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
        {
            // Calculate Direction away from the Object and how far the Particle is from the Object
            Vector3 sDirectionAwayFromObject = cParticle.Position - mcExternalObjectPosition;
            float fDistance = sDirectionAwayFromObject.Length();

            // If the Particle is close enough to the Object to be affected by it
            if (fDistance < mfAttractRepelRange)
            {
                // Repel the Particle from the Object
                sDirectionAwayFromObject.Normalize();
                cParticle.Velocity += sDirectionAwayFromObject * (mfAttractRepelRange - fDistance) * mfAttractRepelForce;
                cParticle.RotationalVelocity += 0.005f;
            }
        }
 //===========================================================
 // Particle Update Functions
 //===========================================================
 protected void IncreaseSizeBasedOnLifetime(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
 {
     cParticle.Size = ((1.0f + cParticle.NormalizedElapsedTime) / 1.0f) * cParticle.StartSize;
 }
Beispiel #25
0
        protected void GenerateSmokeParticle(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
        {
            // If the Smoke Particle System is initialized
            if (mcSmokeParticleSystem != null && mcSmokeParticleSystem.IsInitialized)
            {
                // Only create a Smoke Particles some of the time
                if (RandomNumber.NextFloat() < mfAmountOfSmokeToRelease)
                {
                    // Create a new Smoke Particle at the same Position as this Fire Particle
                    DefaultSprite3DBillboardParticle cSmokeParticle = new DefaultSprite3DBillboardParticle();
                    mcSmokeParticleSystem.InitializeParticle(cSmokeParticle);
                    cSmokeParticle.Position = cParticle.Position;

                    // Add the Particle to the Smoke Particle System
                    mcSmokeParticleSystem.AddParticle(cSmokeParticle);
                }
            }
        }
Beispiel #26
0
        public void InitializeParticleFireOnHorizontalRing(DefaultSprite3DBillboardParticle cParticle)
        {
            Quaternion cBackup = Emitter.OrientationData.Orientation;
            Emitter.OrientationData.Orientation = Quaternion.Identity;
            InitializeParticleUsingInitialProperties(cParticle);
            Emitter.OrientationData.Orientation = cBackup;

            cParticle.Position = DPSFHelper.PointOnSphere(RandomNumber.Between(0, MathHelper.TwoPi), 0, 100);
            cParticle.Position = Vector3.Transform(cParticle.Position, Emitter.OrientationData.Orientation);
            cParticle.Position += Emitter.PositionData.Position;
        }
 protected void UpdateParticleRemoveWindForce(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
 {
     cParticle.ExternalForce = Vector3.Zero;
 }
		//===========================================================
		// Particle Update Functions
		//===========================================================

        protected void UpdateParticleChangeParticleColor(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
		{
			// Assign this Particle a new Random Color
			cParticle.Color = DPSFHelper.RandomColor();
		}
        /// <summary>
        /// Example of how to create a Particle Initialization Function
        /// </summary>
        /// <param name="cParticle">The Particle to be Initialized</param>
        public void InitializeParticleProperties(DefaultSprite3DBillboardParticle cParticle)
        {
            Quaternion cBackup = Emitter.OrientationData.Orientation;
            Emitter.OrientationData.Orientation = Quaternion.Identity;
            InitializeParticleUsingInitialProperties(cParticle);
            Emitter.OrientationData.Orientation = cBackup;

            cParticle.Position =offSet;
            cParticle.Position = Vector3.Transform(cParticle.Position, Emitter.OrientationData.Orientation);
            cParticle.Position += Emitter.PositionData.Position;

            cParticle.Velocity = Vector3.Transform(cParticle.Velocity, Emitter.OrientationData.Orientation);
            switch (type)
            {
                case 0:
                    cParticle.StartColor = defaultColor[layer];
                    cParticle.EndColor = defaultEnd[layer];
                    break;
                case 1:
                    cParticle.StartColor = boostColor[layer];
                    cParticle.EndColor = boostFadeEnd[layer];
                    break;
                default:
                    cParticle.StartColor = defaultColor[layer];
                    cParticle.EndColor = defaultEnd[layer];
                    break;
            }
        }
        public void InitializeParticlePropertiesRespawn(DefaultSprite3DBillboardParticle cParticle)
        {
            //-----------------------------------------------------------
            // TODO: Initialize all of the Particle's properties here.
            // If you plan on simply using the default InitializeParticleUsingInitialProperties
            // Particle Initialization Function (see the LoadParticleSystem() function above), 
            // then you may delete this function all together.
            //-----------------------------------------------------------
            // Set the Particle's Lifetime (how long it should exist for)
            cParticle.Lifetime = 1.0f;

            // Set the Particle's initial Position to be wherever the Emitter is
            cParticle.Position = Vector3.Zero; 
            cParticle.Position = Vector3.Transform(cParticle.Position, Emitter.OrientationData.Orientation);


            // Set the Particle's Velocity
            cParticle.Velocity = DPSFHelper.PointOnSphere(RandomNumber.Between(0, MathHelper.TwoPi), RandomNumber.Between(0, MathHelper.TwoPi), radius);

            // Adjust the Particle's Velocity direction according to the Emitter's Orientation
            cParticle.Velocity = Vector3.Transform(cParticle.Velocity, Emitter.OrientationData.Orientation);
            cParticle.Position += Emitter.PositionData.Position;


            // Give the Particle a random Size
            // Since we have Size Lerp enabled we must also set the Start and End Size
            cParticle.Width = cParticle.StartWidth = cParticle.EndWidth = cParticle.EndHeight =
                cParticle.Height = cParticle.StartHeight = size;

            // Give the Particle a random Color
            // Since we have Color Lerp enabled we must also set the Start and End Color
            cParticle.Color = cParticle.StartColor = Color.White;
            cParticle.EndColor = Color.Blue;
        }
        protected void UpdateParticleChangeColor3(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
		{
			cParticle.Color = Color.Blue;
		}
        //===========================================================
        // Particle Update Functions
        //===========================================================

        /// <summary>
        /// Randomly changes the direction of the particle
        /// </summary>
        /// <param name="cParticle">The Particle to update</param>
        /// <param name="fElapsedTimeInSeconds">How long it has been since the last update</param>
        protected void UpdateParticleVelocityRandomly(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
        {
            cParticle.Velocity = DPSFHelper.RandomNormalizedVector() * mfParticleSpeed;
        }
        /// <summary>
        /// Example of how to create a Particle Initialization Function
        /// </summary>
        /// <param name="cParticle">The Particle to be Initialized</param>
        public void InitializeParticleProperties(DefaultSprite3DBillboardParticle cParticle)
        {
            //-----------------------------------------------------------
            // TODO: Initialize all of the Particle's properties here.
            // If you plan on simply using the default InitializeParticleUsingInitialProperties
            // Particle Initialization Function (see the LoadParticleSystem() function above), 
            // then you may delete this function all together.
            //-----------------------------------------------------------
            // Set the Particle's Lifetime (how long it should exist for)
            cParticle.Lifetime = 0.1f;

            // Set the Particle's initial Position to be wherever the Emitter is
            cParticle.Position = Emitter.PositionData.Position;

            // Set the Particle's Velocity
            Vector3 sVelocityMin = new Vector3(-1.8f, -1.8f, -3f);
            Vector3 sVelocityMax = new Vector3(1.8f, 1.8f, -1.8f);
            cParticle.Velocity = DPSFHelper.RandomVectorBetweenTwoVectors(sVelocityMin, sVelocityMax);
            
            // Adjust the Particle's Velocity direction according to the Emitter's Orientation
            cParticle.Velocity = Vector3.Transform(cParticle.Velocity, Emitter.OrientationData.Orientation);

            cParticle.Velocity += velocity;
            // Give the Particle a random Size
            // Since we have Size Lerp enabled we must also set the Start and End Size
            cParticle.Width = cParticle.StartWidth = cParticle.EndWidth = cParticle.EndHeight =
                cParticle.Height = cParticle.StartHeight = 2f * RandomNumber.NextFloat();

            // Give the Particle a random Color
            // Since we have Color Lerp enabled we must also set the Start and End Color
            cParticle.Color = cParticle.StartColor = Color.Yellow;
            cParticle.EndColor = Color.Red;
        }
Beispiel #34
0
            // Used to generate smoke coming off the ring of fire
            public void InitializeSmokeRingParticle(DefaultSprite3DBillboardParticle cParticle)
            {
                cParticle.Lifetime = RandomNumber.Between(1.0f, 5.0f);

                cParticle.Position = new Vector3(0, 10, 0);
                cParticle.StartSize = RandomNumber.Next(10, 40);
                cParticle.EndSize = RandomNumber.Next(20, 60);
                cParticle.Size = cParticle.StartSize;
                cParticle.Color = Color.White; //Color.Gray;
                cParticle.Rotation = RandomNumber.Between(0, MathHelper.TwoPi);

                cParticle.Velocity = new Vector3(RandomNumber.Next(0, 30), RandomNumber.Next(10, 30), RandomNumber.Next(-20, 10));
                cParticle.Acceleration = Vector3.Zero;
                cParticle.RotationalVelocity = RandomNumber.Between(-MathHelper.Pi, MathHelper.Pi);
            }
 protected void UpdateColor(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
 {
     cParticle.Color = msaColors[miCurrentColor];
 }
        /// <summary>
        /// Example of how to create a Particle Initialization Function
        /// </summary>
        /// <param name="cParticle">The Particle to be Initialized</param>
        public void InitializeParticleSimple(DefaultSprite3DBillboardParticle cParticle)
        {
            cParticle.Lifetime = 1.0f;

            // Set the Particle's initial Position to be wherever the Emitter is
            cParticle.Position = Emitter.PositionData.Position;

            // Set the Particle's Velocity
            cParticle.Velocity = new Vector3(0, mfParticleSpeed, 0);

            // Adjust the Particle's Velocity direction according to the Emitter's Orientation
            cParticle.Velocity = Vector3.Transform(cParticle.Velocity, Emitter.OrientationData.Orientation);

            // Give the Particle a random Size
            // Since we have Size Lerp enabled we must also set the Start and End Size
            cParticle.Size = cParticle.StartSize = cParticle.EndSize = 25;

            // Give the Particle a random Color
            // Since we have Color Lerp enabled we must also set the Start and End Color
            cParticle.Color = cParticle.StartColor = cParticle.EndColor = Color.Red;
        }
        protected void AttractParticleToExternalObject(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
        {
            // Calculate Direction towards the Object and how far the Particle is from the Object
            Vector3 sDirectionTowardsObject = mcExternalObjectPosition - cParticle.Position;
            float fDistance = sDirectionTowardsObject.Length();

            // If the Particle is close enough to the Object to be affected by it
            if (fDistance < mfAttractRepelRange)
            {
                // Attract the Particle to the Object
                sDirectionTowardsObject.Normalize();
                cParticle.Velocity = sDirectionTowardsObject * (mfAttractRepelRange - fDistance) * mfAttractRepelForce;
            }
        }
 protected void UpdateParticleRemoveWindForce(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
 {
     cParticle.ExternalForce = Vector3.Zero;
 }
 //===========================================================
 // Particle Update Functions
 //===========================================================
 protected void IncreaseSizeBasedOnLifetime(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
 {
     cParticle.Size = ((1.0f + cParticle.NormalizedElapsedTime) / 1.0f) * cParticle.StartSize;
 }
 protected void UpdateParticleToChange(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
 {
     cParticle.Velocity = DPSFHelper.RandomNormalizedVector() * mfParticleSpeed;
     cParticle.Color = DPSFHelper.RandomColor();
     cParticle.Size = RandomNumber.Next(10, 40);
     cParticle.RotationalVelocity = RandomNumber.Between(-MathHelper.Pi, MathHelper.Pi);
 }
        //===========================================================
        // Particle Update Functions
        //===========================================================
        protected void UpdateParticleBounceOffFloor(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
        {
            // If the Particle has hit the floor and is still travelling downwards
            if (cParticle.Position.Y <= 0 && cParticle.Velocity.Y < 0)
            {
                // Make the Particle Bounce upwards
                cParticle.Velocity.Y *= -mfBounciness;

                // Reduce the Particles X and Z speed
                cParticle.Velocity.X *= 0.8f;
                cParticle.Velocity.Z *= 0.8f;

                // Reduce the Particles Rotation speed
                cParticle.RotationalVelocity *= 0.8f;
            }
        }
 protected void UpdateParticleChangeVelocityAndRotation(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
 {
     if (RandomNumber.Next(0, 100) == 50)
     {
         Vector3 sChange = new Vector3(RandomNumber.Next(-3, 3), RandomNumber.Next(-3, 3), RandomNumber.Next(-3, 3));
         cParticle.Velocity += sChange;
         cParticle.RotationalVelocity += RandomNumber.Between(-MathHelper.PiOver4, MathHelper.PiOver4);
     }
 }
 protected void UpdateParticleAddWindForce(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
 {
     cParticle.ExternalForce = Vector3.Lerp(Vector3.Zero, mcMaxWindForce, RandomNumber.Between(0.1f, 1.0f));
 }
Beispiel #44
0
		//===========================================================
		// Particle Update Functions
		//===========================================================
		protected void UpdatedPositionOnFigure8(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)
		{
			float fRadius = 25;
			float fHeight1 = 75;
			float fHeight2 = 25;

			Vector3 sPosition = new Vector3();

			// If the Particle is on the first loop
			if (cParticle.NormalizedElapsedTime < 0.5f)
			{
				// Calculate the angle on the circle that the particle should be at
				float fAngle = (cParticle.NormalizedElapsedTime * 2 * MathHelper.TwoPi) - MathHelper.PiOver2;

				// Calculate where on the loop the Particle should be
				sPosition = DPSFHelper.PointOnSphere(-MathHelper.PiOver2, fAngle, fRadius) + new Vector3(0, fHeight1, 0);
			}
			// Else it is on the second loop
			else
			{
				// Calculate the angle on the circle that the particle should be at
				float fAngle = MathHelper.TwoPi - (((cParticle.NormalizedElapsedTime - 0.5f) * 2 * MathHelper.TwoPi) - MathHelper.PiOver2);

				// Calculate where on the loop the Particle should be
				sPosition = DPSFHelper.PointOnSphere(-MathHelper.PiOver2, fAngle, fRadius) + new Vector3(0, fHeight2, 0);
			}

			// Set the new Position of the Particle
			cParticle.Position = sPosition;
		}