public bool ResetToDefaults(IKSolverFullBodyBiped solver, float speed) { if (this.inInteraction) { return(false); } if (this.isPaused) { return(false); } if (this.defaults) { return(false); } this.resetTimer = Mathf.Clamp(this.resetTimer -= Time.deltaTime * speed, 0f, 1f); if (this.effector.isEndEffector) { solver.GetChain(this.effectorType).pull = Mathf.Lerp(this.defaultPull, solver.GetChain(this.effectorType).pull, this.resetTimer); solver.GetChain(this.effectorType).reach = Mathf.Lerp(this.defaultReach, solver.GetChain(this.effectorType).reach, this.resetTimer); solver.GetChain(this.effectorType).push = Mathf.Lerp(this.defaultPush, solver.GetChain(this.effectorType).push, this.resetTimer); solver.GetChain(this.effectorType).pushParent = Mathf.Lerp(this.defaultPushParent, solver.GetChain(this.effectorType).pushParent, this.resetTimer); } this.effector.positionWeight = Mathf.Lerp(0f, this.effector.positionWeight, this.resetTimer); this.effector.rotationWeight = Mathf.Lerp(0f, this.effector.rotationWeight, this.resetTimer); if (this.resetTimer <= 0f) { this.defaults = true; } return(true); }
// Apply the curve to the specified solver, effector, with the value and weight. private void Apply(IKSolverFullBodyBiped solver, FullBodyBipedEffector effector, WeightCurve.Type type, float value, float weight) { switch (type) { case WeightCurve.Type.PositionWeight: solver.GetEffector(effector).positionWeight = Mathf.Lerp(solver.GetEffector(effector).positionWeight, value, weight); return; case WeightCurve.Type.RotationWeight: solver.GetEffector(effector).rotationWeight = Mathf.Lerp(solver.GetEffector(effector).rotationWeight, value, weight); return; case WeightCurve.Type.PositionOffsetX: solver.GetEffector(effector).position += solver.GetRoot().rotation *Vector3.right *value *weight; return; case WeightCurve.Type.PositionOffsetY: solver.GetEffector(effector).position += solver.GetRoot().rotation *Vector3.up *value *weight; return; case WeightCurve.Type.PositionOffsetZ: solver.GetEffector(effector).position += solver.GetRoot().rotation *Vector3.forward *value *weight; return; case WeightCurve.Type.Pull: solver.GetChain(effector).pull = Mathf.Lerp(solver.GetChain(effector).pull, value, weight); return; case WeightCurve.Type.Reach: solver.GetChain(effector).reach = Mathf.Lerp(solver.GetChain(effector).reach, value, weight); return; } }
// Interpolate to default values when currently not in interaction public void ResetToDefaults(IKSolverFullBodyBiped solver, float speed) { if (inInteraction) { return; } if (isPaused) { return; } if (defaults) { return; } resetTimer = Mathf.Clamp(resetTimer -= Time.deltaTime * speed, 0f, 1f); // Pull and Reach if (effector.isEndEffector) { solver.GetChain(effectorType).pull = Mathf.Lerp(defaultPull, solver.GetChain(effectorType).pull, resetTimer); solver.GetChain(effectorType).reach = Mathf.Lerp(defaultReach, solver.GetChain(effectorType).reach, resetTimer); } // Effector weights effector.positionWeight = Mathf.Lerp(0f, effector.positionWeight, resetTimer); effector.rotationWeight = Mathf.Lerp(0f, effector.rotationWeight, resetTimer); if (resetTimer <= 0f) { defaults = true; } }
// Initiate this, get the default values public void Initiate(IKSolverFullBodyBiped solver) { // Find the effector if we haven't already if (effector == null) { effector = solver.GetEffector(effectorType); poser = effector.bone.GetComponent <Poser>(); } defaultPull = solver.GetChain(effectorType).pull; defaultReach = solver.GetChain(effectorType).reach; }
public void Initiate(InteractionSystem interactionSystem, IKSolverFullBodyBiped solver) { this.interactionSystem = interactionSystem; if (this.effector == null) { this.effector = solver.GetEffector(this.effectorType); this.poser = this.effector.bone.GetComponent <Poser>(); } this.defaultPull = solver.GetChain(this.effectorType).pull; this.defaultReach = solver.GetChain(this.effectorType).reach; this.defaultPush = solver.GetChain(this.effectorType).push; this.defaultPushParent = solver.GetChain(this.effectorType).pushParent; }
// Apply the curve to the specified solver, effector, with the value and weight. private void Apply(IKSolverFullBodyBiped solver, FullBodyBipedEffector effector, WeightCurve.Type type, float value, float weight) { switch (type) { case WeightCurve.Type.PositionWeight: solver.GetEffector(effector).positionWeight = Mathf.Lerp(solver.GetEffector(effector).positionWeight, value, weight); return; case WeightCurve.Type.RotationWeight: solver.GetEffector(effector).rotationWeight = Mathf.Lerp(solver.GetEffector(effector).rotationWeight, value, weight); return; case WeightCurve.Type.PositionOffsetX: Vector3 xOffset = (positionOffsetSpace != null ? positionOffsetSpace.rotation : solver.GetRoot().rotation) * Vector3.right * value; solver.GetEffector(effector).position += xOffset * weight; //solver.GetEffector(effector).positionOffset += xOffset; return; case WeightCurve.Type.PositionOffsetY: Vector3 yOffset = (positionOffsetSpace != null ? positionOffsetSpace.rotation : solver.GetRoot().rotation) * Vector3.up * value; solver.GetEffector(effector).position += yOffset * weight; //solver.GetEffector(effector).positionOffset += yOffset; return; case WeightCurve.Type.PositionOffsetZ: Vector3 zOffset = (positionOffsetSpace != null ? positionOffsetSpace.rotation : solver.GetRoot().rotation) * Vector3.forward * value; solver.GetEffector(effector).position += zOffset * weight; //solver.GetEffector(effector).positionOffset += zOffset; return; case WeightCurve.Type.Pull: solver.GetChain(effector).pull = Mathf.Lerp(solver.GetChain(effector).pull, value, weight); return; case WeightCurve.Type.Reach: solver.GetChain(effector).reach = Mathf.Lerp(solver.GetChain(effector).reach, value, weight); return; case WeightCurve.Type.Push: solver.GetChain(effector).push = Mathf.Lerp(solver.GetChain(effector).push, value, weight); return; case WeightCurve.Type.PushParent: solver.GetChain(effector).pushParent = Mathf.Lerp(solver.GetChain(effector).pushParent, value, weight); return; case WeightCurve.Type.BendGoalWeight: solver.GetChain(effector).bendConstraint.weight = Mathf.Lerp(solver.GetChain(effector).bendConstraint.weight, value, weight); return; } }
// Initiate this, get the default values public void Initiate(InteractionSystem interactionSystem, IKSolverFullBodyBiped solver) { this.interactionSystem = interactionSystem; // Find the effector if we haven't already if (effector == null) { effector = solver.GetEffector(effectorType); poser = effector.bone.GetComponent<Poser>(); } defaultPull = solver.GetChain(effectorType).pull; defaultReach = solver.GetChain(effectorType).reach; defaultPush = solver.GetChain(effectorType).push; defaultPushParent = solver.GetChain(effectorType).pushParent; }
// Initiate this, get the default values public void Initiate(InteractionSystem interactionSystem, IKSolverFullBodyBiped solver) { this.interactionSystem = interactionSystem; // Find the effector if we haven't already if (effector == null) { effector = solver.GetEffector(effectorType); poser = effector.bone.GetComponent <Poser>(); } defaultPull = solver.GetChain(effectorType).pull; defaultReach = solver.GetChain(effectorType).reach; defaultPush = solver.GetChain(effectorType).push; defaultPushParent = solver.GetChain(effectorType).pushParent; }
private void Apply(IKSolverFullBodyBiped solver, FullBodyBipedEffector effector, InteractionObject.WeightCurve.Type type, float value, float weight) { switch (type) { case InteractionObject.WeightCurve.Type.PositionWeight: solver.GetEffector(effector).positionWeight = Mathf.Lerp(solver.GetEffector(effector).positionWeight, value, weight); return; case InteractionObject.WeightCurve.Type.RotationWeight: solver.GetEffector(effector).rotationWeight = Mathf.Lerp(solver.GetEffector(effector).rotationWeight, value, weight); return; case InteractionObject.WeightCurve.Type.PositionOffsetX: solver.GetEffector(effector).position += ((this.positionOffsetSpace != null) ? this.positionOffsetSpace.rotation : solver.GetRoot().rotation) * Vector3.right * value * weight; return; case InteractionObject.WeightCurve.Type.PositionOffsetY: solver.GetEffector(effector).position += ((this.positionOffsetSpace != null) ? this.positionOffsetSpace.rotation : solver.GetRoot().rotation) * Vector3.up * value * weight; return; case InteractionObject.WeightCurve.Type.PositionOffsetZ: solver.GetEffector(effector).position += ((this.positionOffsetSpace != null) ? this.positionOffsetSpace.rotation : solver.GetRoot().rotation) * Vector3.forward * value * weight; return; case InteractionObject.WeightCurve.Type.Pull: solver.GetChain(effector).pull = Mathf.Lerp(solver.GetChain(effector).pull, value, weight); return; case InteractionObject.WeightCurve.Type.Reach: solver.GetChain(effector).reach = Mathf.Lerp(solver.GetChain(effector).reach, value, weight); return; case InteractionObject.WeightCurve.Type.RotateBoneWeight: return; case InteractionObject.WeightCurve.Type.Push: solver.GetChain(effector).push = Mathf.Lerp(solver.GetChain(effector).push, value, weight); return; case InteractionObject.WeightCurve.Type.PushParent: solver.GetChain(effector).pushParent = Mathf.Lerp(solver.GetChain(effector).pushParent, value, weight); return; default: return; } }
// Interpolate to default values when currently not in interaction public bool ResetToDefaults(IKSolverFullBodyBiped solver, float speed) { if (inInteraction) return false; if (isPaused) return false; if (defaults) return false; resetTimer = Mathf.Clamp(resetTimer -= Time.deltaTime * speed, 0f, 1f); // Pull and Reach if (effector.isEndEffector) { solver.GetChain(effectorType).pull = Mathf.Lerp(defaultPull, solver.GetChain(effectorType).pull, resetTimer); solver.GetChain(effectorType).reach = Mathf.Lerp(defaultReach, solver.GetChain(effectorType).reach, resetTimer); solver.GetChain(effectorType).push = Mathf.Lerp(defaultPush, solver.GetChain(effectorType).push, resetTimer); solver.GetChain(effectorType).pushParent = Mathf.Lerp(defaultPushParent, solver.GetChain(effectorType).pushParent, resetTimer); } // Effector weights effector.positionWeight = Mathf.Lerp(0f, effector.positionWeight, resetTimer); effector.rotationWeight = Mathf.Lerp(0f, effector.rotationWeight, resetTimer); if (resetTimer <= 0f) defaults = true; return true; }
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; }
// Apply the curve to the specified solver, effector, with the value and weight. private void Apply(IKSolverFullBodyBiped solver, FullBodyBipedEffector effector, WeightCurve.Type type, float value, float weight) { switch(type) { case WeightCurve.Type.PositionWeight: solver.GetEffector(effector).positionWeight = Mathf.Lerp(solver.GetEffector(effector).positionWeight, value, weight); return; case WeightCurve.Type.RotationWeight: solver.GetEffector(effector).rotationWeight = Mathf.Lerp(solver.GetEffector(effector).rotationWeight, value, weight); return; case WeightCurve.Type.PositionOffsetX: solver.GetEffector(effector).position += (positionOffsetSpace != null? positionOffsetSpace.rotation: solver.GetRoot().rotation) * Vector3.right * value * weight; return; case WeightCurve.Type.PositionOffsetY: solver.GetEffector(effector).position += (positionOffsetSpace != null? positionOffsetSpace.rotation: solver.GetRoot().rotation) * Vector3.up * value * weight; return; case WeightCurve.Type.PositionOffsetZ: solver.GetEffector(effector).position += (positionOffsetSpace != null? positionOffsetSpace.rotation: solver.GetRoot().rotation) * Vector3.forward * value * weight; return; case WeightCurve.Type.Pull: solver.GetChain(effector).pull = Mathf.Lerp(solver.GetChain(effector).pull, value, weight); return; case WeightCurve.Type.Reach: solver.GetChain(effector).reach = Mathf.Lerp(solver.GetChain(effector).reach, value, weight); return; case WeightCurve.Type.Push: solver.GetChain(effector).push = Mathf.Lerp(solver.GetChain(effector).push, value, weight); return; case WeightCurve.Type.PushParent: solver.GetChain(effector).pushParent = Mathf.Lerp(solver.GetChain(effector).pushParent, value, weight); return; } }
// Initiate this, get the default values public void Initiate(IKSolverFullBodyBiped solver) { // Find the effector if we haven't already if (effector == null) { effector = solver.GetEffector(effectorType); poser = effector.bone.GetComponent<Poser>(); } defaultPull = solver.GetChain(effectorType).pull; defaultReach = solver.GetChain(effectorType).reach; }