PolySkeleton.h 2.1 KB

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