PolySkeleton.h 2.4 KB

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