ParticleSystemSettings.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // ParticleSystemSettings.cs
  4. //
  5. // Microsoft XNA Community Game Platform
  6. // Copyright (C) Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #endregion
  9. #region Using Statements
  10. using Microsoft.Xna.Framework;
  11. using Microsoft.Xna.Framework.Content;
  12. using Microsoft.Xna.Framework.Graphics;
  13. #endregion
  14. namespace ParticlesSettings
  15. {
  16. /// <summary>
  17. /// Used to specify the method of acceleration for a particle system.
  18. /// </summary>
  19. public enum AccelerationMode
  20. {
  21. /// <summary>
  22. /// The particle system does not use acceleration.
  23. /// </summary>
  24. None,
  25. /// <summary>
  26. /// The particle system computes the acceleration by using the
  27. /// MinAccelerationScale and MaxAccelerationScale values to compute a random
  28. /// scalar value which is then multiplied by the direction of the particles.
  29. /// </summary>
  30. Scalar,
  31. /// <summary>
  32. /// The particle system computes the acceleration by using the EndVelocity
  33. /// value and solving the equation vt = v0 + (a0 * t) for a0. See
  34. /// ParticleSystem.cs for more details.
  35. /// </summary>
  36. EndVelocity,
  37. /// <summary>
  38. /// The particle system computes the acceleration by using the
  39. /// MinAccelerationVector and MaxAccelerationVector values to compute a random
  40. /// vector value which is used as the acceleration of the particles.
  41. /// </summary>
  42. Vector
  43. }
  44. /// <summary>
  45. /// Settings class describes all the tweakable options used
  46. /// to control the appearance of a particle system. Many of the
  47. /// settings are marked with an attribute that makes them optional
  48. /// so that XML files can be simpler if they wish to use the default
  49. /// values.
  50. /// </summary>
  51. public class ParticleSystemSettings
  52. {
  53. // Sets the range of particles used for each "effect" when the particle system
  54. // is used.
  55. public int MinNumParticles;
  56. public int MaxNumParticles;
  57. // Name of the texture used by this particle system.
  58. public string TextureFilename = null;
  59. // MinDirectionAngle and MaxDirectionAngle are used to control the possible
  60. // directions of motion for the particles. We use degrees instead of radians
  61. // for the settings to make it easier to construct the XML. The ParticleSystem
  62. // will convert these to radians as it needs.
  63. [ContentSerializer(Optional = true)]
  64. public float MinDirectionAngle = 0;
  65. [ContentSerializer(Optional = true)]
  66. public float MaxDirectionAngle = 360;
  67. // MinInitialSpeed and MaxInitialSpeed are used to control the initial speed
  68. // of the particles.
  69. public float MinInitialSpeed;
  70. public float MaxInitialSpeed;
  71. // Sets the mode for computing the acceleration of the particles.
  72. public AccelerationMode AccelerationMode = AccelerationMode.None;
  73. // Controls how the particle velocity will change over their lifetime. If set
  74. // to 1, particles will keep going at the same speed as when they were created.
  75. // If set to 0, particles will come to a complete stop right before they die.
  76. // Values greater than 1 make the particles speed up over time. This field is
  77. // used when using the AccelerationMode.EndVelocity mode.
  78. [ContentSerializer(Optional = true)]
  79. public float EndVelocity = 1f;
  80. // Controls the minimum and maximum acceleration for the particle when using the
  81. // AccelerationMode.Scalar mode.
  82. [ContentSerializer(Optional = true)]
  83. public float MinAccelerationScale = 0;
  84. [ContentSerializer(Optional = true)]
  85. public float MaxAccelerationScale = 0;
  86. // Controls the minimum and maximum acceleration for the particle when using the
  87. // AccelerationMode.Vector mode.
  88. [ContentSerializer(Optional = true)]
  89. public Vector2 MinAccelerationVector = Vector2.Zero;
  90. [ContentSerializer(Optional = true)]
  91. public Vector2 MaxAccelerationVector = Vector2.Zero;
  92. // Controls how much particles are influenced by the velocity of the object
  93. // which created them. AddParticles takes in a Vector2 which is the base velocity
  94. // for the particles being created. That velocity is first multiplied by this
  95. // EmitterVelocitySensitivity to determine how much the particles are actually
  96. // affected by that velocity.
  97. [ContentSerializer(Optional = true)]
  98. public float EmitterVelocitySensitivity = 0;
  99. // Range of values controlling how fast the particles rotate. Again, these
  100. // values should be in degrees for easier XML authoring.
  101. [ContentSerializer(Optional = true)]
  102. public float MinRotationSpeed = 0;
  103. [ContentSerializer(Optional = true)]
  104. public float MaxRotationSpeed = 0;
  105. // Range of values controlling how long a particle will last.
  106. public float MinLifetime;
  107. public float MaxLifetime;
  108. // Range of values controlling how big the particles are
  109. [ContentSerializer(Optional = true)]
  110. public float MinSize = 1;
  111. [ContentSerializer(Optional = true)]
  112. public float MaxSize = 1;
  113. // Controls the gravity applied to the particles. This can pull particles down
  114. // to simulate gravity, up for effects like smoke, or any other direction.
  115. [ContentSerializer(Optional = true)]
  116. public Vector2 Gravity = Vector2.Zero;
  117. // Alpha blending settings. Our default gives us a BlendState equivalent to
  118. // BlendState.AlphaBlend which is suitable for many particle effects.
  119. [ContentSerializer(Optional = true)]
  120. public Blend SourceBlend = Blend.One;
  121. [ContentSerializer(Optional = true)]
  122. public Blend DestinationBlend = Blend.InverseSourceAlpha;
  123. }
  124. }