From 70f58352786ce74bc986fbfb9021d6313b32cb9d Mon Sep 17 00:00:00 2001
From: "Anthony J. Thibault" <tony@highfidelity.io>
Date: Tue, 15 Sep 2015 18:00:13 -0700
Subject: [PATCH] Updated left hand point and grab State Machine and animations

---
 interface/src/avatar/MyAvatar.cpp    |   2 +-
 tests/animation/src/data/avatar.json | 128 ++++++++++++++++++++-------
 2 files changed, 98 insertions(+), 32 deletions(-)

diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp
index da2e78c5a3..e165b5c617 100644
--- a/interface/src/avatar/MyAvatar.cpp
+++ b/interface/src/avatar/MyAvatar.cpp
@@ -1302,7 +1302,7 @@ void MyAvatar::initAnimGraph() {
     // or run a local web-server
     // python -m SimpleHTTPServer&
     //auto graphUrl = QUrl("http://localhost:8000/avatar.json");
-    auto graphUrl = QUrl("https://gist.githubusercontent.com/hyperlogic/04a02c47eb56d8bfaebb/raw/883c7ce8e75ad3f72a0d513c317fe4b74a41c3b8/ik-avatar-hands.json");
+    auto graphUrl = QUrl("https://gist.githubusercontent.com/hyperlogic/04a02c47eb56d8bfaebb/raw/5f2a4e268d35147c83d44881e268f83a6296e89b/ik-avatar-hands.json");
     _rig->initAnimGraph(graphUrl, _skeletonModel.getGeometry()->getFBXGeometry());
 }
 
diff --git a/tests/animation/src/data/avatar.json b/tests/animation/src/data/avatar.json
index 72650893d7..f5adfe2bfd 100644
--- a/tests/animation/src/data/avatar.json
+++ b/tests/animation/src/data/avatar.json
@@ -120,7 +120,7 @@
                                         "id": "rightHandIdle",
                                         "type": "clip",
                                         "data": {
-                                            "url": "http://hifi-public.s3.amazonaws.com/ozan/anim/hand_anims/right_hand_point.fbx",
+                                            "url": "http://hifi-public.s3.amazonaws.com/ozan/anim/hand_anims/point_right_hand.fbx",
                                             "startFrame": 0.0,
                                             "endFrame": 0.0,
                                             "timeScale": 1.0,
@@ -132,7 +132,7 @@
                                         "id": "rightHandPointHold",
                                         "type": "clip",
                                         "data": {
-                                            "url": "http://hifi-public.s3.amazonaws.com/ozan/anim/hand_anims/right_hand_point.fbx",
+                                            "url": "http://hifi-public.s3.amazonaws.com/ozan/anim/hand_anims/point_right_hand.fbx",
                                             "startFrame": 12.0,
                                             "endFrame": 12.0,
                                             "timeScale": 1.0,
@@ -144,7 +144,7 @@
                                         "id": "rightHandPointIntro",
                                         "type": "clip",
                                         "data": {
-                                            "url": "http://hifi-public.s3.amazonaws.com/ozan/anim/hand_anims/right_hand_point.fbx",
+                                            "url": "http://hifi-public.s3.amazonaws.com/ozan/anim/hand_anims/point_right_hand.fbx",
                                             "startFrame": 0.0,
                                             "endFrame": 12.0,
                                             "timeScale": 1.0,
@@ -156,7 +156,7 @@
                                         "id": "rightHandPointOutro",
                                         "type": "clip",
                                         "data": {
-                                            "url": "http://hifi-public.s3.amazonaws.com/ozan/anim/hand_anims/right_hand_point.fbx",
+                                            "url": "http://hifi-public.s3.amazonaws.com/ozan/anim/hand_anims/point_right_hand.fbx",
                                             "startFrame": 0.0,
                                             "endFrame": 65.0,
                                             "timeScale": 1.0,
@@ -176,7 +176,7 @@
                                                 "id": "rightHandOpen",
                                                 "type": "clip",
                                                 "data": {
-                                                    "url": "http://hifi-public.s3.amazonaws.com/ozan/anim/hand_anims/right_hand_point.fbx",
+                                                    "url": "http://hifi-public.s3.amazonaws.com/ozan/anim/hand_anims/point_right_hand.fbx",
                                                     "startFrame": 0.0,
                                                     "endFrame": 0.0,
                                                     "timeScale": 1.0,
@@ -217,29 +217,49 @@
                                             "states": [
                                                 {
                                                     "id": "leftHandIdle",
-                                                    "interpTarget": 6,
-                                                    "interpDuration": 6,
+                                                    "interpTarget": 3,
+                                                    "interpDuration": 3,
                                                     "transitions": [
-                                                        { "var": "isLeftHandPoint", "state": "leftHandPoint" },
+                                                        { "var": "isLeftHandPoint", "state": "leftHandPointIntro" },
                                                         { "var": "isLeftHandGrab", "state": "leftHandGrab" }
                                                     ]
                                                 },
                                                 {
-                                                    "id": "leftHandPoint",
-                                                    "interpTarget": 6,
-                                                    "interpDuration": 6,
+                                                    "id": "leftHandPointIntro",
+                                                    "interpTarget": 3,
+                                                    "interpDuration": 3,
                                                     "transitions": [
                                                         { "var": "isLeftHandIdle", "state": "leftHandIdle" },
+                                                        { "var": "isLeftHandPointIntroOnDone", "state": "leftHandPointHold" },
                                                         { "var": "isLeftHandGrab", "state": "leftHandGrab" }
                                                     ]
                                                 },
+                                                {
+                                                    "id": "leftHandPointHold",
+                                                    "interpTarget": 3,
+                                                    "interpDuration": 3,
+                                                    "transitions": [
+                                                        { "var": "isLeftHandIdle", "state": "leftHandPointOutro" },
+                                                        { "var": "isLeftHandGrab", "state": "leftHandGrab" }
+                                                    ]
+                                                },
+                                                {
+                                                    "id": "leftHandPointOutro",
+                                                    "interpTarget": 3,
+                                                    "interpDuration": 3,
+                                                    "transitions": [
+                                                        { "var": "isLeftHandPointOutroOnDone", "state": "leftHandIdle" },
+                                                        { "var": "isLeftHandGrab", "state": "leftHandGrab" },
+                                                        { "var": "isLeftHandPoint", "state": "leftHandPointHold" }
+                                                    ]
+                                                },
                                                 {
                                                     "id": "leftHandGrab",
-                                                    "interpTarget": 6,
-                                                    "interpDuration": 6,
+                                                    "interpTarget": 3,
+                                                    "interpDuration": 3,
                                                     "transitions": [
                                                         { "var": "isLeftHandIdle", "state": "leftHandIdle" },
-                                                        { "var": "isLeftHandPoint", "state": "leftHandPoint" }
+                                                        { "var": "isLeftHandPoint_DISABLED", "state": "leftHandPointHold" }
                                                     ]
                                                 }
                                             ]
@@ -249,19 +269,7 @@
                                                 "id": "leftHandIdle",
                                                 "type": "clip",
                                                 "data": {
-                                                    "url": "http://hifi-public.s3.amazonaws.com/ozan/anim/squeeze_hands/left_hand_anim.fbx",
-                                                    "startFrame": 30.0,
-                                                    "endFrame": 30.0,
-                                                    "timeScale": 1.0,
-                                                    "loopFlag": true
-                                                },
-                                                "children": []
-                                            },
-                                            {
-                                                "id": "leftHandPoint",
-                                                "type": "clip",
-                                                "data": {
-                                                    "url": "http://hifi-public.s3.amazonaws.com/ozan/anim/squeeze_hands/left_hand_anim.fbx",
+                                                    "url": "http://hifi-public.s3.amazonaws.com/ozan/anim/hand_anims/point_left_hand.fbx",
                                                     "startFrame": 0.0,
                                                     "endFrame": 0.0,
                                                     "timeScale": 1.0,
@@ -270,16 +278,74 @@
                                                 "children": []
                                             },
                                             {
-                                                "id": "leftHandGrab",
+                                                "id": "leftHandPointHold",
                                                 "type": "clip",
                                                 "data": {
-                                                    "url": "http://hifi-public.s3.amazonaws.com/ozan/anim/squeeze_hands/left_hand_anim.fbx",
-                                                    "startFrame": 15.0,
-                                                    "endFrame": 15.0,
+                                                    "url": "http://hifi-public.s3.amazonaws.com/ozan/anim/hand_anims/point_left_hand.fbx",
+                                                    "startFrame": 12.0,
+                                                    "endFrame": 12.0,
                                                     "timeScale": 1.0,
                                                     "loopFlag": true
                                                 },
                                                 "children": []
+                                            },
+                                            {
+                                                "id": "leftHandPointIntro",
+                                                "type": "clip",
+                                                "data": {
+                                                    "url": "http://hifi-public.s3.amazonaws.com/ozan/anim/hand_anims/point_left_hand.fbx",
+                                                    "startFrame": 0.0,
+                                                    "endFrame": 12.0,
+                                                    "timeScale": 1.0,
+                                                    "loopFlag": false
+                                                },
+                                                "children": []
+                                            },
+                                            {
+                                                "id": "leftHandPointOutro",
+                                                "type": "clip",
+                                                "data": {
+                                                    "url": "http://hifi-public.s3.amazonaws.com/ozan/anim/hand_anims/point_left_hand.fbx",
+                                                    "startFrame": 0.0,
+                                                    "endFrame": 65.0,
+                                                    "timeScale": 1.0,
+                                                    "loopFlag": false
+                                                },
+                                                "children": []
+                                            },
+                                            {
+                                                "id": "leftHandGrab",
+                                                "type": "blendLinear",
+                                                "data": {
+                                                    "alpha": 0.0,
+                                                    "alphaVar": "leftHandGrabBlend"
+                                                },
+                                                "children": [
+                                                    {
+                                                        "id": "leftHandOpen",
+                                                        "type": "clip",
+                                                        "data": {
+                                                            "url": "http://hifi-public.s3.amazonaws.com/ozan/anim/hand_anims/point_left_hand.fbx",
+                                                            "startFrame": 0.0,
+                                                            "endFrame": 0.0,
+                                                            "timeScale": 1.0,
+                                                            "loopFlag": true
+                                                        },
+                                                        "children": []
+                                                    },
+                                                    {
+                                                        "id": "leftHandClose",
+                                                        "type": "clip",
+                                                        "data": {
+                                                            "url": "http://hifi-public.s3.amazonaws.com/ozan/anim/squeeze_hands/left_hand_anim.fbx",
+                                                            "startFrame": 15.0,
+                                                            "endFrame": 15.0,
+                                                            "timeScale": 1.0,
+                                                            "loopFlag": true
+                                                        },
+                                                        "children": []
+                                                    }
+                                                ]
                                             }
                                         ]
                                     },