123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- #region File Description
- //-----------------------------------------------------------------------------
- // ParticleSettings.cs
- //
- // Microsoft XNA Community Game Platform
- // Copyright (C) Microsoft Corporation. All rights reserved.
- //-----------------------------------------------------------------------------
- #endregion
- #region Using Statements
- using System;
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework.Content;
- #endregion
- namespace Particle3DSample
- {
- /// <summary>
- /// Settings class describes all the tweakable options used
- /// to control the appearance of a particle system.
- /// </summary>
- public class ParticleSettings
- {
- // Name of the texture used by this particle system.
- public string TextureName = null;
- // Maximum number of particles that can be displayed at one time.
- public int MaxParticles = 100;
- // How long these particles will last.
- public TimeSpan Duration = TimeSpan.FromSeconds(1);
- // If greater than zero, some particles will last a shorter time than others.
- public float DurationRandomness = 0;
- // Controls how much particles are influenced by the velocity of the object
- // which created them. You can see this in action with the explosion effect,
- // where the flames continue to move in the same direction as the source
- // projectile. The projectile trail particles, on the other hand, set this
- // value very low so they are less affected by the velocity of the projectile.
- public float EmitterVelocitySensitivity = 1;
- // Range of values controlling how much X and Z axis velocity to give each
- // particle. Values for individual particles are randomly chosen from somewhere
- // between these limits.
- public float MinHorizontalVelocity = 0;
- public float MaxHorizontalVelocity = 0;
- // Range of values controlling how much Y axis velocity to give each particle.
- // Values for individual particles are randomly chosen from somewhere between
- // these limits.
- public float MinVerticalVelocity = 0;
- public float MaxVerticalVelocity = 0;
- // Direction and strength of the gravity effect. Note that this can point in any
- // direction, not just down! The fire effect points it upward to make the flames
- // rise, and the smoke plume points it sideways to simulate wind.
- public Vector3 Gravity = Vector3.Zero;
- // Controls how the particle velocity will change over their lifetime. If set
- // to 1, particles will keep going at the same speed as when they were created.
- // If set to 0, particles will come to a complete stop right before they die.
- // Values greater than 1 make the particles speed up over time.
- public float EndVelocity = 1;
- // Range of values controlling the particle color and alpha. Values for
- // individual particles are randomly chosen from somewhere between these limits.
- public Color MinColor = Color.White;
- public Color MaxColor = Color.White;
- // Range of values controlling how fast the particles rotate. Values for
- // individual particles are randomly chosen from somewhere between these
- // limits. If both these values are set to 0, the particle system will
- // automatically switch to an alternative shader technique that does not
- // support rotation, and thus requires significantly less GPU power. This
- // means if you don't need the rotation effect, you may get a performance
- // boost from leaving these values at 0.
- public float MinRotateSpeed = 0;
- public float MaxRotateSpeed = 0;
- // Range of values controlling how big the particles are when first created.
- // Values for individual particles are randomly chosen from somewhere between
- // these limits.
- public float MinStartSize = 100;
- public float MaxStartSize = 100;
- // Range of values controlling how big particles become at the end of their
- // life. Values for individual particles are randomly chosen from somewhere
- // between these limits.
- public float MinEndSize = 100;
- public float MaxEndSize = 100;
- // Alpha blending settings.
- [ContentSerializerIgnore]
- public BlendState BlendState = BlendState.NonPremultiplied;
- [ContentSerializer(ElementName = "BlendState")]
- private string BlendStateSerializationHelper
- {
- get { return BlendState.Name.Replace("BlendState.", string.Empty); }
- set
- {
- switch (value)
- {
- case "AlphaBlend": BlendState = BlendState.AlphaBlend; break;
- case "Additive": BlendState = BlendState.Additive; break;
- case "NonPremultiplied": BlendState = BlendState.NonPremultiplied; break;
- default:
- throw new ArgumentException("Unknown blend state " + value);
- }
- }
- }
- }
- }
|