ClothRuleBehavior.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 <SceneAPI/SceneCore/Components/BehaviorComponent.h>
  10. #include <SceneAPI/SceneCore/Events/ManifestMetaInfoBus.h>
  11. #include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
  12. namespace AZ
  13. {
  14. namespace SceneAPI
  15. {
  16. namespace DataTypes
  17. {
  18. class ISceneNodeGroup;
  19. }
  20. namespace Containers
  21. {
  22. class Scene;
  23. class SceneGraph;
  24. }
  25. }
  26. }
  27. namespace NvCloth
  28. {
  29. namespace Pipeline
  30. {
  31. class ClothRule;
  32. //! This class defines the behavior of how to treat the cloth rule data
  33. //! through the SceneAPI.
  34. //! It specifies the valid Scene Groups that are allowed to have
  35. //! cloth rules (aka cloth modifiers), these are Mesh and Actor groups.
  36. //! It also validates the cloth rules data for the manifest (asset containing
  37. //! all the Scene information from the Scene Settings).
  38. class ClothRuleBehavior
  39. : public AZ::SceneAPI::SceneCore::BehaviorComponent
  40. , public AZ::SceneAPI::Events::ManifestMetaInfoBus::Handler
  41. , public AZ::SceneAPI::Events::AssetImportRequestBus::Handler
  42. {
  43. public:
  44. AZ_COMPONENT(ClothRuleBehavior, "{00FA6C8A-27D2-4C0E-B601-6917950432E5}", AZ::SceneAPI::SceneCore::BehaviorComponent);
  45. static void Reflect(AZ::ReflectContext* context);
  46. // BehaviorComponent overrides ...
  47. void Activate() override;
  48. void Deactivate() override;
  49. // ManifestMetaInfoBus::Handler overrides ...
  50. void GetAvailableModifiers(
  51. AZ::SceneAPI::Events::ManifestMetaInfo::ModifiersList& modifiers,
  52. const AZ::SceneAPI::Containers::Scene& scene,
  53. const AZ::SceneAPI::DataTypes::IManifestObject& target) override;
  54. void InitializeObject(const AZ::SceneAPI::Containers::Scene& scene, AZ::SceneAPI::DataTypes::IManifestObject& target) override;
  55. void GetPolicyName(AZStd::string& result) const override
  56. {
  57. result = "ClothRuleBehavior";
  58. }
  59. // AssetImportRequestBus::Handler overrides ....
  60. AZ::SceneAPI::Events::ProcessingResult UpdateManifest(AZ::SceneAPI::Containers::Scene& scene, ManifestAction action, RequestingApplication requester) override;
  61. protected:
  62. bool IsValidGroupType(const AZ::SceneAPI::DataTypes::ISceneNodeGroup& group) const;
  63. bool UpdateClothRules(AZ::SceneAPI::Containers::Scene& scene);
  64. bool UpdateClothRule(const AZ::SceneAPI::Containers::SceneGraph& graph, const AZ::SceneAPI::DataTypes::ISceneNodeGroup& group, ClothRule& clothRule);
  65. bool ContainsVertexColorStream(const AZ::SceneAPI::Containers::SceneGraph& graph, const AZStd::string& streamName) const;
  66. };
  67. } // namespace Pipeline
  68. } // namespace NvCloth