2
0

Animation.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. const std::string& GetFileName() const { return mFileName; }
  23. // is >= 0.0f and <= mDuration
  24. void GetGlobalPoseAtTime(std::vector<Matrix4>& outPoses, const class Skeleton* inSkeleton, float inTime) const;
  25. private:
  26. // Number of bones for the animation
  27. size_t mNumBones;
  28. // Number of frames in the animation
  29. size_t mNumFrames;
  30. // Duration of the animation in seconds
  31. float mDuration;
  32. // Duration of each frame in the animation
  33. float mFrameDuration;
  34. // Transform information for each frame on the track
  35. // Each index in the outer vector is a bone, inner vector
  36. // is a frame
  37. std::vector<std::vector<BoneTransform>> mTracks;
  38. std::string mFileName;
  39. };