VertexPointcloud.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 VertexPointcloud : IVertexCustom
  12. {
  13. public VertexPointcloud(Vector4 color, float intensity, float classification)
  14. {
  15. Color = color;
  16. Intensity = intensity;
  17. Classification = classification;
  18. }
  19. public const string INTENSITYATTRIBUTENAME = "_INTENSITY";
  20. public const string CLASSIFICATIONATTRIBUTENAME = "_CLASSIFICATION";
  21. public Vector4 Color;
  22. public float Intensity;
  23. public float Classification;
  24. IEnumerable<KeyValuePair<string, AttributeFormat>> IVertexReflection.GetEncodingAttributes()
  25. {
  26. yield return new KeyValuePair<string, AttributeFormat>("COLOR_0", new AttributeFormat(DimensionType.VEC4, EncodingType.UNSIGNED_BYTE, true));
  27. yield return new KeyValuePair<string, AttributeFormat>(INTENSITYATTRIBUTENAME, new AttributeFormat(DimensionType.SCALAR));
  28. yield return new KeyValuePair<string, AttributeFormat>(CLASSIFICATIONATTRIBUTENAME, new AttributeFormat(DimensionType.SCALAR));
  29. }
  30. public int MaxColors => 1;
  31. public int MaxTextCoords => 0;
  32. public IEnumerable<string> CustomAttributes => throw new NotImplementedException();
  33. void IVertexMaterial.SetColor(int setIndex, Vector4 color) {
  34. if (setIndex == 0) Color = color;
  35. }
  36. public void SetTexCoord(int setIndex, Vector2 coord) { }
  37. public Vector4 GetColor(int index) {
  38. return Color;
  39. }
  40. public Vector2 GetTexCoord(int index) { throw new ArgumentOutOfRangeException(nameof(index)); }
  41. public void Validate() { }
  42. public object GetCustomAttribute(string attributeName)
  43. {
  44. throw new NotImplementedException();
  45. }
  46. public bool TryGetCustomAttribute(string attributeName, out object value)
  47. {
  48. if (attributeName == INTENSITYATTRIBUTENAME) {
  49. value = Intensity; return true;
  50. }
  51. else if(attributeName == CLASSIFICATIONATTRIBUTENAME)
  52. {
  53. value = Classification; return true;
  54. }
  55. else
  56. {
  57. value = null; return false;
  58. }
  59. }
  60. public void SetCustomAttribute(string attributeName, object value)
  61. {
  62. throw new NotImplementedException();
  63. }
  64. public VertexMaterialDelta Subtract(IVertexMaterial baseValue)
  65. {
  66. throw new NotImplementedException();
  67. }
  68. public void Add(in VertexMaterialDelta delta)
  69. {
  70. throw new NotImplementedException();
  71. }
  72. }
  73. }