Animation.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // ----------------------------------------------------------------
  2. // From Game Programming in C++ by Sanjay Madhav
  3. // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
  4. //
  5. // Released under the BSD License
  6. // See LICENSE in root directory for full details.
  7. // ----------------------------------------------------------------
  8. #pragma once
  9. #include "BoneTransform.h"
  10. #include <vector>
  11. #include <string>
  12. class Animation
  13. {
  14. public:
  15. bool Load(const std::string& fileName);
  16. size_t GetNumBones() const { return mNumBones; }
  17. size_t GetNumFrames() const { return mNumFrames; }
  18. float GetDuration() const { return mDuration; }
  19. float GetFrameDuration() const { return mFrameDuration; }
  20. // Fills the provided vector with the global (current) pose matrices for each
  21. // bone at the specified time in the animation. It is expected that the time
  22. // is >= 0.0f and <= mDuration
  23. void GetGlobalPoseAtTime(std::vector<Matrix4>& outPoses, const class Skeleton* inSkeleton, float inTime) const;
  24. private:
  25. // Number of bones for the animation
  26. size_t mNumBones;
  27. // Number of frames in the animation
  28. size_t mNumFrames;
  29. // Duration of the animation in seconds
  30. float mDuration;
  31. // Duration of each frame in the animation
  32. float mFrameDuration;
  33. // Transform information for each frame on the track
  34. // Each index in the outer vector is a bone, inner vector
  35. // is a frame
  36. std::vector<std::vector<BoneTransform>> mTracks;
  37. };