ParticleVertex.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //-----------------------------------------------------------------------------
  2. // ParticleVertex.cs
  3. //
  4. // Microsoft XNA Community Game Platform
  5. // Copyright (C) Microsoft Corporation. All rights reserved.
  6. //-----------------------------------------------------------------------------
  7. using Microsoft.Xna.Framework;
  8. using Microsoft.Xna.Framework.Graphics;
  9. using Microsoft.Xna.Framework.Graphics.PackedVector;
  10. namespace Particle3DSample
  11. {
  12. /// <summary>
  13. /// Custom vertex structure for drawing particles.
  14. /// </summary>
  15. struct ParticleVertex
  16. {
  17. // Stores which corner of the particle quad this vertex represents.
  18. public Short2 Corner;
  19. // Stores the starting position of the particle.
  20. public Vector3 Position;
  21. // Stores the starting velocity of the particle.
  22. public Vector3 Velocity;
  23. // Four random values, used to make each particle look slightly different.
  24. public Color Random;
  25. // The time (in seconds) at which this particle was created.
  26. public float Time;
  27. // Describe the layout of this vertex structure.
  28. public static readonly VertexDeclaration VertexDeclaration = new VertexDeclaration
  29. (
  30. new VertexElement (0, VertexElementFormat.Short2,
  31. VertexElementUsage.Position, 0),
  32. new VertexElement (4, VertexElementFormat.Vector3,
  33. VertexElementUsage.Position, 1),
  34. new VertexElement (16, VertexElementFormat.Vector3,
  35. VertexElementUsage.Normal, 0),
  36. new VertexElement (28, VertexElementFormat.Color,
  37. VertexElementUsage.Color, 0),
  38. new VertexElement (32, VertexElementFormat.Single,
  39. VertexElementUsage.TextureCoordinate, 0)
  40. );
  41. // Describe the size of this vertex structure.
  42. public const int SizeInBytes = 36;
  43. }
  44. }