mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 11:44:09 +02:00
Use animation for pointing index finger instead of setting joint angles
This commit is contained in:
parent
e723385df2
commit
a205d2a00c
6 changed files with 107 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.
|
@ -128,7 +128,17 @@
|
||||||
"id": "rightHandGrasp",
|
"id": "rightHandGrasp",
|
||||||
"interpTarget": 3,
|
"interpTarget": 3,
|
||||||
"interpDuration": 3,
|
"interpDuration": 3,
|
||||||
"transitions": []
|
"transitions": [
|
||||||
|
{ "var": "isRightIndexPoint", "state": "rightIndexPoint" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "rightIndexPoint",
|
||||||
|
"interpTarget": 15,
|
||||||
|
"interpDuration": 3,
|
||||||
|
"transitions": [
|
||||||
|
{ "var": "isRightHandGrasp", "state": "rightHandGrasp" }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -166,6 +176,40 @@
|
||||||
"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": []
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -175,7 +219,7 @@
|
||||||
"data": {
|
"data": {
|
||||||
"alpha": 0.0,
|
"alpha": 0.0,
|
||||||
"boneSet": "leftHand",
|
"boneSet": "leftHand",
|
||||||
"alphaVar" : "leftHandOverlayAlpha"
|
"alphaVar": "leftHandOverlayAlpha"
|
||||||
},
|
},
|
||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
|
@ -188,7 +232,17 @@
|
||||||
"id": "leftHandGrasp",
|
"id": "leftHandGrasp",
|
||||||
"interpTarget": 3,
|
"interpTarget": 3,
|
||||||
"interpDuration": 3,
|
"interpDuration": 3,
|
||||||
"transitions": []
|
"transitions": [
|
||||||
|
{ "var": "isLeftIndexPoint", "state": "leftIndexPoint" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "leftIndexPoint",
|
||||||
|
"interpTarget": 15,
|
||||||
|
"interpDuration": 3,
|
||||||
|
"transitions": [
|
||||||
|
{ "var": "isLeftHandGrasp", "state": "leftHandGrasp" }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -226,6 +280,40 @@
|
||||||
"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": []
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -28,8 +28,6 @@ var animStateHandlerID;
|
||||||
var isPointingIndex = false;
|
var isPointingIndex = 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"];
|
|
||||||
|
|
||||||
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 +44,28 @@ 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",
|
||||||
|
"isRightHandGrasp", "isRightIndexPoint"
|
||||||
|
]
|
||||||
);
|
);
|
||||||
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: !isPointingIndex,
|
||||||
|
isLeftIndexPoint: isPointingIndex,
|
||||||
|
isRightHandGrasp: !isPointingIndex,
|
||||||
|
isRightIndexPoint: isPointingIndex
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function update(dt) {
|
function update(dt) {
|
||||||
|
@ -83,14 +92,6 @@ function update(dt) {
|
||||||
} else {
|
} else {
|
||||||
rightHandOverlayAlpha = clamp(rightHandOverlayAlpha - OVERLAY_RAMP_RATE * dt, 0, 1);
|
rightHandOverlayAlpha = clamp(rightHandOverlayAlpha - OVERLAY_RAMP_RATE * dt, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Point index finger.
|
|
||||||
if (isPointingIndex) {
|
|
||||||
var zeroRotation = { x: 0, y: 0, z: 0, w: 1 };
|
|
||||||
for (var i = 0; i < indexfingerJointNames.length; i++) {
|
|
||||||
MyAvatar.setJointRotation(indexfingerJointNames[i], zeroRotation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleMessages(channel, message, sender) {
|
function handleMessages(channel, message, sender) {
|
||||||
|
@ -99,12 +100,6 @@ function handleMessages(channel, message, sender) {
|
||||||
if (data.pointIndex !== undefined) {
|
if (data.pointIndex !== undefined) {
|
||||||
print("pointIndex: " + data.pointIndex);
|
print("pointIndex: " + data.pointIndex);
|
||||||
isPointingIndex = data.pointIndex;
|
isPointingIndex = data.pointIndex;
|
||||||
|
|
||||||
if (!isPointingIndex) {
|
|
||||||
for (var i = 0; i < indexfingerJointNames.length; i++) {
|
|
||||||
MyAvatar.clearJointData(indexfingerJointNames[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue