BsSpecificImporter.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. namespace BansheeEngine
  6. {
  7. /** @addtogroup Importer-Internal
  8. * @{
  9. */
  10. /**
  11. * Contains a resource that was imported from a file that contains multiple resources (for example an animation from an
  12. * FBX file).
  13. */
  14. struct SubResourceRaw
  15. {
  16. WString name; /**< Unique name of the sub-resource. */
  17. SPtr<Resource> value; /**< Contents of the sub-resource. */
  18. };
  19. /**
  20. * Abstract class that is to be specialized for converting a certain asset type into an engine usable resource
  21. * (for example a .png file into an engine usable texture).
  22. *
  23. * On initialization this class must register itself with the Importer module, which delegates asset import calls to a
  24. * specific importer.
  25. */
  26. class BS_CORE_EXPORT SpecificImporter
  27. {
  28. public:
  29. SpecificImporter() {}
  30. virtual ~SpecificImporter() {}
  31. /**
  32. * Check is the provided extension supported by this importer.
  33. *
  34. * @note Provided extension should be without the leading dot.
  35. */
  36. virtual bool isExtensionSupported(const WString& ext) const = 0;
  37. /** Check if the provided magic number is supported by this importer. */
  38. virtual bool isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const = 0;
  39. /**
  40. * Imports the given file. If file contains more than one resource only the primary resource is imported (for
  41. * example for an FBX a mesh would be imported, but animations ignored).
  42. *
  43. * @param[in] filePath Pathname of the file, with file extension.
  44. * @param[in] importOptions Options that can control how is the resource imported.
  45. * @return null if it fails, otherwise the loaded object.
  46. */
  47. virtual SPtr<Resource> import(const Path& filePath, SPtr<const ImportOptions> importOptions) = 0;
  48. /**
  49. * Imports the given file. This method returns all imported resources, which is relevant for files that can contain
  50. * multiple resources (for example an FBX which may contain both a mesh and animations).
  51. *
  52. * @param[in] filePath Pathname of the file, with file extension.
  53. * @param[in] importOptions Options that can control how are the resources imported.
  54. * @return Empty array if it fails, otherwise the loaded objects. First element is always the
  55. * primary resource.
  56. */
  57. virtual Vector<SubResourceRaw> importAll(const Path& filePath, SPtr<const ImportOptions> importOptions);
  58. /**
  59. * Creates import options specific for this importer. Import options are provided when calling import() in order
  60. * to customize the import, and provide additional information.
  61. */
  62. virtual SPtr<ImportOptions> createImportOptions() const;
  63. /**
  64. * Gets the default import options.
  65. *
  66. * @return The default import options.
  67. */
  68. SPtr<const ImportOptions> getDefaultImportOptions() const;
  69. private:
  70. mutable SPtr<const ImportOptions> mDefaultImportOptions;
  71. };
  72. /** @} */
  73. }