Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; This function gets passed XYZ Euler angles values of Havok bone and Anim bone
- Begin Function {fHavokRotX, fHavokRotY, fHavokRotZ, fAnimRotX, fAnimRotY, fAnimRotZ}
- ;******* H A V O K **********************************
- ; Convert Euler angles to quaternions
- QFromEuler fHavokNodeQuatW fHavokNodeQuatX fHavokNodeQuatY fHavokNodeQuatZ fHavokRotX fHavokRotY fHavokRotZ
- ; Store quaternions into array
- arHavokNodeQuat = Ar_List fHavokNodeQuatW, fHavokNodeQuatX, fHavokNodeQuatY, fHavokNodeQuatZ
- ; Make matrix out of array from above
- arHavokNodeMatrix = Quaternion_GetMatrix arHavokNodeQuat
- ;***********************************************************
- ;******* A N I M *************************************
- ; Convert Euler angles to quaternions
- QFromEuler fAnimNodeQuatW fAnimNodeQuatX fAnimNodeQuatY fAnimNodeQuatZ fAnimRotX fAnimRotY fAnimRotZ
- ; Invert Anim quaternions
- fAnimNodeQuatX *= -1
- fAnimNodeQuatY *= -1
- fAnimNodeQuatZ *= -1
- ; Store quaternions into array
- arAnimNodeQuat = Ar_List fAnimNodeQuatW, fAnimNodeQuatX, fAnimNodeQuatY, fAnimNodeQuatZ
- ; Make matrix out of array from above
- arAnimNodeMatrix = Quaternion_GetMatrix arAnimNodeQuat
- ;**********************************************************
- ; Multiply havok matrix and anim matrix to get the difference between havok rotation and anim rotation
- arMatrixMultResult = Matrix_ApplyOperationWithMatrix arHavokNodeMatrix "*" arAnimNodeMatrix
- ; Convert resulting matrix into quaternion
- arMatrixQuat = Matrix3x3_GetQuaternion arMatrixMultResult
- ; Convert quaternions back to euler angles
- QToEuler fAngVelX fAngVelY fAngVelZ (arMatrixQuat[0]) (arMatrixQuat[1]) (arMatrixQuat[2]) (arMatrixQuat[3])
- ; Store everything into array since UDFs can only return single value
- arAngVelValues = Ar_List fAngVelX, fAngVelY, fAngVelZ
- ; UDF will return this array
- SetFunctionValue arAngVelValues
- End
Advertisement
Add Comment
Please, Sign In to add comment