public Vector3 GetBendGoalPosition(FullBodyBipedChain type, bool world = true) { OCIChar.IKInfo info = this._target.ociChar.listIKTarget[_chainToIndex[type]]; if (!this._target.ikEnabled || info.active == false) { return(Vector3.zero); } return(world ? info.guideObject.transformTarget.position : info.guideObject.transformTarget.localPosition); }
private void SetLimbOrientation(FullBodyBipedChain chain, BipedLimbOrientations.LimbOrientation limbOrientation) { if (chain == FullBodyBipedChain.LeftArm || chain == FullBodyBipedChain.RightArm) { this.GetBendConstraint(chain).SetLimbOrientation(-limbOrientation.upperBoneForwardAxis, -limbOrientation.lowerBoneForwardAxis, -limbOrientation.lastBoneLeftAxis); this.GetLimbMapping(chain).SetLimbOrientation(-limbOrientation.upperBoneForwardAxis, -limbOrientation.lowerBoneForwardAxis); return; } this.GetBendConstraint(chain).SetLimbOrientation(limbOrientation.upperBoneForwardAxis, limbOrientation.lowerBoneForwardAxis, limbOrientation.lastBoneLeftAxis); this.GetLimbMapping(chain).SetLimbOrientation(limbOrientation.upperBoneForwardAxis, limbOrientation.lowerBoneForwardAxis); }
private void RotateShoulder(FullBodyBipedChain chain, float weight, float offset) { Quaternion b = Quaternion.FromToRotation(this.GetParentBoneMap(chain).swingDirection, this.ik.solver.GetEndEffector(chain).position - this.GetParentBoneMap(chain).transform.position); Vector3 vector = this.ik.solver.GetEndEffector(chain).position - this.ik.solver.GetLimbMapping(chain).bone1.position; float num = this.ik.solver.GetChain(chain).nodes[0].length + this.ik.solver.GetChain(chain).nodes[1].length; float num2 = vector.magnitude / num - 1f + offset; num2 = Mathf.Clamp(num2 * weight, 0f, 1f); Quaternion lhs = Quaternion.Lerp(Quaternion.identity, b, num2 * this.ik.solver.GetEndEffector(chain).positionWeight *this.ik.solver.IKPositionWeight); this.ik.solver.GetLimbMapping(chain).parentBone.rotation = lhs * this.ik.solver.GetLimbMapping(chain).parentBone.rotation; }
/// <summary> /// Gets the bend constraint of a limb. /// </summary> public IKConstraintBend GetBendConstraint(FullBodyBipedChain limb) { switch (limb) { case FullBodyBipedChain.LeftArm: return(chain[1].bendConstraint); case FullBodyBipedChain.RightArm: return(chain[2].bendConstraint); case FullBodyBipedChain.LeftLeg: return(chain[3].bendConstraint); case FullBodyBipedChain.RightLeg: return(chain[4].bendConstraint); } return(null); }
private static int GetEndEffectorIndex(FullBodyBipedChain chainType) { switch (chainType) { case FullBodyBipedChain.LeftArm: return(5); case FullBodyBipedChain.RightArm: return(6); case FullBodyBipedChain.LeftLeg: return(7); case FullBodyBipedChain.RightLeg: return(8); } return(0); }
private static int GetStartEffectorIndex(FullBodyBipedChain chainType) { switch (chainType) { case FullBodyBipedChain.LeftArm: return(1); case FullBodyBipedChain.RightArm: return(2); case FullBodyBipedChain.LeftLeg: return(3); case FullBodyBipedChain.RightLeg: return(4); } return(0); }
/// <summary> /// Gets the chain of a limb. /// </summary> public FBIKChain GetChain(FullBodyBipedChain c) { switch (c) { case FullBodyBipedChain.LeftArm: return(chain.children[0]); case FullBodyBipedChain.RightArm: return(chain.children[1]); case FullBodyBipedChain.LeftLeg: return(chain.children[2]); case FullBodyBipedChain.RightLeg: return(chain.children[3]); } return(null); }
/// <summary> /// Gets the limb mapping for the limb. /// </summary> public IKMappingLimb GetLimbMapping(FullBodyBipedChain chain) { switch (chain) { case FullBodyBipedChain.LeftArm: return(limbMappings[0]); case FullBodyBipedChain.RightArm: return(limbMappings[1]); case FullBodyBipedChain.LeftLeg: return(limbMappings[2]); case FullBodyBipedChain.RightLeg: return(limbMappings[3]); } return(null); }
/// <summary> /// Gets the effector of type. /// </summary> public IKEffector GetEndEffector(FullBodyBipedChain c) { switch (c) { case FullBodyBipedChain.LeftArm: return(effectors[5]); case FullBodyBipedChain.RightArm: return(effectors[6]); case FullBodyBipedChain.LeftLeg: return(effectors[7]); case FullBodyBipedChain.RightLeg: return(effectors[8]); } return(null); }
/// <summary> /// Gets the bend constraint of a limb. /// </summary> public IKConstraintBend GetBendConstraint(FullBodyBipedChain chain) { switch (chain) { case FullBodyBipedChain.LeftArm: return(bendConstraints[0]); case FullBodyBipedChain.RightArm: return(bendConstraints[1]); case FullBodyBipedChain.LeftLeg: return(bendConstraints[2]); case FullBodyBipedChain.RightLeg: return(bendConstraints[3]); } return(null); }
private static int GetLimbMappingIndex(FullBodyBipedChain chainType) { switch (chainType) { case FullBodyBipedChain.LeftArm: return(0); case FullBodyBipedChain.RightArm: return(1); case FullBodyBipedChain.LeftLeg: return(2); case FullBodyBipedChain.RightLeg: return(3); } return(0); }
private static string GetStartEffectorName(FullBodyBipedChain chain) { switch (chain) { case FullBodyBipedChain.LeftArm: return("Left Shoulder Effector"); case FullBodyBipedChain.RightArm: return("Right Shoulder Effector"); case FullBodyBipedChain.LeftLeg: return("Left Thigh Effector"); case FullBodyBipedChain.RightLeg: return("Right Thigh Effector"); default: return(string.Empty); } }
private static string GetEndBoneMappingName(FullBodyBipedChain chain) { switch (chain) { case FullBodyBipedChain.LeftArm: return("Maintain Hand Rot"); case FullBodyBipedChain.RightArm: return("Maintain Hand Rot"); case FullBodyBipedChain.LeftLeg: return("Maintain Foot Rot"); case FullBodyBipedChain.RightLeg: return("Maintain Foot Rot"); default: return(string.Empty); } }
public void SetBendGoalPosition(FullBodyBipedChain type, Vector3 targetPosition, bool world = true) { OCIChar.IKInfo info = this._target.ociChar.listIKTarget[_chainToIndex[type]]; if (this._target.ikEnabled && info.active) { if (this._currentDragType != DragType.None) { if (this._oldPosValues.ContainsKey(info.guideObject.dicKey) == false) { this._oldPosValues.Add(info.guideObject.dicKey, info.guideObject.changeAmount.pos); } info.guideObject.changeAmount.pos = world ? info.guideObject.transformTarget.parent.InverseTransformPoint(targetPosition) : targetPosition; } } }
/* * Sets the bend direction of a limb to the local axes specified by the LimbOrientation. * */ private void SetLimbOrientation(FullBodyBipedChain chain, BipedLimbOrientations.LimbOrientation limbOrientation) { bool inverse = chain == FullBodyBipedChain.LeftArm || chain == FullBodyBipedChain.RightArm; if (inverse) { GetBendConstraint(chain).SetLimbOrientation(-limbOrientation.upperBoneForwardAxis, -limbOrientation.lowerBoneForwardAxis, -limbOrientation.lastBoneLeftAxis); GetLimbMapping(chain).SetLimbOrientation(-limbOrientation.upperBoneForwardAxis, -limbOrientation.lowerBoneForwardAxis); } else { GetBendConstraint(chain).SetLimbOrientation(limbOrientation.upperBoneForwardAxis, limbOrientation.lowerBoneForwardAxis, limbOrientation.lastBoneLeftAxis); GetLimbMapping(chain).SetLimbOrientation(limbOrientation.upperBoneForwardAxis, limbOrientation.lowerBoneForwardAxis); } }
private static string GetEndEffectorName(FullBodyBipedChain chain) { switch (chain) { case FullBodyBipedChain.LeftArm: return("Left Hand Effector"); case FullBodyBipedChain.RightArm: return("Right Hand Effector"); case FullBodyBipedChain.LeftLeg: return("Left Foot Effector"); case FullBodyBipedChain.RightLeg: return("Right Foot Effector"); default: return(string.Empty); } }
private FullBodyBipedChain GetTwinChain(FullBodyBipedChain chain) { switch (chain) { case FullBodyBipedChain.LeftArm: return(FullBodyBipedChain.RightArm); case FullBodyBipedChain.RightArm: return(FullBodyBipedChain.LeftArm); case FullBodyBipedChain.LeftLeg: return(FullBodyBipedChain.RightLeg); case FullBodyBipedChain.RightLeg: return(FullBodyBipedChain.LeftLeg); } return(chain); }
public FBIKChain GetChain(FullBodyBipedChain c) { switch (c) { case FullBodyBipedChain.LeftArm: return(this.chain[1]); case FullBodyBipedChain.RightArm: return(this.chain[2]); case FullBodyBipedChain.LeftLeg: return(this.chain[3]); case FullBodyBipedChain.RightLeg: return(this.chain[4]); default: return(null); } }
// Rotates a shoulder of a FBBIK character private void RotateShoulder(FullBodyBipedChain chain, float weight, float offset) { // Get FromToRotation from the current swing direction of the shoulder to the IK target direction Quaternion fromTo = Quaternion.FromToRotation(GetParentBoneMap(chain).swingDirection, ik.solver.GetEndEffector(chain).position - GetParentBoneMap(chain).transform.position); // Direction to the IK target Vector3 toTarget = ik.solver.GetEndEffector(chain).position - ik.solver.GetLimbMapping(chain).bone1.position; // Length of the limb float limbLength = ik.solver.GetChain(chain).nodes[0].length + ik.solver.GetChain(chain).nodes[1].length; // Divide IK Target direction magnitude by limb length to know how much the limb is being pulled float delta = (toTarget.magnitude / limbLength) - 1f + offset; delta = Mathf.Clamp(delta * weight, 0f, 1f); // Calculate the rotation offset for the shoulder Quaternion rotationOffset = Quaternion.Lerp(Quaternion.identity, fromTo, delta * ik.solver.GetEndEffector(chain).positionWeight * ik.solver.IKPositionWeight); // Rotate the shoulder ik.solver.GetLimbMapping(chain).parentBone.rotation = rotationOffset * ik.solver.GetLimbMapping(chain).parentBone.rotation; }
// Rotates a shoulder of a FBBIK character private void RotateShoulder(FullBodyBipedChain chain, float weight, float offset) { // Get FromToRotation from the current swing direction of the shoulder to the IK target direction Quaternion fromTo = Quaternion.FromToRotation(GetParentBoneMap(chain).swingDirection, ik.solver.GetEndEffector(chain).position - GetParentBoneMap(chain).transform.position); // Direction to the IK target Vector3 toTarget = ik.solver.GetEndEffector(chain).position - ik.solver.GetLimbMapping(chain).bone1.position; // Length of the limb float limbLength = ik.solver.GetChain(chain).nodes[0].length + ik.solver.GetChain(chain).nodes[1].length; // Divide IK Target direction magnitude by limb length to know how much the limb is being pulled float delta = (toTarget.magnitude / limbLength) - 1f + offset; delta = Mathf.Clamp(delta * weight, 0f, 1f); // Calculate the rotation offset for the shoulder Quaternion rotationOffset = Quaternion.Lerp(Quaternion.identity, fromTo, delta * ik.solver.GetEndEffector(chain).positionWeight); // Rotate the shoulder ik.solver.GetLimbMapping(chain).parentBone.rotation = rotationOffset * ik.solver.GetLimbMapping(chain).parentBone.rotation; }
/// <summary> /// Gets the bend constraint of a limb. /// </summary> public IKConstraintBend GetBendConstraint(FullBodyBipedChain chain) { switch(chain) { case FullBodyBipedChain.LeftArm: return bendConstraints[0]; case FullBodyBipedChain.RightArm: return bendConstraints[1]; case FullBodyBipedChain.LeftLeg: return bendConstraints[2]; case FullBodyBipedChain.RightLeg: return bendConstraints[3]; } return null; }
public float weight = 1.5f; // Weight of shoulder rotation #endregion Fields #region Methods // Get the shoulder BoneMap private IKMapping.BoneMap GetParentBoneMap(FullBodyBipedChain chain) { return ik.solver.GetLimbMapping(chain).GetBoneMap(IKMappingLimb.BoneMapType.Parent); }
private void SwapPoseInternal() { this.StartDrag(DragType.Both); this._lockDrag = true; this._additionalRotationEqualsCommands = new List <GuideCommand.EqualsInfo>(); HashSet <Transform> done = new HashSet <Transform>(); foreach (OCIChar.BoneInfo bone in this._target.ociChar.listBones) { Transform twinBoneTransform = null; Transform boneTransform = bone.guideObject.transformTarget; switch (bone.boneGroup) { case OIBoneInfo.BoneGroup.Hair: continue; case OIBoneInfo.BoneGroup.Skirt: twinBoneTransform = this.GetSkirtTwinBone(boneTransform); break; case OIBoneInfo.BoneGroup.Neck: case OIBoneInfo.BoneGroup.Body: case OIBoneInfo.BoneGroup.Breast: case OIBoneInfo.BoneGroup.RightLeg: case OIBoneInfo.BoneGroup.LeftLeg: case OIBoneInfo.BoneGroup.RightArm: case OIBoneInfo.BoneGroup.LeftArm: case OIBoneInfo.BoneGroup.RightHand: case OIBoneInfo.BoneGroup.LeftHand: default: twinBoneTransform = this._bonesEditor.GetTwinBone(boneTransform); if (twinBoneTransform == null) { twinBoneTransform = boneTransform; } break; } OCIChar.BoneInfo twinBone; if (twinBoneTransform != null && this._target.fkObjects.TryGetValue(twinBoneTransform.gameObject, out twinBone)) { if (done.Contains(boneTransform) || done.Contains(twinBoneTransform)) { continue; } done.Add(boneTransform); if (twinBoneTransform != boneTransform) { done.Add(twinBoneTransform); } if (twinBoneTransform == boneTransform) { Quaternion rot = Quaternion.Euler(bone.guideObject.changeAmount.rot); rot = new Quaternion(rot.x, -rot.y, -rot.z, rot.w); Vector3 oldRotValue = bone.guideObject.changeAmount.rot; bone.guideObject.changeAmount.rot = rot.eulerAngles; this._additionalRotationEqualsCommands.Add(new GuideCommand.EqualsInfo() { dicKey = bone.guideObject.dicKey, oldValue = oldRotValue, newValue = bone.guideObject.changeAmount.rot }); } else { Quaternion rot = Quaternion.Euler(bone.guideObject.changeAmount.rot); rot = new Quaternion(rot.x, -rot.y, -rot.z, rot.w); Quaternion twinRot = Quaternion.Euler(twinBone.guideObject.changeAmount.rot); twinRot = new Quaternion(twinRot.x, -twinRot.y, -twinRot.z, twinRot.w); Vector3 oldRotValue = bone.guideObject.changeAmount.rot; Vector3 oldTwinRotValue = twinBone.guideObject.changeAmount.rot; bone.guideObject.changeAmount.rot = twinRot.eulerAngles; twinBone.guideObject.changeAmount.rot = rot.eulerAngles; this._additionalRotationEqualsCommands.Add(new GuideCommand.EqualsInfo() { dicKey = bone.guideObject.dicKey, oldValue = oldRotValue, newValue = bone.guideObject.changeAmount.rot }); this._additionalRotationEqualsCommands.Add(new GuideCommand.EqualsInfo() { dicKey = twinBone.guideObject.dicKey, oldValue = oldTwinRotValue, newValue = twinBone.guideObject.changeAmount.rot }); } } } foreach (KeyValuePair <FullBodyBipedEffector, int> pair in _effectorToIndex) { switch (pair.Key) { case FullBodyBipedEffector.Body: case FullBodyBipedEffector.LeftShoulder: case FullBodyBipedEffector.LeftHand: case FullBodyBipedEffector.LeftThigh: case FullBodyBipedEffector.LeftFoot: FullBodyBipedEffector twin = this.GetTwinEffector(pair.Key); Vector3 position = this._target.ociChar.listIKTarget[pair.Value].guideObject.transformTarget.localPosition; position.x *= -1f; Vector3 twinPosition = this._target.ociChar.listIKTarget[_effectorToIndex[twin]].guideObject.transformTarget.localPosition; twinPosition.x *= -1f; this.SetBoneTargetPosition(pair.Key, twinPosition, false); this.SetBoneTargetPosition(twin, position, false); break; } } foreach (KeyValuePair <FullBodyBipedChain, int> pair in _chainToIndex) { switch (pair.Key) { case FullBodyBipedChain.LeftArm: case FullBodyBipedChain.LeftLeg: FullBodyBipedChain twin = this.GetTwinChain(pair.Key); Vector3 position = this._target.ociChar.listIKTarget[pair.Value].guideObject.transformTarget.localPosition; position.x *= -1f; Vector3 twinPosition = this._target.ociChar.listIKTarget[_chainToIndex[twin]].guideObject.transformTarget.localPosition; twinPosition.x *= -1f; this.SetBendGoalPosition(pair.Key, twinPosition, false); this.SetBendGoalPosition(twin, position, false); break; } } this._scheduleNextIKPostUpdate = () => { foreach (KeyValuePair <FullBodyBipedEffector, int> pair in _effectorToIndex) { switch (pair.Key) { case FullBodyBipedEffector.LeftHand: case FullBodyBipedEffector.LeftFoot: FullBodyBipedEffector twin = this.GetTwinEffector(pair.Key); Quaternion rot = this._target.ociChar.listIKTarget[pair.Value].guideObject.transformTarget.localRotation; rot = new Quaternion(-rot.x, rot.y, rot.z, -rot.w); Quaternion twinRot = this._target.ociChar.listIKTarget[_effectorToIndex[twin]].guideObject.transformTarget.localRotation; twinRot = new Quaternion(-twinRot.x, twinRot.y, twinRot.z, -twinRot.w); this.SetBoneTargetRotation(pair.Key, twinRot); this.SetBoneTargetRotation(twin, rot); break; } } this._lockDrag = false; this.StopDrag(); }; }
private static int GetEndEffectorIndex(FullBodyBipedChain chainType) { switch(chainType) { case FullBodyBipedChain.LeftArm: return 5; case FullBodyBipedChain.RightArm: return 6; case FullBodyBipedChain.LeftLeg: return 7; case FullBodyBipedChain.RightLeg: return 8; } return 0; }
private static string GetStartEffectorName(FullBodyBipedChain chain) { switch(chain) { case FullBodyBipedChain.LeftArm: return "Left Shoulder Effector"; case FullBodyBipedChain.RightArm: return "Right Shoulder Effector"; case FullBodyBipedChain.LeftLeg: return "Left Thigh Effector"; case FullBodyBipedChain.RightLeg: return "Right Thigh Effector"; default: return string.Empty; } }
private static void AddLimb(SerializedProperty prop, SerializedProperty chain, FullBodyBipedChain chainType, GUIContent guiContent) { EditorGUILayout.PropertyField(chain, guiContent, false); GUILayout.BeginHorizontal(); GUILayout.Space(10); GUILayout.BeginVertical(); if (chain.isExpanded) { var effectors = prop.FindPropertyRelative("effectors"); var endEffector = effectors.GetArrayElementAtIndex(GetEndEffectorIndex(chainType)); var startEffector = effectors.GetArrayElementAtIndex(GetStartEffectorIndex(chainType)); var mapping = prop.FindPropertyRelative("limbMappings").GetArrayElementAtIndex(GetLimbMappingIndex(chainType)); GUILayout.BeginVertical(style); DrawLabel(GetEndEffectorName(chainType), endEffectorIcon); AddProperty(endEffector.FindPropertyRelative("target"), new GUIContent("Target", "Target Transform (optional, you can also use IKEffector.position and IKEffector.rotation directly).")); AddProperty(endEffector.FindPropertyRelative("positionWeight"), new GUIContent("Position Weight", "The weight of pinning the effector bone to the effector position.")); AddProperty(endEffector.FindPropertyRelative("rotationWeight"), new GUIContent("Rotation Weight", "The weight of pinning the effector bone to the effector rotation.")); AddProperty(endEffector.FindPropertyRelative("maintainRelativePositionWeight"), new GUIContent("Maintain Relative Pos", "Maintains the position of the hand/foot fixed relative to the chest/hips while effector positionWeight is not weighed in.")); DrawLabel(GetStartEffectorName(chainType), startEffectorIcon); AddProperty(startEffector.FindPropertyRelative("target"), new GUIContent("Target", "Target Transform (optional, you can also use IKEffector.position and IKEffector.rotation directly).")); AddProperty(startEffector.FindPropertyRelative("positionWeight"), new GUIContent("Position Weight", "The weight of pinning the effector bone to the effector position.")); DrawLabel("Chain", null); AddProperty(chain.FindPropertyRelative("pull"), new GUIContent("Pull", "The weight of pulling other chains.")); AddProperty(chain.FindPropertyRelative("reach"), new GUIContent("Reach", "Pulls the first node closer to the last node of the chain.")); AddProperty(chain.FindPropertyRelative("push"), new GUIContent("Push", "The weight of the end-effector pushing the first node.")); AddProperty(chain.FindPropertyRelative("pushParent"), new GUIContent("Push Parent", "The amount of push force transferred to the parent (from hand or foot to the body).")); AddProperty(chain.FindPropertyRelative("reachSmoothing"), new GUIContent("Reach Smoothing", "Smoothing the effect of the Reach with the expense of some accuracy.")); AddProperty(chain.FindPropertyRelative("pushSmoothing"), new GUIContent("Push Smoothing", "Smoothing the effect of the Push.")); AddProperty(chain.FindPropertyRelative("bendConstraint").FindPropertyRelative("bendGoal"), new GUIContent("Bend Goal", "The Transform to bend towards (optional, you can also use ik.leftArmChain.bendConstraint.direction).")); AddProperty(chain.FindPropertyRelative("bendConstraint").FindPropertyRelative("weight"), new GUIContent("Bend Goal Weight", "The weight of to bending towards the Bend Goal (optional, you can also use ik.leftArmChain.bendConstraint.weight).")); DrawLabel("Mapping", null); AddProperty(mapping.FindPropertyRelative("weight"), new GUIContent("Mapping Weight", "The weight of mapping the limb to it's IK pose. This can be useful if you want to disable the effect of IK for the limb.")); AddProperty(mapping.FindPropertyRelative("maintainRotationWeight"), new GUIContent(GetEndBoneMappingName(chainType), "The weight of maintaining the bone's animated rotation in world space.")); GUILayout.Space(5); GUILayout.EndVertical(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); }
} // 0x00000001807F09A0-0x00000001807F0F30 private IKMapping.BoneMap GetParentBoneMap(FullBodyBipedChain chain) => default; // 0x00000001807F0850-0x00000001807F0890
/// <summary> /// Gets the limb mapping for the limb. /// </summary> public IKMappingLimb GetLimbMapping(FullBodyBipedChain chain) { switch(chain) { case FullBodyBipedChain.LeftArm: return limbMappings[0]; case FullBodyBipedChain.RightArm: return limbMappings[1]; case FullBodyBipedChain.LeftLeg: return limbMappings[2]; case FullBodyBipedChain.RightLeg: return limbMappings[3]; } return null; }
/// <summary> /// Gets the effector of type. /// </summary> public IKEffector GetEndEffector(FullBodyBipedChain c) { switch(c) { case FullBodyBipedChain.LeftArm: return effectors[5]; case FullBodyBipedChain.RightArm: return effectors[6]; case FullBodyBipedChain.LeftLeg: return effectors[7]; case FullBodyBipedChain.RightLeg: return effectors[8]; } return null; }
private static FullBodyBipedEffector GetStartEffector(FullBodyBipedChain chain) { switch(chain) { case FullBodyBipedChain.LeftArm: return FullBodyBipedEffector.LeftShoulder; case FullBodyBipedChain.RightArm: return FullBodyBipedEffector.RightShoulder; case FullBodyBipedChain.LeftLeg: return FullBodyBipedEffector.LeftThigh; default: return FullBodyBipedEffector.RightThigh; } }
private static int GetLimbMappingIndex(FullBodyBipedChain chainType) { switch(chainType) { case FullBodyBipedChain.LeftArm: return 0; case FullBodyBipedChain.RightArm: return 1; case FullBodyBipedChain.LeftLeg: return 2; case FullBodyBipedChain.RightLeg: return 3; } return 0; }
public void CopyLimbToTwin(FullBodyBipedChain ikLimb, OIBoneInfo.BoneGroup fkLimb) { this._scheduleNextIKPostUpdate = this.CopyLimbToTwinInternal; this._nextIKCopy = ikLimb; this._nextFKCopy = fkLimb; }
private void CopyLimbToTwinInternal() { this.StartDrag(DragType.Both); this._lockDrag = true; HashSet <OIBoneInfo.BoneGroup> fkTwinLimb = new HashSet <OIBoneInfo.BoneGroup>(); switch (this._nextFKCopy) { case OIBoneInfo.BoneGroup.RightLeg: fkTwinLimb.Add(OIBoneInfo.BoneGroup.LeftLeg); fkTwinLimb.Add((OIBoneInfo.BoneGroup) 5); break; case OIBoneInfo.BoneGroup.LeftLeg: fkTwinLimb.Add(OIBoneInfo.BoneGroup.RightLeg); fkTwinLimb.Add((OIBoneInfo.BoneGroup) 3); break; case OIBoneInfo.BoneGroup.RightArm: fkTwinLimb.Add(OIBoneInfo.BoneGroup.LeftArm); fkTwinLimb.Add((OIBoneInfo.BoneGroup) 17); break; case OIBoneInfo.BoneGroup.LeftArm: fkTwinLimb.Add(OIBoneInfo.BoneGroup.RightArm); fkTwinLimb.Add((OIBoneInfo.BoneGroup) 9); break; } this._additionalRotationEqualsCommands = new List <GuideCommand.EqualsInfo>(); foreach (OCIChar.BoneInfo bone in this._target.ociChar.listBones) { Transform twinBoneTransform = null; Transform boneTransform = bone.guideObject.transformTarget; if (fkTwinLimb.Contains(bone.boneGroup) == false) { continue; } twinBoneTransform = this._bonesEditor.GetTwinBone(boneTransform); if (twinBoneTransform == null) { twinBoneTransform = boneTransform; } OCIChar.BoneInfo twinBone; if (twinBoneTransform != null && this._target.fkObjects.TryGetValue(twinBoneTransform.gameObject, out twinBone)) { if (twinBoneTransform == boneTransform) { Quaternion rot = Quaternion.Euler(bone.guideObject.changeAmount.rot); rot = new Quaternion(rot.x, -rot.y, -rot.z, rot.w); Vector3 oldRotValue = bone.guideObject.changeAmount.rot; bone.guideObject.changeAmount.rot = rot.eulerAngles; this._additionalRotationEqualsCommands.Add(new GuideCommand.EqualsInfo() { dicKey = bone.guideObject.dicKey, oldValue = oldRotValue, newValue = bone.guideObject.changeAmount.rot }); } else { Quaternion twinRot = Quaternion.Euler(twinBone.guideObject.changeAmount.rot); twinRot = new Quaternion(twinRot.x, -twinRot.y, -twinRot.z, twinRot.w); Vector3 oldRotValue = bone.guideObject.changeAmount.rot; bone.guideObject.changeAmount.rot = twinRot.eulerAngles; this._additionalRotationEqualsCommands.Add(new GuideCommand.EqualsInfo() { dicKey = bone.guideObject.dicKey, oldValue = oldRotValue, newValue = bone.guideObject.changeAmount.rot }); } } } FullBodyBipedChain limb = this._nextIKCopy; FullBodyBipedEffector effectorSrc; FullBodyBipedChain bendGoalSrc; FullBodyBipedEffector effectorDest; FullBodyBipedChain bendGoalDest; Transform effectorSrcRealBone; Transform effectorDestRealBone; Transform root; switch (limb) { case FullBodyBipedChain.LeftArm: effectorSrc = FullBodyBipedEffector.LeftHand; effectorSrcRealBone = this._body.references.leftHand; effectorDestRealBone = this._body.references.rightHand; root = this._body.solver.spineMapping.spineBones[this._body.solver.spineMapping.spineBones.Length - 2]; break; case FullBodyBipedChain.LeftLeg: effectorSrc = FullBodyBipedEffector.LeftFoot; effectorSrcRealBone = this._body.references.leftFoot; effectorDestRealBone = this._body.references.rightFoot; root = this._body.solver.spineMapping.spineBones[0]; break; case FullBodyBipedChain.RightArm: effectorSrc = FullBodyBipedEffector.RightHand; effectorSrcRealBone = this._body.references.rightHand; effectorDestRealBone = this._body.references.leftHand; root = this._body.solver.spineMapping.spineBones[this._body.solver.spineMapping.spineBones.Length - 2]; break; case FullBodyBipedChain.RightLeg: effectorSrc = FullBodyBipedEffector.RightFoot; effectorSrcRealBone = this._body.references.rightFoot; effectorDestRealBone = this._body.references.leftFoot; root = this._body.solver.spineMapping.spineBones[0]; break; default: effectorSrc = FullBodyBipedEffector.RightHand; effectorSrcRealBone = null; effectorDestRealBone = null; root = null; break; } bendGoalSrc = limb; bendGoalDest = this.GetTwinChain(limb); effectorDest = this.GetTwinEffector(effectorSrc); Vector3 localPos = root.InverseTransformPoint(this._target.ociChar.listIKTarget[_effectorToIndex[effectorSrc]].guideObject.transformTarget.position); localPos.x *= -1f; Vector3 effectorPosition = root.TransformPoint(localPos); localPos = root.InverseTransformPoint(this._target.ociChar.listIKTarget[_chainToIndex[bendGoalSrc]].guideObject.transformTarget.position); localPos.x *= -1f; Vector3 bendGoalPosition = root.TransformPoint(localPos); this.SetBoneTargetPosition(effectorDest, effectorPosition); this.SetBendGoalPosition(bendGoalDest, bendGoalPosition); this.SetBoneTargetRotation(effectorDest, this.GetBoneTargetRotation(effectorDest)); this._scheduleNextIKPostUpdate = () => { Quaternion rot = effectorSrcRealBone.localRotation; rot = new Quaternion(rot.x, -rot.y, -rot.z, rot.w); effectorDestRealBone.localRotation = rot; //Setting real bone local rotation OCIChar.IKInfo effectorDestInfo = this._target.ociChar.listIKTarget[_effectorToIndex[effectorDest]]; effectorDestInfo.guideObject.transformTarget.rotation = effectorDestRealBone.rotation; //Using real bone rotation to set IK target rotation; this.SetBoneTargetRotation(effectorDest, effectorDestInfo.guideObject.transformTarget.localRotation); //Setting again the IK target with its own local rotation through normal means so it isn't ignored by neo while saving this._lockDrag = false; this.StopDrag(); }; }
} // 0x00000001804C85D0-0x00000001804C85E0 // Methods public void Apply(FullBodyBipedChain chain, IKSolverFullBodyBiped solver) { } // 0x00000001804C8550-0x00000001804C85D0
/// <summary> /// Gets the bend constraint of a limb. /// </summary> public IKConstraintBend GetBendConstraint(FullBodyBipedChain limb) { switch(limb) { case FullBodyBipedChain.LeftArm: return chain[1].bendConstraint; case FullBodyBipedChain.RightArm: return chain[2].bendConstraint; case FullBodyBipedChain.LeftLeg: return chain[3].bendConstraint; case FullBodyBipedChain.RightLeg: return chain[4].bendConstraint; } return null; }
} // 0x00000001807F0F30-0x00000001807F1030 private void RotateShoulder(FullBodyBipedChain chain, float weight, float offset) { } // 0x00000001807F09A0-0x00000001807F0F30
public void Apply(FullBodyBipedChain chain, IKSolverFullBodyBiped solver) { solver.GetChain(chain).reachSmoothing = this.reachSmoothing; solver.GetEndEffector(chain).maintainRelativePositionWeight = this.maintainRelativePositionWeight; solver.GetLimbMapping(chain).weight = this.mappingWeight; }
public FBIKChain.ReachSmoothing reachSmoothing; // Smoothing of the Reach effect (since 0.2) #endregion Fields #region Methods // Apply the settings public void Apply(FullBodyBipedChain chain, IKSolverFullBodyBiped solver) { solver.GetChain(chain).reachSmoothing = reachSmoothing; solver.GetEndEffector(chain).maintainRelativePositionWeight = maintainRelativePositionWeight; solver.GetLimbMapping(chain).weight = mappingWeight; }
private static string GetEndEffectorName(FullBodyBipedChain chain) { switch(chain) { case FullBodyBipedChain.LeftArm: return "Left Hand Effector"; case FullBodyBipedChain.RightArm: return "Right Hand Effector"; case FullBodyBipedChain.LeftLeg: return "Left Foot Effector"; case FullBodyBipedChain.RightLeg: return "Right Foot Effector"; default: return string.Empty; } }
/// <summary> /// Sets chain weights for the specified chain. /// </summary> public void SetChainWeights(FullBodyBipedChain c, float pull, float reach = 0f) { GetChain(c).pull = pull; GetChain(c).reach = reach; }
private static string GetEndBoneMappingName(FullBodyBipedChain chain) { switch(chain) { case FullBodyBipedChain.LeftArm: return "Maintain Hand Rot"; case FullBodyBipedChain.RightArm: return "Maintain Hand Rot"; case FullBodyBipedChain.LeftLeg: return "Maintain Foot Rot"; case FullBodyBipedChain.RightLeg: return "Maintain Foot Rot"; default: return string.Empty; } }
public bool IsPartEnabled(FullBodyBipedChain part) { return(this._target.ikEnabled && this._target.ociChar.listIKTarget[_chainToIndex[part]].active); }
private static int GetStartEffectorIndex(FullBodyBipedChain chainType) { switch(chainType) { case FullBodyBipedChain.LeftArm: return 1; case FullBodyBipedChain.RightArm: return 2; case FullBodyBipedChain.LeftLeg: return 3; case FullBodyBipedChain.RightLeg: return 4; } return 0; }
/// <summary> /// Gets the chain of a limb. /// </summary> public FBIKChain GetChain(FullBodyBipedChain c) { switch(c) { case FullBodyBipedChain.LeftArm: return chain[1]; case FullBodyBipedChain.RightArm: return chain[2]; case FullBodyBipedChain.LeftLeg: return chain[3]; case FullBodyBipedChain.RightLeg: return chain[4]; } return null; }
protected override void ResetAction() { limb = FullBodyBipedChain.LeftArm; pull = new FsmFloat { UseVariable = true }; reach = new FsmFloat { UseVariable = true }; push = new FsmFloat { UseVariable = true }; pushParent = new FsmFloat { UseVariable = true }; bendGoal = new FsmGameObject { UseVariable = true }; bendGoalWeight = new FsmFloat { UseVariable = true }; target = new FsmGameObject { UseVariable = true }; position = new FsmVector3 { UseVariable = true }; positionWeight = new FsmFloat { UseVariable = true }; rotation = new FsmQuaternion { UseVariable = true }; rotationWeight = new FsmFloat { UseVariable = true }; positionOffset = new FsmVector3 { UseVariable = true }; maintainRelativePositionWeight = new FsmFloat { UseVariable = true }; startEffectorTarget = new FsmGameObject { UseVariable = true }; startEffectorPosition = new FsmVector3 { UseVariable = true }; startEffectorPositionWeight = new FsmFloat { UseVariable = true }; startEffectorPositionOffset = new FsmVector3 { UseVariable = true }; maintainRotationWeight = new FsmFloat { UseVariable = true }; mappingWeight = new FsmFloat { UseVariable = true}; reachSmoothing = FBIKChain.Smoothing.Exponential; pushSmoothing = FBIKChain.Smoothing.Exponential; rotation = Quaternion.identity; mappingWeight = 1f; pull = 1f; reach = 0.05f; push = 0f; pushParent = 0f; bendGoalWeight = 0f; }
// Get the shoulder BoneMap private IKMapping.BoneMap GetParentBoneMap(FullBodyBipedChain chain) { return(ik.solver.GetLimbMapping(chain).GetBoneMap(IKMappingLimb.BoneMapType.Parent)); }