BsSkeleton.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. #include "BsIReflectable.h"
  6. #include "BsMatrix4.h"
  7. namespace BansheeEngine
  8. {
  9. /** @addtogroup Animation-Internal
  10. * @{
  11. */
  12. struct BONE_DESC
  13. {
  14. String name;
  15. UINT32 parent;
  16. Matrix4 invBindPose;
  17. };
  18. struct ANIMATION_STATE_DESC
  19. {
  20. const AnimationClip* clip;
  21. float weight;
  22. float speed;
  23. bool loop;
  24. UINT8 layer;
  25. };
  26. struct SkeletonPose
  27. {
  28. SkeletonPose(UINT32 numBones)
  29. :numBones(numBones), bonePoses(bs_newN<Matrix4>(numBones))
  30. {}
  31. ~SkeletonPose()
  32. {
  33. bs_deleteN(bonePoses, numBones);
  34. }
  35. Matrix4* bonePoses;
  36. UINT32 numBones;
  37. };
  38. struct SkeletonBoneInfo
  39. {
  40. String name;
  41. UINT32 parent;
  42. };
  43. class BS_CORE_EXPORT Skeleton : public IReflectable // Note: Must be immutable in order to be usable on multiple threads
  44. {
  45. public:
  46. ~Skeleton();
  47. void getPose(SkeletonPose& pose, const AnimationClip& clip, float time, bool loop = true);
  48. void getPose(SkeletonPose& pose, const ANIMATION_STATE_DESC* states, UINT32 numStates, float time);
  49. static SPtr<Skeleton> create(BONE_DESC* bones, UINT32 numBones);
  50. private:
  51. Skeleton();
  52. Skeleton(BONE_DESC* bones, UINT32 numBones);
  53. UINT32 mNumBones;
  54. Matrix4* mBindPoses;
  55. SkeletonBoneInfo* mBoneInfo;
  56. /************************************************************************/
  57. /* SERIALIZATION */
  58. /************************************************************************/
  59. public:
  60. friend class SkeletonRTTI;
  61. static RTTITypeBase* getRTTIStatic();
  62. RTTITypeBase* getRTTI() const override;
  63. /**
  64. * Creates a Skeleton with no data. You must populate its data manually.
  65. *
  66. * @note For serialization use only.
  67. */
  68. static SPtr<Skeleton> createEmpty();
  69. };
  70. /** @} */
  71. }