void InitIKFromRig(IKRigConfig rig) { if (rig == null) { Debug.LogError("*** Cannot initialize from rig, missing rig. ***"); return; } Transform hmdTarget = hmd.transform.Find("CenterEyeAnchor/HeadIKTarget"); //Get the HeadIKTarget that we added to the OVRCameraRig. hmdTarget.transform.Rotate(rig.headIKOffset); ikLimbTorso = CreateIKLimb( "Torso", animator.GetBoneTransform(rig.torsoBaseBone), animator.GetBoneTransform(rig.torsoJointBone), animator.GetBoneTransform(rig.torsoTipBone), rig.torsoRotationPolicy, rig.torsoFalseBaseParent, rig.torsoJointParent, rig.torsoJointOffset ); ikLimbTorso.target.parent = hmdTarget; ikLimbTorso.elbowTarget.parent = animator.GetBoneTransform(rig.torsoJointParent); if (ikLimbTorso.elbowTarget.parent == null) { ikLimbTorso.elbowTarget.parent = this.transform; } ikLimbTorso.IsEnabled = true; Debug.Log("- Created Torso from Rig"); ikLimbLeftHand = CreateIKLimb( "LeftArm", animator.GetBoneTransform(rig.leftArmBaseBone), animator.GetBoneTransform(rig.leftArmJointBone), animator.GetBoneTransform(rig.leftArmTipBone), rig.leftArmRotationPolicy, rig.leftArmFalseBaseParent, rig.leftArmJointParent, rig.leftArmJointOffset ); ikLimbLeftHand.target.transform.localPosition = Vector3.zero; ikLimbLeftHand.target.transform.position += ikLimbTorso.target.transform.right * -.2f; ikLimbLeftHand.IsEnabled = true; Debug.Log("- Created LeftArm from Rig."); ikLimbRightHand = CreateIKLimb( "RightArm", animator.GetBoneTransform(rig.rightArmBaseBone), animator.GetBoneTransform(rig.rightArmJointBone), animator.GetBoneTransform(rig.rightArmTipBone), rig.rightArmRotationPolicy, rig.rightArmFalseBaseParent, rig.rightArmJointParent, rig.rightArmJointOffset ); ikLimbRightHand.target.transform.localPosition = Vector3.zero; ikLimbRightHand.target.transform.position += ikLimbTorso.target.transform.right * .2f; ikLimbRightHand.IsEnabled = true; Debug.Log("- Created RightArm from Rig."); }
void InitIKFromRig(IKRigConfig rig) { if (rig == null) { Debug.LogError ("*** Cannot initialize from rig, missing rig. ***"); return; } Transform hmdTarget = hmd.transform.Find ("CenterEyeAnchor/HeadIKTarget"); //Get the HeadIKTarget that we added to the OVRCameraRig. hmdTarget.transform.Rotate(rig.headIKOffset); ikLimbTorso = CreateIKLimb( "Torso", animator.GetBoneTransform(rig.torsoBaseBone), animator.GetBoneTransform(rig.torsoJointBone), animator.GetBoneTransform(rig.torsoTipBone), rig.torsoRotationPolicy, rig.torsoFalseBaseParent, rig.torsoJointParent, rig.torsoJointOffset ); ikLimbTorso.target.parent = hmdTarget; ikLimbTorso.elbowTarget.parent = animator.GetBoneTransform(rig.torsoJointParent); if(ikLimbTorso.elbowTarget.parent==null) ikLimbTorso.elbowTarget.parent = this.transform; ikLimbTorso.IsEnabled = true; Debug.Log ("- Created Torso from Rig"); ikLimbLeftHand = CreateIKLimb ( "LeftArm", animator.GetBoneTransform(rig.leftArmBaseBone), animator.GetBoneTransform(rig.leftArmJointBone), animator.GetBoneTransform(rig.leftArmTipBone), rig.leftArmRotationPolicy, rig.leftArmFalseBaseParent, rig.leftArmJointParent, rig.leftArmJointOffset ); ikLimbLeftHand.target.transform.localPosition = Vector3.zero; ikLimbLeftHand.target.transform.position += ikLimbTorso.target.transform.right * -.2f; ikLimbLeftHand.IsEnabled = true; Debug.Log ("- Created LeftArm from Rig."); ikLimbRightHand = CreateIKLimb ( "RightArm", animator.GetBoneTransform(rig.rightArmBaseBone), animator.GetBoneTransform(rig.rightArmJointBone), animator.GetBoneTransform(rig.rightArmTipBone), rig.rightArmRotationPolicy, rig.rightArmFalseBaseParent, rig.rightArmJointParent, rig.rightArmJointOffset ); ikLimbRightHand.target.transform.localPosition = Vector3.zero; ikLimbRightHand.target.transform.position += ikLimbTorso.target.transform.right * .2f; ikLimbRightHand.IsEnabled = true; Debug.Log ("- Created RightArm from Rig."); }