Advertisement
baryonSasuke

Current frame joint transformations calculation

Dec 31st, 2020
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. public List<Matrix> slerpBetweenFrames(AnimationFrame frame1, AnimationFrame frame2, List<Matrix> jointUnbindMatrices,
  2. float inter, int numJoints) {
  3.  
  4. // Currently does not take joint scaling into account because I did not have to worry about that while building the MD5anim
  5. // loader, but I doubt that is the cause here.
  6.  
  7. List<Matrix> results = new ArrayList<>(numJoints);
  8. for(int i = 0;i < numJoints;i++) {
  9. var joint1 = frame1.joints.get(i);
  10. var joint2 = frame2.joints.get(i);
  11.  
  12. var int_pos = joint1.pos.add(joint2.pos.sub(joint1.pos).scalarMul(inter));
  13. var int_orient = Quaternion.slerp(joint1.orient, joint2.orient, inter);
  14.  
  15. var localMat = int_orient.getRotationMatrix().addColumn(int_pos).addRow(new Vector(0,0,0,1));
  16. Matrix jointMat;
  17. if(jointUnbindMatrices != null) {
  18. jointMat = localMat.matMul(jointUnbindMatrices.get(i));
  19. }
  20. else {
  21. jointMat = localMat;
  22. }
  23. results.add(jointMat);
  24. // results.add(Matrix.getIdentityMatrix(4));
  25. }
  26. return results;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement