Guest User

Untitled

a guest
May 6th, 2025
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. ; This function gets passed XYZ Euler angles values of Havok bone and Anim bone
  2. Begin Function {fHavokRotX, fHavokRotY, fHavokRotZ, fAnimRotX, fAnimRotY, fAnimRotZ}
  3.  
  4. ;******* H A V O K **********************************
  5. ; Convert Euler angles to quaternions
  6. QFromEuler fHavokNodeQuatW fHavokNodeQuatX fHavokNodeQuatY fHavokNodeQuatZ fHavokRotX fHavokRotY fHavokRotZ
  7.  
  8. ; Store quaternions into array
  9. arHavokNodeQuat = Ar_List fHavokNodeQuatW, fHavokNodeQuatX, fHavokNodeQuatY, fHavokNodeQuatZ
  10.  
  11. ; Make matrix out of array from above
  12. arHavokNodeMatrix = Quaternion_GetMatrix arHavokNodeQuat
  13. ;***********************************************************
  14.  
  15.  
  16. ;******* A N I M *************************************
  17. ; Convert Euler angles to quaternions
  18. QFromEuler fAnimNodeQuatW fAnimNodeQuatX fAnimNodeQuatY fAnimNodeQuatZ fAnimRotX fAnimRotY fAnimRotZ
  19.  
  20. ; Invert Anim quaternions
  21. fAnimNodeQuatX *= -1
  22. fAnimNodeQuatY *= -1
  23. fAnimNodeQuatZ *= -1
  24.  
  25. ; Store quaternions into array
  26. arAnimNodeQuat = Ar_List fAnimNodeQuatW, fAnimNodeQuatX, fAnimNodeQuatY, fAnimNodeQuatZ
  27.  
  28. ; Make matrix out of array from above
  29. arAnimNodeMatrix = Quaternion_GetMatrix arAnimNodeQuat
  30. ;**********************************************************
  31.  
  32. ; Multiply havok matrix and anim matrix to get the difference between havok rotation and anim rotation
  33. arMatrixMultResult = Matrix_ApplyOperationWithMatrix arHavokNodeMatrix "*" arAnimNodeMatrix
  34.  
  35. ; Convert resulting matrix into quaternion
  36. arMatrixQuat = Matrix3x3_GetQuaternion arMatrixMultResult
  37.  
  38. ; Convert quaternions back to euler angles
  39. QToEuler fAngVelX fAngVelY fAngVelZ (arMatrixQuat[0]) (arMatrixQuat[1]) (arMatrixQuat[2]) (arMatrixQuat[3])
  40.  
  41. ; Store everything into array since UDFs can only return single value
  42. arAngVelValues = Ar_List fAngVelX, fAngVelY, fAngVelZ
  43.  
  44. ; UDF will return this array
  45. SetFunctionValue arAngVelValues
  46. End
Advertisement
Add Comment
Please, Sign In to add comment