mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
Merge pull request #2983 from PhilipRosedale/master
Added squeezeHands.js for open/close hand animation with controller trigger
This commit is contained in:
commit
47c71e2d3a
3 changed files with 60 additions and 15 deletions
|
@ -20,21 +20,21 @@ var jointMappings = "\n# Joint list start";
|
||||||
for (var i = 0; i < jointList.length; i++) {
|
for (var i = 0; i < jointList.length; i++) {
|
||||||
jointMappings = jointMappings + "\njointIndex = " + jointList[i] + " = " + i;
|
jointMappings = jointMappings + "\njointIndex = " + jointList[i] + " = " + i;
|
||||||
}
|
}
|
||||||
print(jointMappings + "\n# Joint list end");
|
print(jointMappings + "\n# Joint list end");
|
||||||
|
|
||||||
Script.update.connect(function(deltaTime) {
|
Script.update.connect(function(deltaTime) {
|
||||||
cumulativeTime += deltaTime;
|
cumulativeTime += deltaTime;
|
||||||
MyAvatar.setJointData("joint_R_hip", Quat.fromPitchYawRollDegrees(0.0, 0.0, AMPLITUDE * Math.sin(cumulativeTime * FREQUENCY)));
|
MyAvatar.setJointData("RightUpLeg", Quat.fromPitchYawRollDegrees(AMPLITUDE * Math.sin(cumulativeTime * FREQUENCY), 0.0, 0.0));
|
||||||
MyAvatar.setJointData("joint_L_hip", Quat.fromPitchYawRollDegrees(0.0, 0.0, -AMPLITUDE * Math.sin(cumulativeTime * FREQUENCY)));
|
MyAvatar.setJointData("LeftUpLeg", Quat.fromPitchYawRollDegrees(-AMPLITUDE * Math.sin(cumulativeTime * FREQUENCY), 0.0, 0.0));
|
||||||
MyAvatar.setJointData("joint_R_knee", Quat.fromPitchYawRollDegrees(0.0, 0.0,
|
MyAvatar.setJointData("RightLeg", Quat.fromPitchYawRollDegrees(
|
||||||
AMPLITUDE * (1.0 + Math.sin(cumulativeTime * FREQUENCY))));
|
AMPLITUDE * (1.0 + Math.sin(cumulativeTime * FREQUENCY)),0.0, 0.0));
|
||||||
MyAvatar.setJointData("joint_L_knee", Quat.fromPitchYawRollDegrees(0.0, 0.0,
|
MyAvatar.setJointData("LeftLeg", Quat.fromPitchYawRollDegrees(
|
||||||
AMPLITUDE * (1.0 - Math.sin(cumulativeTime * FREQUENCY))));
|
AMPLITUDE * (1.0 - Math.sin(cumulativeTime * FREQUENCY)),0.0, 0.0));
|
||||||
});
|
});
|
||||||
|
|
||||||
Script.scriptEnding.connect(function() {
|
Script.scriptEnding.connect(function() {
|
||||||
MyAvatar.clearJointData("joint_R_hip");
|
MyAvatar.clearJointData("RightUpLeg");
|
||||||
MyAvatar.clearJointData("joint_L_hip");
|
MyAvatar.clearJointData("LeftUpLeg");
|
||||||
MyAvatar.clearJointData("joint_R_knee");
|
MyAvatar.clearJointData("RightLeg");
|
||||||
MyAvatar.clearJointData("joint_L_knee");
|
MyAvatar.clearJointData("LeftLeg");
|
||||||
});
|
});
|
||||||
|
|
49
examples/squeezeHands.js
Normal file
49
examples/squeezeHands.js
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
//
|
||||||
|
// squeezeHands.js
|
||||||
|
// examples
|
||||||
|
//
|
||||||
|
// Created by Philip Rosedale on June 4, 2014
|
||||||
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
var rightHandAnimation = "https://s3-us-west-1.amazonaws.com/highfidelity-public/animations/HandAnim.fbx";
|
||||||
|
var leftHandAnimation = "";
|
||||||
|
|
||||||
|
var LEFT = 0;
|
||||||
|
var RIGHT = 1;
|
||||||
|
|
||||||
|
var lastLeftFrame = 0;
|
||||||
|
var lastRightFrame = 0;
|
||||||
|
|
||||||
|
var LAST_FRAME = 15.0; // What is the number of the last frame we want to use in the animation?
|
||||||
|
|
||||||
|
Script.update.connect(function(deltaTime) {
|
||||||
|
var leftTriggerValue = Controller.getTriggerValue(LEFT);
|
||||||
|
var rightTriggerValue = Controller.getTriggerValue(RIGHT);
|
||||||
|
|
||||||
|
var leftFrame, rightFrame;
|
||||||
|
|
||||||
|
// Average last two trigger frames together for a bit of smoothing
|
||||||
|
leftFrame = (leftTriggerValue * LAST_FRAME) * 0.5 + lastLeftFrame * 0.5;
|
||||||
|
rightFrame = (rightTriggerValue * LAST_FRAME) * 0.5 + lastRightFrame * 0.5;
|
||||||
|
|
||||||
|
if ((leftFrame != lastLeftFrame) && leftHandAnimation.length){
|
||||||
|
MyAvatar.stopAnimation(leftHandAnimation);
|
||||||
|
MyAvatar.startAnimation(leftHandAnimation, 30.0, 1.0, false, true, leftFrame, leftFrame);
|
||||||
|
}
|
||||||
|
if ((rightFrame != lastRightFrame) && rightHandAnimation.length) {
|
||||||
|
MyAvatar.stopAnimation(rightHandAnimation);
|
||||||
|
MyAvatar.startAnimation(rightHandAnimation, 30.0, 1.0, false, true, rightFrame, rightFrame);
|
||||||
|
}
|
||||||
|
|
||||||
|
lastLeftFrame = leftFrame;
|
||||||
|
lastRightFrame = rightFrame;
|
||||||
|
});
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(function() {
|
||||||
|
MyAvatar.stopAnimation(leftHandAnimation);
|
||||||
|
MyAvatar.stopAnimation(rightHandAnimation);
|
||||||
|
});
|
|
@ -324,7 +324,6 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
|
||||||
|
|
||||||
// Get vertical FoV of the displayed overlay texture
|
// Get vertical FoV of the displayed overlay texture
|
||||||
const float halfVerticalAngle = _oculusAngle / 2.0f;
|
const float halfVerticalAngle = _oculusAngle / 2.0f;
|
||||||
const float verticalAngle = halfVerticalAngle * 2.0f;
|
|
||||||
const float overlayAspectRatio = glWidget->width() / (float)glWidget->height();
|
const float overlayAspectRatio = glWidget->width() / (float)glWidget->height();
|
||||||
const float halfOverlayHeight = _distance * tan(halfVerticalAngle);
|
const float halfOverlayHeight = _distance * tan(halfVerticalAngle);
|
||||||
|
|
||||||
|
@ -393,7 +392,6 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
|
||||||
|
|
||||||
float newWidth = magnifyWidth * magnification;
|
float newWidth = magnifyWidth * magnification;
|
||||||
float newHeight = magnifyHeight * magnification;
|
float newHeight = magnifyHeight * magnification;
|
||||||
float tmp;
|
|
||||||
|
|
||||||
// Magnification Texture Coordinates
|
// Magnification Texture Coordinates
|
||||||
float magnifyULeft = mouseX / (float)widgetWidth;
|
float magnifyULeft = mouseX / (float)widgetWidth;
|
||||||
|
@ -409,8 +407,6 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
|
||||||
float leftAngle = (newMouseX / (float)widgetWidth) * horizontalAngle - halfHorizontalAngle;
|
float leftAngle = (newMouseX / (float)widgetWidth) * horizontalAngle - halfHorizontalAngle;
|
||||||
float rightAngle = ((newMouseX + newWidth) / (float)widgetWidth) * horizontalAngle - halfHorizontalAngle;
|
float rightAngle = ((newMouseX + newWidth) / (float)widgetWidth) * horizontalAngle - halfHorizontalAngle;
|
||||||
|
|
||||||
float halfMagnifyHeight = magnifyHeight / 2.0f;
|
|
||||||
|
|
||||||
float leftX, rightX, leftZ, rightZ;
|
float leftX, rightX, leftZ, rightZ;
|
||||||
|
|
||||||
// Get position on hemisphere using angle
|
// Get position on hemisphere using angle
|
||||||
|
|
Loading…
Reference in a new issue