// Initiates the LimbIK solver public void Initiate(Transform hand, int index) { initiated = false; if (!IsValid(true, hand)) { return; } solver = new IKSolverLimb(); solver.IKPositionWeight = weight; solver.bendModifier = IKSolverLimb.BendModifier.Target; solver.bendModifierWeight = 1f; IKPosition = tip.position; IKRotation = tip.rotation; if (bone3 != null) { bone3RelativeToTarget = Quaternion.Inverse(IKRotation) * bone3.rotation; bone3DefaultLocalPosition = bone3.localPosition; bone3DefaultLocalRotation = bone3.localRotation; } solver.SetChain(bone1, bone2, tip, hand); solver.Initiate(hand); initiated = true; }
// Initiates the LimbIK solver public void Initiate(Transform hand, int index) { initiated = false; string errorMessage = string.Empty; if (!IsValid(ref errorMessage)) { Warning.Log(errorMessage, hand, false); return; } solver = new IKSolverLimb(); solver.IKPositionWeight = weight; solver.bendModifier = IKSolverLimb.BendModifier.Target; solver.bendModifierWeight = 1f; defaultBendNormal = -Vector3.Cross(tip.position - bone1.position, bone2.position - bone1.position).normalized; solver.bendNormal = defaultBendNormal; Vector3 axisWorld = Vector3.Cross(bone2.position - bone1.position, tip.position - bone1.position); bone1Axis = Quaternion.Inverse(bone1.rotation) * axisWorld; tipAxis = Quaternion.Inverse(tip.rotation) * axisWorld; Vector3 normal = bone2.position - bone1.position; Vector3 tangent = -Vector3.Cross(tip.position - bone1.position, bone2.position - bone1.position); Vector3.OrthoNormalize(ref normal, ref tangent); bone1TwistAxis = Quaternion.Inverse(bone1.rotation) * tangent; IKPosition = tip.position; IKRotation = tip.rotation; if (bone3 != null) { bone3RelativeToTarget = Quaternion.Inverse(IKRotation) * bone3.rotation; bone3DefaultLocalPosition = bone3.localPosition; bone3DefaultLocalRotation = bone3.localRotation; } solver.SetChain(bone1, bone2, tip, hand); solver.Initiate(hand); initiated = true; }
protected override void InitiateSolver() { if (!BipedReferences.CheckSetupError(this.references, Application.isPlaying)) { return; } this.solvers.AssignReferences(this.references); if (this.solvers.spine.bones.Length > 1) { this.solvers.spine.Initiate(base.transform); } this.solvers.lookAt.Initiate(base.transform); this.solvers.aim.Initiate(base.transform); IKSolverLimb[] limbs = this.solvers.limbs; for (int i = 0; i < limbs.Length; i++) { IKSolverLimb iKSolverLimb = limbs[i]; iKSolverLimb.Initiate(base.transform); } this.solvers.pelvis.Initiate(this.references.pelvis); }
// Initiates the LimbIK solver public void Initiate(Transform hand, int index) { initiated = false; string errorMessage = string.Empty; if (!IsValid(ref errorMessage)) { Warning.Log(errorMessage, hand, false); return; } solver = new IKSolverLimb(); solver.IKPositionWeight = weight; solver.bendModifier = IKSolverLimb.BendModifier.Target; solver.bendModifierWeight = 1f; IKPosition = tip.position; IKRotation = tip.rotation; if (bone3 != null) { bone3RelativeToTarget = Quaternion.Inverse(IKRotation) * bone3.rotation; bone3DefaultLocalPosition = bone3.localPosition; bone3DefaultLocalRotation = bone3.localRotation; } solver.SetChain(bone1, bone2, tip, hand); solver.Initiate(hand); initiated = true; }