示例#1
0
        /// <summary>
        /// Primary blend funciton, will always use the terminating state's mandible muscle force and target offset.
        /// This is to retain compatability with animations that rely on this blend funciton to work.
        /// </summary>
        /// <param name="targetState"></param>
        /// <param name="blendFactor"></param>
        public void blend(MusclePosition targetState, float blendFactor)
        {
            float modifiedBlendFactor = blendFactor;

            if (blendFactor < 1.0f)
            {
                EasingFunctions.Ease(targetState.Easing, 0, 1, blendFactor, 1);
            }

            if (MuscleController.MovingTarget != null) //If this is null then the whole mandible simulation is invalid and its better to do nothing
            {
                MuscleController.changeForce("MovingMuscleDynamic", targetState.muscleForce);
                MuscleController.MovingTarget.Offset = targetState.movingTargetPosition;

                ControlPointBehavior leftCP = ControlPointController.getControlPoint("LeftCP");
                float delta = targetState.leftCPPosition - leftCPPosition;
                leftCP.setLocation(leftCPPosition + delta * modifiedBlendFactor);

                ControlPointBehavior rightCP = ControlPointController.getControlPoint("RightCP");
                delta = targetState.rightCPPosition - rightCPPosition;
                rightCP.setLocation(rightCPPosition + delta * modifiedBlendFactor);
            }

            FKRoot pelvis;

            if (pelvisChainState != null && targetState.pelvisChainState != null && PoseableObjectsManager.tryGetFkChainRoot("Pelvis", out pelvis))
            {
                //This creates garbage, but it is unknown if this has negative effects
                FKChainState blendedState = new FKChainState();
                blendedState.setToBlendOf(pelvisChainState, targetState.pelvisChainState, modifiedBlendFactor);
                pelvis.applyChainState(blendedState);
            }
        }
示例#2
0
        public void captureState()
        {
            MuscleBehavior movingMuscle = MuscleController.getMuscle("MovingMuscleDynamic");

            if (movingMuscle != null)
            {
                muscleForce = movingMuscle.getForce();
            }
            if (MuscleController.MovingTarget != null)
            {
                movingTargetPosition = MuscleController.MovingTarget.Offset;
            }
            ControlPointBehavior leftCP  = ControlPointController.getControlPoint("LeftCP");
            ControlPointBehavior rightCP = ControlPointController.getControlPoint("RightCP");

            if (leftCP != null)
            {
                leftCPPosition = leftCP.CurrentLocation;
            }
            if (rightCP != null)
            {
                rightCPPosition = rightCP.CurrentLocation;
            }

            //Setup the pelvis fk chain if available
            FKRoot pelvis;

            if (PoseableObjectsManager.tryGetFkChainRoot("Pelvis", out pelvis))
            {
                pelvisChainState = new FKChainState();
                pelvis.addToChainState(pelvisChainState);
            }
            else
            {
                pelvisChainState = null;
            }
        }