mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 08:57:27 +02:00
Merge pull request #1586 from PhilipRosedale/master
Clap script and better bird sounds
This commit is contained in:
commit
17abbc4715
6 changed files with 92 additions and 15 deletions
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// This sample script watches your hydra hands and makes clapping sound
|
// This sample script watches your hydra hands and makes clapping sound when they come close together fast
|
||||||
//
|
//
|
||||||
|
|
||||||
function length(v) {
|
function length(v) {
|
||||||
|
@ -17,7 +17,13 @@ function vMinus(a, b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// First, load the clap sound from a URL
|
// First, load the clap sound from a URL
|
||||||
var clap = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/clap1.raw");
|
var clap1 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/claps/clap1.raw");
|
||||||
|
var clap2 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/claps/clap2.raw");
|
||||||
|
var clap3 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/claps/clap3.raw");
|
||||||
|
var clap4 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/claps/clap4.raw");
|
||||||
|
var clap5 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/claps/clap5.raw");
|
||||||
|
var clap6 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/claps/clap6.raw");
|
||||||
|
|
||||||
var clapping = new Array();
|
var clapping = new Array();
|
||||||
clapping[0] = false;
|
clapping[0] = false;
|
||||||
clapping[1] = false;
|
clapping[1] = false;
|
||||||
|
@ -33,16 +39,23 @@ function maybePlaySound() {
|
||||||
var speed = length(palmVelocity);
|
var speed = length(palmVelocity);
|
||||||
|
|
||||||
const CLAP_SPEED = 0.2;
|
const CLAP_SPEED = 0.2;
|
||||||
const CLAP_DISTANCE = 0.3;
|
const CLAP_DISTANCE = 0.2;
|
||||||
|
|
||||||
if (!clapping[palm] && (distanceBetween < CLAP_DISTANCE) && (speed > CLAP_SPEED)) {
|
if (!clapping[palm] && (distanceBetween < CLAP_DISTANCE) && (speed > CLAP_SPEED)) {
|
||||||
var options = new AudioInjectionOptions();
|
var options = new AudioInjectionOptions();
|
||||||
options.position = palm1Position;
|
options.position = palm1Position;
|
||||||
options.volume = speed / 2.0;
|
options.volume = speed / 2.0;
|
||||||
if (options.volume > 1.0) options.volume = 1.0;
|
if (options.volume > 1.0) options.volume = 1.0;
|
||||||
|
which = Math.floor((Math.random() * 6) + 1);
|
||||||
|
if (which == 1) { Audio.playSound(clap1, options); }
|
||||||
|
else if (which == 2) { Audio.playSound(clap2, options); }
|
||||||
|
else if (which == 3) { Audio.playSound(clap3, options); }
|
||||||
|
else if (which == 4) { Audio.playSound(clap4, options); }
|
||||||
|
else if (which == 5) { Audio.playSound(clap5, options); }
|
||||||
|
else { Audio.playSound(clap6, options); }
|
||||||
Audio.playSound(clap, options);
|
Audio.playSound(clap, options);
|
||||||
clapping[palm] = true;
|
clapping[palm] = true;
|
||||||
} else if (clapping[palm] && (speed < (CLAP_SPEED / 1.5))) {
|
} else if (clapping[palm] && (speed < (CLAP_SPEED / 4.0))) {
|
||||||
clapping[palm] = false;
|
clapping[palm] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
62
examples/fountain.js
Normal file
62
examples/fountain.js
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
|
||||||
|
|
||||||
|
function vLength(v) {
|
||||||
|
return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
function printVector(v) {
|
||||||
|
print(v.x + ", " + v.y + ", " + v.z + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a random vector with individual lengths between a,b
|
||||||
|
function randVector(a, b) {
|
||||||
|
var rval = { x: a + Math.random() * (b - a), y: a + Math.random() * (b - a), z: a + Math.random() * (b - a) };
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
|
function vMinus(a, b) {
|
||||||
|
var rval = { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z };
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
|
function vPlus(a, b) {
|
||||||
|
var rval = { x: a.x + b.x, y: a.y + b.y, z: a.z + b.z };
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
|
function vCopy(a, b) {
|
||||||
|
a.x = b.x;
|
||||||
|
a.y = b.y;
|
||||||
|
a.z = b.z;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns a vector which is fraction of the way between a and b
|
||||||
|
function vInterpolate(a, b, fraction) {
|
||||||
|
var rval = { x: a.x + (b.x - a.x) * fraction, y: a.y + (b.y - a.y) * fraction, z: a.z + (b.z - a.z) * fraction };
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
|
var position = { x: 5.0 / TREE_SCALE, y: 5.0 / TREE_SCALE, z: 5.0 / TREE_SCALE };
|
||||||
|
Voxels.queueDestructiveVoxelAdd(position.x, position.y - (1.0 / TREE_SCALE), position.z, 0.5 / TREE_SCALE, 255, 255, 1);
|
||||||
|
|
||||||
|
function makeFountain() {
|
||||||
|
if (Math.random() < 0.06) {
|
||||||
|
//print("Made particle!\n");
|
||||||
|
|
||||||
|
var size = (0.02 + (Math.random() * 0.05)) / TREE_SCALE;
|
||||||
|
var velocity = { x: (Math.random() * 1.0 - 0.5) / TREE_SCALE,
|
||||||
|
y: (1.0 + (Math.random() * 2.0)) / TREE_SCALE,
|
||||||
|
z: (Math.random() * 1.0 - 0.5) / TREE_SCALE };
|
||||||
|
|
||||||
|
var gravity = { x: 0, y: -0.5 / TREE_SCALE, z: 0 }; // gravity has no effect on these bullets
|
||||||
|
var color = { red: 0, green: 0, blue: 128 };
|
||||||
|
var damping = 0.25; // no damping
|
||||||
|
var inHand = false;
|
||||||
|
var script = "";
|
||||||
|
|
||||||
|
Particles.queueParticleAdd(position, size, color, velocity, gravity, damping, inHand, script);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// register the call back so it fires before each data send
|
||||||
|
Agent.willSendVisualDataCallback.connect(makeFountain);
|
|
@ -3,7 +3,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
// First, load the clap sound from a URL
|
// First, load the clap sound from a URL
|
||||||
var clap = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/clap1.raw");
|
var clap = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/bushtit_1.raw");
|
||||||
|
|
||||||
function maybePlaySound() {
|
function maybePlaySound() {
|
||||||
if (Math.random() < 0.01) {
|
if (Math.random() < 0.01) {
|
||||||
|
|
|
@ -41,16 +41,19 @@ function vInterpolate(a, b, fraction) {
|
||||||
|
|
||||||
// Decide what kind of bird we are
|
// Decide what kind of bird we are
|
||||||
var tweet;
|
var tweet;
|
||||||
|
|
||||||
var which = Math.random();
|
var which = Math.random();
|
||||||
if (which < 1.0) {
|
if (which < 0.2) {
|
||||||
tweet = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/bushtit_1.raw");
|
tweet = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/bushtit_1.raw");
|
||||||
} else if (which < 0.4) {
|
} else if (which < 0.4) {
|
||||||
tweet = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/bushtit_2.raw");
|
tweet = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/rosyfacedlovebird.raw");
|
||||||
} else if (which < 0.6) {
|
} else if (which < 0.6) {
|
||||||
tweet = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/bushtit_3.raw");
|
tweet = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/saysphoebe.raw");
|
||||||
|
} else if (which < 0.8) {
|
||||||
|
tweet = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/mexicanWhipoorwill.raw");
|
||||||
} else {
|
} else {
|
||||||
tweet = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/mexicanWhipoorwill.raw");
|
tweet = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/westernscreechowl.raw");
|
||||||
}
|
}
|
||||||
|
|
||||||
var position = { x: 0, y: 0, z: 0 };
|
var position = { x: 0, y: 0, z: 0 };
|
||||||
var lastPosition = { x: 0, y: 0, z: 0 };
|
var lastPosition = { x: 0, y: 0, z: 0 };
|
||||||
|
@ -58,7 +61,7 @@ var oldPosition = { x: 0, y: 0, z:0 };
|
||||||
var targetPosition = { x: 0, y: 0, z: 0 };
|
var targetPosition = { x: 0, y: 0, z: 0 };
|
||||||
|
|
||||||
var size = 0.125;
|
var size = 0.125;
|
||||||
var range = 4.0; // Over what distance in meters do you want your bird to fly around
|
var range = 50.0; // Over what distance in meters do you want your bird to fly around
|
||||||
var color = { r: 100, g: 50, b: 150 };
|
var color = { r: 100, g: 50, b: 150 };
|
||||||
var colorEdge = { r:255, g:250, b:175 };
|
var colorEdge = { r:255, g:250, b:175 };
|
||||||
var frame = 0;
|
var frame = 0;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
//
|
//
|
||||||
// Cube.cpp
|
// VoxelSystem.cpp
|
||||||
// interface
|
|
||||||
//
|
//
|
||||||
// Created by Philip on 12/31/12.
|
// Created by Philip on 12/31/12.
|
||||||
// Copyright (c) 2012 High Fidelity, Inc. All rights reserved.
|
// Copyright (c) 2012 High Fidelity, Inc. All rights reserved.
|
||||||
|
|
|
@ -119,7 +119,7 @@ void SixenseManager::update(float deltaTime) {
|
||||||
FingerData finger(palm, &hand);
|
FingerData finger(palm, &hand);
|
||||||
finger.setActive(true);
|
finger.setActive(true);
|
||||||
finger.setRawRootPosition(position);
|
finger.setRawRootPosition(position);
|
||||||
const float FINGER_LENGTH = 150.0f; // Millimeters
|
const float FINGER_LENGTH = 300.0f; // Millimeters
|
||||||
const glm::vec3 FINGER_VECTOR(0.0f, 0.0f, FINGER_LENGTH);
|
const glm::vec3 FINGER_VECTOR(0.0f, 0.0f, FINGER_LENGTH);
|
||||||
const glm::vec3 newTipPosition = position + rotation * FINGER_VECTOR;
|
const glm::vec3 newTipPosition = position + rotation * FINGER_VECTOR;
|
||||||
finger.setRawTipPosition(position + rotation * FINGER_VECTOR);
|
finger.setRawTipPosition(position + rotation * FINGER_VECTOR);
|
||||||
|
|
Loading…
Reference in a new issue