Advertisement
Guest User

Animation

a guest
Mar 29th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. case MeshDataType::ANIMATIONCLIPS:
  2. {
  3. pMesh->m_HasAnimations = true;
  4.  
  5. //Start parsing the AnimationClips
  6. //1. Read the clipCount
  7. unsigned int ClipCount = binReader->Read<unsigned int>();
  8. //2. For every clip
  9. for (size_t i = 0; i < ClipCount; i++)
  10. {
  11. //3. Create a AnimationClip object (clip)
  12. AnimationClip clip;
  13. //4. Read/Assign the ClipName
  14. clip.Name = binReader->ReadString();
  15. //5. Read/Assign the ClipDuration
  16. clip.Duration = binReader->Read<float>();
  17. //6. Read/Assign the TicksPerSecond
  18. clip.TicksPerSecond = binReader->Read<float>();
  19. //7. Read the KeyCount for this clip
  20. unsigned int keyCount = binReader->Read<unsigned int>();
  21. //8. For every key
  22. for (size_t i = 0; i < keyCount; i++)
  23. {
  24. //9. Create a AnimationKey object (key)
  25. AnimationKey key;
  26. //10. Read/Assign the Tick
  27. key.Tick = binReader->Read<float>();
  28. //11. Read the TransformCount
  29. unsigned int boneTransformCount = binReader->Read<unsigned int>();
  30. //12. For every transform
  31. for (size_t i = 0; i < boneTransformCount; i++)
  32. {
  33. //13. Create a XMFLOAT4X4
  34. XMFLOAT4X4 matrix;
  35. //14. The following 16 floats are the matrix values, they are stored by row
  36. // float0 = readFloat (ROW1) (_11)
  37. float float0 = binReader->Read<float>();
  38. // float1 = readFloat (ROW1) (_12)
  39. float float1 = binReader->Read<float>();
  40. // float2 = readFloat (ROW1)
  41. float float2 = binReader->Read<float>();
  42. // float3 = readFloat (ROW1)
  43. float float3 = binReader->Read<float>();
  44. // float4 = readFloat (ROW2) (_21)
  45. float float4 = binReader->Read<float>();
  46. //...
  47. float float5 = binReader->Read<float>();
  48. float float6 = binReader->Read<float>();
  49. float float7 = binReader->Read<float>();
  50. float float8 = binReader->Read<float>();
  51. float float9 = binReader->Read<float>();
  52. float float10 = binReader->Read<float>();
  53. float float11 = binReader->Read<float>();
  54. float float12 = binReader->Read<float>();
  55. float float13 = binReader->Read<float>();
  56. float float14 = binReader->Read<float>();
  57. // float15 = readFloat (ROW4) (_44)
  58. float float15 = binReader->Read<float>();
  59.  
  60. //
  61. //MATRIX:
  62. // [ float0 float1 float2 float3 ]
  63. // [ float4 ... ... ... ]
  64. // [ ... ... ... ... ]
  65. // [ ... ... ... float15]
  66. matrix =
  67. {
  68. float0,float1,float2,float3,
  69. float4,float5,float6,float7,
  70. float8,float9,float10,float11,
  71. float12,float13,float14,float15
  72. };
  73. //15. Add The matrix to the BoneTransform vector of the key
  74. key.BoneTransforms.push_back(matrix);
  75. //16. Add the key to the key vector of the clip
  76. clip.Keys.push_back(key);
  77. //17. Add the clip to the AnimationClip vector of the MeshFilter (pMesh->m_AnimationClips)
  78. pMesh->m_AnimationClips.push_back(clip);
  79. }
  80.  
  81. }
  82.  
  83. }
  84.  
  85. }
  86. break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement