MotionSetAsset.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/Asset/AssetCommon.h>
  10. #include <Integration/System/SystemCommon.h>
  11. #include <Integration/Assets/AssetCommon.h>
  12. #include <Integration/Assets/MotionAsset.h>
  13. namespace AZ
  14. {
  15. namespace IO
  16. {
  17. class GenericStream;
  18. }
  19. }
  20. namespace EMotionFX
  21. {
  22. class MotionSet;
  23. namespace Integration
  24. {
  25. class CustomMotionSetCallback;
  26. /**
  27. * Represents a shared motion set asset in-memory, and is registered with the AZ::Data::AssetDatabase.
  28. */
  29. class MotionSetAsset
  30. : public EMotionFXAsset
  31. , public AZ::Data::AssetBus::MultiHandler
  32. {
  33. public:
  34. AZ_RTTI(MotionSetAsset, "{1DA936A0-F766-4B2F-B89C-9F4C8E1310F9}", EMotionFXAsset)
  35. AZ_CLASS_ALLOCATOR_DECL
  36. MotionSetAsset(AZ::Data::AssetId id = AZ::Data::AssetId());
  37. ~MotionSetAsset() override;
  38. // AZ::Data::AssetBus::MultiHandler
  39. void OnAssetReloaded(AZ::Data::Asset<AZ::Data::AssetData> asset) override;
  40. static void NotifyMotionSetModified(const AZ::Data::Asset<MotionSetAsset>& asset);
  41. void SetData(EMotionFX::MotionSet* motionSet);
  42. AZStd::unique_ptr<EMotionFX::MotionSet> m_emfxMotionSet; ///< EMotionFX motion set
  43. AZStd::vector<AZ::Data::Asset<MotionAsset>> m_motionAssets; ///< Handles to all contained motions
  44. bool m_isReloadPending = false; ///< True if a dependent motion was reloaded and we're pending our own reload notification.
  45. };
  46. /**
  47. * Handler responsible for creating, loading, and initializing shared motion set assets.
  48. */
  49. class MotionSetAssetHandler : public EMotionFXAssetHandler<MotionSetAsset>
  50. {
  51. public:
  52. AZ_CLASS_ALLOCATOR_DECL
  53. bool OnInitAsset(const AZ::Data::Asset<AZ::Data::AssetData>& asset) override;
  54. AZ::Data::AssetType GetAssetType() const override;
  55. void GetAssetTypeExtensions(AZStd::vector<AZStd::string>& extensions) override;
  56. const char* GetAssetTypeDisplayName() const override;
  57. const char* GetBrowserIcon() const override;
  58. };
  59. class MotionSetAssetBuilderHandler : public MotionSetAssetHandler
  60. {
  61. public:
  62. void InitAsset(const AZ::Data::Asset<AZ::Data::AssetData>& asset, bool loadStageSucceeded, bool isReload) override;
  63. AZ::Data::AssetHandler::LoadResult LoadAssetData(
  64. const AZ::Data::Asset<AZ::Data::AssetData>& asset,
  65. AZStd::shared_ptr<AZ::Data::AssetDataStream> stream,
  66. const AZ::Data::AssetFilterCB& assetLoadFilterCB) override;
  67. };
  68. } // namespace Integration
  69. } // namespace EMotionFX
  70. namespace AZ
  71. {
  72. AZ_TYPE_INFO_SPECIALIZE(EMotionFX::Integration::EMotionFXPtr<EMotionFX::Integration::MotionSetAsset>, "{5A306008-884B-486C-BEBB-186E28E3B63D}");
  73. }