PolySkeleton.h 2.4 KB

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