TriLibReaders.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. #if !TRILIB_DISABLE_FBX_IMPORT
  4. #if TRILIB_USE_FBXSDK
  5. using TriLibCore.FBXSDK;
  6. #else
  7. using TriLibCore.Fbx.Reader;
  8. #endif
  9. #endif
  10. #if !TRILIB_DISABLE_GLTF_IMPORT
  11. using TriLibCore.Gltf.Reader;
  12. #endif
  13. #if !TRILIB_DISABLE_OBJ_IMPORT
  14. #if !TRILIB_USE_FBXSDK
  15. using TriLibCore.Obj.Reader;
  16. #endif
  17. #endif
  18. #if !TRILIB_DISABLE_STL_IMPORT
  19. using TriLibCore.Stl.Reader;
  20. #endif
  21. #if !TRILIB_DISABLE_PLY_IMPORT
  22. using TriLibCore.Ply.Reader;
  23. #endif
  24. #if !TRILIB_DISABLE_3MF_IMPORT
  25. using TriLibCore.ThreeMf.Reader;
  26. #endif
  27. #if !TRILIB_DISABLE_DAE_IMPORT
  28. #if !TRILIB_USE_FBXSDK
  29. using TriLibCore.Dae.Reader;
  30. #endif
  31. #endif
  32. namespace TriLibCore
  33. {
  34. /// <summary>
  35. /// Represents a series of methods to retrieve TriLib reader infos.
  36. /// </summary>
  37. public class Readers
  38. {
  39. /// <summary>
  40. /// Gets all TriLib reader extensions.
  41. /// </summary>
  42. public static IList<string> Extensions
  43. {
  44. get
  45. {
  46. var extensions = new List<string>();
  47. #if !TRILIB_DISABLE_FBX_IMPORT
  48. extensions.AddRange(FbxReader.GetExtensions());
  49. #endif
  50. #if !TRILIB_DISABLE_GLTF_IMPORT
  51. extensions.AddRange(GltfReader.GetExtensions());
  52. #endif
  53. #if !TRILIB_DISABLE_OBJ_IMPORT
  54. #if !TRILIB_USE_FBXSDK
  55. extensions.AddRange(ObjReader.GetExtensions());
  56. #endif
  57. #endif
  58. #if !TRILIB_DISABLE_STL_IMPORT
  59. extensions.AddRange(StlReader.GetExtensions());
  60. #endif
  61. #if !TRILIB_DISABLE_PLY_IMPORT
  62. extensions.AddRange(PlyReader.GetExtensions());
  63. #endif
  64. #if !TRILIB_DISABLE_3MF_IMPORT
  65. extensions.AddRange(ThreeMfReader.GetExtensions());
  66. #endif
  67. #if !TRILIB_DISABLE_DAE_IMPORT
  68. #if !TRILIB_USE_FBXSDK
  69. extensions.AddRange(DaeReader.GetExtensions());
  70. #endif
  71. #endif
  72. return extensions;
  73. }
  74. }
  75. /// <summary>
  76. /// Returns the Reader used to process the given extension.
  77. /// </summary>
  78. /// <param name="extension">The extension to search the Reader for.</param>
  79. /// <returns>The Reader used to process the extension, if found. Otherwise, <c>null</c>.</returns>
  80. public static ReaderBase FindReaderForExtension(string extension)
  81. {
  82. #if !TRILIB_DISABLE_FBX_IMPORT
  83. if (((IList)FbxReader.GetExtensions()).Contains(extension))
  84. {
  85. return new FbxReader();
  86. }
  87. #endif
  88. #if !TRILIB_DISABLE_GLTF_IMPORT
  89. if (((IList)GltfReader.GetExtensions()).Contains(extension))
  90. {
  91. return new GltfReader();
  92. }
  93. #endif
  94. #if !TRILIB_DISABLE_OBJ_IMPORT
  95. #if !TRILIB_USE_FBXSDK
  96. if (((IList)ObjReader.GetExtensions()).Contains(extension))
  97. {
  98. return new ObjReader();
  99. }
  100. #endif
  101. #endif
  102. #if !TRILIB_DISABLE_STL_IMPORT
  103. if (((IList)StlReader.GetExtensions()).Contains(extension))
  104. {
  105. return new StlReader();
  106. }
  107. #endif
  108. #if !TRILIB_DISABLE_PLY_IMPORT
  109. if (((IList)PlyReader.GetExtensions()).Contains(extension))
  110. {
  111. return new PlyReader();
  112. }
  113. #endif
  114. #if !TRILIB_DISABLE_3MF_IMPORT
  115. if (((IList)ThreeMfReader.GetExtensions()).Contains(extension))
  116. {
  117. return new ThreeMfReader();
  118. }
  119. #endif
  120. #if !TRILIB_DISABLE_DAE_IMPORT
  121. #if !TRILIB_USE_FBXSDK
  122. if (((IList)DaeReader.GetExtensions()).Contains(extension))
  123. {
  124. return new DaeReader();
  125. }
  126. #endif
  127. #endif
  128. return null;
  129. }
  130. }
  131. }