Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case MeshDataType::ANIMATIONCLIPS:
- {
- pMesh->m_HasAnimations = true;
- //Start parsing the AnimationClips
- //1. Read the clipCount
- unsigned int ClipCount = binReader->Read<unsigned int>();
- //2. For every clip
- for (size_t i = 0; i < ClipCount; i++)
- {
- //3. Create a AnimationClip object (clip)
- AnimationClip clip;
- //4. Read/Assign the ClipName
- clip.Name = binReader->ReadString();
- //5. Read/Assign the ClipDuration
- clip.Duration = binReader->Read<float>();
- //6. Read/Assign the TicksPerSecond
- clip.TicksPerSecond = binReader->Read<float>();
- //7. Read the KeyCount for this clip
- unsigned int keyCount = binReader->Read<unsigned int>();
- //8. For every key
- for (size_t i = 0; i < keyCount; i++)
- {
- //9. Create a AnimationKey object (key)
- AnimationKey key;
- //10. Read/Assign the Tick
- key.Tick = binReader->Read<float>();
- //11. Read the TransformCount
- unsigned int boneTransformCount = binReader->Read<unsigned int>();
- //12. For every transform
- for (size_t i = 0; i < boneTransformCount; i++)
- {
- //13. Create a XMFLOAT4X4
- XMFLOAT4X4 matrix;
- //14. The following 16 floats are the matrix values, they are stored by row
- // float0 = readFloat (ROW1) (_11)
- float float0 = binReader->Read<float>();
- // float1 = readFloat (ROW1) (_12)
- float float1 = binReader->Read<float>();
- // float2 = readFloat (ROW1)
- float float2 = binReader->Read<float>();
- // float3 = readFloat (ROW1)
- float float3 = binReader->Read<float>();
- // float4 = readFloat (ROW2) (_21)
- float float4 = binReader->Read<float>();
- //...
- float float5 = binReader->Read<float>();
- float float6 = binReader->Read<float>();
- float float7 = binReader->Read<float>();
- float float8 = binReader->Read<float>();
- float float9 = binReader->Read<float>();
- float float10 = binReader->Read<float>();
- float float11 = binReader->Read<float>();
- float float12 = binReader->Read<float>();
- float float13 = binReader->Read<float>();
- float float14 = binReader->Read<float>();
- // float15 = readFloat (ROW4) (_44)
- float float15 = binReader->Read<float>();
- //
- //MATRIX:
- // [ float0 float1 float2 float3 ]
- // [ float4 ... ... ... ]
- // [ ... ... ... ... ]
- // [ ... ... ... float15]
- matrix =
- {
- float0,float1,float2,float3,
- float4,float5,float6,float7,
- float8,float9,float10,float11,
- float12,float13,float14,float15
- };
- //15. Add The matrix to the BoneTransform vector of the key
- key.BoneTransforms.push_back(matrix);
- //16. Add the key to the key vector of the clip
- clip.Keys.push_back(key);
- //17. Add the clip to the AnimationClip vector of the MeshFilter (pMesh->m_AnimationClips)
- pMesh->m_AnimationClips.push_back(clip);
- }
- }
- }
- }
- break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement