#NEWLINE# def compute( self , plug , dataBlock ) : #NEWLINE# #INDENT# "Compute the upper leg's elevation angle as well as the orientation for the first twist joint in the hip." #NEWLINE# if ( ( plug == AM_HipConstraintNode . rotate ) or ( plug == AM_HipConstraintNode . angle ) ) : #NEWLINE# #INDENT# dataHandle = dataBlock . inputValue ( AM_HipConstraintNode . rotateOrder ) #NEWLINE# eRotateOrder = dataHandle . asShort ( ) #NEWLINE# dataHandle = dataBlock . inputValue ( AM_HipConstraintNode . hipAim ) #NEWLINE# vHipForward = dataHandle . asVector ( ) . normal ( ) #NEWLINE# dataHandle = dataBlock . inputValue ( AM_HipConstraintNode . hipFront ) #NEWLINE# vHipUp = dataHandle . asVector ( ) . normal ( ) #NEWLINE# dataHandle = dataBlock . inputValue ( AM_HipConstraintNode . pelvisAim ) #NEWLINE# vPelvisForward = dataHandle . asVector ( ) . normal ( ) #NEWLINE# dataHandle = dataBlock . inputValue ( AM_HipConstraintNode . pelvisFront ) #NEWLINE# vPelvisUp = dataHandle . asVector ( ) . normal ( ) #NEWLINE# dataHandle = dataBlock . inputValue ( AM_HipConstraintNode . hipPivot ) #NEWLINE# vHipPivot = dataHandle . asVector ( ) #NEWLINE# dataHandle = dataBlock . inputValue ( AM_HipConstraintNode . pelvisPivot ) #NEWLINE# vPelvisPivot = dataHandle . asVector ( ) #NEWLINE# dataHandle = dataBlock . inputValue ( AM_HipConstraintNode . jointOrient ) #NEWLINE# vJointOrient = dataHandle . asVector ( ) #NEWLINE# eJointOrient = OM . MEulerRotation ( math . radians ( vJointOrient . x ) , math . radians ( vJointOrient . y ) , math . radians ( vJointOrient . z ) , 0 ) #NEWLINE# qJointOrient = eJointOrient . asQuaternion ( ) #NEWLINE# qJointOrient . conjugateIt ( ) #NEWLINE# dataHandle = dataBlock . inputValue ( AM_HipConstraintNode . pelvis ) #NEWLINE# mPelvis = dataHandle . asMatrix ( ) #NEWLINE# mPelvis = OM . MTransformationMatrix ( mPelvis ) #NEWLINE# qPelvis = mPelvis . rotation ( ) #NEWLINE# dataHandle = dataBlock . inputValue ( AM_HipConstraintNode . hip ) #NEWLINE# mHip = dataHandle . asMatrix ( ) #NEWLINE# mHip = OM . MTransformationMatrix ( mHip ) #NEWLINE# qHip = mHip . rotation ( ) #NEWLINE# dataHandle = dataBlock . inputValue ( AM_HipConstraintNode . parentInverseMatrix ) #NEWLINE# mParent = dataHandle . asMatrix ( ) #NEWLINE# mParent = OM . MTransformationMatrix ( mParent ) #NEWLINE# qParent = mParent . rotation ( ) #NEWLINE# vHipRight = OM . MVector ( ( vHipUp ^ vHipForward ) ) . normal ( ) #NEWLINE# vHipUp = ( vHipForward ^ vHipRight ) #NEWLINE# vPelvisRight = OM . MVector ( ( vPelvisUp ^ vPelvisForward ) ) . normal ( ) #NEWLINE# vPelvisUp = ( vPelvisForward ^ vPelvisRight ) #NEWLINE# vPelvisForwardRotated = vPelvisForward . rotateBy ( qPelvis ) #NEWLINE# vPelvisUpRotated = vPelvisUp . rotateBy ( qPelvis ) #NEWLINE# vHipForwardRotated = vHipForward . rotateBy ( qHip ) #NEWLINE# dDotPitch = ( vPelvisForwardRotated * vHipForwardRotated ) #NEWLINE# dDotYaw = ( vPelvisUpRotated * ( vHipForwardRotated - ( vPelvisForwardRotated * dDotPitch ) ) . normal ( ) ) #NEWLINE# dAngle = math . degrees ( math . acos ( min ( max ( ( - 1.0 ) , ( - dDotPitch ) ) , 1.0 ) ) ) #NEWLINE# dInterpAmt = ( ( 2.0 - ( 1.0 - dDotPitch ) ) * abs ( dDotYaw ) ) #NEWLINE# vTargetUp = vPelvisUp . rotateBy ( OM . MQuaternion ( ( ( ( cmp ( dDotYaw , 0.0 ) * dInterpAmt ) * math . pi ) * 0.5 ) , vPelvisRight ) ) #NEWLINE# vTargetUp = vTargetUp . rotateBy ( qPelvis ) #NEWLINE# vTargetRight = ( vTargetUp ^ vHipForwardRotated ) . normal ( ) #NEWLINE# vTargetUp = ( vHipForwardRotated ^ vTargetRight ) #NEWLINE# mList = [ vTargetRight . x , vTargetRight . y , vTargetRight . z , 0.0 , vTargetUp . x , vTargetUp . y , vTargetUp . z , 0.0 , vHipForwardRotated . x , vHipForwardRotated . y , vHipForwardRotated . z , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 ] #NEWLINE# mTarget = OM . MMatrix ( ) #NEWLINE# OM . MScriptUtil . createMatrixFromList ( mList , mTarget ) #NEWLINE# qTarget = OM . MQuaternion ( OM . MTransformationMatrix ( mTarget ) . rotation ( ) ) #NEWLINE# mList = [ vHipRight . x , vHipRight . y , vHipRight . z , 0.0 , vHipUp . x , vHipUp . y , vHipUp . z , 0.0 , vHipForward . x , vHipForward . y , vHipForward . z , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 ] #NEWLINE# mFromNormal = OM . MMatrix ( ) #NEWLINE# OM . MScriptUtil . createMatrixFromList ( mList , mFromNormal ) #NEWLINE# qFromNormal = OM . MQuaternion ( OM . MTransformationMatrix ( mFromNormal ) . rotation ( ) ) #NEWLINE# if ( qFromNormal . w > 0.0 ) : #NEWLINE# #INDENT# qFromNormal . invertIt ( ) #NEWLINE# #UNINDENT# qFinal = OM . MQuaternion ( ( ( ( qFromNormal * qTarget ) * qParent ) * qJointOrient ) ) #NEWLINE# eFinal = qFinal . asEulerRotation ( ) #NEWLINE# eFinal . reorderIt ( eRotateOrder ) #NEWLINE# outputHandle = dataBlock . outputValue ( AM_HipConstraintNode . rotate ) #NEWLINE# outputHandle . set3Double ( math . degrees ( eFinal . x ) , math . degrees ( eFinal . y ) , math . degrees ( eFinal . z ) ) #NEWLINE# outputHandle = dataBlock . outputValue ( AM_HipConstraintNode . angle ) #NEWLINE# outputHandle . setDouble ( dAngle ) #NEWLINE# dataBlock . setClean ( plug ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return OM . kUnknownParameter