added fountain script

This commit is contained in:
Philip Rosedale 2014-01-17 17:10:15 -08:00
parent 08c49bb68f
commit 4547f07739
3 changed files with 63 additions and 3 deletions

62
examples/fountain.js Normal file
View 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);

View file

@ -175,8 +175,6 @@ void MyAvatar::simulate(float deltaTime, Transmitter* transmitter) {
// Compute instantaneous acceleration
float forwardAcceleration = glm::length(glm::dot(getBodyFrontDirection(), getVelocity() - oldVelocity)) / deltaTime;
const float ACCELERATION_PITCH_DECAY = 0.4f;
const float ACCELERATION_PULL_THRESHOLD = 0.2f;
const float OCULUS_ACCELERATION_PULL_THRESHOLD = 1.0f;
const int OCULUS_YAW_OFFSET_THRESHOLD = 10;

View file

@ -119,7 +119,7 @@ void SixenseManager::update(float deltaTime) {
FingerData finger(palm, &hand);
finger.setActive(true);
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 newTipPosition = position + rotation * FINGER_VECTOR;
finger.setRawTipPosition(position + rotation * FINGER_VECTOR);