BsSpecificImporter.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 in convertinga 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. * @return null if it fails, otherwise the loaded object.
  45. */
  46. virtual ResourcePtr import(const Path& filePath, ConstImportOptionsPtr importOptions) = 0;
  47. /**
  48. * Imports the given file. This method returns all imported resources, which is relevant for files that can contain
  49. * multiple resources (for example an FBX which may contain both a mesh and animations).
  50. *
  51. * @param[in] filePath Pathname of the file, with file extension.
  52. * @return Empty array if it fails, otherwise the loaded objects. First element is always the
  53. * primary resource.
  54. */
  55. virtual Vector<SubResourceRaw> importAll(const Path& filePath, ConstImportOptionsPtr importOptions);
  56. /**
  57. * Creates import options specific for this importer. Import options are provided when calling import() in order
  58. * to customize the import, and provide additional information.
  59. */
  60. virtual ImportOptionsPtr createImportOptions() const;
  61. /**
  62. * Gets the default import options.
  63. *
  64. * @return The default import options.
  65. */
  66. ConstImportOptionsPtr getDefaultImportOptions() const;
  67. private:
  68. mutable ConstImportOptionsPtr mDefaultImportOptions;
  69. };
  70. /** @} */
  71. }