mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
finish air guitar, gun initial position on hand tweak
This commit is contained in:
parent
8c5a1c7bc8
commit
95f6bcbbd6
2 changed files with 56 additions and 31 deletions
|
@ -25,22 +25,21 @@ function vMinus(a, b) {
|
|||
return rval;
|
||||
}
|
||||
|
||||
// First, load two percussion sounds to be used on the sticks
|
||||
// Load sounds that will be played
|
||||
|
||||
var guitarType = 2;
|
||||
var chords = new Array();
|
||||
// Nylon string guitar
|
||||
chords[1] = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guitars/Guitar+-+Nylon+A.raw");
|
||||
chords[2] = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guitars/Guitar+-+Nylon+B.raw");
|
||||
chords[3] = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guitars/Guitar+-+Nylon+E.raw");
|
||||
// Electric guitar
|
||||
chords[4] = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guitars/Guitar+-+Metal+A+short.raw");
|
||||
chords[5] = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guitars/Guitar+-+Metal+B+short.raw");
|
||||
chords[6] = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guitars/Guitar+-+Metal+E+short.raw");
|
||||
|
||||
if (guitarType == 1) {
|
||||
var chord1 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guitars/Guitar+-+Nylon+A.raw");
|
||||
var chord2 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guitars/Guitar+-+Nylon+B.raw");
|
||||
var chord3 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guitars/Guitar+-+Nylon+E.raw");
|
||||
} else {
|
||||
var chord1 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guitars/Guitar+-+Metal+A+short.raw");
|
||||
var chord2 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guitars/Guitar+-+Metal+B+short.raw");
|
||||
var chord3 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guitars/Guitar+-+Metal+E+short.raw");
|
||||
}
|
||||
var guitarSelector = 3;
|
||||
|
||||
|
||||
var whichChord = chord1;
|
||||
var whichChord = chords[guitarSelector + 1];
|
||||
|
||||
var leftHanded = false;
|
||||
if (leftHanded) {
|
||||
|
@ -55,40 +54,66 @@ var lastPosition = { x: 0.0,
|
|||
y: 0.0,
|
||||
z: 0.0 };
|
||||
|
||||
var soundPlaying = false;
|
||||
var selectorPressed = false;
|
||||
|
||||
function checkHands(deltaTime) {
|
||||
for (var palm = 0; palm < 2; palm++) {
|
||||
var palmVelocity = Controller.getSpatialControlVelocity(palm * 2 + 1);
|
||||
var speed = length(palmVelocity);
|
||||
var speed = length(palmVelocity) / 4.0;
|
||||
var position = Controller.getSpatialControlPosition(palm * 2 + 1);
|
||||
var myPelvis = MyAvatar.position;
|
||||
var trigger = Controller.getTriggerValue(strumHand);
|
||||
var chord = Controller.getTriggerValue(chordHand);
|
||||
|
||||
if ((chord > 0.1) && Audio.isInjectorPlaying(soundPlaying)) {
|
||||
// If chord finger trigger pulled, stop current chord
|
||||
Audio.stopInjector(soundPlaying);
|
||||
}
|
||||
|
||||
var BUTTON_COUNT = 6;
|
||||
|
||||
// Change guitars if button FWD (5) pressed
|
||||
if (Controller.isButtonPressed(chordHand * BUTTON_COUNT + 5)) {
|
||||
if (!selectorPressed) {
|
||||
if (guitarSelector == 0) {
|
||||
guitarSelector = 3;
|
||||
} else {
|
||||
guitarSelector = 0;
|
||||
}
|
||||
selectorPressed = true;
|
||||
}
|
||||
} else {
|
||||
selectorPressed = false;
|
||||
}
|
||||
|
||||
if (Controller.isButtonPressed(chordHand * BUTTON_COUNT + 1)) {
|
||||
whichChord = chords[guitarSelector + 1];
|
||||
} else if (Controller.isButtonPressed(chordHand * BUTTON_COUNT + 2)) {
|
||||
whichChord = chords[guitarSelector + 2];
|
||||
} else if (Controller.isButtonPressed(chordHand * BUTTON_COUNT + 3)) {
|
||||
whichChord = chords[guitarSelector + 3];
|
||||
}
|
||||
|
||||
if (palm == strumHand) {
|
||||
|
||||
var STRUM_HEIGHT_ABOVE_PELVIS = -0.30;
|
||||
var STRUM_HEIGHT_ABOVE_PELVIS = 0.00;
|
||||
var strumTriggerHeight = myPelvis.y + STRUM_HEIGHT_ABOVE_PELVIS;
|
||||
//printVector(position);
|
||||
if ((position.y < strumTriggerHeight) && (lastPosition.y >= strumTriggerHeight)) {
|
||||
// If hand passes downward through guitar strings, play a chord!
|
||||
if ( ( ((position.y < strumTriggerHeight) && (lastPosition.y >= strumTriggerHeight)) ||
|
||||
((position.y > strumTriggerHeight) && (lastPosition.y <= strumTriggerHeight)) ) && (trigger > 0.1) ){
|
||||
// If hand passes downward or upward through 'strings', and finger trigger pulled, play
|
||||
var options = new AudioInjectionOptions();
|
||||
options.position = position;
|
||||
if (speed > 1.0) { speed = 1.0; }
|
||||
options.volume = speed;
|
||||
Audio.playSound(whichChord, options);
|
||||
if (Audio.isInjectorPlaying(soundPlaying)) {
|
||||
Audio.stopInjector(soundPlaying);
|
||||
}
|
||||
soundPlaying = Audio.playSound(whichChord, options);
|
||||
}
|
||||
lastPosition = Controller.getSpatialControlPosition(palm * 2 + 1);
|
||||
} else {
|
||||
// This is the chord controller
|
||||
var distanceFromPelvis = Vec3.length(Vec3.subtract(position, myPelvis));
|
||||
//print(distanceFromPelvis);
|
||||
if (distanceFromPelvis > 0.63) {
|
||||
whichChord = chord3;
|
||||
} else if (distanceFromPelvis > 0.55) {
|
||||
whichChord = chord2;
|
||||
} else {
|
||||
whichChord = chord1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ function keyPressEvent(event) {
|
|||
}
|
||||
}
|
||||
|
||||
MyAvatar.attach(gunModel, "RightHand", {x: -0.10, y: 0.0, z: 0.0}, Quat.fromPitchYawRollDegrees(-90, 180, 0), 0.14);
|
||||
MyAvatar.attach(gunModel, "RightHand", {x: -0.02, y: -.14, z: 0.07}, Quat.fromPitchYawRollDegrees(-70, -151, 72), 0.20);
|
||||
|
||||
function update(deltaTime) {
|
||||
// Check for mouseLook movement, update rotation
|
||||
|
|
Loading…
Reference in a new issue