HairAsset.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 <AzCore/Asset/AssetSerializer.h>
  11. #include <AzFramework/Asset/GenericAssetHandler.h>
  12. #include <TressFX/TressFXAsset.h>
  13. namespace AZ
  14. {
  15. namespace Render
  16. {
  17. namespace Hair
  18. {
  19. //! HairAsset is a simple AssetData wrapper around the TressFXAsset used by the AP.
  20. //! Is comprises of the hair vertices data file, the hair bone skinning information file
  21. //! and the collision data file.
  22. //! The plan is to separate the collision data as it can have the relation of 1:1, 1:N or N:1
  23. //! meaning that the hair can have multiple collision handling (not only single mesh), and at
  24. //! the other end multiple hairs can have the same collision (hairdo and fur for example).
  25. class HairAsset final
  26. : public AZ::Data::AssetData
  27. {
  28. public:
  29. static constexpr inline const char* DisplayName = "HairAsset";
  30. static constexpr inline const char* Extension = "tfxhair";
  31. static constexpr inline const char* Group = "Hair";
  32. AZ_RTTI(HairAsset, "{52842B73-8F75-4620-8231-31EBCC74DD85}", AZ::Data::AssetData);
  33. AZ_CLASS_ALLOCATOR(HairAsset, AZ::SystemAllocator);
  34. AZStd::unique_ptr<AMD::TressFXAsset> m_tressFXAsset;
  35. };
  36. // HairAssetHandler
  37. // This handler class help to load the .tfxhair file (which is a combined file of .tfx, .tfxbone and .tfxmesh)
  38. // from an AssetDataStream.
  39. class HairAssetHandler final
  40. : public AzFramework::GenericAssetHandler<HairAsset>
  41. {
  42. public:
  43. HairAssetHandler();
  44. private:
  45. Data::AssetHandler::LoadResult LoadAssetData(
  46. const Data::Asset<Data::AssetData>& asset, AZStd::shared_ptr<Data::AssetDataStream> stream,
  47. const Data::AssetFilterCB& assetLoadFilterCB) override;
  48. };
  49. }
  50. }
  51. }