Esempio n. 1
0
 public void Apply(IKSolverFullBodyBiped solver, FullBodyBipedEffector effector, InteractionTarget target, float timer, float weight)
 {
     for (int i = 0; i < this.weightCurves.Length; i++)
     {
         float num = (!(target == null)) ? target.GetValue(this.weightCurves[i].type) : 1f;
         this.Apply(solver, effector, this.weightCurves[i].type, this.weightCurves[i].GetValue(timer), weight * num);
     }
     for (int j = 0; j < this.multipliers.Length; j++)
     {
         if (this.multipliers[j].curve == this.multipliers[j].result && !Warning.logged)
         {
             Warning.Log("InteractionObject Multiplier 'Curve' " + this.multipliers[j].curve.ToString() + "and 'Result' are the same.", base.transform, false);
         }
         int weightCurveIndex = this.GetWeightCurveIndex(this.multipliers[j].curve);
         if (weightCurveIndex != -1)
         {
             float num2 = (!(target == null)) ? target.GetValue(this.multipliers[j].result) : 1f;
             this.Apply(solver, effector, this.multipliers[j].result, this.multipliers[j].GetValue(this.weightCurves[weightCurveIndex], timer), weight * num2);
         }
         else if (!Warning.logged)
         {
             Warning.Log("InteractionObject Multiplier curve " + this.multipliers[j].curve.ToString() + "does not exist.", base.transform, false);
         }
     }
 }
Esempio n. 2
0
        // Called by the InteractionSystem when an interaction starts
        private void OnStart(FullBodyBipedEffector effectorType, InteractionObject interactionObject)
        {
            if (effectorType != FullBodyBipedEffector.LeftHand)
            {
                return;
            }

            // Rotate the pivot of the hand targets by 90 degrees so we could grab the box from any direction

            // Get the flat direction towards the character
            Vector3 characterDirection = (interactionSystem.transform.position - pivot.position).normalized;

            characterDirection.y = 0f;

            // Convert the direction to local space of the box
            Vector3 characterDirectionLocal = box.transform.InverseTransformDirection(characterDirection);

            // QuaTools.GetAxis returns a 90 degree ortographic axis for any direction
            Vector3 axis   = QuaTools.GetAxis(characterDirectionLocal);
            Vector3 upAxis = QuaTools.GetAxis(box.transform.InverseTransformDirection(interactionSystem.transform.up));

            // Rotate towards axis and upAxis
            pivot.localRotation = Quaternion.LookRotation(axis, upAxis);

            // Rotate the hold point so it matches the current rotation of the box
            boxHoldPoint.rotation = box.transform.rotation;
        }
        public IKMappingLimb GetLimbMapping(FullBodyBipedEffector effector)
        {
            switch (effector)
            {
            case FullBodyBipedEffector.LeftShoulder:
                return(this.limbMappings[0]);

            case FullBodyBipedEffector.RightShoulder:
                return(this.limbMappings[1]);

            case FullBodyBipedEffector.LeftThigh:
                return(this.limbMappings[2]);

            case FullBodyBipedEffector.RightThigh:
                return(this.limbMappings[3]);

            case FullBodyBipedEffector.LeftHand:
                return(this.limbMappings[0]);

            case FullBodyBipedEffector.RightHand:
                return(this.limbMappings[1]);

            case FullBodyBipedEffector.LeftFoot:
                return(this.limbMappings[2]);

            case FullBodyBipedEffector.RightFoot:
                return(this.limbMappings[3]);

            default:
                return(null);
            }
        }
        public FBIKChain GetChain(FullBodyBipedEffector effector)
        {
            switch (effector)
            {
            case FullBodyBipedEffector.Body:
                return(this.chain[0]);

            case FullBodyBipedEffector.LeftShoulder:
                return(this.chain[1]);

            case FullBodyBipedEffector.RightShoulder:
                return(this.chain[2]);

            case FullBodyBipedEffector.LeftThigh:
                return(this.chain[3]);

            case FullBodyBipedEffector.RightThigh:
                return(this.chain[4]);

            case FullBodyBipedEffector.LeftHand:
                return(this.chain[1]);

            case FullBodyBipedEffector.RightHand:
                return(this.chain[2]);

            case FullBodyBipedEffector.LeftFoot:
                return(this.chain[3]);

            case FullBodyBipedEffector.RightFoot:
                return(this.chain[4]);

            default:
                return(null);
            }
        }
        public IKEffector GetEffector(FullBodyBipedEffector effector)
        {
            switch (effector)
            {
            case FullBodyBipedEffector.Body:
                return(this.effectors[0]);

            case FullBodyBipedEffector.LeftShoulder:
                return(this.effectors[1]);

            case FullBodyBipedEffector.RightShoulder:
                return(this.effectors[2]);

            case FullBodyBipedEffector.LeftThigh:
                return(this.effectors[3]);

            case FullBodyBipedEffector.RightThigh:
                return(this.effectors[4]);

            case FullBodyBipedEffector.LeftHand:
                return(this.effectors[5]);

            case FullBodyBipedEffector.RightHand:
                return(this.effectors[6]);

            case FullBodyBipedEffector.LeftFoot:
                return(this.effectors[7]);

            case FullBodyBipedEffector.RightFoot:
                return(this.effectors[8]);

            default:
                return(null);
            }
        }
Esempio n. 6
0
 public void StartInteraction(FullBodyBipedEffector effector, InteractionObject obj)
 {
     if (this.state == BodyIKState.Offline)
     {
         this.primaryEffectors.Add(effector, obj);
         this.handlerPrimary.StartInteraction(effector, obj, true);
         this.state = BodyIKState.Online;
     }
     else if (this.state == BodyIKState.Online ||
              this.state == BodyIKState.Swapping)
     {
         // Is this effector already being used?
         if (this.primaryEffectors.ContainsKey(effector))
         {
             this.PerformSwap(effector, obj);
         }
         else
         {
             this.primaryEffectors.Add(effector, obj);
             this.handlerPrimary.StartInteraction(effector, obj, true);
         }
     }
     else if (this.state == BodyIKState.Stopping)
     {
         this.primaryEffectors.Add(effector, obj);
         this.handlerPrimary.StartInteraction(effector, obj, true);
         this.state = BodyIKState.Online;
     }
 }
Esempio n. 7
0
        // Called by the InteractionSystem when an interaction is paused (on trigger)
        private void OnPause(FullBodyBipedEffector effectorType, InteractionObject interactionObject)
        {
            if (effectorType != FullBodyBipedEffector.LeftHand)
            {
                return;
            }
            if (interactionObject != obj)
            {
                return;
            }

            // Make the object inherit the character's movement
            obj.transform.parent = interactionSystem.transform;

            // Make the object kinematic
            var r = obj.GetComponent <Rigidbody>();

            if (r != null)
            {
                r.isKinematic = true;
            }

            // Set object pick up position and rotation to current
            pickUpPosition = obj.transform.position;
            pickUpRotation = obj.transform.rotation;
            holdWeight     = 0f;
            holdWeightVel  = 0f;
        }
Esempio n. 8
0
 private void OnGUI()
 {
     if (this.interactionSystem == null)
     {
         return;
     }
     if (GUILayout.Button("Start Interaction With " + this.interactionObject.name, new GUILayoutOption[0]))
     {
         if (this.effectors.Length == 0)
         {
             Debug.Log("Please select the effectors to interact with.");
         }
         FullBodyBipedEffector[] array = this.effectors;
         for (int i = 0; i < array.Length; i++)
         {
             FullBodyBipedEffector effectorType = array[i];
             this.interactionSystem.StartInteraction(effectorType, this.interactionObject, true);
         }
     }
     if (this.effectors.Length == 0)
     {
         return;
     }
     if (this.interactionSystem.IsPaused(this.effectors[0]) && GUILayout.Button("Resume Interaction With " + this.interactionObject.name, new GUILayoutOption[0]))
     {
         this.interactionSystem.ResumeAll();
     }
 }
Esempio n. 9
0
        //private void OnCoordinateReplaced(OCIChar chara, CharDefine.CoordinateType type, bool force);


        private FullBodyBipedEffector GetTwinEffector(FullBodyBipedEffector effector)
        {
            switch (effector)
            {
            case FullBodyBipedEffector.LeftFoot:
                return(FullBodyBipedEffector.RightFoot);

            case FullBodyBipedEffector.RightFoot:
                return(FullBodyBipedEffector.LeftFoot);

            case FullBodyBipedEffector.LeftHand:
                return(FullBodyBipedEffector.RightHand);

            case FullBodyBipedEffector.RightHand:
                return(FullBodyBipedEffector.LeftHand);

            case FullBodyBipedEffector.LeftThigh:
                return(FullBodyBipedEffector.RightThigh);

            case FullBodyBipedEffector.RightThigh:
                return(FullBodyBipedEffector.LeftThigh);

            case FullBodyBipedEffector.LeftShoulder:
                return(FullBodyBipedEffector.RightShoulder);

            case FullBodyBipedEffector.RightShoulder:
                return(FullBodyBipedEffector.LeftShoulder);
            }
            return(effector);
        }
Esempio n. 10
0
			// Placing an effector so that an arbitrary Transform (target) ends up at targetPosition
			private void InverseTransformEffector(FullBodyBipedEffector effector, Transform target, Vector3 targetPosition, float weight) {
				// Direction from the target to the effector
				Vector3 toEffector = ik.solver.GetEffector(effector).bone.position - target.position;

				// Positioning the effector
				ik.solver.GetEffector(effector).position = Vector3.Lerp(ik.solver.GetEffector(effector).bone.position, targetPosition + toEffector, weight);
			}
Esempio n. 11
0
 public void StartInteraction(
     FullBodyBipedEffector effector,
     InteractionObject obj)
 {
     this.bodyController.StartInteraction(effector, obj);
     this.lookController.HeadOnly(this.DefaultDelay);
 }
Esempio n. 12
0
        /// <summary>
        /// Gets the InteractionTarget of the specified effector type and InteractionSystem tag.
        /// </summary>
        public InteractionTarget GetTarget(FullBodyBipedEffector effectorType, InteractionSystem interactionSystem)
        {
            if (interactionSystem.CompareTag(string.Empty) || interactionSystem.CompareTag(""))
            {
                foreach (InteractionTarget target in targets)
                {
                    if (target.effectorType == effectorType)
                    {
                        return(target);
                    }
                }

                return(null);
            }

            foreach (InteractionTarget target in targets)
            {
                if (target.effectorType == effectorType && target.CompareTag(interactionSystem.tag))
                {
                    return(target);
                }
            }

            return(null);
        }
Esempio n. 13
0
        // 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;
            }
        }
            // Placing an effector so that an arbitrary Transform (target) ends up at targetPosition
            private void InverseTransformEffector(FullBodyBipedEffector effector, Transform target, Vector3 targetPosition, float weight)
            {
                // Direction from the target to the effector
                Vector3 toEffector = ik.solver.GetEffector(effector).bone.position - target.position;

                // Positioning the effector
                ik.solver.GetEffector(effector).position = Vector3.Lerp(ik.solver.GetEffector(effector).bone.position, targetPosition + toEffector, weight);
            }
Esempio n. 15
0
 public Node FootTap(GameObject p, FullBodyBipedEffector foot, InteractionObject attractor)
 {
     return(new Sequence(
                p.GetComponent <BehaviorMecanim>().Node_StartInteraction(foot, attractor),
                new LeafWait(200),
                p.GetComponent <BehaviorMecanim>().Node_StopInteraction(foot)
                ));
 }
Esempio n. 16
0
 private void OnInteractionStop(FullBodyBipedEffector effectorType, InteractionObject interactionObject)
 {
     if (effectorType != this.effectorType || interactionObject != this.interactionObject)
     {
         return;
     }
     this.inTouch = false;
 }
 public void OnInteractionStop(FullBodyBipedEffector effectorType, InteractionObject interactionObject)
 {
     Debug.Log("intrecation end");
     m_isInteracting = false;
     if (m_currentInteractableObject != null)
     {
         OnInteractionStopEvent(m_currentInteractableObject);
     }
 }
Esempio n. 18
0
 private void OnInteractionTrigger(
     FullBodyBipedEffector effector, 
     InteractionObject obj)
 {
     if (this.triggers == null)
         this.triggers = new Dictionary<FullBodyBipedEffector, bool>();
     if (this.triggers.ContainsKey(effector))
         this.triggers[effector] = true;
 }
Esempio n. 19
0
 private void OnInteractionFinish(
     FullBodyBipedEffector effector,
     InteractionObject obj)
 {
     if (this.finish == null)
         this.finish = new Dictionary<FullBodyBipedEffector, bool>();
     if (this.finish.ContainsKey(effector))
         this.finish[effector] = true;
 }
Esempio n. 20
0
 private void OnInteractionPickUp(
     FullBodyBipedEffector effectorType,
     InteractionObject interactionObject)
 {
     if (this.InteractionPickUp != null)
     {
         this.InteractionPickUp(effectorType, interactionObject);
     }
 }
 public void OnInteractionStart(FullBodyBipedEffector effectorType, InteractionObject interactionObject)
 {
     // m_interactionIndicator.ShowInteractionIndicator(false);
     m_isInteracting = true;
     if (m_currentInteractableObject != null)
     {
         OnInteractionStartEvent(m_currentInteractableObject);
     }
 }
Esempio n. 22
0
 private void OnInteractionRelease(
     FullBodyBipedEffector effectorType,
     InteractionObject interactionObject)
 {
     if (this.InteractionRelease != null)
     {
         this.InteractionRelease(effectorType, interactionObject);
     }
 }
Esempio n. 23
0
 public Quaternion GetBoneTargetRotation(FullBodyBipedEffector type)
 {
     OCIChar.IKInfo info = this._target.ociChar.listIKTarget[_effectorToIndex[type]];
     if (!this._target.ikEnabled || info.active == false)
     {
         return(Quaternion.identity);
     }
     return(info.guideObject.transformTarget.localRotation);
 }
Esempio n. 24
0
 public Vector3 GetBoneTargetPosition(FullBodyBipedEffector type, bool world = true)
 {
     OCIChar.IKInfo info = this._target.ociChar.listIKTarget[_effectorToIndex[type]];
     if (!this._target.ikEnabled || info.active == false)
     {
         return(Vector3.zero);
     }
     return(world ? info.guideObject.transformTarget.position : info.guideObject.transformTarget.localPosition);
 }
 private void OnEffectorTrigger(
     FullBodyBipedEffector effectorType,
     InteractionObject interactionObject)
 {
     if (this.InteractionTrigger != null)
     {
         this.InteractionTrigger(this, effectorType, interactionObject);
     }
 }
 private void OnEffectorResume(
     FullBodyBipedEffector effectorType,
     InteractionObject interactionObject)
 {
     if (this.InteractionResume != null)
     {
         this.InteractionResume(this, effectorType, interactionObject);
     }
 }
 private void OnEffectorStop(
     FullBodyBipedEffector effectorType,
     InteractionObject interactionObject)
 {
     if (this.InteractionStop != null)
     {
         this.InteractionStop(this, effectorType, interactionObject);
     }
 }
Esempio n. 28
0
 public void ResumeInteraction(FullBodyBipedEffector effector)
 {
     if (this.state == BodyIKState.Online ||
         this.state == BodyIKState.Swapping)
     {
         // TODO: What if we swap immediately after? The interaction
         //       will get stuck at the trigger again.
         this.handlerPrimary.ResumeInteraction(effector);
     }
 }
Esempio n. 29
0
 private void OnInteractionStop(
     CrossfadeInteractionHandler handler,
     FullBodyBipedEffector effectorType,
     InteractionObject interactionObject)
 {
     if (this.BodyStop != null)
     {
         this.BodyStop(effectorType, interactionObject);
     }
 }
Esempio n. 30
0
        // Called by the InteractionSystem when an interaction is resumed from being paused
        private void OnDrop(FullBodyBipedEffector effectorType, InteractionObject interactionObject)
        {
            if (effectorType != FullBodyBipedEffector.LeftHand) return;

            // Make the box independent of the character
            box.transform.parent = null;

            // Turn on physics for the box
            if (box.GetComponent<Rigidbody>() != null) box.GetComponent<Rigidbody>().isKinematic = false;
        }
Esempio n. 31
0
		/// <summary>
		/// Determines whether this effector is interaction and not paused
		/// </summary>
		public bool IsInInteraction(FullBodyBipedEffector effectorType) {
			if (!IsValid(true)) return false;

			for (int i = 0; i < interactionEffectors.Length; i++) {
				if (interactionEffectors[i].effectorType == effectorType) {
					return interactionEffectors[i].inInteraction && !interactionEffectors[i].isPaused;
				}
			}
			return false;
		}
Esempio n. 32
0
		// Called by the InteractionSystem when an interaction starts
		private void OnStart(FullBodyBipedEffector effectorType, InteractionObject interactionObject) {
			if (effectorType != FullBodyBipedEffector.LeftHand) return;
			if (interactionObject != obj) return;
			
			// Rotate the pivot of the hand targets
			RotatePivot();

			// Rotate the hold point so it matches the current rotation of the object
			holdPoint.rotation = obj.transform.rotation;
		}
Esempio n. 33
0
 private Transform GetTarget(FullBodyBipedEffector effectorType)
 {
     for (int i = 0; i < targets.Length; i++)
     {
         if (targets[i].effectorType == effectorType)
         {
             return(targets[i].transform);
         }
     }
     return(transform);
 }
Esempio n. 34
0
 private void OnInteractionFinish(
     FullBodyBipedEffector effector,
     InteractionObject obj)
 {
     if (this.finish == null)
     {
         this.finish = new Dictionary <FullBodyBipedEffector, bool>();
     }
     if (this.finish.ContainsKey(effector))
     {
         this.finish[effector] = true;
     }
 }
Esempio n. 35
0
 private void OnInteractionTrigger(
     FullBodyBipedEffector effector,
     InteractionObject obj)
 {
     if (this.triggers == null)
     {
         this.triggers = new Dictionary <FullBodyBipedEffector, bool>();
     }
     if (this.triggers.ContainsKey(effector))
     {
         this.triggers[effector] = true;
     }
 }
Esempio n. 36
0
 private void OnStart(FullBodyBipedEffector effectorType, InteractionObject interactionObject)
 {
     if (effectorType != FullBodyBipedEffector.LeftHand)
     {
         return;
     }
     if (interactionObject != this.obj)
     {
         return;
     }
     this.RotatePivot();
     this.holdPoint.rotation = this.obj.transform.rotation;
 }
Esempio n. 37
0
		// Called by the InteractionSystem when an interaction is paused (on trigger)
		private void OnPause(FullBodyBipedEffector effectorType, InteractionObject interactionObject) {
			if (effectorType != FullBodyBipedEffector.LeftHand) return;
			if (interactionObject != obj) return;

			// Make the object inherit the character's movement
			obj.transform.parent = interactionSystem.transform;
			
			// Make the object kinematic
			var r = obj.GetComponent<Rigidbody>();
			if (r != null) r.isKinematic = true;

			// Set object pick up position and rotation to current
			pickUpPosition = obj.transform.position;
			pickUpRotation = obj.transform.rotation;
			holdWeight = 0f;
			holdWeightVel = 0f;
		}
Esempio n. 38
0
        // Applies the weight curves and multipliers to the FBBIK solver
        public void Apply(IKSolverFullBodyBiped solver, FullBodyBipedEffector effector, InteractionTarget target, float timer, float weight)
        {
            for (int i = 0; i < weightCurves.Length; i++) {
                float mlp = target == null? 1f: target.GetValue(weightCurves[i].type);

                Apply(solver, effector, weightCurves[i].type, weightCurves[i].GetValue(timer), weight * mlp);
            }

            for (int i = 0; i < multipliers.Length; i++) {
                if (multipliers[i].curve == multipliers[i].result) {
                    if (!Warning.logged) Warning.Log("InteractionObject Multiplier 'Curve' " + multipliers[i].curve.ToString() + "and 'Result' are the same.", transform);
                }

                int curveIndex = GetWeightCurveIndex(multipliers[i].curve);

                if (curveIndex != -1) {
                    float mlp = target == null? 1f: target.GetValue(multipliers[i].result);

                    Apply(solver, effector, multipliers[i].result, multipliers[i].GetValue(weightCurves[curveIndex], timer), weight * mlp);
                } else {
                    if (!Warning.logged) Warning.Log("InteractionObject Multiplier curve " + multipliers[i].curve.ToString() + "does not exist.", transform);
                }
            }
        }
 public void StartInteraction(FullBodyBipedEffector effector, InteractionObject obj)
 {
     if (this.state == BodyIKState.Offline)
     {
         this.primaryEffectors.Add(effector, obj);
         this.handlerPrimary.StartInteraction(effector, obj, true);
         this.state = BodyIKState.Online;
     }
     else if (this.state == BodyIKState.Online
         || this.state == BodyIKState.Swapping)
     {
         // Is this effector already being used?
         if (this.primaryEffectors.ContainsKey(effector))
         {
             this.PerformSwap(effector, obj);
         }
         else
         {
             this.primaryEffectors.Add(effector, obj);
             this.handlerPrimary.StartInteraction(effector, obj, true);
         }
     }
     else if (this.state == BodyIKState.Stopping)
     {
         this.primaryEffectors.Add(effector, obj);
         this.handlerPrimary.StartInteraction(effector, obj, true);
         this.state = BodyIKState.Online;
     }
 }
		/// <summary>
		/// Sets effector weights for the specified effector.
		/// </summary>
		public void SetEffectorWeights(FullBodyBipedEffector effector, float positionWeight, float rotationWeight) {
			GetEffector(effector).positionWeight = Mathf.Clamp(positionWeight, 0f, 1f);
			GetEffector(effector).rotationWeight = Mathf.Clamp(rotationWeight, 0f, 1f);
		}
		// Gets the interaction target Transform
		private Transform GetTarget(FullBodyBipedEffector effectorType) {
			for (int i = 0; i < targets.Length; i++) {
				if (targets[i].effectorType == effectorType) return targets[i].transform;
			}
			return transform;
		}
Esempio n. 42
0
 private void OnInteractionStop(
     FullBodyBipedEffector effectorType,
     InteractionObject interactionObject)
 {
     if (this.InteractionStop != null)
         this.InteractionStop(effectorType, interactionObject);
 }
Esempio n. 43
0
 private void OnInteractionTrigger(
     FullBodyBipedEffector effectorType,
     InteractionObject interactionObject)
 {
     if (this.InteractionTrigger != null)
         this.InteractionTrigger(effectorType, interactionObject);
 }
        private void PerformSwap(FullBodyBipedEffector effector, InteractionObject obj)
        {
            // Move all the effectors to the secondary IK solver
            foreach (var kv in this.primaryEffectors)
            {
                if (kv.Key != effector)
                {
                    this.handlerSecondary.StartInteraction(kv.Key, kv.Value, true);
                    this.secondaryEffectors[kv.Key] = kv.Value;
                }
            }
            this.handlerSecondary.StartInteraction(effector, obj, true);
            this.secondaryEffectors[effector] = obj;

            // Swap solvers
            this.Swap();

            // Store the intermediate state
            float time = Time.time;
            this.swapTimeFinish = time + this.SwapTime;
            this.state = BodyIKState.Swapping;
        }
Esempio n. 45
0
        /// <summary>
        /// Stops the interaction of an effector.
        /// </summary>
        public void StopInteraction(FullBodyBipedEffector effectorType)
        {
            if (!IsValid(true)) return;

            for (int i = 0; i < interactionEffectors.Length; i++) {
                if (interactionEffectors[i].effectorType == effectorType) interactionEffectors[i].Stop();
            }
        }
 private void OnInteractionResume(
     CrossfadeInteractionHandler handler,
     FullBodyBipedEffector effectorType,
     InteractionObject interactionObject)
 {
     if (this.BodyResume != null)
         this.BodyResume(effectorType, interactionObject);
 }
Esempio n. 47
0
			// Called by the interaction system
			private void OnInteractionStop(FullBodyBipedEffector effectorType, InteractionObject interactionObject) {
				if (effectorType != this.effectorType || interactionObject != this.interactionObject) return;
				
				inTouch = false;
			}
Esempio n. 48
0
        /// <summary>
        /// Gets the current interaction object of an effector.
        /// </summary>
        public InteractionObject GetInteractionObject(FullBodyBipedEffector effectorType)
        {
            if (!IsValid(true)) return null;

            for (int i = 0; i < interactionEffectors.Length; i++) {
                if (interactionEffectors[i].effectorType == effectorType) {
                    return interactionEffectors[i].interactionObject;
                }
            }
            return null;
        }
Esempio n. 49
0
        /// <summary>
        /// Starts the interaction between an effector and an interaction object.
        /// </summary>
        public void StartInteraction(FullBodyBipedEffector effectorType, InteractionObject interactionObject, bool interrupt)
        {
            if (!IsValid(true)) return;

            for (int i = 0; i < interactionEffectors.Length; i++) {
                if (interactionEffectors[i].effectorType == effectorType) {
                    interactionEffectors[i].Start(interactionObject, targetTag, fadeInTime, interrupt);
                    return;
                }
            }
        }
		// Returns the InteractionTarget of effector type and tag
		public Transform GetTarget(FullBodyBipedEffector effectorType, string tag) {
			if (tag == string.Empty || tag == "") return GetTarget(effectorType);
			
			for (int i = 0; i < targets.Length; i++) {
				if (targets[i].effectorType == effectorType && targets[i].tag == tag) return targets[i].transform;
			}

			return transform;
		}
Esempio n. 51
0
 /// <summary>
 /// Sets effector weights for the specified effector.
 /// </summary>
 public void SetEffectorWeights(FullBodyBipedEffector effector, float positionWeight, float rotationWeight, float falloff = 0.5f)
 {
     GetEffector(effector).positionWeight = positionWeight;
     GetEffector(effector).rotationWeight = rotationWeight;
 }
		/// <summary>
		/// Gets the limb mapping for the effector type.
		/// </summary>
		public IKMappingLimb GetLimbMapping(FullBodyBipedEffector effector) {
			switch(effector) {
			case FullBodyBipedEffector.LeftShoulder: return limbMappings[0];
			case FullBodyBipedEffector.RightShoulder: return limbMappings[1];
			case FullBodyBipedEffector.LeftThigh: return limbMappings[2];
			case FullBodyBipedEffector.RightThigh: return limbMappings[3];
			case FullBodyBipedEffector.LeftHand: return limbMappings[0];
			case FullBodyBipedEffector.RightHand: return limbMappings[1];
			case FullBodyBipedEffector.LeftFoot: return limbMappings[2];
			case FullBodyBipedEffector.RightFoot: return limbMappings[3];
			default: return null;
			}
		}
 private void OnInteractionTrigger(
     CrossfadeInteractionHandler handler,
     FullBodyBipedEffector effectorType,
     InteractionObject interactionObject)
 {
     if (this.BodyTrigger != null)
         this.BodyTrigger(effectorType, interactionObject);
 }
		/// <summary>
		///  Gets the effector of type. 
		/// </summary>
		public IKEffector GetEffector(FullBodyBipedEffector effector) {
			switch(effector) {
			case FullBodyBipedEffector.Body: return effectors[0];
			case FullBodyBipedEffector.LeftShoulder: return effectors[1];
			case FullBodyBipedEffector.RightShoulder: return effectors[2];
			case FullBodyBipedEffector.LeftThigh: return effectors[3];
			case FullBodyBipedEffector.RightThigh: return effectors[4];
			case FullBodyBipedEffector.LeftHand: return effectors[5];
			case FullBodyBipedEffector.RightHand: return effectors[6];
			case FullBodyBipedEffector.LeftFoot: return effectors[7];
			case FullBodyBipedEffector.RightFoot: return effectors[8];
			}
			return null;
		}
Esempio n. 55
0
 private void OnInteractionRelease(
     FullBodyBipedEffector effectorType,
     InteractionObject interactionObject)
 {
     if (this.InteractionRelease != null)
         this.InteractionRelease(effectorType, interactionObject);
 }
		/// <summary>
		///  Gets the chain of the specified effector. 
		/// </summary>
		public FBIKChain GetChain(FullBodyBipedEffector effector) {
			switch(effector) {
			case FullBodyBipedEffector.Body: return chain[0];
			case FullBodyBipedEffector.LeftShoulder: return chain[1];
			case FullBodyBipedEffector.RightShoulder: return chain[2];
			case FullBodyBipedEffector.LeftThigh: return chain[3];
			case FullBodyBipedEffector.RightThigh: return chain[4];
			case FullBodyBipedEffector.LeftHand: return chain[1];
			case FullBodyBipedEffector.RightHand: return chain[2];
			case FullBodyBipedEffector.LeftFoot: return chain[3];
			case FullBodyBipedEffector.RightFoot: return chain[4];
			}
			return null;
		}
Esempio n. 57
0
 protected Node ST_Get_Ball(GameObject picker, FullBodyBipedEffector effector, InteractionObject ball, string tracer)
 {
     Val<FullBodyBipedEffector> eff = Val.V(() => effector);
     Val<InteractionObject> ba = Val.V(() => ball);
     return new Sequence(
         new LeafTrace(tracer),
         picker.GetComponent<BehaviorMecanim>().Node_StartInteraction(eff, ba),
         new LeafWait(1000));
 }
		// 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;
			}
		}
 public void ResumeInteraction(FullBodyBipedEffector effector)
 {
     if (this.state == BodyIKState.Online
         || this.state == BodyIKState.Swapping)
     {
         // TODO: What if we swap immediately after? The interaction
         //       will get stuck at the trigger again.
         this.handlerPrimary.ResumeInteraction(effector);
     }
 }
        public void StopInteraction(FullBodyBipedEffector effector)
        {
            if (this.primaryEffectors.ContainsKey(effector) == true)
            {
                this.primaryEffectors.Remove(effector);
                this.handlerPrimary.StopInteraction(effector);

                // If this is our last active effector, shut down
                if (this.primaryEffectors.Count == 0)
                    this.state = BodyIKState.Stopping;
            }
        }