mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 06:53:01 +02:00
Desktop users of different height can shake hands
This commit is contained in:
parent
e4df4369ad
commit
52c288bfed
1 changed files with 34 additions and 2 deletions
|
@ -198,7 +198,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var animationData = {};
|
var animationData = {};
|
||||||
function updateAnimationData() {
|
function updateAnimationData(verticalOffset) {
|
||||||
// all we are doing here is moving the right hand to a spot
|
// all we are doing here is moving the right hand to a spot
|
||||||
// that is in front of and a bit above the hips. Basing how
|
// that is in front of and a bit above the hips. Basing how
|
||||||
// far in front as scaling with the avatar's height (say hips
|
// far in front as scaling with the avatar's height (say hips
|
||||||
|
@ -209,6 +209,9 @@
|
||||||
offset = 0.8 * MyAvatar.getAbsoluteJointTranslationInObjectFrame(headIndex).y;
|
offset = 0.8 * MyAvatar.getAbsoluteJointTranslationInObjectFrame(headIndex).y;
|
||||||
}
|
}
|
||||||
animationData.rightHandPosition = Vec3.multiply(offset, {x: -0.25, y: 0.8, z: 1.3});
|
animationData.rightHandPosition = Vec3.multiply(offset, {x: -0.25, y: 0.8, z: 1.3});
|
||||||
|
if (verticalOffset) {
|
||||||
|
animationData.rightHandPosition.y += verticalOffset;
|
||||||
|
}
|
||||||
animationData.rightHandRotation = Quat.fromPitchYawRollDegrees(90, 0, 90);
|
animationData.rightHandRotation = Quat.fromPitchYawRollDegrees(90, 0, 90);
|
||||||
}
|
}
|
||||||
function shakeHandsAnimation() {
|
function shakeHandsAnimation() {
|
||||||
|
@ -347,7 +350,32 @@
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
function findNearestAvatar() {
|
||||||
|
// We only look some max distance away (much larger than the handshake distance, but still...)
|
||||||
|
var minDistance = MAX_AVATAR_DISTANCE * 20;
|
||||||
|
var closestAvatar;
|
||||||
|
AvatarList.getAvatarIdentifiers().forEach(function (id) {
|
||||||
|
var avatar = AvatarList.getAvatar(id);
|
||||||
|
if (avatar && avatar.sessionUUID != MyAvatar.sessionUUID) {
|
||||||
|
var currentDistance = Vec3.distance(avatar.position, MyAvatar.position);
|
||||||
|
if (minDistance > currentDistance) {
|
||||||
|
minDistance = currentDistance;
|
||||||
|
closestAvatar = avatar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return closestAvatar;
|
||||||
|
}
|
||||||
|
function adjustAnimationHeight() {
|
||||||
|
var avatar = findNearestAvatar();
|
||||||
|
if (avatar) {
|
||||||
|
var myHeadIndex = MyAvatar.getJointIndex("Head");
|
||||||
|
var otherHeadIndex = avatar.getJointIndex("Head");
|
||||||
|
var diff = (avatar.getJointPosition(otherHeadIndex).y - MyAvatar.getJointPosition(myHeadIndex).y) / 2;
|
||||||
|
print("head height difference: " + diff);
|
||||||
|
updateAnimationData(diff);
|
||||||
|
}
|
||||||
|
}
|
||||||
function findNearestWaitingAvatar() {
|
function findNearestWaitingAvatar() {
|
||||||
var handPosition = getHandPosition(MyAvatar, currentHandJointIndex);
|
var handPosition = getHandPosition(MyAvatar, currentHandJointIndex);
|
||||||
var minDistance = MAX_AVATAR_DISTANCE;
|
var minDistance = MAX_AVATAR_DISTANCE;
|
||||||
|
@ -436,6 +464,10 @@
|
||||||
handStringMessageSend({
|
handStringMessageSend({
|
||||||
key: "waiting",
|
key: "waiting",
|
||||||
});
|
});
|
||||||
|
// potentially adjust height of handshake
|
||||||
|
if (fromKeyboard) {
|
||||||
|
adjustAnimationHeight();
|
||||||
|
}
|
||||||
lookForWaitingAvatar();
|
lookForWaitingAvatar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue