[C++] The IN55 project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
2.6KB

  1. #ifndef __BONEANIM_H__
  2. #define __BONEANIM_H__
  3. #include <assimp/cimport.h>
  4. #include <assimp/scene.h>
  5. #include <assimp/postprocess.h>
  6. #include <vertice.h>
  7. #include <bone.h>
  8. #include <mesh.h>
  9. class BoneAnim
  10. {
  11. private:
  12. aiString boneName;
  13. aiVectorKey* transList;
  14. aiVectorKey* scalList;
  15. aiQuatKey* rotList;
  16. int ciT,ciS,ciR;
  17. int nbTrans, nbRot, nbScal;
  18. public:
  19. BoneAnim(int nt, int nr, int ns, const aiString &name){
  20. boneName = name;
  21. nbTrans = nt;
  22. nbRot = nr;
  23. nbScal = ns;
  24. transList = (aiVectorKey*)malloc(nbTrans*sizeof(aiVectorKey));
  25. rotList = (aiQuatKey*)malloc(nbRot*sizeof(aiQuatKey));
  26. scalList = (aiVectorKey*)malloc(nbScal*sizeof(aiVectorKey));
  27. ciT=0;
  28. ciS=0;
  29. ciR=0;
  30. }
  31. void addTrans(aiVectorKey nT){
  32. if(ciT<nbTrans){
  33. transList[ciT]=nT;
  34. ciT++;
  35. }
  36. }
  37. void addScal(aiVectorKey nS){
  38. if(ciS<nbScal){
  39. scalList[ciS]=nS;
  40. ciS++;
  41. }
  42. }
  43. void addRot(aiQuatKey nR){
  44. if(ciR<nbRot){
  45. rotList[ciR]=nR;
  46. ciR++;
  47. }
  48. }
  49. aiString &getName() {return boneName; };
  50. int getNbTrans(){return nbTrans;};
  51. int getNbScal(){return nbScal;};
  52. int getNbRot(){return nbRot;};
  53. aiVectorKey getTrans(int i){return transList[i]; };
  54. aiVectorKey getScal(int i){return scalList[i]; };
  55. aiQuatKey getRot(int i) {return rotList[i]; };
  56. unsigned int findScaling(float AnimationTime) {
  57. assert(this->nbScal > 0);
  58. for (int i = 0 ; i < this->nbScal - 1 ; i++) {
  59. if (AnimationTime < (float)this->scalList[i + 1].mTime) {
  60. return i;
  61. }
  62. }
  63. assert(0);
  64. }
  65. unsigned int findPosition(float AnimationTime) {
  66. assert(this->nbTrans > 0);
  67. for (int i = 0 ; i < this->nbTrans - 1 ; i++) {
  68. if (AnimationTime < (float)this->transList[i + 1].mTime) {
  69. return i;
  70. }
  71. }
  72. assert(0);
  73. }
  74. unsigned int findRotation(float AnimationTime) {
  75. assert(this->nbRot > 0);
  76. for (int i = 0 ; i < this->nbRot - 1 ; i++) {
  77. if (AnimationTime < (float)this->rotList[i + 1].mTime) {
  78. return i;
  79. }
  80. }
  81. assert(0);
  82. }
  83. };
  84. #endif