Frame.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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/Memory/Memory.h>
  10. #include <AzCore/RTTI/RTTI.h>
  11. #include <EMotionFX/Source/EMotionFXConfig.h>
  12. #include <EMotionFX/Source/Pose.h>
  13. namespace EMotionFX
  14. {
  15. class Motion;
  16. namespace MotionMatching
  17. {
  18. //! A motion matching frame.
  19. //! This holds information required in order to extract a given pose in a given motion.
  20. class EMFX_API Frame
  21. {
  22. public:
  23. AZ_RTTI(Frame, "{985BD732-D80E-4898-AB6C-CAB22D88AACD}")
  24. AZ_CLASS_ALLOCATOR_DECL
  25. Frame();
  26. Frame(size_t frameIndex, Motion* sourceMotion, float sampleTime, bool mirrored);
  27. ~Frame() = default;
  28. //! Sample the pose for the given frame.
  29. //! @param[in] outputPose The pose used to store the sampled result.
  30. //! @param[in] timeOffset Frames in the frame database are samples with a given sample rate (default = 30 fps).
  31. //! For calculating velocities for example, it is needed to sample a pose close to a frame but not exactly at the frame position.
  32. //! The timeOffset parameter can be used for that and represents the offset in time from the frame sample time in seconds.
  33. //! In case the time offset is 0.0, the pose exactly at the frame position will be sampled.
  34. void SamplePose(Pose* outputPose, float timeOffset = 0.0f) const;
  35. Motion* GetSourceMotion() const;
  36. float GetSampleTime() const;
  37. size_t GetFrameIndex() const { return m_frameIndex; }
  38. bool GetMirrored() const { return m_mirrored; }
  39. void SetSourceMotion(Motion* sourceMotion);
  40. void SetSampleTime(float sampleTime);
  41. void SetFrameIndex(size_t frameIndex);
  42. void SetMirrored(bool enabled);
  43. private:
  44. size_t m_frameIndex = 0; //< The motion frame index inside the data object.
  45. float m_sampleTime = 0.0f; //< The time offset in the original motion.
  46. Motion* m_sourceMotion = nullptr; //< The original motion that we sample from to restore the pose.
  47. bool m_mirrored = false; //< Is this frame mirrored?
  48. };
  49. } // namespace MotionMatching
  50. } // namespace EMotionFX