2
0

CustomVertex.cs 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // CustomVertex.cs
  4. //
  5. // Microsoft XNA Community Game Platform
  6. // Copyright (C) Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #endregion
  9. using Microsoft.Xna.Framework;
  10. using Microsoft.Xna.Framework.Content;
  11. using Microsoft.Xna.Framework.Graphics;
  12. namespace CustomVertex
  13. {
  14. //[StructLayout(LayoutKind.Sequential)]
  15. public struct CustomVertex1 : IVertexType
  16. {
  17. Vector3 vertexPosition;
  18. Vector2 vertexTextureCoordinate;
  19. public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration
  20. (
  21. new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
  22. new VertexElement(12, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0)
  23. );
  24. //The constructor for the custom vertex. This allows similar
  25. //initialization of custom vertex arrays as compared to arrays of a
  26. //standard vertex type, such as VertexPositionColor.
  27. public CustomVertex1(Vector3 pos, Vector2 textureCoordinate)
  28. {
  29. vertexPosition = pos;
  30. vertexTextureCoordinate = textureCoordinate;
  31. }
  32. //Public methods for accessing the components of the custom vertex.
  33. public Vector3 Position
  34. {
  35. get { return vertexPosition; }
  36. set { vertexPosition = value; }
  37. }
  38. public Vector2 TextureCoordinate
  39. {
  40. get { return vertexTextureCoordinate; }
  41. set { vertexTextureCoordinate = value; }
  42. }
  43. VertexDeclaration IVertexType.VertexDeclaration
  44. {
  45. get { return VertexDeclaration; }
  46. }
  47. }
  48. }