mirror of
https://github.com/JulianGro/overte.git
synced 2025-05-07 15:39:51 +02:00
Merge pull request #9756 from ctrlaltdavid/21122
Point index finger and raise thumb if not touching controller
This commit is contained in:
commit
4925b3c47c
14 changed files with 306 additions and 24 deletions
Binary file not shown.
Binary file not shown.
BIN
interface/resources/avatar/animations/touch_point_open_left.fbx
Normal file
BIN
interface/resources/avatar/animations/touch_point_open_left.fbx
Normal file
Binary file not shown.
BIN
interface/resources/avatar/animations/touch_point_open_right.fbx
Normal file
BIN
interface/resources/avatar/animations/touch_point_open_right.fbx
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
interface/resources/avatar/animations/touch_thumb_open_left.fbx
Normal file
BIN
interface/resources/avatar/animations/touch_thumb_open_left.fbx
Normal file
Binary file not shown.
BIN
interface/resources/avatar/animations/touch_thumb_open_right.fbx
Normal file
BIN
interface/resources/avatar/animations/touch_thumb_open_right.fbx
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -128,7 +128,41 @@
|
||||||
"id": "rightHandGrasp",
|
"id": "rightHandGrasp",
|
||||||
"interpTarget": 3,
|
"interpTarget": 3,
|
||||||
"interpDuration": 3,
|
"interpDuration": 3,
|
||||||
"transitions": []
|
"transitions": [
|
||||||
|
{ "var": "isRightIndexPoint", "state": "rightIndexPoint" },
|
||||||
|
{ "var": "isRightThumbRaise", "state": "rightThumbRaise" },
|
||||||
|
{ "var": "isRightIndexPointAndThumbRaise", "state": "rightIndexPointAndThumbRaise" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "rightIndexPoint",
|
||||||
|
"interpTarget": 15,
|
||||||
|
"interpDuration": 3,
|
||||||
|
"transitions": [
|
||||||
|
{ "var": "isRightHandGrasp", "state": "rightHandGrasp" },
|
||||||
|
{ "var": "isRightThumbRaise", "state": "rightThumbRaise" },
|
||||||
|
{ "var": "isRightIndexPointAndThumbRaise", "state": "rightIndexPointAndThumbRaise" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "rightThumbRaise",
|
||||||
|
"interpTarget": 15,
|
||||||
|
"interpDuration": 3,
|
||||||
|
"transitions": [
|
||||||
|
{ "var": "isRightHandGrasp", "state": "rightHandGrasp" },
|
||||||
|
{ "var": "isRightIndexPoint", "state": "rightIndexPoint" },
|
||||||
|
{ "var": "isRightIndexPointAndThumbRaise", "state": "rightIndexPointAndThumbRaise" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "rightIndexPointAndThumbRaise",
|
||||||
|
"interpTarget": 15,
|
||||||
|
"interpDuration": 3,
|
||||||
|
"transitions": [
|
||||||
|
{ "var": "isRightHandGrasp", "state": "rightHandGrasp" },
|
||||||
|
{ "var": "isRightIndexPoint", "state": "rightIndexPoint" },
|
||||||
|
{ "var": "isRightThumbRaise", "state": "rightThumbRaise" }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -166,6 +200,108 @@
|
||||||
"children": []
|
"children": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "rightIndexPoint",
|
||||||
|
"type": "blendLinear",
|
||||||
|
"data": {
|
||||||
|
"alpha": 0.0,
|
||||||
|
"alphaVar": "rightHandGraspAlpha"
|
||||||
|
},
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": "rightIndexPointOpen",
|
||||||
|
"type": "clip",
|
||||||
|
"data": {
|
||||||
|
"url": "animations/touch_point_open_right.fbx",
|
||||||
|
"startFrame": 15.0,
|
||||||
|
"endFrame": 15.0,
|
||||||
|
"timeScale": 1.0,
|
||||||
|
"loopFlag": true
|
||||||
|
},
|
||||||
|
"children": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "rightIndexPointClosed",
|
||||||
|
"type": "clip",
|
||||||
|
"data": {
|
||||||
|
"url": "animations/touch_point_closed_right.fbx",
|
||||||
|
"startFrame": 15.0,
|
||||||
|
"endFrame": 15.0,
|
||||||
|
"timeScale": 1.0,
|
||||||
|
"loopFlag": true
|
||||||
|
},
|
||||||
|
"children": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "rightThumbRaise",
|
||||||
|
"type": "blendLinear",
|
||||||
|
"data": {
|
||||||
|
"alpha": 0.0,
|
||||||
|
"alphaVar": "rightHandGraspAlpha"
|
||||||
|
},
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": "rightThumbRaiseOpen",
|
||||||
|
"type": "clip",
|
||||||
|
"data": {
|
||||||
|
"url": "animations/touch_thumb_open_right.fbx",
|
||||||
|
"startFrame": 15.0,
|
||||||
|
"endFrame": 15.0,
|
||||||
|
"timeScale": 1.0,
|
||||||
|
"loopFlag": true
|
||||||
|
},
|
||||||
|
"children": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "rightThumbRaiseClosed",
|
||||||
|
"type": "clip",
|
||||||
|
"data": {
|
||||||
|
"url": "animations/touch_thumb_closed_right.fbx",
|
||||||
|
"startFrame": 15.0,
|
||||||
|
"endFrame": 15.0,
|
||||||
|
"timeScale": 1.0,
|
||||||
|
"loopFlag": true
|
||||||
|
},
|
||||||
|
"children": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "rightIndexPointAndThumbRaise",
|
||||||
|
"type": "blendLinear",
|
||||||
|
"data": {
|
||||||
|
"alpha": 0.0,
|
||||||
|
"alphaVar": "rightHandGraspAlpha"
|
||||||
|
},
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": "rightIndexPointAndThumbRaiseOpen",
|
||||||
|
"type": "clip",
|
||||||
|
"data": {
|
||||||
|
"url": "animations/touch_thumb_point_open_right.fbx",
|
||||||
|
"startFrame": 15.0,
|
||||||
|
"endFrame": 15.0,
|
||||||
|
"timeScale": 1.0,
|
||||||
|
"loopFlag": true
|
||||||
|
},
|
||||||
|
"children": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "rightIndexPointAndThumbRaiseClosed",
|
||||||
|
"type": "clip",
|
||||||
|
"data": {
|
||||||
|
"url": "animations/touch_thumb_point_closed_right.fbx",
|
||||||
|
"startFrame": 15.0,
|
||||||
|
"endFrame": 15.0,
|
||||||
|
"timeScale": 1.0,
|
||||||
|
"loopFlag": true
|
||||||
|
},
|
||||||
|
"children": []
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -175,7 +311,7 @@
|
||||||
"data": {
|
"data": {
|
||||||
"alpha": 0.0,
|
"alpha": 0.0,
|
||||||
"boneSet": "leftHand",
|
"boneSet": "leftHand",
|
||||||
"alphaVar" : "leftHandOverlayAlpha"
|
"alphaVar": "leftHandOverlayAlpha"
|
||||||
},
|
},
|
||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
|
@ -188,7 +324,41 @@
|
||||||
"id": "leftHandGrasp",
|
"id": "leftHandGrasp",
|
||||||
"interpTarget": 3,
|
"interpTarget": 3,
|
||||||
"interpDuration": 3,
|
"interpDuration": 3,
|
||||||
"transitions": []
|
"transitions": [
|
||||||
|
{ "var": "isLeftIndexPoint", "state": "leftIndexPoint" },
|
||||||
|
{ "var": "isLeftThumbRaise", "state": "leftThumbRaise" },
|
||||||
|
{ "var": "isLeftIndexPointAndThumbRaise", "state": "leftIndexPointAndThumbRaise" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "leftIndexPoint",
|
||||||
|
"interpTarget": 15,
|
||||||
|
"interpDuration": 3,
|
||||||
|
"transitions": [
|
||||||
|
{ "var": "isLeftHandGrasp", "state": "leftHandGrasp" },
|
||||||
|
{ "var": "isLeftThumbRaise", "state": "leftThumbRaise" },
|
||||||
|
{ "var": "isLeftIndexPointAndThumbRaise", "state": "leftIndexPointAndThumbRaise" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "leftThumbRaise",
|
||||||
|
"interpTarget": 15,
|
||||||
|
"interpDuration": 3,
|
||||||
|
"transitions": [
|
||||||
|
{ "var": "isLeftHandGrasp", "state": "leftHandGrasp" },
|
||||||
|
{ "var": "isLeftIndexPoint", "state": "leftIndexPoint" },
|
||||||
|
{ "var": "isLeftIndexPointAndThumbRaise", "state": "leftIndexPointAndThumbRaise" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "leftIndexPointAndThumbRaise",
|
||||||
|
"interpTarget": 15,
|
||||||
|
"interpDuration": 3,
|
||||||
|
"transitions": [
|
||||||
|
{ "var": "isLeftHandGrasp", "state": "leftHandGrasp" },
|
||||||
|
{ "var": "isLeftIndexPoint", "state": "leftIndexPoint" },
|
||||||
|
{ "var": "isLeftThumbRaise", "state": "leftThumbRaise" }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -226,6 +396,108 @@
|
||||||
"children": []
|
"children": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "leftIndexPoint",
|
||||||
|
"type": "blendLinear",
|
||||||
|
"data": {
|
||||||
|
"alpha": 0.0,
|
||||||
|
"alphaVar": "leftHandGraspAlpha"
|
||||||
|
},
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": "leftIndexPointOpen",
|
||||||
|
"type": "clip",
|
||||||
|
"data": {
|
||||||
|
"url": "animations/touch_point_open_left.fbx",
|
||||||
|
"startFrame": 15.0,
|
||||||
|
"endFrame": 15.0,
|
||||||
|
"timeScale": 1.0,
|
||||||
|
"loopFlag": true
|
||||||
|
},
|
||||||
|
"children": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "leftIndexPointClosed",
|
||||||
|
"type": "clip",
|
||||||
|
"data": {
|
||||||
|
"url": "animations/touch_point_closed_left.fbx",
|
||||||
|
"startFrame": 15.0,
|
||||||
|
"endFrame": 15.0,
|
||||||
|
"timeScale": 1.0,
|
||||||
|
"loopFlag": true
|
||||||
|
},
|
||||||
|
"children": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "leftThumbRaise",
|
||||||
|
"type": "blendLinear",
|
||||||
|
"data": {
|
||||||
|
"alpha": 0.0,
|
||||||
|
"alphaVar": "leftHandGraspAlpha"
|
||||||
|
},
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": "leftThumbRaiseOpen",
|
||||||
|
"type": "clip",
|
||||||
|
"data": {
|
||||||
|
"url": "animations/touch_thumb_open_left.fbx",
|
||||||
|
"startFrame": 15.0,
|
||||||
|
"endFrame": 15.0,
|
||||||
|
"timeScale": 1.0,
|
||||||
|
"loopFlag": true
|
||||||
|
},
|
||||||
|
"children": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "leftThumbRaiseClosed",
|
||||||
|
"type": "clip",
|
||||||
|
"data": {
|
||||||
|
"url": "animations/touch_thumb_closed_left.fbx",
|
||||||
|
"startFrame": 15.0,
|
||||||
|
"endFrame": 15.0,
|
||||||
|
"timeScale": 1.0,
|
||||||
|
"loopFlag": true
|
||||||
|
},
|
||||||
|
"children": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "leftIndexPointAndThumbRaise",
|
||||||
|
"type": "blendLinear",
|
||||||
|
"data": {
|
||||||
|
"alpha": 0.0,
|
||||||
|
"alphaVar": "leftHandGraspAlpha"
|
||||||
|
},
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": "leftIndexPointAndThumbRaiseOpen",
|
||||||
|
"type": "clip",
|
||||||
|
"data": {
|
||||||
|
"url": "animations/touch_thumb_point_open_left.fbx",
|
||||||
|
"startFrame": 15.0,
|
||||||
|
"endFrame": 15.0,
|
||||||
|
"timeScale": 1.0,
|
||||||
|
"loopFlag": true
|
||||||
|
},
|
||||||
|
"children": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "leftIndexPointAndThumbRaiseClosed",
|
||||||
|
"type": "clip",
|
||||||
|
"data": {
|
||||||
|
"url": "animations/touch_thumb_point_closed_left.fbx",
|
||||||
|
"startFrame": 15.0,
|
||||||
|
"endFrame": 15.0,
|
||||||
|
"timeScale": 1.0,
|
||||||
|
"loopFlag": true
|
||||||
|
},
|
||||||
|
"children": []
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -25,10 +25,13 @@ var OVERLAY_RAMP_RATE = 8.0;
|
||||||
|
|
||||||
var animStateHandlerID;
|
var animStateHandlerID;
|
||||||
|
|
||||||
var isPointingIndex = false;
|
var isBothIndexesPointing = false;
|
||||||
var HIFI_POINT_INDEX_MESSAGE_CHANNEL = "Hifi-Point-Index";
|
var HIFI_POINT_INDEX_MESSAGE_CHANNEL = "Hifi-Point-Index";
|
||||||
|
|
||||||
var indexfingerJointNames = ["LeftHandIndex1", "LeftHandIndex2", "LeftHandIndex3", "RightHandIndex1", "RightHandIndex2", "RightHandIndex3"];
|
var isLeftIndexPointing = false;
|
||||||
|
var isRightIndexPointing = false;
|
||||||
|
var isLeftThumbRaised = false;
|
||||||
|
var isRightThumbRaised = false;
|
||||||
|
|
||||||
function clamp(val, min, max) {
|
function clamp(val, min, max) {
|
||||||
return Math.min(Math.max(val, min), max);
|
return Math.min(Math.max(val, min), max);
|
||||||
|
@ -46,17 +49,32 @@ function init() {
|
||||||
Script.update.connect(update);
|
Script.update.connect(update);
|
||||||
animStateHandlerID = MyAvatar.addAnimationStateHandler(
|
animStateHandlerID = MyAvatar.addAnimationStateHandler(
|
||||||
animStateHandler,
|
animStateHandler,
|
||||||
["leftHandOverlayAlpha", "rightHandOverlayAlpha", "leftHandGraspAlpha", "rightHandGraspAlpha"]
|
[
|
||||||
|
"leftHandOverlayAlpha", "leftHandGraspAlpha",
|
||||||
|
"rightHandOverlayAlpha", "rightHandGraspAlpha",
|
||||||
|
"isLeftHandGrasp", "isLeftIndexPoint", "isLeftThumbRaise", "isLeftIndexPointAndThumbRaise",
|
||||||
|
"isRightHandGrasp", "isRightIndexPoint", "isRightThumbRaise", "isRightIndexPointAndThumbRaise",
|
||||||
|
]
|
||||||
);
|
);
|
||||||
Messages.subscribe(HIFI_POINT_INDEX_MESSAGE_CHANNEL);
|
Messages.subscribe(HIFI_POINT_INDEX_MESSAGE_CHANNEL);
|
||||||
Messages.messageReceived.connect(handleMessages);
|
Messages.messageReceived.connect(handleMessages);
|
||||||
}
|
}
|
||||||
|
|
||||||
function animStateHandler(props) {
|
function animStateHandler(props) {
|
||||||
return { leftHandOverlayAlpha: leftHandOverlayAlpha,
|
return {
|
||||||
leftHandGraspAlpha: lastLeftTrigger,
|
leftHandOverlayAlpha: leftHandOverlayAlpha,
|
||||||
rightHandOverlayAlpha: rightHandOverlayAlpha,
|
leftHandGraspAlpha: lastLeftTrigger,
|
||||||
rightHandGraspAlpha: lastRightTrigger };
|
rightHandOverlayAlpha: rightHandOverlayAlpha,
|
||||||
|
rightHandGraspAlpha: lastRightTrigger,
|
||||||
|
isLeftHandGrasp: !isBothIndexesPointing && !isLeftIndexPointing && !isLeftThumbRaised,
|
||||||
|
isLeftIndexPoint: (isBothIndexesPointing || isLeftIndexPointing) && !isLeftThumbRaised,
|
||||||
|
isLeftThumbRaise: !isBothIndexesPointing && !isLeftIndexPointing && isLeftThumbRaised,
|
||||||
|
isLeftIndexPointAndThumbRaise: (isBothIndexesPointing || isLeftIndexPointing) && isLeftThumbRaised,
|
||||||
|
isRightHandGrasp: !isBothIndexesPointing && !isRightIndexPointing && !isRightThumbRaised,
|
||||||
|
isRightIndexPoint: (isBothIndexesPointing || isRightIndexPointing) && !isRightThumbRaised,
|
||||||
|
isRightThumbRaise: !isBothIndexesPointing && !isRightIndexPointing && isRightThumbRaised,
|
||||||
|
isRightIndexPointAndThumbRaise: (isBothIndexesPointing || isRightIndexPointing) && isRightThumbRaised
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function update(dt) {
|
function update(dt) {
|
||||||
|
@ -84,13 +102,11 @@ function update(dt) {
|
||||||
rightHandOverlayAlpha = clamp(rightHandOverlayAlpha - OVERLAY_RAMP_RATE * dt, 0, 1);
|
rightHandOverlayAlpha = clamp(rightHandOverlayAlpha - OVERLAY_RAMP_RATE * dt, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Point index finger.
|
// Pointing index fingers and raising thumbs
|
||||||
if (isPointingIndex) {
|
isLeftIndexPointing = leftHandPose.valid && Controller.getValue(Controller.Standard.LeftIndexPoint) === 1;
|
||||||
var zeroRotation = { x: 0, y: 0, z: 0, w: 1 };
|
isRightIndexPointing = rightHandPose.valid && Controller.getValue(Controller.Standard.RightIndexPoint) === 1;
|
||||||
for (var i = 0; i < indexfingerJointNames.length; i++) {
|
isLeftThumbRaised = leftHandPose.valid && Controller.getValue(Controller.Standard.LeftThumbUp) === 1;
|
||||||
MyAvatar.setJointRotation(indexfingerJointNames[i], zeroRotation);
|
isRightThumbRaised = rightHandPose.valid && Controller.getValue(Controller.Standard.RightThumbUp) === 1;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleMessages(channel, message, sender) {
|
function handleMessages(channel, message, sender) {
|
||||||
|
@ -98,13 +114,7 @@ function handleMessages(channel, message, sender) {
|
||||||
var data = JSON.parse(message);
|
var data = JSON.parse(message);
|
||||||
if (data.pointIndex !== undefined) {
|
if (data.pointIndex !== undefined) {
|
||||||
print("pointIndex: " + data.pointIndex);
|
print("pointIndex: " + data.pointIndex);
|
||||||
isPointingIndex = data.pointIndex;
|
isBothIndexesPointing = data.pointIndex;
|
||||||
|
|
||||||
if (!isPointingIndex) {
|
|
||||||
for (var i = 0; i < indexfingerJointNames.length; i++) {
|
|
||||||
MyAvatar.clearJointData(indexfingerJointNames[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue