BsSpecificImporter.h 3.0 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. /** @cond INTERNAL */
  8. /** @addtogroup Importer
  9. * @{
  10. */
  11. /**
  12. * Contains a resource that was imported from a file that contains multiple resources (e.g. an animation from an FBX
  13. * file).
  14. */
  15. struct SubResourceRaw
  16. {
  17. WString name; /**< Unique name of the sub-resource. */
  18. SPtr<Resource> value; /**< Contents of the sub-resource. */
  19. };
  20. /**
  21. * Abstract class that is to be specialized in convertinga certain asset type into an engine usable resource.
  22. * (e.g. a .png file into an engine usable texture).
  23. *
  24. * On initialization this class must register itself with the Importer module, which delegates asset import calls to a
  25. * specific importer.
  26. */
  27. class BS_CORE_EXPORT SpecificImporter
  28. {
  29. public:
  30. SpecificImporter() {}
  31. virtual ~SpecificImporter() {}
  32. /**
  33. * Check is the provided extension supported by this importer.
  34. *
  35. * @note Provided extension should be without the leading dot.
  36. */
  37. virtual bool isExtensionSupported(const WString& ext) const = 0;
  38. /** Check if the provided magic number is supported by this importer. */
  39. virtual bool isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const = 0;
  40. /**
  41. * Imports the given file. If file contains more than one resource only the primary resource is imported (e.g. for
  42. * an FBX a mesh would be imported, but animations ignored).
  43. *
  44. * @param[in] filePath Pathname of the file, with file extension.
  45. * @return null if it fails, otherwise the loaded object.
  46. */
  47. virtual ResourcePtr import(const Path& filePath, ConstImportOptionsPtr 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 (e.g. an FBX which may contain both a mesh and animations).
  51. *
  52. * @param[in] filePath Pathname of the file, with file extension.
  53. * @return Empty array if it fails, otherwise the loaded objects. First element is always the
  54. * primary resource.
  55. */
  56. virtual Vector<SubResourceRaw> importAll(const Path& filePath, ConstImportOptionsPtr importOptions);
  57. /**
  58. * Creates import options specific for this importer. Import options are provided when calling import() in order
  59. * to customize the import, and provide additional information.
  60. */
  61. virtual ImportOptionsPtr createImportOptions() const;
  62. /**
  63. * Gets the default import options.
  64. *
  65. * @return The default import options.
  66. */
  67. ConstImportOptionsPtr getDefaultImportOptions() const;
  68. private:
  69. mutable ConstImportOptionsPtr mDefaultImportOptions;
  70. };
  71. /** @} */
  72. /** @endcond */
  73. }