VertexWithFeatureId.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics.CodeAnalysis;
  4. using System.Numerics;
  5. using SharpGLTF.Geometry.VertexTypes;
  6. using SharpGLTF.Memory;
  7. using SharpGLTF.Schema2;
  8. namespace SharpGLTF
  9. {
  10. [System.Diagnostics.DebuggerDisplay("𝐂:{Color} 𝐔𝐕:{TexCoord}")]
  11. public struct VertexWithFeatureId : IVertexCustom
  12. {
  13. public static implicit operator VertexWithFeatureId(float batchId)
  14. {
  15. return new VertexWithFeatureId(batchId);
  16. }
  17. public VertexWithFeatureId(float batchId)
  18. {
  19. BatchId = batchId;
  20. }
  21. public const string CUSTOMATTRIBUTENAME = "_FEATURE_ID_0";
  22. public float BatchId;
  23. IEnumerable<KeyValuePair<string, AttributeFormat>> IVertexReflection.GetEncodingAttributes()
  24. {
  25. yield return new KeyValuePair<string, AttributeFormat>(CUSTOMATTRIBUTENAME, new AttributeFormat(DimensionType.SCALAR));
  26. }
  27. public int MaxColors => 0;
  28. public int MaxTextCoords => 0;
  29. public IEnumerable<string> CustomAttributes => throw new NotImplementedException();
  30. public void SetColor(int setIndex, Vector4 color) { }
  31. public void SetTexCoord(int setIndex, Vector2 coord) { }
  32. public Vector4 GetColor(int index) { throw new ArgumentOutOfRangeException(nameof(index)); }
  33. public Vector2 GetTexCoord(int index) { throw new ArgumentOutOfRangeException(nameof(index)); }
  34. public void Validate() { }
  35. public object GetCustomAttribute(string attributeName)
  36. {
  37. return attributeName == CUSTOMATTRIBUTENAME ? (Object)BatchId : null;
  38. }
  39. public bool TryGetCustomAttribute(string attributeName, out object value)
  40. {
  41. if (attributeName != CUSTOMATTRIBUTENAME) { value = null; return false; }
  42. value = BatchId; return true;
  43. }
  44. public void SetCustomAttribute(string attributeName, object value)
  45. {
  46. throw new NotImplementedException();
  47. }
  48. public VertexMaterialDelta Subtract(IVertexMaterial baseValue)
  49. {
  50. throw new NotImplementedException();
  51. }
  52. public void Add(in VertexMaterialDelta delta)
  53. {
  54. throw new NotImplementedException();
  55. }
  56. }
  57. }