Example #1
0
        public MotionMatchingState(string name, MotionMatchingStateType type, int index, int stateID)
        {
            this.name               = name;
            this.stateType          = type;
            this.index              = index;
            this.nodeID             = stateID;
            poseCostType            = PoseCostType.Position;
            trajectoryCostType      = TrajectoryCostType.PositionVelocityOrientation;
            trajectoryCostWeight    = 1f;
            poseCostWeight          = 1f;
            transitions             = new List <Transition>();
            speedMultiplier         = 1f;
            whereCanFindingNextPose = new List <float2>();
            motionDataGroups        = new List <MotionDataGroup>();
            motionDataGroups.Add(new MotionDataGroup("MotionGroup"));

            switch (this.stateType)
            {
            case MotionMatchingStateType.MotionMatching:
                mmFeatures = new MotionMatchingStateFeatures();
                break;

            case MotionMatchingStateType.SingleAnimation:
                saFeatures = new SingleAnimationStateFeatures();
                break;

            case MotionMatchingStateType.ContactAnimationState:
                csFeatures = new ContactStateFeatures();
                break;
            }
        }
Example #2
0
 public int ShouldTransitionBegin(
     float currentAnimLocalTime,
     float currentAnimGlobalTime,
     int animationIndex,
     MotionMatching motionMatchingComponent,
     MotionMatchingStateType currentStateType,
     MotionMatchingData data
     )
 {
     for (int i = 0; i < options.Count; i++)
     {
         if (options[i].ShouldTranistionFromThisOption(
                 currentAnimLocalTime,
                 currentAnimGlobalTime,
                 animationIndex,
                 motionMatchingComponent,
                 currentStateType,
                 data
                 ))
         {
             return(i);
         }
     }
     return(-1);
 }
        // Adding and removing state
        public void AddState(
            string stateName,
            MotionMatchingStateType type,
            int stateID,
            Vector2 nodePosition
            )
        {
            string newName = stateName;
            int    counter = 0;

            if (states == null)
            {
                states = new List <MotionMatchingState>();
            }
            for (int i = 0; i < states.Count; i++)
            {
                if (states[i].GetName() == newName)
                {
                    counter++;
                    newName = stateName + counter.ToString();
                    i       = 0;
                }
            }
            int stateIndex = states.Count;

            states.Add(new MotionMatchingState(newName, type, stateIndex, stateID));
            if (nodes == null)
            {
                nodes = new List <MotionMatchingNode>();
            }
            string title = "";

            switch (type)
            {
            case MotionMatchingStateType.MotionMatching:
                title = "Motion Matching:";
                break;

            case MotionMatchingStateType.SingleAnimation:
                title = "Single Animation:";
                break;

            case MotionMatchingStateType.ContactAnimationState:
                title = "Contact State:";
                break;
            }
            nodes.Add(new MotionMatchingNode(
                          new Rect(nodePosition, new Vector2(nodeW, nodeH)),
                          type == MotionMatchingStateType.ContactAnimationState ? MotionMatchingNodeType.Contact : MotionMatchingNodeType.State,
                          title,
                          stateID,
                          stateIndex
                          ));
        }
 public int GetIndexOfFirstStateDiffrentType(MotionMatchingStateType type)
 {
     for (int i = 0; i < this.states.Count; i++)
     {
         if (this.states[i].GetStateType() != type)
         {
             return(i);
         }
     }
     return(-1);
 }
Example #5
0
        public bool ShouldTranistionFromThisOption(
            float currentAnimLocalTime,
            float currentAnimGlobalTime,
            int animationIndex,
            MotionMatching motionMatchingComponent,
            MotionMatchingStateType currentStateType,
            MotionMatchingData data
            )
        {
            if (currentStateType != MotionMatchingStateType.MotionMatching)
            {
                if (
                    (currentAnimLocalTime < this.whenCanCheckingTransition[animationIndex].x || currentAnimLocalTime > this.whenCanCheckingTransition[animationIndex].y)
                    )
                {
                    if (
                        (startOnExitTime && currentAnimGlobalTime < (data.animationLength - (blendTime))) ||
                        !startOnExitTime
                        )
                    {
                        return(false);
                    }
                }
            }

            for (int conditionIndex = 0; conditionIndex < floatConditions.Count; conditionIndex++)
            {
                if (!floatConditions[conditionIndex].CalculateCondition(motionMatchingComponent))
                {
                    return(false);
                }
            }

            for (int conditionIndex = 0; conditionIndex < intConditions.Count; conditionIndex++)
            {
                if (!intConditions[conditionIndex].CalculateCondition(motionMatchingComponent))
                {
                    return(false);
                }
            }

            for (int conditionIndex = 0; conditionIndex < boolConditions.Count; conditionIndex++)
            {
                if (!boolConditions[conditionIndex].CalculateCondition(motionMatchingComponent))
                {
                    return(false);
                }
            }

            return(true);
        }
Example #6
0
        public Transition(MotionMatchingStateType type, int toState)
        {
            this.nextStateIndex = toState;
            this.nextStateType  = type;
            options             = new List <TransitionOptions>();

            switch (this.nextStateType)
            {
            case MotionMatchingStateType.MotionMatching:

                break;

            case MotionMatchingStateType.SingleAnimation:

                break;
            }
        }