mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:35:08 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into puck-lost-tracking
This commit is contained in:
commit
3f5a13d5a9
8 changed files with 300 additions and 11 deletions
70
interface/resources/icons/tablet-icons/raise-hand-a.svg
Normal file
70
interface/resources/icons/tablet-icons/raise-hand-a.svg
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
|
||||
<svg
|
||||
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
width="50"
|
||||
height="50"
|
||||
viewBox="0 0 50 50"
|
||||
id="svg3713"
|
||||
sodipodi:docname="raise-hand-a.svg"
|
||||
inkscape:version="0.92.1 r15371">
|
||||
<metadata
|
||||
id="metadata3719">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs3717">
|
||||
<linearGradient
|
||||
id="linearGradient6484"
|
||||
osb:paint="solid">
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop6482" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1001"
|
||||
id="namedview3715"
|
||||
showgrid="false"
|
||||
inkscape:zoom="11.8"
|
||||
inkscape:cx="-20"
|
||||
inkscape:cy="23.559322"
|
||||
inkscape:window-x="-9"
|
||||
inkscape:window-y="-9"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg3713" />
|
||||
<path
|
||||
d="m 38.064897,12.746263 c -0.728,0 -1.412,0.196 -2,0.538 v -2.538 c 0,-2.2060002 -1.794,-4.0000002 -4,-4.0000002 -0.824,0 -1.588,0.25 -2.226,0.678 -0.548,-1.558 -2.032,-2.678 -3.774,-2.678 -1.742,0 -3.228,1.12 -3.774,2.678 -0.636,-0.428 -1.402,-0.678 -2.226,-0.678 -2.206,0 -4,1.794 -4,4.0000002 v 14.746 l -2.692,-4.666 c -0.522,-0.95 -1.374,-1.626 -2.398,-1.906 -0.9980001,-0.272 -2.0360001,-0.128 -2.9240001,0.404 -1.814,1.088 -2.506,3.548 -1.54,5.484 0.06,0.122 1.336,2.736 5.3200001,10.7 1.876,3.75 3.934,6.432 6.118,7.968 1.714,1.206 2.898,1.268 3.118,1.268 h 10 c 1.702,0 3.284,-0.554 4.704,-1.644 1.334,-1.026 2.492,-2.51 3.44,-4.408 1.868,-3.736 2.856,-8.904 2.856,-14.948 v -7 c 0,-2.206 -1.794,-4 -4,-4 z m 2,11 c 0,5.734 -0.914,10.592 -2.644,14.052 -1.128,2.256 -3.148,4.948 -6.356,4.948 h -9.98 c -0.078,-0.006 -0.92,-0.1 -2.19,-1.05 -1.266,-0.948 -3.21,-2.944 -5.276,-7.08 -4.0540001,-8.108 -5.3000001,-10.662 -5.3120001,-10.686 -0.002,-0.004 -0.002,-0.006 -0.004,-0.008 -0.502,-1.006 -0.146,-2.324 0.778,-2.878 0.416,-0.25 0.902,-0.316 1.3700001,-0.19 0.498,0.136 0.916,0.472 1.174,0.944 0.004,0.006 0.008,0.014 0.012,0.02 l 3.122,5.41 c 0.638,1.166 1.356,1.656 2.134,1.458 0.78,-0.198 1.174,-0.978 1.174,-2.314 v -15.626 c 0,-1.1020002 0.898,-2.0000002 2,-2.0000002 1.102,0 2,0.898 2,2.0000002 v 13 c 0,0.552 0.448,1 1,1 0.552,0 1,-0.448 1,-1 V 8.7462628 c 0,-1.102 0.898,-2 2,-2 1.102,0 2,0.898 2,2 V 23.746263 c 0,0.552 0.448,1 1,1 0.552,0 1,-0.448 1,-1 v -13 c 0,-1.1020002 0.898,-2.0000002 2,-2.0000002 1.102,0 2,0.898 2,2.0000002 v 15 c 0,0.552 0.448,1 1,1 0.552,0 1,-0.448 1,-1 v -9 c 0,-1.102 0.898,-2 2,-2 1.102,0 2,0.898 2,2 v 7 z"
|
||||
id="path3711"
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#000000;stroke-width:1;stroke:#000000;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
inkscape:transform-center-x="0.33898322"
|
||||
inkscape:transform-center-y="-0.6779661" />
|
||||
</svg>
|
After Width: | Height: | Size: 3.6 KiB |
60
interface/resources/icons/tablet-icons/raise-hand-i.svg
Normal file
60
interface/resources/icons/tablet-icons/raise-hand-i.svg
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
width="50"
|
||||
height="50"
|
||||
viewBox="0 0 50 50"
|
||||
id="svg3713"
|
||||
sodipodi:docname="raise-hand-i.svg"
|
||||
inkscape:version="0.92.1 r15371">
|
||||
<metadata
|
||||
id="metadata3719">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs3717" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1001"
|
||||
id="namedview3715"
|
||||
showgrid="false"
|
||||
inkscape:zoom="11.8"
|
||||
inkscape:cx="-20"
|
||||
inkscape:cy="23.559322"
|
||||
inkscape:window-x="-9"
|
||||
inkscape:window-y="-9"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg3713" />
|
||||
<path
|
||||
d="m 38.064897,12.746263 c -0.728,0 -1.412,0.196 -2,0.538 v -2.538 c 0,-2.2060002 -1.794,-4.0000002 -4,-4.0000002 -0.824,0 -1.588,0.25 -2.226,0.678 -0.548,-1.558 -2.032,-2.678 -3.774,-2.678 -1.742,0 -3.228,1.12 -3.774,2.678 -0.636,-0.428 -1.402,-0.678 -2.226,-0.678 -2.206,0 -4,1.794 -4,4.0000002 v 14.746 l -2.692,-4.666 c -0.522,-0.95 -1.374,-1.626 -2.398,-1.906 -0.9980001,-0.272 -2.0360001,-0.128 -2.9240001,0.404 -1.814,1.088 -2.506,3.548 -1.54,5.484 0.06,0.122 1.336,2.736 5.3200001,10.7 1.876,3.75 3.934,6.432 6.118,7.968 1.714,1.206 2.898,1.268 3.118,1.268 h 10 c 1.702,0 3.284,-0.554 4.704,-1.644 1.334,-1.026 2.492,-2.51 3.44,-4.408 1.868,-3.736 2.856,-8.904 2.856,-14.948 v -7 c 0,-2.206 -1.794,-4 -4,-4 z m 2,11 c 0,5.734 -0.914,10.592 -2.644,14.052 -1.128,2.256 -3.148,4.948 -6.356,4.948 h -9.98 c -0.078,-0.006 -0.92,-0.1 -2.19,-1.05 -1.266,-0.948 -3.21,-2.944 -5.276,-7.08 -4.0540001,-8.108 -5.3000001,-10.662 -5.3120001,-10.686 -0.002,-0.004 -0.002,-0.006 -0.004,-0.008 -0.502,-1.006 -0.146,-2.324 0.778,-2.878 0.416,-0.25 0.902,-0.316 1.3700001,-0.19 0.498,0.136 0.916,0.472 1.174,0.944 0.004,0.006 0.008,0.014 0.012,0.02 l 3.122,5.41 c 0.638,1.166 1.356,1.656 2.134,1.458 0.78,-0.198 1.174,-0.978 1.174,-2.314 v -15.626 c 0,-1.1020002 0.898,-2.0000002 2,-2.0000002 1.102,0 2,0.898 2,2.0000002 v 13 c 0,0.552 0.448,1 1,1 0.552,0 1,-0.448 1,-1 V 8.7462628 c 0,-1.102 0.898,-2 2,-2 1.102,0 2,0.898 2,2 V 23.746263 c 0,0.552 0.448,1 1,1 0.552,0 1,-0.448 1,-1 v -13 c 0,-1.1020002 0.898,-2.0000002 2,-2.0000002 1.102,0 2,0.898 2,2.0000002 v 15 c 0,0.552 0.448,1 1,1 0.552,0 1,-0.448 1,-1 v -9 c 0,-1.102 0.898,-2 2,-2 1.102,0 2,0.898 2,2 v 7 z"
|
||||
id="path3711"
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#ffffff;stroke-width:1;fill-opacity:1;stroke:#fdfdfc;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
inkscape:transform-center-x="0.33898322"
|
||||
inkscape:transform-center-y="-0.6779661" />
|
||||
</svg>
|
After Width: | Height: | Size: 3.4 KiB |
|
@ -238,8 +238,25 @@ Column {
|
|||
stackShadowNarrowing: root.stackShadowNarrowing;
|
||||
shadowHeight: root.stackedCardShadowHeight;
|
||||
|
||||
hoverThunk: function () { scroll.currentIndex = index; }
|
||||
unhoverThunk: function () { scroll.currentIndex = -1; }
|
||||
hoverThunk: function () { scrollToIndex(index); }
|
||||
unhoverThunk: function () { scrollToIndex(-1); }
|
||||
}
|
||||
}
|
||||
NumberAnimation {
|
||||
id: anim;
|
||||
target: scroll;
|
||||
property: "contentX";
|
||||
duration: 250;
|
||||
}
|
||||
function scrollToIndex(index) {
|
||||
anim.running = false;
|
||||
var pos = scroll.contentX;
|
||||
var destPos;
|
||||
scroll.positionViewAtIndex(index, ListView.Contain);
|
||||
destPos = scroll.contentX;
|
||||
anim.from = pos;
|
||||
anim.to = destPos;
|
||||
scroll.currentIndex = index;
|
||||
anim.running = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -408,6 +408,7 @@ RayToOverlayIntersectionResult Overlays::findRayIntersectionInternal(const PickR
|
|||
const QVector<OverlayID>& overlaysToInclude,
|
||||
const QVector<OverlayID>& overlaysToDiscard,
|
||||
bool visibleOnly, bool collidableOnly) {
|
||||
QReadLocker lock(&_lock);
|
||||
float bestDistance = std::numeric_limits<float>::max();
|
||||
bool bestIsFront = false;
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ static glm::mat4 computeOffset(glm::mat4 defaultToReferenceMat, glm::mat4 defaul
|
|||
}
|
||||
|
||||
static bool sortPucksYPosition(std::pair<uint32_t, controller::Pose> firstPuck, std::pair<uint32_t, controller::Pose> secondPuck) {
|
||||
return (firstPuck.second.translation.y < firstPuck.second.translation.y);
|
||||
return (firstPuck.second.translation.y < secondPuck.second.translation.y);
|
||||
}
|
||||
|
||||
static QString deviceTrackingResultToString(vr::ETrackingResult trackingResult) {
|
||||
|
@ -280,6 +280,7 @@ void ViveControllerManager::InputDevice::calibrateOrUncalibrate(const controller
|
|||
}
|
||||
|
||||
void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibrationData& inputCalibration) {
|
||||
qDebug() << "Puck Calibration: Starting...";
|
||||
// convert the hmd head from sensor space to avatar space
|
||||
glm::mat4 hmdSensorFlippedMat = inputCalibration.hmdSensorMat * Matrices::Y_180;
|
||||
glm::mat4 sensorToAvatarMat = glm::inverse(inputCalibration.avatarMat) * inputCalibration.sensorToWorldMat;
|
||||
|
@ -299,18 +300,24 @@ void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibr
|
|||
glm::mat4 defaultToReferenceMat = currentHead * glm::inverse(inputCalibration.defaultHeadMat);
|
||||
|
||||
int puckCount = (int)_validTrackedObjects.size();
|
||||
qDebug() << "Puck Calibration: " << puckCount << " pucks found for calibration";
|
||||
_config = _preferedConfig;
|
||||
if (_config != Config::Auto && puckCount < MIN_PUCK_COUNT) {
|
||||
qDebug() << "Puck Calibration: Failed: Could not meet the minimal # of pucks";
|
||||
uncalibrate();
|
||||
return;
|
||||
} else if (_config == Config::Auto){
|
||||
if (puckCount == MIN_PUCK_COUNT) {
|
||||
_config = Config::Feet;
|
||||
qDebug() << "Puck Calibration: Auto Config: " << configToString(_config) << " configuration";
|
||||
} else if (puckCount == MIN_FEET_AND_HIPS) {
|
||||
_config = Config::FeetAndHips;
|
||||
qDebug() << "Puck Calibration: Auto Config: " << configToString(_config) << " configuration";
|
||||
} else if (puckCount >= MIN_FEET_HIPS_CHEST) {
|
||||
_config = Config::FeetHipsAndChest;
|
||||
qDebug() << "Puck Calibration: Auto Config: " << configToString(_config) << " configuration";
|
||||
} else {
|
||||
qDebug() << "Puck Calibration: Auto Config Failed: Could not meet the minimal # of pucks";
|
||||
uncalibrate();
|
||||
return;
|
||||
}
|
||||
|
@ -318,8 +325,6 @@ void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibr
|
|||
|
||||
std::sort(_validTrackedObjects.begin(), _validTrackedObjects.end(), sortPucksYPosition);
|
||||
|
||||
|
||||
|
||||
auto& firstFoot = _validTrackedObjects[FIRST_FOOT];
|
||||
auto& secondFoot = _validTrackedObjects[SECOND_FOOT];
|
||||
controller::Pose& firstFootPose = firstFoot.second;
|
||||
|
@ -349,10 +354,12 @@ void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibr
|
|||
_jointToPuckMap[controller::SPINE2] = _validTrackedObjects[CHEST].first;
|
||||
_pucksOffset[_validTrackedObjects[CHEST].first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultSpine2, _validTrackedObjects[CHEST].second);
|
||||
} else {
|
||||
qDebug() << "Puck Calibration: " << configToString(_config) << " Config Failed: Could not meet the minimal # of pucks";
|
||||
uncalibrate();
|
||||
return;
|
||||
}
|
||||
_calibrated = true;
|
||||
qDebug() << "PuckCalibration: " << configToString(_config) << " Configuration Successful";
|
||||
}
|
||||
|
||||
void ViveControllerManager::InputDevice::uncalibrate() {
|
||||
|
@ -618,9 +625,9 @@ void ViveControllerManager::InputDevice::saveSettings() const {
|
|||
settings.endGroup();
|
||||
}
|
||||
|
||||
QString ViveControllerManager::InputDevice::configToString() {
|
||||
QString ViveControllerManager::InputDevice::configToString(Config config) {
|
||||
QString currentConfig;
|
||||
switch (_preferedConfig) {
|
||||
switch (config) {
|
||||
case Config::Auto:
|
||||
currentConfig = "Auto";
|
||||
break;
|
||||
|
@ -658,7 +665,7 @@ void ViveControllerManager::InputDevice::createPreferences() {
|
|||
static const QString VIVE_PUCKS_CONFIG = "Vive Pucks Configuration";
|
||||
|
||||
{
|
||||
auto getter = [this]()->QString { return configToString(); };
|
||||
auto getter = [this]()->QString { return configToString(_preferedConfig); };
|
||||
auto setter = [this](const QString& value) { setConfigFromString(value); saveSettings(); };
|
||||
auto preference = new ComboBoxPreference(VIVE_PUCKS_CONFIG, "Configuration", getter, setter);
|
||||
QStringList list = (QStringList() << "Auto" << "Feet" << "FeetAndHips" << "FeetHipsAndChest");
|
||||
|
|
|
@ -129,7 +129,7 @@ private:
|
|||
bool _timeTilCalibrationSet { false };
|
||||
mutable std::recursive_mutex _lock;
|
||||
|
||||
QString configToString();
|
||||
QString configToString(Config config);
|
||||
void setConfigFromString(const QString& value);
|
||||
void loadSettings();
|
||||
void saveSettings() const;
|
||||
|
|
|
@ -198,7 +198,7 @@
|
|||
}
|
||||
|
||||
var animationData = {};
|
||||
function updateAnimationData() {
|
||||
function updateAnimationData(verticalOffset) {
|
||||
// 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
|
||||
// far in front as scaling with the avatar's height (say hips
|
||||
|
@ -209,6 +209,9 @@
|
|||
offset = 0.8 * MyAvatar.getAbsoluteJointTranslationInObjectFrame(headIndex).y;
|
||||
}
|
||||
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);
|
||||
}
|
||||
function shakeHandsAnimation() {
|
||||
|
@ -347,7 +350,32 @@
|
|||
}
|
||||
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() {
|
||||
var handPosition = getHandPosition(MyAvatar, currentHandJointIndex);
|
||||
var minDistance = MAX_AVATAR_DISTANCE;
|
||||
|
@ -436,6 +464,10 @@
|
|||
handStringMessageSend({
|
||||
key: "waiting",
|
||||
});
|
||||
// potentially adjust height of handshake
|
||||
if (fromKeyboard) {
|
||||
adjustAnimationHeight();
|
||||
}
|
||||
lookForWaitingAvatar();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
"use strict";
|
||||
//
|
||||
// tablet-raiseHand.js
|
||||
//
|
||||
// client script that creates a tablet button to raise hand
|
||||
//
|
||||
// Created by Triplelexx on 17/04/22
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Hand icons adapted from https://linearicons.com, created by Perxis https://perxis.com CC BY-SA 4.0 license.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
(function() { // BEGIN LOCAL_SCOPE
|
||||
var BUTTON_NAME = "RAISE\nHAND";
|
||||
var USERCONNECTION_MESSAGE_CHANNEL = "io.highfidelity.makeUserConnection";
|
||||
var DEBUG_PREFIX = "TABLET RAISE HAND: ";
|
||||
var isRaiseHandButtonActive = false;
|
||||
var animHandlerId;
|
||||
|
||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
var button = tablet.addButton({
|
||||
text: BUTTON_NAME,
|
||||
icon: "icons/tablet-icons/raise-hand-i.svg",
|
||||
activeIcon: "icons/tablet-icons/raise-hand-a.svg"
|
||||
});
|
||||
|
||||
function onClicked() {
|
||||
isRaiseHandButtonActive = !isRaiseHandButtonActive;
|
||||
button.editProperties({ isActive: isRaiseHandButtonActive });
|
||||
if (isRaiseHandButtonActive) {
|
||||
removeAnimation();
|
||||
animHandlerId = MyAvatar.addAnimationStateHandler(raiseHandAnimation, []);
|
||||
Messages.subscribe(USERCONNECTION_MESSAGE_CHANNEL);
|
||||
Messages.messageReceived.connect(messageHandler);
|
||||
} else {
|
||||
removeAnimation();
|
||||
Messages.unsubscribe(USERCONNECTION_MESSAGE_CHANNEL);
|
||||
Messages.messageReceived.disconnect(messageHandler);
|
||||
}
|
||||
}
|
||||
|
||||
function removeAnimation() {
|
||||
if (animHandlerId) {
|
||||
animHandlerId = MyAvatar.removeAnimationStateHandler(animHandlerId);
|
||||
}
|
||||
}
|
||||
|
||||
function raiseHandAnimation(animationProperties) {
|
||||
// all we are doing here is moving the right hand to a spot that is above the hips.
|
||||
var headIndex = MyAvatar.getJointIndex("Head");
|
||||
var offset = 0.0;
|
||||
var result = {};
|
||||
if (headIndex) {
|
||||
offset = 0.85 * MyAvatar.getAbsoluteJointTranslationInObjectFrame(headIndex).y;
|
||||
}
|
||||
var handPos = Vec3.multiply(offset, { x: -0.7, y: 1.25, z: 0.25 });
|
||||
result.rightHandPosition = handPos;
|
||||
result.rightHandRotation = Quat.fromPitchYawRollDegrees(0, 0, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
function messageHandler(channel, messageString, senderID) {
|
||||
if (channel !== USERCONNECTION_MESSAGE_CHANNEL && senderID !== MyAvatar.sessionUUID) {
|
||||
return;
|
||||
}
|
||||
var message = {};
|
||||
try {
|
||||
message = JSON.parse(messageString);
|
||||
} catch (e) {
|
||||
print(DEBUG_PREFIX + "messageHandler error: " + e);
|
||||
}
|
||||
switch (message.key) {
|
||||
case "waiting":
|
||||
case "connecting":
|
||||
case "connectionAck":
|
||||
case "connectionRequest":
|
||||
case "done":
|
||||
removeAnimation();
|
||||
if (isRaiseHandButtonActive) {
|
||||
isRaiseHandButtonActive = false;
|
||||
button.editProperties({ isActive: isRaiseHandButtonActive });
|
||||
}
|
||||
break;
|
||||
default:
|
||||
print(DEBUG_PREFIX + "messageHandler unknown message: " + message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
button.clicked.connect(onClicked);
|
||||
|
||||
Script.scriptEnding.connect(function() {
|
||||
Messages.unsubscribe(USERCONNECTION_MESSAGE_CHANNEL);
|
||||
Messages.messageReceived.disconnect(messageHandler);
|
||||
button.clicked.disconnect(onClicked);
|
||||
tablet.removeButton(button);
|
||||
removeAnimation();
|
||||
});
|
||||
}()); // END LOCAL_SCOPE
|
Loading…
Reference in a new issue