private static GetLeftClavicle ( BipedReferences references ) : |
||
references | BipedReferences | |
return |
public void SetToReferences(BipedReferences references, Transform rootNode = null) { this.root = references.root; if (rootNode == null) { rootNode = IKSolverFullBodyBiped.DetectRootNodeBone(references); } this.rootNode = rootNode; if (this.chain == null || this.chain.Length != 5) { this.chain = new FBIKChain[5]; } for (int i = 0; i < this.chain.Length; i++) { if (this.chain[i] == null) { this.chain[i] = new FBIKChain(); } } this.chain[0].pin = 0f; this.chain[0].SetNodes(new Transform[] { rootNode }); this.chain[0].children = new int[] { 1, 2, 3, 4 }; this.chain[1].SetNodes(new Transform[] { references.leftUpperArm, references.leftForearm, references.leftHand }); this.chain[2].SetNodes(new Transform[] { references.rightUpperArm, references.rightForearm, references.rightHand }); this.chain[3].SetNodes(new Transform[] { references.leftThigh, references.leftCalf, references.leftFoot }); this.chain[4].SetNodes(new Transform[] { references.rightThigh, references.rightCalf, references.rightFoot }); if (this.effectors.Length != 9) { this.effectors = new IKEffector[] { new IKEffector(), new IKEffector(), new IKEffector(), new IKEffector(), new IKEffector(), new IKEffector(), new IKEffector(), new IKEffector(), new IKEffector() }; } this.effectors[0].bone = rootNode; this.effectors[0].childBones = new Transform[] { references.leftThigh, references.rightThigh }; this.effectors[1].bone = references.leftUpperArm; this.effectors[2].bone = references.rightUpperArm; this.effectors[3].bone = references.leftThigh; this.effectors[4].bone = references.rightThigh; this.effectors[5].bone = references.leftHand; this.effectors[6].bone = references.rightHand; this.effectors[7].bone = references.leftFoot; this.effectors[8].bone = references.rightFoot; this.effectors[5].planeBone1 = references.leftUpperArm; this.effectors[5].planeBone2 = references.rightUpperArm; this.effectors[5].planeBone3 = rootNode; this.effectors[6].planeBone1 = references.rightUpperArm; this.effectors[6].planeBone2 = references.leftUpperArm; this.effectors[6].planeBone3 = rootNode; this.effectors[7].planeBone1 = references.leftThigh; this.effectors[7].planeBone2 = references.rightThigh; this.effectors[7].planeBone3 = rootNode; this.effectors[8].planeBone1 = references.rightThigh; this.effectors[8].planeBone2 = references.leftThigh; this.effectors[8].planeBone3 = rootNode; this.chain[0].childConstraints = new FBIKChain.ChildConstraint[] { new FBIKChain.ChildConstraint(references.leftUpperArm, references.rightThigh, 0f, 1f), new FBIKChain.ChildConstraint(references.rightUpperArm, references.leftThigh, 0f, 1f), new FBIKChain.ChildConstraint(references.leftUpperArm, references.rightUpperArm, 0f, 0f), new FBIKChain.ChildConstraint(references.leftThigh, references.rightThigh, 0f, 0f) }; Transform[] array = new Transform[references.spine.Length + 1]; array[0] = references.pelvis; for (int j = 0; j < references.spine.Length; j++) { array[j + 1] = references.spine[j]; } if (this.spineMapping == null) { this.spineMapping = new IKMappingSpine(); this.spineMapping.iterations = 3; } this.spineMapping.SetBones(array, references.leftUpperArm, references.rightUpperArm, references.leftThigh, references.rightThigh); int num = (!(references.head != null)) ? 0 : 1; if (this.boneMappings.Length != num) { this.boneMappings = new IKMappingBone[num]; for (int k = 0; k < this.boneMappings.Length; k++) { this.boneMappings[k] = new IKMappingBone(); } if (num == 1) { this.boneMappings[0].maintainRotationWeight = 0f; } } if (this.boneMappings.Length > 0) { this.boneMappings[0].bone = references.head; } if (this.limbMappings.Length != 4) { this.limbMappings = new IKMappingLimb[] { new IKMappingLimb(), new IKMappingLimb(), new IKMappingLimb(), new IKMappingLimb() }; this.limbMappings[2].maintainRotationWeight = 1f; this.limbMappings[3].maintainRotationWeight = 1f; } this.limbMappings[0].SetBones(references.leftUpperArm, references.leftForearm, references.leftHand, IKSolverFullBodyBiped.GetLeftClavicle(references)); this.limbMappings[1].SetBones(references.rightUpperArm, references.rightForearm, references.rightHand, IKSolverFullBodyBiped.GetRightClavicle(references)); this.limbMappings[2].SetBones(references.leftThigh, references.leftCalf, references.leftFoot, null); this.limbMappings[3].SetBones(references.rightThigh, references.rightCalf, references.rightFoot, null); if (Application.isPlaying) { base.Initiate(references.root); } }