예제 #1
0
        private void CreatePointStates(AnimatorController animator, int layerIndex, HandClips clips)
        {
            BlendTree     blendTree;
            AnimatorState flexState = animator.CreateBlendTreeInController("Point", out blendTree, layerIndex);

            blendTree.blendType      = BlendTreeType.Simple1D;
            blendTree.blendParameter = FLEX_PARAM;
            blendTree.AddChild(clips.indexCap, 0f);
            blendTree.AddChild(clips.indexPoint, 1f);
            blendTree.useAutomaticThresholds = true;
            animator.layers[layerIndex].stateMachine.defaultState = flexState;
        }
예제 #2
0
        private void CreateFlexStates(AnimatorController animator, int layerIndex, HandClips clips)
        {
            BlendTree     blendTree;
            AnimatorState flexState = animator.CreateBlendTreeInController("Flex", out blendTree, layerIndex);

            blendTree.blendType       = BlendTreeType.FreeformCartesian2D;
            blendTree.blendParameter  = FLEX_PARAM;
            blendTree.blendParameterY = PINCH_PARAM;
            blendTree.AddChild(clips.handCap, new Vector2(0f, 0f));
            blendTree.AddChild(clips.handPinch, new Vector2(0f, 0.835f));
            blendTree.AddChild(clips.handPinch, new Vector2(0f, 1f));
            blendTree.AddChild(clips.handMidFist, new Vector2(0.5f, 0f));
            blendTree.AddChild(clips.handMidFist, new Vector2(0.5f, 1f));
            blendTree.AddChild(clips.hand3qtrFist, new Vector2(0.835f, 0f));
            blendTree.AddChild(clips.hand3qtrFist, new Vector2(0.835f, 1f));
            blendTree.AddChild(clips.handFist, new Vector2(1f, 0f));
            blendTree.AddChild(clips.handFist, new Vector2(1f, 1f));
            animator.layers[layerIndex].stateMachine.defaultState = flexState;
        }
예제 #3
0
        private AnimatorController CreateAnimator(string path, HandClips clips)
        {
            AnimatorController animator = AnimatorController.CreateAnimatorControllerAtPath(path);

            animator.AddParameter(FLEX_PARAM, AnimatorControllerParameterType.Float);
            animator.AddParameter(POSE_PARAM, AnimatorControllerParameterType.Float);
            animator.AddParameter(PINCH_PARAM, AnimatorControllerParameterType.Float);

            animator.RemoveLayer(0);
            CreateLayer(animator, "Flex Layer");
            CreateLayer(animator, "Thumb Layer");
            CreateLayer(animator, "Point Layer");

            CreateFlexStates(animator, 0, clips);
            CreateThumbUpStates(animator, 1, clips);
            CreatePointStates(animator, 2, clips);

            return(animator);
        }
예제 #4
0
        private void GenerateMirrorAnimatorAsset()
        {
            HandClips clips = new HandClips()
            {
                handFist     = GenerateMirrorClipAsset(_handFist),
                hand3qtrFist = GenerateMirrorClipAsset(_hand3qtrFist),
                handMidFist  = GenerateMirrorClipAsset(_handMidFist),
                handPinch    = GenerateMirrorClipAsset(_handPinch),
                handCap      = GenerateMirrorClipAsset(_handCap),
                thumbUp      = GenerateMirrorClipAsset(_thumbUp),
                indexPoint   = GenerateMirrorClipAsset(_indexPoint),

                indexMask = GenerateMirrorMaskAsset(_indexMask),
                thumbMask = GenerateMirrorMaskAsset(_thumbMask)
            };

            GetHandPrefixes(out string prefix, out string mirrorPrefix);
            string path = GenerateAnimatorPath(mirrorPrefix);

            CreateAnimator(path, clips);
        }
예제 #5
0
        private void GenerateAnimatorAsset()
        {
            HandClips clips = new HandClips()
            {
                handFist     = _handFist,
                hand3qtrFist = _hand3qtrFist,
                handMidFist  = _handMidFist,
                handPinch    = _handPinch,
                handCap      = _handCap,
                thumbUp      = _thumbUp,
                indexPoint   = _indexPoint,

                indexMask = _indexMask,
                thumbMask = _thumbMask
            };

            GetHandPrefixes(out string prefix, out string mirrorPrefix);
            string path = GenerateAnimatorPath(prefix);

            CreateAnimator(path, clips);
        }
예제 #6
0
        private void CreateThumbUpStates(AnimatorController animator, int layerIndex, HandClips clips)
        {
            AnimatorState thumbupState = animator.AddMotion(clips.thumbUp, layerIndex);

            animator.layers[layerIndex].stateMachine.defaultState = thumbupState;
        }