Enums.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using UnityEngine;
  2. namespace Siccity.GLTFUtility {
  3. public enum AlphaMode { OPAQUE, MASK, BLEND }
  4. public enum AccessorType { SCALAR, VEC2, VEC3, VEC4, MAT2, MAT3, MAT4 }
  5. public enum RenderingMode { POINTS = 0, LINES = 1, LINE_LOOP = 2, LINE_STRIP = 3, TRIANGLES = 4, TRIANGLE_STRIP = 5, TRIANGLE_FAN = 6 }
  6. public enum GLType { UNSET = -1, BYTE = 5120, UNSIGNED_BYTE = 5121, SHORT = 5122, UNSIGNED_SHORT = 5123, UNSIGNED_INT = 5125, FLOAT = 5126 }
  7. public enum Format { AUTO, GLTF, GLB }
  8. public enum CameraType { perspective, orthographic }
  9. public enum InterpolationMode { ImportFromFile = -1, LINEAR = 0, STEP = 1, CUBICSPLINE = 2 }
  10. public static class EnumExtensions {
  11. public static int ByteSize(this GLType gltype) {
  12. switch (gltype) {
  13. case GLType.BYTE:
  14. return sizeof(sbyte);
  15. case GLType.UNSIGNED_BYTE:
  16. return sizeof(byte);
  17. case GLType.SHORT:
  18. return sizeof(short);
  19. case GLType.UNSIGNED_SHORT:
  20. return sizeof(ushort);
  21. case GLType.FLOAT:
  22. return sizeof(float);
  23. case GLType.UNSIGNED_INT:
  24. return sizeof(uint);
  25. default:
  26. Debug.LogError("GLType " + (int) gltype + " not supported!");
  27. return 0;
  28. }
  29. }
  30. public static int ComponentCount(this AccessorType accessorType) {
  31. switch (accessorType) {
  32. case AccessorType.SCALAR:
  33. return 1;
  34. case AccessorType.VEC2:
  35. return 2;
  36. case AccessorType.VEC3:
  37. return 3;
  38. case AccessorType.VEC4:
  39. return 4;
  40. case AccessorType.MAT2:
  41. return 4;
  42. case AccessorType.MAT3:
  43. return 9;
  44. case AccessorType.MAT4:
  45. return 16;
  46. default:
  47. Debug.LogError("AccessorType " + accessorType + " not supported!");
  48. return 0;
  49. }
  50. }
  51. }
  52. }