PolySkeleton.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * PolySkeleton.h
  3. * Poly
  4. *
  5. * Created by Ivan Safrin on 9/4/08.
  6. * Copyright 2008 __MyCompanyName__. All rights reserved.
  7. *
  8. */
  9. // @package BasicTypes
  10. #pragma once
  11. #include "PolyGlobals.h"
  12. #include "PolyBone.h"
  13. #include <string>
  14. #include <vector>
  15. using std::string;
  16. using std::vector;
  17. namespace Polycode {
  18. class _PolyExport BoneTrack {
  19. public:
  20. BoneTrack(Bone *bone);
  21. ~BoneTrack();
  22. void Play();
  23. void Stop();
  24. void Update();
  25. void setSpeed(float speed);
  26. BezierCurve *scaleX;
  27. BezierCurve *scaleY;
  28. BezierCurve *scaleZ;
  29. BezierCurve *QuatW;
  30. BezierCurve *QuatX;
  31. BezierCurve *QuatY;
  32. BezierCurve *QuatZ;
  33. BezierCurve *LocX;
  34. BezierCurve *LocY;
  35. BezierCurve *LocZ;
  36. Vector3 LocXVec;
  37. Vector3 LocYVec;
  38. Vector3 LocZVec;
  39. Quaternion boneQuat;
  40. QuaternionTween *quatTween;
  41. Vector3 QuatWVec;
  42. Vector3 QuatXVec;
  43. Vector3 QuatYVec;
  44. Vector3 QuatZVec;
  45. protected:
  46. bool initialized;
  47. Bone *targetBone;
  48. vector <BezierPathTween*> pathTweens;
  49. };
  50. class _PolyExport SkeletonAnimation {
  51. public:
  52. SkeletonAnimation(string name, float duration);
  53. ~SkeletonAnimation();
  54. void addBoneTrack(BoneTrack *boneTrack);
  55. string getName();
  56. void Play();
  57. void Stop();
  58. void Update();
  59. void setSpeed(float speed);
  60. private:
  61. string name;
  62. float duration;
  63. vector<BoneTrack*> boneTracks;
  64. };
  65. class _PolyExport Skeleton : public SceneEntity {
  66. public:
  67. Skeleton(string fileName);
  68. void loadSkeleton(string fileName);
  69. ~Skeleton();
  70. void playAnimation(string animName);
  71. SkeletonAnimation *getAnimation(string name);
  72. void Update();
  73. Bone *getBoneByName(string name);
  74. void bonesVisible(bool val);
  75. void enableBoneLabels(Font *font, float size, float scale);
  76. int getNumBones();
  77. Bone *getBone(int index);
  78. SkeletonAnimation *getCurrentAnimation() { return currentAnimation; }
  79. private:
  80. SkeletonAnimation *currentAnimation;
  81. vector<Bone*> bones;
  82. vector<SkeletonAnimation*> animations;
  83. };
  84. }