VertexSkinned.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Microsoft.Xna.Framework;
  5. using Microsoft.Xna.Framework.Graphics;
  6. namespace SharpGLTF.Runtime.Template
  7. {
  8. struct VertexSkinned : IVertexType
  9. {
  10. #region static
  11. private static VertexDeclaration _VDecl = CreateVertexDeclaration();
  12. public static VertexDeclaration CreateVertexDeclaration()
  13. {
  14. int offset = 0;
  15. var a = new VertexElement(offset, VertexElementFormat.Vector3, VertexElementUsage.Position, 0);
  16. offset += 3 * 4;
  17. var b = new VertexElement(offset, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0);
  18. offset += 3 * 4;
  19. var c = new VertexElement(offset, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0);
  20. offset += 2 * 4;
  21. var d = new VertexElement(offset, VertexElementFormat.Byte4, VertexElementUsage.BlendIndices, 0);
  22. offset += 4 * 1;
  23. var e = new VertexElement(offset, VertexElementFormat.Vector4, VertexElementUsage.BlendWeight, 0);
  24. offset += 4 * 4;
  25. return new VertexDeclaration(a, b, c, d, e);
  26. }
  27. #endregion
  28. #region data
  29. public VertexDeclaration VertexDeclaration => _VDecl;
  30. public Vector3 Position;
  31. public Vector3 Normal;
  32. public Vector2 TextureCoordinate;
  33. public Microsoft.Xna.Framework.Graphics.PackedVector.Byte4 BlendIndices;
  34. public Vector4 BlendWeight;
  35. #endregion
  36. }
  37. }