ActorHelper.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 <EMotionFX/Source/Actor.h>
  10. #include <EMotionFX/Source/TransformData.h>
  11. namespace UnitTest
  12. {
  13. using SkinInfluence = AZStd::tuple<size_t, float>;
  14. using VertexSkinInfluences = AZStd::vector<SkinInfluence>;
  15. //! Helper class to setup an actor.
  16. class ActorHelper
  17. : public EMotionFX::Actor
  18. {
  19. public:
  20. explicit ActorHelper(const char* name);
  21. //! Adds a node to the skeleton.
  22. size_t AddJoint(
  23. const AZStd::string& name,
  24. const AZ::Transform& localTransform = AZ::Transform::CreateIdentity(),
  25. const AZStd::string& parentName = "");
  26. //! Adds a collider to the cloh configuration.
  27. void AddClothCollider(const Physics::CharacterColliderNodeConfiguration& colliderNode);
  28. //! Finishes to construct the actor.
  29. //! @note This function must be called last, before using Actor.
  30. void FinishSetup();
  31. };
  32. AZ::Data::Asset<AZ::Data::AssetData> CreateAssetFromActor(
  33. AZStd::unique_ptr<EMotionFX::Actor> actor);
  34. Physics::CharacterColliderNodeConfiguration CreateSphereCollider(
  35. const AZStd::string& jointName,
  36. float radius,
  37. const AZ::Transform& offset = AZ::Transform::CreateIdentity());
  38. Physics::CharacterColliderNodeConfiguration CreateCapsuleCollider(
  39. const AZStd::string& jointName,
  40. float height, float radius,
  41. const AZ::Transform& offset = AZ::Transform::CreateIdentity());
  42. Physics::CharacterColliderNodeConfiguration CreateBoxCollider(
  43. const AZStd::string& jointName,
  44. const AZ::Vector3& dimensions,
  45. const AZ::Transform& offset = AZ::Transform::CreateIdentity());
  46. EMotionFX::Mesh* CreateEMotionFXMesh(
  47. const AZStd::vector<AZ::Vector3>& vertices,
  48. const AZStd::vector<AZ::u32>& indices,
  49. const AZStd::vector<VertexSkinInfluences>& skinningInfo = {},
  50. const AZStd::vector<AZ::Vector2>& uvs = {});
  51. } // namespace UnitTest