mirror of
https://github.com/overte-org/overte.git
synced 2025-04-24 20:34:20 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into head_rotation_fix
This commit is contained in:
commit
e73f8baf93
144 changed files with 2181 additions and 2660 deletions
2
BUILD.md
2
BUILD.md
|
@ -60,5 +60,5 @@ OS X users who tap our [homebrew formulas repository](https://github.com/highfid
|
|||
|
||||
####Devices
|
||||
|
||||
You can support external input/output devices such as Leap Motion, Faceplus, Faceshift, PrioVR, MIDI, Razr Hydra and more by adding each individual SDK in the visible building path. Refer to the readme file available in each device folder in [interface/external/](interface/external) for the detailed explanation of the requirements to use the device.
|
||||
You can support external input/output devices such as Leap Motion, Faceshift, PrioVR, MIDI, Razr Hydra and more by adding each individual SDK in the visible building path. Refer to the readme file available in each device folder in [interface/external/](interface/external) for the detailed explanation of the requirements to use the device.
|
||||
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
# Try to find the Faceplus library
|
||||
#
|
||||
# You must provide a FACEPLUS_ROOT_DIR which contains lib and include directories
|
||||
#
|
||||
# Once done this will define
|
||||
#
|
||||
# FACEPLUS_FOUND - system found Faceplus
|
||||
# FACEPLUS_INCLUDE_DIRS - the Faceplus include directory
|
||||
# FACEPLUS_LIBRARIES - Link this to use Faceplus
|
||||
#
|
||||
# Created on 4/8/2014 by Andrzej Kapolka
|
||||
# Copyright (c) 2014 High Fidelity
|
||||
#
|
||||
|
||||
find_path(FACEPLUS_INCLUDE_DIRS faceplus.h ${FACEPLUS_ROOT_DIR}/include)
|
||||
|
||||
if (WIN32)
|
||||
find_library(FACEPLUS_LIBRARIES faceplus.lib ${FACEPLUS_ROOT_DIR}/win32/)
|
||||
endif (WIN32)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Faceplus DEFAULT_MSG FACEPLUS_INCLUDE_DIRS FACEPLUS_LIBRARIES)
|
||||
|
||||
mark_as_advanced(FACEPLUS_INCLUDE_DIRS FACEPLUS_LIBRARIES)
|
|
@ -21,17 +21,17 @@
|
|||
if (WIN32)
|
||||
include("${MACRO_DIR}/HifiLibrarySearchHints.cmake")
|
||||
hifi_library_search_hints("glew")
|
||||
|
||||
find_path(GLEW_INCLUDE_DIRS GL/glew.h PATH_SUFFIXES include HINTS ${GLEW_SEARCH_DIRS})
|
||||
|
||||
find_library(GLEW_LIBRARY_RELEASE glew32s PATH_SUFFIXES "lib/Release/Win32" "lib" HINTS ${GLEW_SEARCH_DIRS})
|
||||
find_library(GLEW_LIBRARY_DEBUG glew32s PATH_SUFFIXES "lib/Debug/Win32" "lib" HINTS ${GLEW_SEARCH_DIRS})
|
||||
find_path(GLEW_INCLUDE_DIRS GL/glew.h PATH_SUFFIXES include HINTS ${GLEW_SEARCH_DIRS})
|
||||
|
||||
find_library(GLEW_LIBRARY_RELEASE glew32s PATH_SUFFIXES "lib/Release/Win32" "lib" HINTS ${GLEW_SEARCH_DIRS})
|
||||
find_library(GLEW_LIBRARY_DEBUG glew32sd PATH_SUFFIXES "lib/Debug/Win32" "lib" HINTS ${GLEW_SEARCH_DIRS})
|
||||
|
||||
include(SelectLibraryConfigurations)
|
||||
select_library_configurations(GLEW)
|
||||
endif ()
|
||||
|
||||
set(GLEW_LIBRARIES "${GLEW_LIBRARY}")
|
||||
set(GLEW_LIBRARIES ${GLEW_LIBRARY})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_INCLUDE_DIRS GLEW_LIBRARIES)
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
//
|
||||
|
||||
//For procedural walk animation
|
||||
Script.include("libraries/globals.js");
|
||||
Script.include("../libraries/globals.js");
|
||||
Script.include(HIFI_PUBLIC_BUCKET + "scripts/proceduralAnimationAPI.js");
|
||||
|
||||
var procAnimAPI = new ProcAnimAPI();
|
|
@ -11,8 +11,8 @@
|
|||
//
|
||||
|
||||
//For procedural walk animation
|
||||
Script.include("libraries/globals.js");
|
||||
Script.include(HIFI_PUBLIC_BUCKET + "scripts/proceduralAnimationAPI.js");
|
||||
Script.include("../libraries/globals.js");
|
||||
Script.include("proceduralAnimationAPI.js");
|
||||
|
||||
var procAnimAPI = new ProcAnimAPI();
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
Script.include("../libraries/globals.js");
|
||||
|
||||
function getRandomFloat(min, max) {
|
||||
return Math.random() * (max - min) + min;
|
|
@ -1,72 +0,0 @@
|
|||
//
|
||||
// avatarCollision.js
|
||||
// examples
|
||||
//
|
||||
// Created by Andrew Meadows on 2014-04-09
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Play a sound on collisions with your avatar
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
|
||||
var SOUND_TRIGGER_CLEAR = 1000; // milliseconds
|
||||
var SOUND_TRIGGER_DELAY = 200; // milliseconds
|
||||
var soundExpiry = 0;
|
||||
var DateObj = new Date();
|
||||
|
||||
var audioOptions = {
|
||||
volume: 0.5,
|
||||
position: { x: 0, y: 0, z: 0 }
|
||||
}
|
||||
|
||||
var hitSounds = new Array();
|
||||
hitSounds[0] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit1.raw");
|
||||
hitSounds[1] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit2.raw");
|
||||
hitSounds[2] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit3.raw");
|
||||
hitSounds[3] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit4.raw");
|
||||
hitSounds[4] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit5.raw");
|
||||
hitSounds[5] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit6.raw");
|
||||
hitSounds[6] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit7.raw");
|
||||
hitSounds[7] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit8.raw");
|
||||
hitSounds[8] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit9.raw");
|
||||
hitSounds[9] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit10.raw");
|
||||
hitSounds[10] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit11.raw");
|
||||
hitSounds[11] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit12.raw");
|
||||
hitSounds[12] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit13.raw");
|
||||
hitSounds[13] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit14.raw");
|
||||
hitSounds[14] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit15.raw");
|
||||
hitSounds[15] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit16.raw");
|
||||
hitSounds[16] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit17.raw");
|
||||
hitSounds[17] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit18.raw");
|
||||
hitSounds[18] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit19.raw");
|
||||
hitSounds[19] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit20.raw");
|
||||
hitSounds[20] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit21.raw");
|
||||
hitSounds[21] = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Collisions-hitsandslaps/Hit22.raw");
|
||||
|
||||
function playHitSound(mySessionID, theirSessionID, collision) {
|
||||
var now = new Date();
|
||||
var msec = now.getTime();
|
||||
if (msec > soundExpiry) {
|
||||
// this is a new contact --> play a new sound
|
||||
var soundIndex = Math.floor((Math.random() * hitSounds.length) % hitSounds.length);
|
||||
audioOptions.position = collision.contactPoint;
|
||||
Audio.playSound(hitSounds[soundIndex], audioOptions);
|
||||
|
||||
// bump the expiry
|
||||
soundExpiry = msec + SOUND_TRIGGER_CLEAR;
|
||||
|
||||
// log the collision info
|
||||
Uuid.print("my sessionID = ", mySessionID);
|
||||
Uuid.print(" their sessionID = ", theirSessionID);
|
||||
Vec3.print(" penetration = ", collision.penetration);
|
||||
Vec3.print(" contactPoint = ", collision.contactPoint);
|
||||
} else {
|
||||
// this is a recurring contact --> continue to delay sound trigger
|
||||
soundExpiry = msec + SOUND_TRIGGER_DELAY;
|
||||
}
|
||||
}
|
||||
MyAvatar.collisionWithAvatar.connect(playHitSound);
|
|
@ -1,139 +0,0 @@
|
|||
//
|
||||
// avatarLocalLight.js
|
||||
//
|
||||
// Created by Tony Peng on July 2nd, 2014
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Set the local light direction and color on the avatar
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var localLightDirections = [ {x: 1.0, y:0.0, z: 0.0}, {x: 0.0, y:0.0, z: 1.0} ];
|
||||
var localLightColors = [ {x: 0.4, y:0.335, z: 0.266}, {x: 0.4, y:0.335, z: 0.266} ];
|
||||
|
||||
var currentSelection = 0;
|
||||
var currentNumLights = 2;
|
||||
var maxNumLights = 2;
|
||||
var currentNumAvatars = 0;
|
||||
var changeDelta = 0.1;
|
||||
var lightsDirty = true;
|
||||
|
||||
function keyPressEvent(event) {
|
||||
|
||||
var choice = parseInt(event.text);
|
||||
|
||||
if (event.text == "1") {
|
||||
currentSelection = 0;
|
||||
print("light election = " + currentSelection);
|
||||
}
|
||||
else if (event.text == "2" ) {
|
||||
currentSelection = 1;
|
||||
print("light selection = " + currentSelection);
|
||||
}
|
||||
else if (event.text == "3" ) {
|
||||
currentSelection = 2;
|
||||
print("light selection = " + currentSelection);
|
||||
}
|
||||
else if (event.text == "4" ) {
|
||||
currentSelection = 3;
|
||||
print("light selection = " + currentSelection);
|
||||
}
|
||||
else if (event.text == "5" ) {
|
||||
localLightColors[currentSelection].x += changeDelta;
|
||||
if ( localLightColors[currentSelection].x > 1.0) {
|
||||
localLightColors[currentSelection].x = 0.0;
|
||||
}
|
||||
|
||||
lightsDirty = true;
|
||||
print("CHANGE RED light " + currentSelection + " color (" + localLightColors[currentSelection].x + ", " + localLightColors[currentSelection].y + ", " + localLightColors[currentSelection].z + " )" );
|
||||
}
|
||||
else if (event.text == "6" ) {
|
||||
localLightColors[currentSelection].y += changeDelta;
|
||||
if ( localLightColors[currentSelection].y > 1.0) {
|
||||
localLightColors[currentSelection].y = 0.0;
|
||||
}
|
||||
|
||||
lightsDirty = true;
|
||||
print("CHANGE GREEN light " + currentSelection + " color (" + localLightColors[currentSelection].x + ", " + localLightColors[currentSelection].y + ", " + localLightColors[currentSelection].z + " )" );
|
||||
}
|
||||
else if (event.text == "7" ) {
|
||||
localLightColors[currentSelection].z += changeDelta;
|
||||
if ( localLightColors[currentSelection].z > 1.0) {
|
||||
localLightColors[currentSelection].z = 0.0;
|
||||
}
|
||||
|
||||
lightsDirty = true;
|
||||
print("CHANGE BLUE light " + currentSelection + " color (" + localLightColors[currentSelection].x + ", " + localLightColors[currentSelection].y + ", " + localLightColors[currentSelection].z + " )" );
|
||||
}
|
||||
else if (event.text == "8" ) {
|
||||
localLightDirections[currentSelection].x += changeDelta;
|
||||
if (localLightDirections[currentSelection].x > 1.0) {
|
||||
localLightDirections[currentSelection].x = -1.0;
|
||||
}
|
||||
|
||||
lightsDirty = true;
|
||||
print("PLUS X light " + currentSelection + " direction (" + localLightDirections[currentSelection].x + ", " + localLightDirections[currentSelection].y + ", " + localLightDirections[currentSelection].z + " )" );
|
||||
}
|
||||
else if (event.text == "9" ) {
|
||||
localLightDirections[currentSelection].x -= changeDelta;
|
||||
if (localLightDirections[currentSelection].x < -1.0) {
|
||||
localLightDirections[currentSelection].x = 1.0;
|
||||
}
|
||||
|
||||
lightsDirty = true;
|
||||
print("MINUS X light " + currentSelection + " direction (" + localLightDirections[currentSelection].x + ", " + localLightDirections[currentSelection].y + ", " + localLightDirections[currentSelection].z + " )" );
|
||||
}
|
||||
else if (event.text == "0" ) {
|
||||
localLightDirections[currentSelection].y += changeDelta;
|
||||
if (localLightDirections[currentSelection].y > 1.0) {
|
||||
localLightDirections[currentSelection].y = -1.0;
|
||||
}
|
||||
|
||||
lightsDirty = true;
|
||||
print("PLUS Y light " + currentSelection + " direction (" + localLightDirections[currentSelection].x + ", " + localLightDirections[currentSelection].y + ", " + localLightDirections[currentSelection].z + " )" );
|
||||
}
|
||||
else if (event.text == "-" ) {
|
||||
localLightDirections[currentSelection].y -= changeDelta;
|
||||
if (localLightDirections[currentSelection].y < -1.0) {
|
||||
localLightDirections[currentSelection].y = 1.0;
|
||||
}
|
||||
|
||||
lightsDirty = true;
|
||||
print("MINUS Y light " + currentSelection + " direction (" + localLightDirections[currentSelection].x + ", " + localLightDirections[currentSelection].y + ", " + localLightDirections[currentSelection].z + " )" );
|
||||
}
|
||||
else if (event.text == "," ) {
|
||||
if (currentNumLights + 1 <= maxNumLights) {
|
||||
++currentNumLights;
|
||||
lightsDirty = true;
|
||||
}
|
||||
|
||||
print("ADD LIGHT, number of lights " + currentNumLights);
|
||||
}
|
||||
else if (event.text == "." ) {
|
||||
if (currentNumLights - 1 >= 0 ) {
|
||||
--currentNumLights;
|
||||
lightsDirty = true;
|
||||
}
|
||||
|
||||
print("REMOVE LIGHT, number of lights " + currentNumLights);
|
||||
}
|
||||
}
|
||||
|
||||
function updateLocalLights()
|
||||
{
|
||||
if (lightsDirty) {
|
||||
var localLights = [];
|
||||
for (var i = 0; i < currentNumLights; i++) {
|
||||
localLights.push({ direction: localLightDirections[i], color: localLightColors[i] });
|
||||
}
|
||||
AvatarManager.setLocalLights(localLights);
|
||||
lightsDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
// main
|
||||
Script.update.connect(updateLocalLights);
|
||||
Controller.keyPressEvent.connect(keyPressEvent);
|
||||
|
233
examples/bot.js
233
examples/bot.js
|
@ -1,233 +0,0 @@
|
|||
//
|
||||
// bot.js
|
||||
// examples
|
||||
//
|
||||
// Created by Stephen Birarda on 2/20/14.
|
||||
// Modified by Philip on 3/3/14
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// This is an example script that demonstrates an NPC avatar.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
|
||||
function getRandomFloat(min, max) {
|
||||
return Math.random() * (max - min) + min;
|
||||
}
|
||||
|
||||
function getRandomInt (min, max) {
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
}
|
||||
|
||||
function printVector(string, vector) {
|
||||
print(string + " " + vector.x + ", " + vector.y + ", " + vector.z);
|
||||
}
|
||||
|
||||
var CHANCE_OF_MOVING = 0.005;
|
||||
var CHANCE_OF_SOUND = 0.005;
|
||||
var CHANCE_OF_HEAD_TURNING = 0.05;
|
||||
var CHANCE_OF_BIG_MOVE = 0.1;
|
||||
var CHANCE_OF_WAVING = 0.009;
|
||||
|
||||
var shouldReceiveVoxels = true;
|
||||
var VOXEL_FPS = 60.0;
|
||||
var lastVoxelQueryTime = 0.0;
|
||||
|
||||
var isMoving = false;
|
||||
var isTurningHead = false;
|
||||
var isPlayingAudio = false;
|
||||
var isWaving = false;
|
||||
var waveFrequency = 0.0;
|
||||
var waveAmplitude = 0.0;
|
||||
|
||||
var X_MIN = 5.0;
|
||||
var X_MAX = 15.0;
|
||||
var Z_MIN = 5.0;
|
||||
var Z_MAX = 15.0;
|
||||
var Y_PELVIS = 1.0;
|
||||
var SPINE_JOINT_NUMBER = 13;
|
||||
var SHOULDER_JOINT_NUMBER = 17;
|
||||
var ELBOW_JOINT_NUMBER = 18;
|
||||
var JOINT_R_HIP = 1;
|
||||
var JOINT_R_KNEE = 2;
|
||||
|
||||
var MOVE_RANGE_SMALL = 0.5;
|
||||
var MOVE_RANGE_BIG = Math.max(X_MAX - X_MIN, Z_MAX - Z_MIN) / 2.0;
|
||||
var TURN_RANGE = 70.0;
|
||||
var STOP_TOLERANCE = 0.05;
|
||||
var MOVE_RATE = 0.05;
|
||||
var TURN_RATE = 0.15;
|
||||
var PITCH_RATE = 0.20;
|
||||
var PITCH_RANGE = 30.0;
|
||||
|
||||
var firstPosition = { x: getRandomFloat(X_MIN, X_MAX), y: Y_PELVIS, z: getRandomFloat(Z_MIN, Z_MAX) };
|
||||
var targetPosition = { x: 0, y: 0, z: 0 };
|
||||
var targetDirection = { x: 0, y: 0, z: 0, w: 0 };
|
||||
var currentDirection = { x: 0, y: 0, z: 0, w: 0 };
|
||||
var targetHeadPitch = 0.0;
|
||||
|
||||
var walkFrequency = 5.0;
|
||||
var walkAmplitude = 45.0;
|
||||
|
||||
var cumulativeTime = 0.0;
|
||||
|
||||
var sounds = [];
|
||||
loadSounds();
|
||||
|
||||
function clamp(val, min, max){
|
||||
return Math.max(min, Math.min(max, val))
|
||||
}
|
||||
|
||||
// Play a random sound from a list of conversational audio clips
|
||||
var AVERAGE_AUDIO_LENGTH = 8000;
|
||||
function playRandomSound() {
|
||||
if (!Agent.isPlayingAvatarSound) {
|
||||
var whichSound = Math.floor((Math.random() * sounds.length) % sounds.length);
|
||||
Agent.playAvatarSound(sounds[whichSound]);
|
||||
}
|
||||
}
|
||||
|
||||
// pick an integer between 1 and 20 for the face model for this bot
|
||||
botNumber = getRandomInt(1, 100);
|
||||
|
||||
if (botNumber <= 20) {
|
||||
newFaceFilePrefix = "bot" + botNumber;
|
||||
newBodyFilePrefix = "defaultAvatar_body"
|
||||
} else {
|
||||
if (botNumber <= 40) {
|
||||
newFaceFilePrefix = "superhero";
|
||||
} else if (botNumber <= 60) {
|
||||
newFaceFilePrefix = "amber";
|
||||
} else if (botNumber <= 80) {
|
||||
newFaceFilePrefix = "ron";
|
||||
} else {
|
||||
newFaceFilePrefix = "angie";
|
||||
}
|
||||
|
||||
newBodyFilePrefix = "bot" + botNumber;
|
||||
}
|
||||
|
||||
// set the face model fst using the bot number
|
||||
// there is no need to change the body model - we're using the default
|
||||
Avatar.faceModelURL = HIFI_PUBLIC_BUCKET + "meshes/" + newFaceFilePrefix + ".fst";
|
||||
Avatar.skeletonModelURL = HIFI_PUBLIC_BUCKET + "meshes/" + newBodyFilePrefix + ".fst";
|
||||
Avatar.billboardURL = HIFI_PUBLIC_BUCKET + "meshes/billboards/bot" + botNumber + ".png";
|
||||
|
||||
Agent.isAvatar = true;
|
||||
Agent.isListeningToAudioStream = true;
|
||||
|
||||
// change the avatar's position to the random one
|
||||
Avatar.position = firstPosition;
|
||||
printVector("New bot, position = ", Avatar.position);
|
||||
|
||||
function stopWaving() {
|
||||
isWaving = false;
|
||||
Avatar.clearJointData(SHOULDER_JOINT_NUMBER);
|
||||
Avatar.clearJointData(ELBOW_JOINT_NUMBER);
|
||||
Avatar.clearJointData(SPINE_JOINT_NUMBER);
|
||||
}
|
||||
|
||||
function keepWalking() {
|
||||
Avatar.setJointData(JOINT_R_HIP, Quat.fromPitchYawRollDegrees(walkAmplitude * Math.sin(cumulativeTime * walkFrequency), 0.0, 0.0));
|
||||
Avatar.setJointData(JOINT_R_KNEE, Quat.fromPitchYawRollDegrees(walkAmplitude * Math.sin(cumulativeTime * walkFrequency), 0.0, 0.0));
|
||||
}
|
||||
|
||||
function stopWalking() {
|
||||
Avatar.clearJointData(JOINT_R_HIP);
|
||||
Avatar.clearJointData(JOINT_R_KNEE);
|
||||
}
|
||||
|
||||
function updateBehavior(deltaTime) {
|
||||
|
||||
cumulativeTime += deltaTime;
|
||||
|
||||
// Hack - right now you need to set the avatar position a bit after the avatar is made to make sure it's there.
|
||||
|
||||
if (CHANCE_OF_MOVING == 0.000) {
|
||||
Avatar.position = firstPosition;
|
||||
}
|
||||
|
||||
if (shouldReceiveVoxels && ((cumulativeTime - lastVoxelQueryTime) > (1.0 / VOXEL_FPS))) {
|
||||
VoxelViewer.setPosition(Avatar.position);
|
||||
VoxelViewer.setOrientation(Avatar.orientation);
|
||||
VoxelViewer.queryOctree();
|
||||
lastVoxelQueryTime = cumulativeTime;
|
||||
/*
|
||||
if (Math.random() < (1.0 / VOXEL_FPS)) {
|
||||
print("Voxels in view = " + VoxelViewer.getOctreeElementsCount());
|
||||
}*/
|
||||
}
|
||||
|
||||
if (!isWaving && (Math.random() < CHANCE_OF_WAVING)) {
|
||||
isWaving = true;
|
||||
waveFrequency = 3.0 + Math.random() * 5.0;
|
||||
waveAmplitude = 5.0 + Math.random() * 60.0;
|
||||
Script.setTimeout(stopWaving, 1000 + Math.random() * 2000);
|
||||
Avatar.setJointData(ELBOW_JOINT_NUMBER, Quat.fromPitchYawRollDegrees(0.0, 45, 0.0)); // Initially turn the palm outward
|
||||
} else if (isWaving) {
|
||||
Avatar.setJointData(SHOULDER_JOINT_NUMBER, Quat.fromPitchYawRollDegrees(0.0, 0.0, 60 + waveAmplitude * Math.sin((cumulativeTime - 0.25) * waveFrequency)));
|
||||
Avatar.setJointData(ELBOW_JOINT_NUMBER, Quat.fromPitchYawRollDegrees(0.0, 0.0, 25 + waveAmplitude/2.0 * Math.sin(cumulativeTime * 1.2 * waveFrequency)));
|
||||
Avatar.setJointData(SPINE_JOINT_NUMBER, Quat.fromPitchYawRollDegrees(0.0, 0.0, 60 + waveAmplitude/4.0 * Math.sin(cumulativeTime * waveFrequency)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (Math.random() < CHANCE_OF_SOUND) {
|
||||
playRandomSound();
|
||||
}
|
||||
|
||||
if (!isTurningHead && (Math.random() < CHANCE_OF_HEAD_TURNING)) {
|
||||
targetHeadPitch = getRandomFloat(-PITCH_RANGE, PITCH_RANGE);
|
||||
isTurningHead = true;
|
||||
} else {
|
||||
Avatar.headPitch = Avatar.headPitch + (targetHeadPitch - Avatar.headPitch) * PITCH_RATE;
|
||||
if (Math.abs(Avatar.headPitch - targetHeadPitch) < STOP_TOLERANCE) {
|
||||
isTurningHead = false;
|
||||
}
|
||||
}
|
||||
if (!isMoving && (Math.random() < CHANCE_OF_MOVING)) {
|
||||
// Set new target location
|
||||
targetDirection = Quat.multiply(Avatar.orientation, Quat.angleAxis(getRandomFloat(-TURN_RANGE, TURN_RANGE), { x:0, y:1, z:0 }));
|
||||
var front = Quat.getFront(targetDirection);
|
||||
if (Math.random() < CHANCE_OF_BIG_MOVE) {
|
||||
targetPosition = Vec3.sum(Avatar.position, Vec3.multiply(front, getRandomFloat(0.0, MOVE_RANGE_BIG)));
|
||||
} else {
|
||||
targetPosition = Vec3.sum(Avatar.position, Vec3.multiply(front, getRandomFloat(0.0, MOVE_RANGE_SMALL)));
|
||||
}
|
||||
targetPosition.x = clamp(targetPosition.x, X_MIN, X_MAX);
|
||||
targetPosition.z = clamp(targetPosition.z, Z_MIN, Z_MAX);
|
||||
targetPosition.y = Y_PELVIS;
|
||||
|
||||
isMoving = true;
|
||||
} else if (isMoving) {
|
||||
keepWalking();
|
||||
Avatar.position = Vec3.sum(Avatar.position, Vec3.multiply(Vec3.subtract(targetPosition, Avatar.position), MOVE_RATE));
|
||||
Avatar.orientation = Quat.mix(Avatar.orientation, targetDirection, TURN_RATE);
|
||||
if (Vec3.length(Vec3.subtract(Avatar.position, targetPosition)) < STOP_TOLERANCE) {
|
||||
isMoving = false;
|
||||
stopWalking();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Script.update.connect(updateBehavior);
|
||||
|
||||
function loadSounds() {
|
||||
var sound_filenames = ["AB1.raw", "Anchorman2.raw", "B1.raw", "B1.raw", "Bale1.raw", "Bandcamp.raw",
|
||||
"Big1.raw", "Big2.raw", "Brian1.raw", "Buster1.raw", "CES1.raw", "CES2.raw", "CES3.raw", "CES4.raw",
|
||||
"Carrie1.raw", "Carrie3.raw", "Charlotte1.raw", "EN1.raw", "EN2.raw", "EN3.raw", "Eugene1.raw", "Francesco1.raw",
|
||||
"Italian1.raw", "Japanese1.raw", "Leigh1.raw", "Lucille1.raw", "Lucille2.raw", "MeanGirls.raw", "Murray2.raw",
|
||||
"Nigel1.raw", "PennyLane.raw", "Pitt1.raw", "Ricardo.raw", "SN.raw", "Sake1.raw", "Samantha1.raw", "Samantha2.raw",
|
||||
"Spicoli1.raw", "Supernatural.raw", "Swearengen1.raw", "TheDude.raw", "Tony.raw", "Triumph1.raw", "Uma1.raw",
|
||||
"Walken1.raw", "Walken2.raw", "Z1.raw", "Z2.raw"
|
||||
];
|
||||
|
||||
var SOUND_BASE_URL = HIFI_PUBLIC_BUCKET + "sounds/Cocktail+Party+Snippets/Raws/";
|
||||
|
||||
for (var i = 0; i < sound_filenames.length; i++) {
|
||||
sounds.push(SoundCache.getSound(SOUND_BASE_URL + sound_filenames[i]));
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
Script.include("../../libraries/globals.js");
|
||||
|
||||
function length(v) {
|
||||
return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
|
||||
|
@ -73,7 +73,7 @@ var soundPlaying = false;
|
|||
var selectorPressed = false;
|
||||
var position;
|
||||
|
||||
MyAvatar.attach(guitarModel, "Hips", {x: -0.0, y: -0.0, z: 0.0}, Quat.fromPitchYawRollDegrees(0, 0, 0), 1.0);
|
||||
MyAvatar.attach(guitarModel, "Hips", {x: -0.2, y: 0.0, z: 0.1}, Quat.fromPitchYawRollDegrees(90, 00, 90), 1.0);
|
||||
|
||||
function checkHands(deltaTime) {
|
||||
for (var palm = 0; palm < 2; palm++) {
|
|
@ -10,7 +10,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
Script.include("../../libraries/globals.js");
|
||||
|
||||
function length(v) {
|
||||
return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
|
|
@ -15,8 +15,8 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
Script.include("libraries/toolBars.js");
|
||||
Script.include("../../libraries/globals.js");
|
||||
Script.include("../../libraries/toolBars.js");
|
||||
|
||||
const LEFT_PALM = 0;
|
||||
const LEFT_TIP = 1;
|
||||
|
@ -192,15 +192,18 @@ function cleanupFrisbees() {
|
|||
}
|
||||
|
||||
function checkControllerSide(hand) {
|
||||
// print("cCS");
|
||||
// If I don't currently have a frisbee in my hand, then try to catch closest one
|
||||
if (!hand.holdingFrisbee && hand.grabButtonPressed()) {
|
||||
var closestEntity = Entities.findClosestEntity(hand.palmPosition(), CATCH_RADIUS);
|
||||
var modelUrl = Entities.getEntityProperties(closestEntity).modelURL;
|
||||
print("lol2"+closestEntity.isKnownID);
|
||||
if (closestEntity.isKnownID && validFrisbeeURL(Entities.getEntityProperties(closestEntity).modelURL)) {
|
||||
print("lol");
|
||||
Entities.editEntity(closestEntity, {modelScale: 1, inHand: true, position: hand.holdPosition(), shouldDie: true});
|
||||
Entities.deleteEntity(closestEntity);
|
||||
debugPrint(hand.message + " HAND- CAUGHT SOMETHING!!");
|
||||
|
||||
print("lol");
|
||||
var properties = {
|
||||
type: "Model",
|
||||
position: hand.holdPosition(),
|
||||
|
@ -208,10 +211,10 @@ function checkControllerSide(hand) {
|
|||
gravity: { x: 0, y: 0, z: 0},
|
||||
inHand: true,
|
||||
dimensions: { x: FRISBEE_RADIUS, y: FRISBEE_RADIUS / 5, z: FRISBEE_RADIUS },
|
||||
damping: 0.00001,
|
||||
damping: 0.999,
|
||||
modelURL: modelUrl,
|
||||
modelScale: FRISBEE_MODEL_SCALE,
|
||||
modelRotation: hand.holdRotation(),
|
||||
scale: FRISBEE_MODEL_SCALE,
|
||||
rotation: hand.holdRotation(),
|
||||
lifetime: FRISBEE_LIFETIME
|
||||
};
|
||||
|
||||
|
@ -235,10 +238,10 @@ function checkControllerSide(hand) {
|
|||
gravity: { x: 0, y: 0, z: 0},
|
||||
inHand: true,
|
||||
dimensions: { x: FRISBEE_RADIUS, y: FRISBEE_RADIUS / 5, z: FRISBEE_RADIUS },
|
||||
damping: 0.00001,
|
||||
damping: 0,
|
||||
modelURL: frisbeeURL(),
|
||||
modelScale: FRISBEE_MODEL_SCALE,
|
||||
modelRotation: hand.holdRotation(),
|
||||
scale: FRISBEE_MODEL_SCALE,
|
||||
rotation: hand.holdRotation(),
|
||||
lifetime: FRISBEE_LIFETIME
|
||||
};
|
||||
|
||||
|
@ -270,7 +273,7 @@ function checkControllerSide(hand) {
|
|||
inHand: false,
|
||||
lifetime: FRISBEE_LIFETIME,
|
||||
gravity: { x: 0, y: -GRAVITY_STRENGTH, z: 0},
|
||||
modelRotation: hand.holdRotation()
|
||||
rotation: hand.holdRotation()
|
||||
};
|
||||
|
||||
Entities.editEntity(hand.entity, properties);
|
||||
|
@ -304,7 +307,7 @@ function hydraCheck() {
|
|||
var numberOfSpatialControls = Controller.getNumberOfSpatialControls();
|
||||
var controllersPerTrigger = numberOfSpatialControls / numberOfTriggers;
|
||||
hydrasConnected = (numberOfButtons == 12 && numberOfTriggers == 2 && controllersPerTrigger == 2);
|
||||
return hydrasConnected;
|
||||
return true;//hydrasConnected;
|
||||
}
|
||||
|
||||
function checkController(deltaTime) {
|
||||
|
@ -314,6 +317,7 @@ function checkController(deltaTime) {
|
|||
}
|
||||
// this is expected for hydras
|
||||
if (hydraCheck()) {
|
||||
///print("testrr ");
|
||||
checkControllerSide(leftHand);
|
||||
checkControllerSide(rightHand);
|
||||
}
|
||||
|
@ -333,7 +337,7 @@ function controlFrisbees(deltaTime) {
|
|||
killSimulations.push(frisbee);
|
||||
continue;
|
||||
}
|
||||
Entities.editEntity(simulatedFrisbees[frisbee], {modelRotation: Quat.multiply(properties.modelRotation, Quat.fromPitchYawRollDegrees(0, speed * deltaTime * SPIN_MULTIPLIER, 0))});
|
||||
Entities.editEntity(simulatedFrisbees[frisbee], {rotation: Quat.multiply(properties.modelRotation, Quat.fromPitchYawRollDegrees(0, speed * deltaTime * SPIN_MULTIPLIER, 0))});
|
||||
|
||||
}
|
||||
for (var i = killSimulations.length - 1; i >= 0; i--) {
|
||||
|
@ -444,4 +448,4 @@ Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
|
|||
Menu.menuItemEvent.connect(menuItemEvent);
|
||||
Script.scriptEnding.connect(scriptEnding);
|
||||
Script.update.connect(checkController);
|
||||
Script.update.connect(controlFrisbees);
|
||||
Script.update.connect(controlFrisbees);
|
|
@ -1,20 +1,20 @@
|
|||
//
|
||||
// grenadeLauncher.js
|
||||
// gun.js
|
||||
// examples
|
||||
// Created by Ben Arnold on 7/11/14.
|
||||
// This is a modified version of gun.js by Brad Hefta-Gaub.
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 12/31/13.
|
||||
// Modified by Philip on 3/3/14
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// This is an example script that turns the hydra controllers and mouse into a entity gun.
|
||||
// It reads the controller, watches for trigger pulls, and launches entities.
|
||||
// When entities collide with voxels they blow big holes out of the voxels.
|
||||
// When entities collide with voxels they blow little holes out of the voxels.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
Script.include("../../libraries/globals.js");
|
||||
|
||||
function getRandomFloat(min, max) {
|
||||
return Math.random() * (max - min) + min;
|
||||
|
@ -26,10 +26,9 @@ var yawFromMouse = 0;
|
|||
var pitchFromMouse = 0;
|
||||
var isMouseDown = false;
|
||||
|
||||
var BULLET_VELOCITY = 3.0;
|
||||
var BULLET_VELOCITY = 5.0;
|
||||
var MIN_THROWER_DELAY = 1000;
|
||||
var MAX_THROWER_DELAY = 1000;
|
||||
var LEFT_BUTTON_1 = 1;
|
||||
var LEFT_BUTTON_3 = 3;
|
||||
var RELOAD_INTERVAL = 5;
|
||||
|
||||
|
@ -44,7 +43,7 @@ var targetLaunchSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Space%2
|
|||
|
||||
var gunModel = "http://public.highfidelity.io/models/attachments/HaloGun.fst";
|
||||
|
||||
var audioOptions {
|
||||
var audioOptions = {
|
||||
volume: 0.9
|
||||
}
|
||||
|
||||
|
@ -89,24 +88,24 @@ if (showScore) {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function printVector(string, vector) {
|
||||
print(string + " " + vector.x + ", " + vector.y + ", " + vector.z);
|
||||
}
|
||||
|
||||
function shootBullet(position, velocity) {
|
||||
var BULLET_SIZE = 0.1;
|
||||
var BULLET_GRAVITY = -3.0;
|
||||
//Creates a grenade with a reasonable lifetime so that one is less likely to accidentally blow up
|
||||
//far away voxels
|
||||
var BULLET_SIZE = 0.01;
|
||||
var BULLET_LIFETIME = 20.0;
|
||||
var BULLET_GRAVITY = -0.02;
|
||||
Entities.addEntity(
|
||||
{ type: "Sphere",
|
||||
position: position,
|
||||
collisionsWillMove: true,
|
||||
dimensions: { x: BULLET_SIZE, y: BULLET_SIZE, z: BULLET_SIZE },
|
||||
dimensions: { x: BULLET_SIZE, y: BULLET_SIZE, z: BULLET_SIZE },
|
||||
color: { red: 10, green: 10, blue: 10 },
|
||||
velocity: velocity,
|
||||
lifetime: BULLET_LIFETIME,
|
||||
gravity: { x: 0, y: BULLET_GRAVITY, z: 0 },
|
||||
lifetime: 10.0,
|
||||
damping: 0 });
|
||||
|
||||
// Play firing sounds
|
||||
|
@ -121,6 +120,7 @@ function shootBullet(position, velocity) {
|
|||
function shootTarget() {
|
||||
var TARGET_SIZE = 0.25;
|
||||
var TARGET_GRAVITY = -0.6;
|
||||
var TARGET_LIFETIME = 300.0;
|
||||
var TARGET_UP_VELOCITY = 3.0;
|
||||
var TARGET_FWD_VELOCITY = 5.0;
|
||||
var DISTANCE_TO_LAUNCH_FROM = 3.0;
|
||||
|
@ -139,12 +139,11 @@ function shootTarget() {
|
|||
Entities.addEntity(
|
||||
{ type: "Sphere",
|
||||
position: newPosition,
|
||||
collisionsWillMove: true,
|
||||
dimensions: { x: TARGET_SIZE, y: TARGET_SIZE, z: TARGET_SIZE },
|
||||
dimensions: { x: TARGET_SIZE, y: TARGET_SIZE, z: TARGET_SIZE },
|
||||
color: { red: 0, green: 200, blue: 200 },
|
||||
velocity: velocity,
|
||||
gravity: { x: 0, y: TARGET_GRAVITY, z: 0 },
|
||||
lifetime: 1000.0,
|
||||
lifetime: TARGET_LIFETIME,
|
||||
damping: 0.0001 });
|
||||
|
||||
// Record start time
|
||||
|
@ -155,11 +154,15 @@ function shootTarget() {
|
|||
Audio.playSound(targetLaunchSound, audioOptions);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function entityCollisionWithEntity(entity1, entity2, collision) {
|
||||
score++;
|
||||
if (showScore) {
|
||||
Overlays.editOverlay(text, { text: "Score: " + score } );
|
||||
}
|
||||
|
||||
// Sort out which entity is which
|
||||
|
||||
// Record shot time
|
||||
var endTime = new Date();
|
||||
|
@ -191,21 +194,20 @@ function playLoadSound() {
|
|||
Audio.playSound(loadSound, audioOptions);
|
||||
}
|
||||
|
||||
//MyAvatar.attach(gunModel, "RightHand", {x: -0.02, y: -.14, z: 0.07}, Quat.fromPitchYawRollDegrees(-70, -151, 72), 0.20);
|
||||
MyAvatar.attach(gunModel, "LeftHand", {x: -0.02, y: -.14, z: 0.07}, Quat.fromPitchYawRollDegrees(-70, -151, 72), 0.20);
|
||||
MyAvatar.attach(gunModel, "RightHand", {x:0.02, y: 0.11, z: 0.04}, Quat.fromPitchYawRollDegrees(-0, -160, -79), 0.20);
|
||||
//MyAvatar.attach(gunModel, "LeftHand", {x: -0.02, y: -.14, z: 0.07}, Quat.fromPitchYawRollDegrees(-70, -151, 72), 0.20);
|
||||
|
||||
// Give a bit of time to load before playing sound
|
||||
Script.setTimeout(playLoadSound, 2000);
|
||||
|
||||
function update(deltaTime) {
|
||||
|
||||
// Check for mouseLook movement, update rotation
|
||||
// rotate body yaw for yaw received from controller or mouse
|
||||
// Check for mouseLook movement, update rotation
|
||||
// rotate body yaw for yaw received from mouse
|
||||
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromVec3Radians( { x: 0, y: yawFromMouse, z: 0 } ));
|
||||
MyAvatar.orientation = newOrientation;
|
||||
yawFromMouse = 0;
|
||||
|
||||
// apply pitch from controller or mouse
|
||||
// apply pitch from mouse
|
||||
var newPitch = MyAvatar.headPitch + pitchFromMouse;
|
||||
MyAvatar.headPitch = newPitch;
|
||||
pitchFromMouse = 0;
|
||||
|
@ -231,7 +233,6 @@ function update(deltaTime) {
|
|||
for (var t = 0; t < numberOfTriggers; t++) {
|
||||
var shootABullet = false;
|
||||
var triggerValue = Controller.getTriggerValue(t);
|
||||
|
||||
if (triggerPulled[t]) {
|
||||
// must release to at least 0.1
|
||||
if (triggerValue < 0.1) {
|
||||
|
@ -245,8 +246,8 @@ function update(deltaTime) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (shootABullet) {
|
||||
|
||||
var palmController = t * controllersPerTrigger;
|
||||
var palmPosition = Controller.getSpatialControlPosition(palmController);
|
||||
|
||||
|
@ -298,8 +299,7 @@ function mouseReleaseEvent(event) {
|
|||
}
|
||||
|
||||
function mouseMoveEvent(event) {
|
||||
//Move the camera if LEFT_BUTTON_1 is pressed
|
||||
if (Controller.isButtonPressed(LEFT_BUTTON_1)) {
|
||||
if (isMouseDown) {
|
||||
var MOUSE_YAW_SCALE = -0.25;
|
||||
var MOUSE_PITCH_SCALE = -12.5;
|
||||
var FIXED_MOUSE_TIMESTEP = 0.016;
|
|
@ -9,7 +9,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
Script.include("../../libraries/globals.js");
|
||||
|
||||
var rightHandAnimation = HIFI_PUBLIC_BUCKET + "animations/RightHandAnimPhilip.fbx";
|
||||
var leftHandAnimation = HIFI_PUBLIC_BUCKET + "animations/LeftHandAnimPhilip.fbx";
|
|
@ -15,7 +15,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
Script.include("../../libraries/globals.js");
|
||||
|
||||
// maybe we should make these constants...
|
||||
var LEFT_PALM = 0;
|
93
examples/controllers/leap/laserPointer.js
Normal file
93
examples/controllers/leap/laserPointer.js
Normal file
|
@ -0,0 +1,93 @@
|
|||
//
|
||||
// laserPointer.js
|
||||
// examples
|
||||
//
|
||||
// Created by Clément Brisset on 7/18/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// If using Hydra controllers, pulling the triggers makes laser pointers emanate from the respective hands.
|
||||
// If using a Leap Motion or similar to control your avatar's hands and fingers, pointing with your index fingers makes
|
||||
// laser pointers emanate from the respective index fingers.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var laserPointer = (function () {
|
||||
|
||||
var NUM_FINGERs = 4, // Excluding thumb
|
||||
fingers = [
|
||||
[ "LeftHandIndex", "LeftHandMiddle", "LeftHandRing", "LeftHandPinky" ],
|
||||
[ "RightHandIndex", "RightHandMiddle", "RightHandRing", "RightHandPinky" ]
|
||||
];
|
||||
|
||||
function isHandPointing(hand) {
|
||||
var MINIMUM_TRIGGER_PULL = 0.9;
|
||||
return Controller.getTriggerValue(hand) > MINIMUM_TRIGGER_PULL;
|
||||
}
|
||||
|
||||
function isFingerPointing(hand) {
|
||||
// Index finger is pointing if final two bones of middle, ring, and pinky fingers are > 90 degrees w.r.t. index finger
|
||||
|
||||
var pointing,
|
||||
indexDirection,
|
||||
otherDirection,
|
||||
f;
|
||||
|
||||
pointing = true;
|
||||
|
||||
indexDirection = Vec3.subtract(
|
||||
MyAvatar.getJointPosition(fingers[hand][0] + "4"),
|
||||
MyAvatar.getJointPosition(fingers[hand][0] + "2")
|
||||
);
|
||||
|
||||
for (f = 1; f < NUM_FINGERs; f += 1) {
|
||||
otherDirection = Vec3.subtract(
|
||||
MyAvatar.getJointPosition(fingers[hand][f] + "4"),
|
||||
MyAvatar.getJointPosition(fingers[hand][f] + "2")
|
||||
);
|
||||
pointing = pointing && Vec3.dot(indexDirection, otherDirection) < 0;
|
||||
}
|
||||
|
||||
return pointing;
|
||||
}
|
||||
|
||||
function update() {
|
||||
var LEFT_HAND = 0,
|
||||
RIGHT_HAND = 1,
|
||||
LEFT_HAND_POINTING_FLAG = 1,
|
||||
RIGHT_HAND_POINTING_FLAG = 2,
|
||||
FINGER_POINTING_FLAG = 4,
|
||||
handState;
|
||||
|
||||
handState = 0;
|
||||
|
||||
if (isHandPointing(LEFT_HAND)) {
|
||||
handState += LEFT_HAND_POINTING_FLAG;
|
||||
}
|
||||
if (isHandPointing(RIGHT_HAND)) {
|
||||
handState += RIGHT_HAND_POINTING_FLAG;
|
||||
}
|
||||
|
||||
if (handState === 0) {
|
||||
if (isFingerPointing(LEFT_HAND)) {
|
||||
handState += LEFT_HAND_POINTING_FLAG;
|
||||
}
|
||||
if (isFingerPointing(RIGHT_HAND)) {
|
||||
handState += RIGHT_HAND_POINTING_FLAG;
|
||||
}
|
||||
if (handState !== 0) {
|
||||
handState += FINGER_POINTING_FLAG;
|
||||
}
|
||||
}
|
||||
|
||||
MyAvatar.setHandState(handState);
|
||||
}
|
||||
|
||||
return {
|
||||
update: update
|
||||
};
|
||||
|
||||
}());
|
||||
|
||||
Script.update.connect(laserPointer.update);
|
|
@ -15,7 +15,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
Script.include("../../libraries/globals.js");
|
||||
|
||||
const KBD_UPPERCASE_DEFAULT = 0;
|
||||
const KBD_LOWERCASE_DEFAULT = 1;
|
|
@ -42,7 +42,15 @@ gridTool = GridTool({ horizontalGrid: grid });
|
|||
Script.include("libraries/entityList.js");
|
||||
var entityListTool = EntityListTool();
|
||||
|
||||
selectionManager.addEventListener(selectionDisplay.updateHandles);
|
||||
var hasShownPropertiesTool = false;
|
||||
|
||||
selectionManager.addEventListener(function() {
|
||||
selectionDisplay.updateHandles();
|
||||
if (selectionManager.hasSelection() && !hasShownPropertiesTool) {
|
||||
propertiesTool.setVisible(true);
|
||||
hasShownPropertiesTool = true;
|
||||
}
|
||||
});
|
||||
|
||||
var windowDimensions = Controller.getViewportDimensions();
|
||||
var toolIconUrl = HIFI_PUBLIC_BUCKET + "images/tools/";
|
||||
|
@ -77,7 +85,6 @@ var modelURLs = [
|
|||
HIFI_PUBLIC_BUCKET + "models/entities/2-Terrain:%20Alder.fbx",
|
||||
HIFI_PUBLIC_BUCKET + "models/entities/2-Terrain:%20Bush1.fbx",
|
||||
HIFI_PUBLIC_BUCKET + "models/entities/2-Terrain:%20Bush6.fbx",
|
||||
HIFI_PUBLIC_BUCKET + "meshes/newInvader16x16-large-purple.svo",
|
||||
HIFI_PUBLIC_BUCKET + "models/entities/3-Buildings-1-Rustic-Shed.fbx",
|
||||
HIFI_PUBLIC_BUCKET + "models/entities/3-Buildings-1-Rustic-Shed2.fbx",
|
||||
HIFI_PUBLIC_BUCKET + "models/entities/3-Buildings-1-Rustic-Shed4.fbx",
|
||||
|
@ -192,8 +199,7 @@ var toolBar = (function () {
|
|||
});
|
||||
|
||||
newTextButton = toolBar.addTool({
|
||||
//imageURL: toolIconUrl + "add-text.svg",
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/tools/add-text.svg", // temporarily
|
||||
imageURL: toolIconUrl + "add-text.svg",
|
||||
subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT },
|
||||
width: toolWidth,
|
||||
height: toolHeight,
|
||||
|
@ -225,10 +231,9 @@ var toolBar = (function () {
|
|||
selectionManager.clearSelections();
|
||||
cameraManager.disable();
|
||||
} else {
|
||||
hasShownPropertiesTool = false;
|
||||
cameraManager.enable();
|
||||
entityListTool.setVisible(true);
|
||||
gridTool.setVisible(true);
|
||||
propertiesTool.setVisible(true);
|
||||
grid.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,6 @@ var modelURLs = [
|
|||
HIFI_PUBLIC_BUCKET + "models/entities/2-Terrain:%20Alder.fbx",
|
||||
HIFI_PUBLIC_BUCKET + "models/entities/2-Terrain:%20Bush1.fbx",
|
||||
HIFI_PUBLIC_BUCKET + "models/entities/2-Terrain:%20Bush6.fbx",
|
||||
HIFI_PUBLIC_BUCKET + "meshes/newInvader16x16-large-purple.svo",
|
||||
HIFI_PUBLIC_BUCKET + "models/entities/3-Buildings-1-Rustic-Shed.fbx",
|
||||
HIFI_PUBLIC_BUCKET + "models/entities/3-Buildings-1-Rustic-Shed2.fbx",
|
||||
HIFI_PUBLIC_BUCKET + "models/entities/3-Buildings-1-Rustic-Shed4.fbx",
|
||||
|
@ -1215,8 +1214,7 @@ var toolBar = (function () {
|
|||
});
|
||||
|
||||
newTextButton = toolBar.addTool({
|
||||
//imageURL: toolIconUrl + "add-text.svg",
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/tools/add-text.svg", // temporarily
|
||||
imageURL: toolIconUrl + "add-text.svg",
|
||||
subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT },
|
||||
width: toolWidth,
|
||||
height: toolHeight,
|
||||
|
|
|
@ -1,202 +0,0 @@
|
|||
//
|
||||
// particleBirds.js
|
||||
// examples
|
||||
//
|
||||
// Created by Benjamin Arnold on May 29, 2014
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// This sample script creates a swarm of tweeting bird entities that fly around the avatar.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
|
||||
// Multiply vector by scalar
|
||||
function vScalarMult(v, s) {
|
||||
var rval = { x: v.x * s, y: v.y * s, z: v.z * s };
|
||||
return rval;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// 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 startTimeInSeconds = new Date().getTime() / 1000;
|
||||
|
||||
var birdLifetime = 20; // lifetime of the birds in seconds!
|
||||
var range = 1.0; // Over what distance in meters do you want the flock to fly around
|
||||
var frame = 0;
|
||||
|
||||
var CHANCE_OF_MOVING = 0.1;
|
||||
var CHANCE_OF_TWEETING = 0.05;
|
||||
var BIRD_GRAVITY = -0.1;
|
||||
var BIRD_FLAP_SPEED = 10.0;
|
||||
var BIRD_VELOCITY = 0.5;
|
||||
var myPosition = MyAvatar.position;
|
||||
|
||||
var range = 1.0; // Distance around avatar where I can move
|
||||
|
||||
// This is our Bird object
|
||||
function Bird (particleID, tweetSound, targetPosition) {
|
||||
this.particleID = particleID;
|
||||
this.tweetSound = tweetSound;
|
||||
this.previousFlapOffset = 0;
|
||||
this.targetPosition = targetPosition;
|
||||
this.moving = false;
|
||||
this.tweeting = -1;
|
||||
}
|
||||
|
||||
// Array of birds
|
||||
var birds = [];
|
||||
|
||||
function addBird()
|
||||
{
|
||||
// Decide what kind of bird we are
|
||||
var tweet;
|
||||
var color;
|
||||
var size;
|
||||
var which = Math.random();
|
||||
if (which < 0.2) {
|
||||
tweet = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Animals/bushtit_1.raw");
|
||||
color = { red: 100, green: 50, blue: 120 };
|
||||
size = 0.08;
|
||||
} else if (which < 0.4) {
|
||||
tweet = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Animals/rosyfacedlovebird.raw");
|
||||
color = { red: 100, green: 150, blue: 75 };
|
||||
size = 0.09;
|
||||
} else if (which < 0.6) {
|
||||
tweet = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Animals/saysphoebe.raw");
|
||||
color = { red: 84, green: 121, blue: 36 };
|
||||
size = 0.05;
|
||||
} else if (which < 0.8) {
|
||||
tweet = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Animals/mexicanWhipoorwill.raw");
|
||||
color = { red: 23, green: 197, blue: 230 };
|
||||
size = 0.12;
|
||||
} else {
|
||||
tweet = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Animals/westernscreechowl.raw");
|
||||
color = { red: 50, green: 67, blue: 144 };
|
||||
size = 0.15;
|
||||
}
|
||||
var properties = {
|
||||
type: "Sphere",
|
||||
lifetime: birdLifetime,
|
||||
position: Vec3.sum(randVector(-range, range), myPosition),
|
||||
velocity: { x: 0, y: 0, z: 0 },
|
||||
gravity: { x: 0, y: BIRD_GRAVITY, z: 0 },
|
||||
dimensions: { x: size * 2, y: size * 2, z: size * 2 },
|
||||
color: color
|
||||
};
|
||||
|
||||
birds.push(new Bird(Entities.addEntity(properties), tweet, properties.position));
|
||||
}
|
||||
|
||||
var numBirds = 30;
|
||||
|
||||
// Generate the birds
|
||||
for (var i = 0; i < numBirds; i++) {
|
||||
addBird();
|
||||
}
|
||||
|
||||
// Main update function
|
||||
function updateBirds(deltaTime) {
|
||||
|
||||
// Check to see if we've been running long enough that our birds are dead
|
||||
var nowTimeInSeconds = new Date().getTime() / 1000;
|
||||
if ((nowTimeInSeconds - startTimeInSeconds) >= birdLifetime) {
|
||||
|
||||
print("our birds are dying, stop our script");
|
||||
Script.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
frame++;
|
||||
// Only update every third frame
|
||||
if ((frame % 3) == 0) {
|
||||
myPosition = MyAvatar.position;
|
||||
|
||||
// Update all the birds
|
||||
for (var i = 0; i < numBirds; i++) {
|
||||
particleID = birds[i].particleID;
|
||||
var properties = Entities.getEntityProperties(particleID);
|
||||
|
||||
// Tweeting behavior
|
||||
if (birds[i].tweeting == 0) {
|
||||
if (Math.random() < CHANCE_OF_TWEETING) {
|
||||
Audio.playSound(birds[i].tweetSound, {
|
||||
position: properties.position,
|
||||
volume: 0.75
|
||||
});
|
||||
birds[i].tweeting = 10;
|
||||
}
|
||||
} else {
|
||||
birds[i].tweeting -= 1;
|
||||
}
|
||||
|
||||
// Begin movement by getting a target
|
||||
if (birds[i].moving == false) {
|
||||
if (Math.random() < CHANCE_OF_MOVING) {
|
||||
var targetPosition = Vec3.sum(randVector(-range, range), myPosition);
|
||||
|
||||
if (targetPosition.x < 0) {
|
||||
targetPosition.x = 0;
|
||||
}
|
||||
if (targetPosition.y < 0) {
|
||||
targetPosition.y = 0;
|
||||
}
|
||||
if (targetPosition.z < 0) {
|
||||
targetPosition.z = 0;
|
||||
}
|
||||
if (targetPosition.x > TREE_SCALE) {
|
||||
targetPosition.x = TREE_SCALE;
|
||||
}
|
||||
if (targetPosition.y > TREE_SCALE) {
|
||||
targetPosition.y = TREE_SCALE;
|
||||
}
|
||||
if (targetPosition.z > TREE_SCALE) {
|
||||
targetPosition.z = TREE_SCALE;
|
||||
}
|
||||
|
||||
birds[i].targetPosition = targetPosition;
|
||||
|
||||
birds[i].moving = true;
|
||||
}
|
||||
}
|
||||
// If we are moving, move towards the target
|
||||
if (birds[i].moving) {
|
||||
var desiredVelocity = Vec3.subtract(birds[i].targetPosition, properties.position);
|
||||
desiredVelocity = vScalarMult(Vec3.normalize(desiredVelocity), BIRD_VELOCITY);
|
||||
|
||||
properties.velocity = vInterpolate(properties.velocity, desiredVelocity, 0.2);
|
||||
// If we are near the target, we should get a new target
|
||||
if (Vec3.length(Vec3.subtract(properties.position, birds[i].targetPosition)) < (properties.dimensions.x / 5.0)) {
|
||||
birds[i].moving = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Use a cosine wave offset to make it look like its flapping.
|
||||
var offset = Math.cos(nowTimeInSeconds * BIRD_FLAP_SPEED) * properties.dimensions.x;
|
||||
properties.position.y = properties.position.y + (offset - birds[i].previousFlapOffset);
|
||||
// Change position relative to previous offset.
|
||||
birds[i].previousFlapOffset = offset;
|
||||
|
||||
// Update the particle
|
||||
Entities.editEntity(particleID, properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// register the call back so it fires before each data send
|
||||
Script.update.connect(updateBirds);
|
|
@ -13,7 +13,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
Script.include("../../libraries/globals.js");
|
||||
|
||||
var sound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Animals/mexicanWhipoorwill.raw");
|
||||
var CHANCE_OF_PLAYING_SOUND = 0.01;
|
|
@ -4,6 +4,10 @@
|
|||
//
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
//
|
||||
// Gives the ability to be set various reverb settings.
|
||||
//
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
|
@ -14,7 +18,7 @@ var audioOptions = new AudioEffectOptions({
|
|||
roomSize: 50,
|
||||
|
||||
// Seconds
|
||||
reverbTime: 4,
|
||||
reverbTime: 10,
|
||||
|
||||
// Between 0 - 1
|
||||
damping: 0.50,
|
|
@ -9,7 +9,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
Script.include("../libraries/globals.js");
|
||||
|
||||
var modelURL = HIFI_PUBLIC_BUCKET + "models/entities/radio/Speakers.fbx";
|
||||
var soundURL = HIFI_PUBLIC_BUCKET + "sounds/family.stereo.raw";
|
|
@ -12,7 +12,7 @@
|
|||
//
|
||||
|
||||
function keyReleaseEvent(event) {
|
||||
if (event.text == "F2") {
|
||||
if (event.text == "r") {
|
||||
MyAvatar.shouldRenderLocally = !MyAvatar.shouldRenderLocally;
|
||||
}
|
||||
}
|
|
@ -8,8 +8,8 @@
|
|||
// This is an example script that demonstrates use of the Camera class's lookAt(), keepLookingAt(), and stopLookingAt()
|
||||
// features.
|
||||
//
|
||||
// To use the script, click on a voxel, and the camera will switch into independent mode and fix it's lookAt on the point
|
||||
// on the face of the voxel that you clicked. Click again and it will stop looking at that point. While in this fixed mode
|
||||
// To use the script, click on a entity, and the camera will switch into independent mode and fix it's lookAt on the point
|
||||
// on the face of the entity that you clicked. Click again and it will stop looking at that point. While in this fixed mode
|
||||
// you can use the arrow keys to change the position of the camera.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
|
@ -12,7 +12,7 @@
|
|||
//
|
||||
|
||||
var count = 0;
|
||||
var moveUntil = 6000;
|
||||
var moveUntil = 1000;
|
||||
var stopAfter = moveUntil + 100;
|
||||
|
||||
var pitch = 0.0;
|
||||
|
@ -25,16 +25,19 @@ var originalProperties = {
|
|||
position: { x: MyAvatar.position.x,
|
||||
y: MyAvatar.position.y,
|
||||
z: MyAvatar.position.z },
|
||||
|
||||
radius : 1,
|
||||
dimensions: {
|
||||
x: 1.62,
|
||||
y: 0.41,
|
||||
z: 1.13
|
||||
},
|
||||
|
||||
color: { red: 0,
|
||||
green: 255,
|
||||
blue: 0 },
|
||||
|
||||
modelURL: "http://www.fungibleinsight.com/faces/beta.fst",
|
||||
modelURL: "http://public.highfidelity.io/cozza13/club/dragon/dragon.fbx",
|
||||
rotation: rotation,
|
||||
animationURL: "http://www.fungibleinsight.com/faces/gangnam_style_2.fbx",
|
||||
animationURL: "http://public.highfidelity.io/cozza13/club/dragon/flying.fbx",
|
||||
animationIsPlaying: true,
|
||||
};
|
||||
|
|
@ -82,9 +82,9 @@ function addButterfly() {
|
|||
damping: 0.00001,
|
||||
dimensions: dimensions,
|
||||
color: color,
|
||||
animationURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/models/content/butterfly/butterfly.fbx",
|
||||
animationURL: "http://public.highfidelity.io/models/content/butterfly/butterfly.fbx",
|
||||
animationSettings: "{\"firstFrame\":0,\"fps\":" + newFrameRate + ",\"frameIndex\":0,\"hold\":false,\"lastFrame\":10000,\"loop\":true,\"running\":true,\"startAutomatically\":false}",
|
||||
modelURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/models/content/butterfly/butterfly.fbx"
|
||||
modelURL: "http://public.highfidelity.io/models/content/butterfly/butterfly.fbx"
|
||||
};
|
||||
butterflies.push(Entities.addEntity(properties));
|
||||
}
|
|
@ -64,7 +64,7 @@ function draw(deltaTime) {
|
|||
y: 1,
|
||||
z: 0 };
|
||||
|
||||
var entitySize = 0.1;
|
||||
var entitySize = 1.1;
|
||||
|
||||
print("number of entitys=" + numberEntitiesAdded +"\n");
|
||||
|
||||
|
@ -99,7 +99,7 @@ function draw(deltaTime) {
|
|||
Script.stop();
|
||||
}
|
||||
|
||||
print("Particles Stats: " + Entities.getLifetimeInSeconds() + " seconds," +
|
||||
print("Entity Stats: " + Entities.getLifetimeInSeconds() + " seconds," +
|
||||
" Queued packets:" + Entities.getLifetimePacketsQueued() + "," +
|
||||
" PPS:" + Entities.getLifetimePPSQueued() + "," +
|
||||
" BPS:" + Entities.getLifetimeBPSQueued() + "," +
|
|
@ -5,7 +5,7 @@
|
|||
// Created by Brad Hefta-Gaub on 12/31/13.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// This is an example script that demonstrates creating and editing a particle
|
||||
// This is an example script that demonstrates creating and editing a particle. Go to the origin of the domain to see the results (0,0,0).
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -29,6 +29,11 @@ var originalProperties = {
|
|||
gravity: { x: 0,
|
||||
y: 0,
|
||||
z: 0 },
|
||||
dimensions: {
|
||||
x: 1,
|
||||
y: 1,
|
||||
z: 1
|
||||
},
|
||||
|
||||
|
||||
color: { red: 0,
|
||||
|
@ -74,7 +79,6 @@ function moveEntity(deltaTime) {
|
|||
y: originalProperties.position.y + (count * positionDelta.y),
|
||||
z: originalProperties.position.z + (count * positionDelta.z)
|
||||
},
|
||||
radius : 0.25,
|
||||
|
||||
};
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
Script.include("../../libraries/globals.js");
|
||||
|
||||
var count = 0;
|
||||
var moveUntil = 2000;
|
||||
|
@ -23,22 +23,22 @@ var roll = 180.0;
|
|||
var rotation = Quat.fromPitchYawRollDegrees(pitch, yaw, roll)
|
||||
|
||||
var originalProperties = {
|
||||
type: "Model",
|
||||
position: { x: 2.0,
|
||||
y: 2.0,
|
||||
z: 0.5 },
|
||||
|
||||
radius : 0.25,
|
||||
|
||||
color: { red: 0,
|
||||
dimensions: {
|
||||
x: 2.16,
|
||||
y: 3.34,
|
||||
z: 0.54
|
||||
},
|
||||
color: { red: 0,
|
||||
green: 255,
|
||||
blue: 0 },
|
||||
|
||||
modelURL: HIFI_PUBLIC_BUCKET + "meshes/Feisar_Ship.FBX",
|
||||
//modelURL: HIFI_PUBLIC_BUCKET + "meshes/birarda/birarda_head.fbx",
|
||||
//modelURL: HIFI_PUBLIC_BUCKET + "meshes/pug.fbx",
|
||||
//modelURL: HIFI_PUBLIC_BUCKET + "meshes/newInvader16x16-large-purple.svo",
|
||||
//modelURL: HIFI_PUBLIC_BUCKET + "meshes/minotaur/mino_full.fbx",
|
||||
//modelURL: HIFI_PUBLIC_BUCKET + "meshes/Combat_tank_V01.FBX",
|
||||
|
||||
|
||||
rotation: rotation
|
||||
};
|
||||
|
@ -67,10 +67,10 @@ function moveEntity(deltaTime) {
|
|||
return; // break early
|
||||
}
|
||||
|
||||
//print("count =" + count);
|
||||
print("count =" + count);
|
||||
count++;
|
||||
|
||||
//print("entityID.creatorTokenID = " + entityID.creatorTokenID);
|
||||
print("entityID.creatorTokenID = " + entityID.creatorTokenID);
|
||||
|
||||
var newProperties = {
|
||||
position: {
|
|
@ -11,30 +11,25 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
Script.include("../libraries/globals.js");
|
||||
|
||||
var count = 0;
|
||||
var stopAfter = 100;
|
||||
var stopAfter = 1000;
|
||||
|
||||
var modelPropertiesA = {
|
||||
type: "Model",
|
||||
position: { x: 1, y: 1, z: 1 },
|
||||
velocity: { x: 0.5, y: 0, z: 0.5 },
|
||||
damping: 0,
|
||||
dimensions: { x: 0.5, y: 0.5, z: 0.5 },
|
||||
dimensions: {
|
||||
x: 2.16,
|
||||
y: 3.34,
|
||||
z: 0.54
|
||||
},
|
||||
modelURL: HIFI_PUBLIC_BUCKET + "meshes/Feisar_Ship.FBX",
|
||||
lifetime: 20
|
||||
};
|
||||
|
||||
var modelPropertiesB = {
|
||||
type: "Model",
|
||||
position: { x: 1, y: 1.5, z: 1 },
|
||||
velocity: { x: 0.5, y: 0, z: 0.5 },
|
||||
damping: 0,
|
||||
dimensions: { x: 0.5, y: 0.5, z: 0.5 },
|
||||
modelURL: HIFI_PUBLIC_BUCKET + "meshes/orc.fbx",
|
||||
lifetime: 20
|
||||
};
|
||||
|
||||
var ballProperties = {
|
||||
type: "Sphere",
|
||||
|
@ -47,7 +42,6 @@ var ballProperties = {
|
|||
};
|
||||
|
||||
var modelAEntityID = Entities.addEntity(modelPropertiesA);
|
||||
var modelBEntityID = Entities.addEntity(modelPropertiesB);
|
||||
var ballEntityID = Entities.addEntity(ballProperties);
|
||||
|
||||
function endAfterAWhile(deltaTime) {
|
|
@ -5,7 +5,7 @@
|
|||
// Created by Brad Hefta-Gaub on 3/4/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// This is an example script that generates particles that act like flocking birds
|
||||
// This is an example script that generates entities that act like flocking birds
|
||||
//
|
||||
// All birds, even flying solo...
|
||||
// birds don't like to fall too fast
|
|
@ -27,7 +27,7 @@ var lightID = Entities.addEntity({
|
|||
angularVelocity: { x: 0, y: 0, z: 0 },
|
||||
angularDamping: 0,
|
||||
|
||||
isSpotlight: false,
|
||||
isSpotlight: true,
|
||||
diffuseColor: { red: 255, green: 255, blue: 0 },
|
||||
ambientColor: { red: 0, green: 0, blue: 0 },
|
||||
specularColor: { red: 255, green: 255, blue: 255 },
|
|
@ -15,10 +15,10 @@ const NUM_OF_TREES = 40;
|
|||
const NUM_OF_SANTAS = 20;
|
||||
|
||||
// Image source: https://openclipart.org/detail/447/christmas-tree-by-theresaknott (heavily edited by Maximillian Merlin)
|
||||
const CHRISTMAS_TREE_SPRITES_URL = "http://test.thoys.nl/hifi/images/santa/christmas-tree.svg";
|
||||
const CHRISTMAS_TREE_SPRITES_URL = "https://s3.amazonaws.com/hifi-public/models/props/xmas/christmas-tree.svg";
|
||||
|
||||
// Image source: http://opengameart.org/content/santa-claus (CC-BY 3.0)
|
||||
const SANTA_SPRITES_URL = "http://test.thoys.nl/hifi/images/santa/Santa.png";
|
||||
const SANTA_SPRITES_URL = "https://s3.amazonaws.com/hifi-public/models/props/xmas/Santa.png";
|
||||
|
||||
Array.prototype.contains = function(obj) {
|
||||
var i = this.length;
|
|
@ -11,7 +11,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
Script.include("../../libraries/globals.js");
|
||||
|
||||
var iteration = 0;
|
||||
|
||||
|
@ -59,7 +59,7 @@ var middleY = gameAt.y + (gameSize.y/2);
|
|||
|
||||
var invaderSize = 0.4;
|
||||
var shipSize = 0.25;
|
||||
var missileSize = 0.1;
|
||||
var missileSize = 1.0;
|
||||
var myShip;
|
||||
var myShipProperties;
|
||||
|
||||
|
@ -101,27 +101,27 @@ var soundInMyHead = true;
|
|||
// models...
|
||||
var invaderModels = new Array();
|
||||
invaderModels[0] = {
|
||||
modelURL: HIFI_PUBLIC_BUCKET + "meshes/newInvader16x16-large-purple.svo",
|
||||
modelURL: HIFI_PUBLIC_BUCKET + "meshes/space_invader.fbx",
|
||||
modelScale: 450,
|
||||
modelTranslation: { x: -1.3, y: -1.3, z: -1.3 },
|
||||
};
|
||||
invaderModels[1] = {
|
||||
modelURL: HIFI_PUBLIC_BUCKET + "meshes/newInvader16x16-large-cyan.svo",
|
||||
modelURL: HIFI_PUBLIC_BUCKET + "meshes/space_invader.fbx",
|
||||
modelScale: 450,
|
||||
modelTranslation: { x: -1.3, y: -1.3, z: -1.3 },
|
||||
};
|
||||
invaderModels[2] = {
|
||||
modelURL: HIFI_PUBLIC_BUCKET + "meshes/newInvader16x16-medium-cyan.svo",
|
||||
modelURL: HIFI_PUBLIC_BUCKET + "meshes/space_invader.fbx",
|
||||
modelScale: 450,
|
||||
modelTranslation: { x: -1.3, y: -1.3, z: -1.3 },
|
||||
};
|
||||
invaderModels[3] = {
|
||||
modelURL: HIFI_PUBLIC_BUCKET + "meshes/newInvader16x16-medium-green.svo",
|
||||
modelURL: HIFI_PUBLIC_BUCKET + "meshes/space_invader.fbx",
|
||||
modelScale: 450,
|
||||
modelTranslation: { x: -1.3, y: -1.3, z: -1.3 },
|
||||
};
|
||||
invaderModels[4] = {
|
||||
modelURL: HIFI_PUBLIC_BUCKET + "meshes/newInvader16x16-small-green.svo",
|
||||
modelURL: HIFI_PUBLIC_BUCKET + "meshes/space_invader.fbx",
|
||||
modelScale: 450,
|
||||
modelTranslation: { x: -1.3, y: -1.3, z: -1.3 },
|
||||
};
|
||||
|
@ -141,7 +141,7 @@ function initializeMyShip() {
|
|||
damping: 0,
|
||||
dimensions: { x: shipSize * 2, y: shipSize * 2, z: shipSize * 2 },
|
||||
color: { red: 0, green: 255, blue: 0 },
|
||||
modelURL: HIFI_PUBLIC_BUCKET + "meshes/myCannon16x16.svo",
|
||||
modelURL: HIFI_PUBLIC_BUCKET + "meshes/space_invader.fbx",
|
||||
lifetime: itemLifetimes
|
||||
};
|
||||
myShip = Entities.addEntity(myShipProperties);
|
||||
|
@ -360,7 +360,7 @@ function keyPressEvent(key) {
|
|||
myShipProperties.position.x = gameAt.x + gameSize.x;
|
||||
}
|
||||
moveShipTo(myShipProperties.position);
|
||||
} else if (key.text == " ") {
|
||||
} else if (key.text == "f") {
|
||||
fireMissile();
|
||||
} else if (key.text == "q") {
|
||||
endGame();
|
|
@ -14,13 +14,6 @@
|
|||
|
||||
print("hello...");
|
||||
|
||||
function entityCollisionWithVoxel(entity, voxel, collision) {
|
||||
print("entityCollisionWithVoxel()..");
|
||||
print(" entity.getID()=" + entity.id);
|
||||
print(" voxel color...=" + voxel.red + ", " + voxel.green + ", " + voxel.blue);
|
||||
Vec3.print('penetration=', collision.penetration);
|
||||
Vec3.print('contactPoint=', collision.contactPoint);
|
||||
}
|
||||
|
||||
function entityCollisionWithEntity(entityA, entityB, collision) {
|
||||
print("entityCollisionWithParticle()..");
|
||||
|
@ -30,7 +23,6 @@ function entityCollisionWithEntity(entityA, entityB, collision) {
|
|||
Vec3.print('contactPoint=', collision.contactPoint);
|
||||
}
|
||||
|
||||
Entities.entityCollisionWithVoxel.connect(entityCollisionWithVoxel);
|
||||
Entities.entityCollisionWithEntity.connect(entityCollisionWithEntity);
|
||||
|
||||
print("here... hello...");
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
//
|
||||
// localVoxelsExample.js
|
||||
// examples
|
||||
//
|
||||
// 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 TREE_SCALE = 16384;
|
||||
var tree = LocalVoxels("tree");
|
||||
tree.setVoxel(0, 0, 0,
|
||||
0.5 * TREE_SCALE,
|
||||
255, 0, 0);
|
||||
tree.setVoxel(0.5 * TREE_SCALE,
|
||||
0.5 * TREE_SCALE,
|
||||
0.5 * TREE_SCALE,
|
||||
0.5 * TREE_SCALE,
|
||||
0, 255, 0);
|
||||
|
||||
var copy = LocalVoxels("copy");
|
||||
tree.pasteFrom(0, 0, 0, TREE_SCALE, "copy");
|
||||
tree.pasteFrom(0, 0, 0, TREE_SCALE, "clipboard");
|
||||
|
||||
var overlay1 = Overlays.addOverlay("localvoxels", {
|
||||
position: {x: 1, y: 1, z: 1},
|
||||
size: 1,
|
||||
name: "tree"
|
||||
});
|
||||
var overlay2 = Overlays.addOverlay("localvoxels", {
|
||||
position: {x: 1, y: 2, z: 1},
|
||||
size: 1,
|
||||
name: "tree"
|
||||
});
|
||||
var overlay3 = Overlays.addOverlay("localvoxels", {
|
||||
position: {x: 1, y: 3, z: 1},
|
||||
size: 1,
|
||||
name: "tree"
|
||||
});
|
||||
var overlay4 = Overlays.addOverlay("localvoxels", {
|
||||
position: {x: 1, y: 4, z: 1},
|
||||
size: 1,
|
||||
name: "copy"
|
||||
});
|
||||
|
||||
var clipboard = Overlays.addOverlay("localvoxels", {
|
||||
position: {x: 1, y: 5, z: 1},
|
||||
size: 1,
|
||||
name: "clipboard"
|
||||
});
|
||||
|
||||
|
||||
|
||||
// When our script shuts down, we should clean up all of our overlays
|
||||
function scriptEnding() {
|
||||
Overlays.deleteOverlay(overlay1);
|
||||
Overlays.deleteOverlay(overlay2);
|
||||
Overlays.deleteOverlay(overlay3);
|
||||
Overlays.deleteOverlay(overlay4);
|
||||
Overlays.deleteOverlay(clipboard);
|
||||
}
|
||||
Script.scriptEnding.connect(scriptEnding);
|
|
@ -15,5 +15,5 @@
|
|||
Script.include("http://public.highfidelity.io/scripts/lookWithTouch.js");
|
||||
|
||||
// You can also include scripts that are relative to the current script
|
||||
Script.include("editVoxels.js");
|
||||
Script.include("../examples/selectAudioDevice.js");
|
||||
//Script.include("../../editEntities.js");
|
||||
//Script.include("../../examples/selectAudioDevice.js");
|
|
@ -15,4 +15,4 @@ print("mySetting: " + Settings.getValue("mySetting"));
|
|||
Settings.setValue("mySetting", "spam");
|
||||
print("mySetting: " + Settings.getValue("mySetting"));
|
||||
|
||||
Script.stop();
|
||||
//Script.stop();
|
|
@ -11,7 +11,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
Script.include("../../libraries/globals.js");
|
||||
|
||||
// The "Swatches" example of this script will create 9 different image overlays, that use the color feature to
|
||||
// display different colors as color swatches. The overlays can be clicked on, to change the "selectedSwatch" variable
|
|
@ -58,7 +58,7 @@ var button1 = Overlays.addOverlay("image", { // green button
|
|||
width: 40,
|
||||
height: 35,
|
||||
subImage: { x: 0, y: 0, width: 39, height: 35 },
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/thumb.png",
|
||||
imageURL: "https://public.highfidelity.io/images/thumb.png",
|
||||
color: readyColor,
|
||||
visible: true
|
||||
});
|
||||
|
@ -69,7 +69,7 @@ var button2 = Overlays.addOverlay("image", { // red button
|
|||
width: 40,
|
||||
height: 35,
|
||||
subImage: { x: 0, y: 0, width: 39, height: 35 },
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/thumb.png",
|
||||
imageURL: "https://public.highfidelity.io/images/thumb.png",
|
||||
color: { red: 250, green: 2, blue: 2},
|
||||
visible: true,
|
||||
});
|
|
@ -1,77 +0,0 @@
|
|||
//
|
||||
// fountain.js
|
||||
// examples
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
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, y: 0.6, z: 5.0 };
|
||||
//Voxels.setVoxel(position.x, 0, position.z, 0.5, 0, 0, 255);
|
||||
|
||||
var totalEntities = 0;
|
||||
function makeFountain(deltaTime) {
|
||||
if (Math.random() < 0.10) {
|
||||
//print("Made entity!\n");
|
||||
var radius = (0.02 + (Math.random() * 0.05));
|
||||
var properties = {
|
||||
type: "Sphere",
|
||||
position: position,
|
||||
dimensions: { x: radius, y: radius, z: radius},
|
||||
color: { red: 0, green: 0, blue: 128 },
|
||||
velocity: { x: (Math.random() * 1.0 - 0.5),
|
||||
y: (1.0 + (Math.random() * 2.0)),
|
||||
z: (Math.random() * 1.0 - 0.5) },
|
||||
gravity: { x: 0, y: -0.1, z: 0 },
|
||||
damping: 0.25,
|
||||
lifetime: 1
|
||||
}
|
||||
|
||||
Entities.addEntity(properties);
|
||||
totalEntities++;
|
||||
}
|
||||
if (totalEntities > 100) {
|
||||
Script.stop();
|
||||
}
|
||||
}
|
||||
// register the call back so it fires before each data send
|
||||
Script.update.connect(makeFountain);
|
208
examples/gun.js
208
examples/gun.js
|
@ -26,14 +26,19 @@ var yawFromMouse = 0;
|
|||
var pitchFromMouse = 0;
|
||||
var isMouseDown = false;
|
||||
|
||||
var BULLET_VELOCITY = 5.0;
|
||||
var BULLET_VELOCITY = 20.0;
|
||||
var MIN_THROWER_DELAY = 1000;
|
||||
var MAX_THROWER_DELAY = 1000;
|
||||
var LEFT_BUTTON_3 = 3;
|
||||
var RELOAD_INTERVAL = 5;
|
||||
|
||||
var KICKBACK_ANGLE = 15;
|
||||
var elbowKickAngle = 0.0;
|
||||
var rotationBeforeKickback;
|
||||
|
||||
var showScore = false;
|
||||
|
||||
|
||||
// Load some sound to use for loading and firing
|
||||
var fireSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Guns/GUN-SHOT2.raw");
|
||||
var loadSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Guns/Gun_Reload_Weapon22.raw");
|
||||
|
@ -48,10 +53,11 @@ var audioOptions = {
|
|||
}
|
||||
|
||||
var shotsFired = 0;
|
||||
|
||||
var shotTime = new Date();
|
||||
|
||||
// initialize our triggers
|
||||
var activeControllers = 0;
|
||||
|
||||
// initialize our controller triggers
|
||||
var triggerPulled = new Array();
|
||||
var numberOfTriggers = Controller.getNumberOfTriggers();
|
||||
for (t = 0; t < numberOfTriggers; t++) {
|
||||
|
@ -59,9 +65,11 @@ for (t = 0; t < numberOfTriggers; t++) {
|
|||
}
|
||||
|
||||
var isLaunchButtonPressed = false;
|
||||
|
||||
var score = 0;
|
||||
|
||||
var bulletID = false;
|
||||
var targetID = false;
|
||||
|
||||
// Create a reticle image in center of screen
|
||||
var screenSize = Controller.getViewportDimensions();
|
||||
var reticle = Overlays.addOverlay("image", {
|
||||
|
@ -74,6 +82,16 @@ var reticle = Overlays.addOverlay("image", {
|
|||
alpha: 1
|
||||
});
|
||||
|
||||
var offButton = Overlays.addOverlay("image", {
|
||||
x: screenSize.x - 48,
|
||||
y: 96,
|
||||
width: 32,
|
||||
height: 32,
|
||||
imageURL: HIFI_PUBLIC_BUCKET + "images/close.png",
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
if (showScore) {
|
||||
var text = Overlays.addOverlay("text", {
|
||||
x: screenSize.x / 2 - 100,
|
||||
|
@ -95,18 +113,20 @@ function printVector(string, vector) {
|
|||
}
|
||||
|
||||
function shootBullet(position, velocity) {
|
||||
var BULLET_SIZE = 0.01;
|
||||
var BULLET_LIFETIME = 20.0;
|
||||
var BULLET_SIZE = 0.07;
|
||||
var BULLET_LIFETIME = 10.0;
|
||||
var BULLET_GRAVITY = -0.02;
|
||||
Entities.addEntity(
|
||||
bulletID = Entities.addEntity(
|
||||
{ type: "Sphere",
|
||||
position: position,
|
||||
dimensions: { x: BULLET_SIZE, y: BULLET_SIZE, z: BULLET_SIZE },
|
||||
color: { red: 10, green: 10, blue: 10 },
|
||||
color: { red: 255, green: 0, blue: 0 },
|
||||
velocity: velocity,
|
||||
lifetime: BULLET_LIFETIME,
|
||||
gravity: { x: 0, y: BULLET_GRAVITY, z: 0 },
|
||||
damping: 0 });
|
||||
gravity: { x: 0, y: BULLET_GRAVITY, z: 0 },
|
||||
ignoreCollisions: false,
|
||||
collisionsWillMove: true
|
||||
});
|
||||
|
||||
// Play firing sounds
|
||||
audioOptions.position = position;
|
||||
|
@ -115,36 +135,45 @@ function shootBullet(position, velocity) {
|
|||
if ((shotsFired % RELOAD_INTERVAL) == 0) {
|
||||
Audio.playSound(loadSound, audioOptions);
|
||||
}
|
||||
|
||||
// Kickback the arm
|
||||
rotationBeforeKickback = MyAvatar.getJointRotation("LeftForeArm");
|
||||
var armRotation = MyAvatar.getJointRotation("LeftForeArm");
|
||||
armRotation = Quat.multiply(armRotation, Quat.fromPitchYawRollDegrees(0.0, 0.0, KICKBACK_ANGLE));
|
||||
MyAvatar.setJointData("LeftForeArm", armRotation);
|
||||
elbowKickAngle = KICKBACK_ANGLE;
|
||||
}
|
||||
|
||||
function shootTarget() {
|
||||
var TARGET_SIZE = 0.25;
|
||||
var TARGET_GRAVITY = -0.6;
|
||||
var TARGET_SIZE = 0.50;
|
||||
var TARGET_GRAVITY = -0.25;
|
||||
var TARGET_LIFETIME = 300.0;
|
||||
var TARGET_UP_VELOCITY = 3.0;
|
||||
var TARGET_FWD_VELOCITY = 5.0;
|
||||
var TARGET_UP_VELOCITY = 0.5;
|
||||
var TARGET_FWD_VELOCITY = 1.0;
|
||||
var DISTANCE_TO_LAUNCH_FROM = 3.0;
|
||||
var ANGLE_RANGE_FOR_LAUNCH = 20.0;
|
||||
var camera = Camera.getPosition();
|
||||
//printVector("camera", camera);
|
||||
var targetDirection = Quat.angleAxis(getRandomFloat(-20.0, 20.0), { x:0, y:1, z:0 });
|
||||
var targetDirection = Quat.angleAxis(getRandomFloat(-ANGLE_RANGE_FOR_LAUNCH, ANGLE_RANGE_FOR_LAUNCH), { x:0, y:1, z:0 });
|
||||
targetDirection = Quat.multiply(Camera.getOrientation(), targetDirection);
|
||||
var forwardVector = Quat.getFront(targetDirection);
|
||||
//printVector("forwardVector", forwardVector);
|
||||
|
||||
var newPosition = Vec3.sum(camera, Vec3.multiply(forwardVector, DISTANCE_TO_LAUNCH_FROM));
|
||||
//printVector("newPosition", newPosition);
|
||||
|
||||
var velocity = Vec3.multiply(forwardVector, TARGET_FWD_VELOCITY);
|
||||
velocity.y += TARGET_UP_VELOCITY;
|
||||
//printVector("velocity", velocity);
|
||||
|
||||
Entities.addEntity(
|
||||
{ type: "Sphere",
|
||||
|
||||
targetID = Entities.addEntity(
|
||||
{ type: "Box",
|
||||
position: newPosition,
|
||||
dimensions: { x: TARGET_SIZE, y: TARGET_SIZE, z: TARGET_SIZE },
|
||||
color: { red: 0, green: 200, blue: 200 },
|
||||
//angularVelocity: { x: 1, y: 0, z: 0 },
|
||||
velocity: velocity,
|
||||
gravity: { x: 0, y: TARGET_GRAVITY, z: 0 },
|
||||
lifetime: TARGET_LIFETIME,
|
||||
damping: 0.0001 });
|
||||
damping: 0.0001,
|
||||
collisionsWillMove: true });
|
||||
|
||||
// Record start time
|
||||
shotTime = new Date();
|
||||
|
@ -157,24 +186,25 @@ function shootTarget() {
|
|||
|
||||
|
||||
function entityCollisionWithEntity(entity1, entity2, collision) {
|
||||
score++;
|
||||
if (showScore) {
|
||||
Overlays.editOverlay(text, { text: "Score: " + score } );
|
||||
}
|
||||
|
||||
// Sort out which entity is which
|
||||
|
||||
// Record shot time
|
||||
var endTime = new Date();
|
||||
var msecs = endTime.valueOf() - shotTime.valueOf();
|
||||
//print("hit, msecs = " + msecs);
|
||||
//Vec3.print("penetration = ", collision.penetration);
|
||||
//Vec3.print("contactPoint = ", collision.contactPoint);
|
||||
Entities.deleteEntity(entity1);
|
||||
Entities.deleteEntity(entity2);
|
||||
// play the sound near the camera so the shooter can hear it
|
||||
audioOptions.position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation()));
|
||||
Audio.playSound(targetHitSound, audioOptions);
|
||||
if (((entity1.id == bulletID.id) || (entity1.id == targetID.id)) &&
|
||||
((entity2.id == bulletID.id) || (entity2.id == targetID.id))) {
|
||||
score++;
|
||||
if (showScore) {
|
||||
Overlays.editOverlay(text, { text: "Score: " + score } );
|
||||
}
|
||||
|
||||
// We will delete the bullet and target in 1/2 sec, but for now we can see them bounce!
|
||||
Script.setTimeout(deleteBulletAndTarget, 500);
|
||||
|
||||
// Turn the target and the bullet white
|
||||
Entities.editEntity(entity1, { color: { red: 255, green: 255, blue: 255 }});
|
||||
Entities.editEntity(entity2, { color: { red: 255, green: 255, blue: 255 }});
|
||||
|
||||
// play the sound near the camera so the shooter can hear it
|
||||
audioOptions.position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation()));
|
||||
Audio.playSound(targetHitSound, audioOptions);
|
||||
}
|
||||
}
|
||||
|
||||
function keyPressEvent(event) {
|
||||
|
@ -186,32 +216,93 @@ function keyPressEvent(event) {
|
|||
shootFromMouse();
|
||||
} else if (event.text == "r") {
|
||||
playLoadSound();
|
||||
} else if (event.text == "s") {
|
||||
// Hit this key to dump a posture from hydra to log
|
||||
Quat.print("arm = ", MyAvatar.getJointRotation("LeftArm"));
|
||||
Quat.print("forearm = ", MyAvatar.getJointRotation("LeftForeArm"));
|
||||
Quat.print("hand = ", MyAvatar.getJointRotation("LeftHand"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function playLoadSound() {
|
||||
audioOptions.position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation()));
|
||||
Audio.playSound(loadSound, audioOptions);
|
||||
// Raise arm to firing posture
|
||||
takeFiringPose();
|
||||
}
|
||||
|
||||
function clearPose() {
|
||||
MyAvatar.clearJointData("LeftForeArm");
|
||||
MyAvatar.clearJointData("LeftArm");
|
||||
MyAvatar.clearJointData("LeftHand");
|
||||
}
|
||||
|
||||
function deleteBulletAndTarget() {
|
||||
Entities.deleteEntity(bulletID);
|
||||
Entities.deleteEntity(targetID);
|
||||
bulletID = false;
|
||||
targetID = false;
|
||||
}
|
||||
|
||||
function takeFiringPose() {
|
||||
clearPose();
|
||||
if (Controller.getNumberOfSpatialControls() == 0) {
|
||||
MyAvatar.setJointData("LeftForeArm", {x: -0.251919, y: -0.0415449, z: 0.499487, w: 0.827843});
|
||||
MyAvatar.setJointData("LeftArm", { x: 0.470196, y: -0.132559, z: 0.494033, w: 0.719219});
|
||||
MyAvatar.setJointData("LeftHand", { x: -0.0104815, y: -0.110551, z: -0.352111, w: 0.929333});
|
||||
}
|
||||
}
|
||||
|
||||
//MyAvatar.attach(gunModel, "RightHand", {x: -0.02, y: -.14, z: 0.07}, Quat.fromPitchYawRollDegrees(-70, -151, 72), 0.20);
|
||||
MyAvatar.attach(gunModel, "LeftHand", {x: -0.02, y: -.14, z: 0.07}, Quat.fromPitchYawRollDegrees(-70, -151, 72), 0.20);
|
||||
|
||||
// Give a bit of time to load before playing sound
|
||||
Script.setTimeout(playLoadSound, 2000);
|
||||
|
||||
function update(deltaTime) {
|
||||
if (bulletID && !bulletID.isKnownID) {
|
||||
print("Trying to identify bullet");
|
||||
bulletID = Entities.identifyEntity(bulletID);
|
||||
}
|
||||
if (targetID && !targetID.isKnownID) {
|
||||
targetID = Entities.identifyEntity(targetID);
|
||||
}
|
||||
// Check for mouseLook movement, update rotation
|
||||
// rotate body yaw for yaw received from mouse
|
||||
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromVec3Radians( { x: 0, y: yawFromMouse, z: 0 } ));
|
||||
MyAvatar.orientation = newOrientation;
|
||||
//MyAvatar.orientation = newOrientation;
|
||||
yawFromMouse = 0;
|
||||
|
||||
// apply pitch from mouse
|
||||
var newPitch = MyAvatar.headPitch + pitchFromMouse;
|
||||
MyAvatar.headPitch = newPitch;
|
||||
//MyAvatar.headPitch = newPitch;
|
||||
pitchFromMouse = 0;
|
||||
|
||||
|
||||
if (activeControllers == 0) {
|
||||
if (Controller.getNumberOfSpatialControls() > 0) {
|
||||
activeControllers = Controller.getNumberOfSpatialControls();
|
||||
clearPose();
|
||||
}
|
||||
}
|
||||
|
||||
var KICKBACK_DECAY_RATE = 0.125;
|
||||
if (elbowKickAngle > 0.0) {
|
||||
if (elbowKickAngle > 0.5) {
|
||||
var newAngle = elbowKickAngle * KICKBACK_DECAY_RATE;
|
||||
elbowKickAngle -= newAngle;
|
||||
var armRotation = MyAvatar.getJointRotation("LeftForeArm");
|
||||
armRotation = Quat.multiply(armRotation, Quat.fromPitchYawRollDegrees(0.0, 0.0, -newAngle));
|
||||
MyAvatar.setJointData("LeftForeArm", armRotation);
|
||||
} else {
|
||||
MyAvatar.setJointData("LeftForeArm", rotationBeforeKickback);
|
||||
if (Controller.getNumberOfSpatialControls() > 0) {
|
||||
clearPose();
|
||||
}
|
||||
elbowKickAngle = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
// Check hydra controller for launch button press
|
||||
if (!isLaunchButtonPressed && Controller.isButtonPressed(LEFT_BUTTON_3)) {
|
||||
isLaunchButtonPressed = true;
|
||||
|
@ -222,15 +313,13 @@ function update(deltaTime) {
|
|||
|
||||
}
|
||||
|
||||
// Check hydra controller for trigger press
|
||||
// check for trigger press
|
||||
|
||||
var numberOfTriggers = Controller.getNumberOfTriggers();
|
||||
var numberOfSpatialControls = Controller.getNumberOfSpatialControls();
|
||||
var controllersPerTrigger = numberOfSpatialControls / numberOfTriggers;
|
||||
var numberOfTriggers = 2;
|
||||
var controllersPerTrigger = 2;
|
||||
|
||||
// this is expected for hydras
|
||||
if (numberOfTriggers == 2 && controllersPerTrigger == 2) {
|
||||
for (var t = 0; t < numberOfTriggers; t++) {
|
||||
for (var t = 0; t < 2; t++) {
|
||||
var shootABullet = false;
|
||||
var triggerValue = Controller.getTriggerValue(t);
|
||||
if (triggerPulled[t]) {
|
||||
|
@ -239,14 +328,13 @@ function update(deltaTime) {
|
|||
triggerPulled[t] = false; // unpulled
|
||||
}
|
||||
} else {
|
||||
// must pull to at least 0.9
|
||||
if (triggerValue > 0.9) {
|
||||
// must pull to at least
|
||||
if (triggerValue > 0.5) {
|
||||
triggerPulled[t] = true; // pulled
|
||||
shootABullet = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (shootABullet) {
|
||||
var palmController = t * controllersPerTrigger;
|
||||
var palmPosition = Controller.getSpatialControlPosition(palmController);
|
||||
|
@ -263,12 +351,8 @@ function update(deltaTime) {
|
|||
var position = { x: fingerTipPosition.x + palmToFingerTipVector.x/2,
|
||||
y: fingerTipPosition.y + palmToFingerTipVector.y/2,
|
||||
z: fingerTipPosition.z + palmToFingerTipVector.z/2};
|
||||
|
||||
var linearVelocity = 25;
|
||||
|
||||
var velocity = { x: palmToFingerTipVector.x * linearVelocity,
|
||||
y: palmToFingerTipVector.y * linearVelocity,
|
||||
z: palmToFingerTipVector.z * linearVelocity };
|
||||
|
||||
var velocity = Vec3.multiply(BULLET_VELOCITY, Vec3.normalize(palmToFingerTipVector));
|
||||
|
||||
shootBullet(position, velocity);
|
||||
}
|
||||
|
@ -280,8 +364,12 @@ function mousePressEvent(event) {
|
|||
isMouseDown = true;
|
||||
lastX = event.x;
|
||||
lastY = event.y;
|
||||
//audioOptions.position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation()));
|
||||
//Audio.playSound(loadSound, audioOptions);
|
||||
|
||||
if (Overlays.getOverlayAtPoint({ x: event.x, y: event.y }) === offButton) {
|
||||
Script.stop();
|
||||
} else {
|
||||
shootFromMouse();
|
||||
}
|
||||
}
|
||||
|
||||
function shootFromMouse() {
|
||||
|
@ -312,8 +400,10 @@ function mouseMoveEvent(event) {
|
|||
|
||||
function scriptEnding() {
|
||||
Overlays.deleteOverlay(reticle);
|
||||
Overlays.deleteOverlay(offButton);
|
||||
Overlays.deleteOverlay(text);
|
||||
MyAvatar.detachOne(gunModel);
|
||||
clearPose();
|
||||
}
|
||||
|
||||
Entities.entityCollisionWithEntity.connect(entityCollisionWithEntity);
|
||||
|
|
|
@ -618,7 +618,7 @@
|
|||
<tr>
|
||||
<td class="label">Script URL</td>
|
||||
<td>
|
||||
<input id="property-script-url"></input>
|
||||
<input id="property-script-url" class="url"></input>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
@ -637,13 +637,13 @@
|
|||
<tr class="model-section">
|
||||
<td class="label">Model URL</td>
|
||||
<td>
|
||||
<input type="text" id="property-model-url"></input>
|
||||
<input type="text" id="property-model-url" class="url"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="model-section">
|
||||
<td class="label">Animation URL</td>
|
||||
<td>
|
||||
<input type="text" id="property-model-animation-url"></input>
|
||||
<input type="text" id="property-model-animation-url" class="url"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="model-section">
|
||||
|
|
|
@ -96,6 +96,10 @@ input {
|
|||
background-color: #eee;
|
||||
}
|
||||
|
||||
input.url {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table#entity-table {
|
||||
border-collapse: collapse;
|
||||
font-family: Sans-Serif;
|
||||
|
@ -171,7 +175,7 @@ table#properties-table {
|
|||
}
|
||||
|
||||
#properties-table td {
|
||||
padding: 5px 0px 5px 10px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
col#col-label {
|
||||
|
|
|
@ -590,7 +590,7 @@ SelectionDisplay = (function () {
|
|||
});
|
||||
|
||||
var yawHandle = Overlays.addOverlay("billboard", {
|
||||
url: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/rotate-arrow-west-north.png",
|
||||
url: "https://public.highfidelity.io/images/rotate-arrow-west-north.png",
|
||||
position: { x:0, y: 0, z: 0},
|
||||
color: rotateHandleColor,
|
||||
alpha: rotateHandleAlpha,
|
||||
|
@ -603,7 +603,7 @@ SelectionDisplay = (function () {
|
|||
|
||||
|
||||
var pitchHandle = Overlays.addOverlay("billboard", {
|
||||
url: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/rotate-arrow-west-north.png",
|
||||
url: "https://public.highfidelity.io/images/rotate-arrow-west-north.png",
|
||||
position: { x:0, y: 0, z: 0},
|
||||
color: rotateHandleColor,
|
||||
alpha: rotateHandleAlpha,
|
||||
|
@ -616,7 +616,7 @@ SelectionDisplay = (function () {
|
|||
|
||||
|
||||
var rollHandle = Overlays.addOverlay("billboard", {
|
||||
url: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/rotate-arrow-west-north.png",
|
||||
url: "https://public.highfidelity.io/images/rotate-arrow-west-north.png",
|
||||
position: { x:0, y: 0, z: 0},
|
||||
color: rotateHandleColor,
|
||||
alpha: rotateHandleAlpha,
|
||||
|
@ -835,8 +835,8 @@ SelectionDisplay = (function () {
|
|||
rollCenter = { x: boundsCenter.x, y: boundsCenter.y, z: far };
|
||||
|
||||
|
||||
Overlays.editOverlay(pitchHandle, { url: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/rotate-arrow-west-south.png" });
|
||||
Overlays.editOverlay(rollHandle, { url: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/rotate-arrow-west-south.png" });
|
||||
Overlays.editOverlay(pitchHandle, { url: "https://public.highfidelity.io/images/rotate-arrow-west-south.png" });
|
||||
Overlays.editOverlay(rollHandle, { url: "https://public.highfidelity.io/images/rotate-arrow-west-south.png" });
|
||||
|
||||
|
||||
} else {
|
||||
|
@ -867,8 +867,8 @@ SelectionDisplay = (function () {
|
|||
pitchCenter = { x: right, y: boundsCenter.y, z: boundsCenter.z };
|
||||
rollCenter = { x: boundsCenter.x, y: boundsCenter.y, z: near};
|
||||
|
||||
Overlays.editOverlay(pitchHandle, { url: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/rotate-arrow-west-north.png" });
|
||||
Overlays.editOverlay(rollHandle, { url: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/rotate-arrow-west-north.png" });
|
||||
Overlays.editOverlay(pitchHandle, { url: "https://public.highfidelity.io/images/rotate-arrow-west-north.png" });
|
||||
Overlays.editOverlay(rollHandle, { url: "https://public.highfidelity.io/images/rotate-arrow-west-north.png" });
|
||||
}
|
||||
} else {
|
||||
|
||||
|
@ -899,8 +899,8 @@ SelectionDisplay = (function () {
|
|||
pitchCenter = { x: left, y: boundsCenter.y, z: boundsCenter.z };
|
||||
rollCenter = { x: boundsCenter.x, y: boundsCenter.y, z: far};
|
||||
|
||||
Overlays.editOverlay(pitchHandle, { url: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/rotate-arrow-west-north.png" });
|
||||
Overlays.editOverlay(rollHandle, { url: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/rotate-arrow-west-north.png" });
|
||||
Overlays.editOverlay(pitchHandle, { url: "https://public.highfidelity.io/images/rotate-arrow-west-north.png" });
|
||||
Overlays.editOverlay(rollHandle, { url: "https://public.highfidelity.io/images/rotate-arrow-west-north.png" });
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -928,8 +928,8 @@ SelectionDisplay = (function () {
|
|||
rollCenter = { x: boundsCenter.x, y: boundsCenter.y, z: near };
|
||||
pitchCenter = { x: left, y: boundsCenter.y, z: boundsCenter.z};
|
||||
|
||||
Overlays.editOverlay(pitchHandle, { url: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/rotate-arrow-west-north.png" });
|
||||
Overlays.editOverlay(rollHandle, { url: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/rotate-arrow-west-north.png" });
|
||||
Overlays.editOverlay(pitchHandle, { url: "https://public.highfidelity.io/images/rotate-arrow-west-north.png" });
|
||||
Overlays.editOverlay(rollHandle, { url: "https://public.highfidelity.io/images/rotate-arrow-west-north.png" });
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -439,7 +439,11 @@ GridTool = function(opts) {
|
|||
} else if (overlay == uiOverlays.snapToGridCheckbox.overlay) {
|
||||
horizontalGrid.setSnapToGrid(!horizontalGrid.getSnapToGrid());
|
||||
} else if (overlay == uiOverlays.moveToAvatar.overlay) {
|
||||
horizontalGrid.setPosition(MyAvatar.position);
|
||||
var position = MyAvatar.getJointPosition("LeftFoot");
|
||||
if (position.x == 0 && position.y == 0 && position.z == 0) {
|
||||
position = MyAvatar.position;
|
||||
}
|
||||
horizontalGrid.setPosition(position);
|
||||
} else if (overlay == uiOverlays.moveToSelection.overlay) {
|
||||
var newPosition = selectionManager.worldPosition;
|
||||
newPosition = Vec3.subtract(newPosition, { x: 0, y: selectionManager.worldDimensions.y * 0.5, z: 0 });
|
||||
|
|
104
examples/libraries/unitTest.js
Normal file
104
examples/libraries/unitTest.js
Normal file
|
@ -0,0 +1,104 @@
|
|||
//
|
||||
// Unittest.js
|
||||
// examples
|
||||
//
|
||||
// Created by Ryan Huffman on 5/4/14
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// This provides very basic unit testing functionality.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
test = function(name, func) {
|
||||
print("Running test: " + name);
|
||||
|
||||
var unitTest = new UnitTest(name, func);
|
||||
|
||||
try {
|
||||
unitTest.run();
|
||||
print(" Success: " + unitTest.numAssertions + " assertions passed");
|
||||
} catch (error) {
|
||||
print(" Failure: " + error.name + " " + error.message);
|
||||
}
|
||||
};
|
||||
|
||||
AssertionException = function(expected, actual, message) {
|
||||
print("Creating exception");
|
||||
this.message = message + "\n: " + actual + " != " + expected;
|
||||
this.name = 'AssertionException';
|
||||
};
|
||||
|
||||
UnthrownException = function(message) {
|
||||
print("Creating exception");
|
||||
this.message = message + "\n";
|
||||
this.name = 'UnthrownException';
|
||||
};
|
||||
|
||||
UnitTest = function(name, func) {
|
||||
this.numAssertions = 0;
|
||||
this.func = func;
|
||||
};
|
||||
|
||||
UnitTest.prototype.run = function() {
|
||||
this.func();
|
||||
};
|
||||
|
||||
UnitTest.prototype.assertNotEquals = function(expected, actual, message) {
|
||||
this.numAssertions++;
|
||||
if (expected == actual) {
|
||||
throw new AssertionException(expected, actual, message);
|
||||
}
|
||||
};
|
||||
|
||||
UnitTest.prototype.assertEquals = function(expected, actual, message) {
|
||||
this.numAssertions++;
|
||||
if (expected != actual) {
|
||||
throw new AssertionException(expected, actual, message);
|
||||
}
|
||||
};
|
||||
|
||||
UnitTest.prototype.assertContains = function (expected, actual, message) {
|
||||
this.numAssertions++;
|
||||
if (actual.indexOf(expected) == -1) {
|
||||
throw new AssertionException(expected, actual, message);
|
||||
}
|
||||
};
|
||||
|
||||
UnitTest.prototype.assertHasProperty = function(property, actual, message) {
|
||||
this.numAssertions++;
|
||||
if (actual[property] === undefined) {
|
||||
throw new AssertionException(property, actual, message);
|
||||
}
|
||||
};
|
||||
|
||||
UnitTest.prototype.assertNull = function(value, message) {
|
||||
this.numAssertions++;
|
||||
if (value !== null) {
|
||||
throw new AssertionException(value, null, message);
|
||||
}
|
||||
}
|
||||
|
||||
UnitTest.prototype.arrayEqual = function(array1, array2, message) {
|
||||
this.numAssertions++;
|
||||
if (array1.length !== array2.length) {
|
||||
throw new AssertionException(array1.length , array2.length , message);
|
||||
}
|
||||
for (var i = 0; i < array1.length; ++i) {
|
||||
if (array1[i] !== array2[i]) {
|
||||
throw new AssertionException(array1[i], array2[i], i + " " + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UnitTest.prototype.raises = function(func, message) {
|
||||
this.numAssertions++;
|
||||
try {
|
||||
func();
|
||||
} catch (error) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new UnthrownException(message);
|
||||
}
|
|
@ -1,304 +0,0 @@
|
|||
//
|
||||
// locationsMenu.js
|
||||
// examples
|
||||
//
|
||||
// Created by Ryan Huffman on 5/28/14
|
||||
// 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
|
||||
//
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
|
||||
var scriptUrl = "https://script.google.com/macros/s/AKfycbwIo4lmF-qUwX1Z-9eA_P-g2gse9oFhNcjVyyksGukyDDEFXgU/exec?action=listOwners&domain=alpha.highfidelity.io";
|
||||
|
||||
var LocationMenu = function(opts) {
|
||||
var self = this;
|
||||
|
||||
var pageSize = opts.pageSize || 10;
|
||||
var menuWidth = opts.menuWidth || 150;
|
||||
var menuHeight = opts.menuItemHeight || 24;
|
||||
|
||||
var inactiveColor = { red: 51, green: 102, blue: 102 };
|
||||
var activeColor = { red: 18, green: 66, blue: 66 };
|
||||
var prevNextColor = { red: 192, green: 192, blue: 192 };
|
||||
var disabledColor = { red: 64, green: 64, blue: 64};
|
||||
var position = { x: 0, y: 0 };
|
||||
|
||||
var locationIconUrl = HIFI_PUBLIC_BUCKET + "images/tools/location.svg";
|
||||
var toolHeight = 50;
|
||||
var toolWidth = 50;
|
||||
var visible = false;
|
||||
var menuItemOffset = {
|
||||
x: 55,
|
||||
y: 0,
|
||||
};
|
||||
var menuItemPadding = 5;
|
||||
var margin = 7;
|
||||
var fullMenuHeight = (2 * menuItemOffset.y) + (menuHeight * (pageSize + 1));
|
||||
var menuOffset = -fullMenuHeight + toolHeight;
|
||||
|
||||
var windowDimensions = Controller.getViewportDimensions();
|
||||
|
||||
this.locations = [];
|
||||
this.numPages = 1;
|
||||
this.page = 0;
|
||||
|
||||
this.menuToggleButton = Overlays.addOverlay("image", {
|
||||
x: position.x,
|
||||
y: position.y,
|
||||
width: toolWidth, height: toolHeight,
|
||||
subImage: { x: 0, y: toolHeight, width: toolWidth, height: toolHeight },
|
||||
imageURL: locationIconUrl,
|
||||
alpha: 0.9
|
||||
});
|
||||
|
||||
this.background = Overlays.addOverlay("text", {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: menuWidth + 10,
|
||||
height: (menuHeight * (pageSize + 1)) + 10,
|
||||
backgroundColor: { red: 0, green: 0, blue: 0},
|
||||
topMargin: 4,
|
||||
leftMargin: 4,
|
||||
text: "",
|
||||
visible: visible,
|
||||
});
|
||||
|
||||
this.menuItems = [];
|
||||
for (var i = 0; i < pageSize; i++) {
|
||||
var menuItem = Overlays.addOverlay("text", {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: menuWidth,
|
||||
height: menuHeight,
|
||||
backgroundColor: inactiveColor,
|
||||
topMargin: margin,
|
||||
leftMargin: margin,
|
||||
text: (i == 0) ? "Loading..." : "",
|
||||
visible: visible,
|
||||
});
|
||||
this.menuItems.push({ overlay: menuItem, location: null });
|
||||
}
|
||||
|
||||
this.previousButton = Overlays.addOverlay("text", {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: menuWidth / 2,
|
||||
height: menuHeight,
|
||||
backgroundColor: disabledColor,
|
||||
topMargin: margin,
|
||||
leftMargin: margin,
|
||||
text: "Previous",
|
||||
visible: visible,
|
||||
});
|
||||
|
||||
this.nextButton = Overlays.addOverlay("text", {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: menuWidth / 2,
|
||||
height: menuHeight,
|
||||
backgroundColor: disabledColor,
|
||||
topMargin: margin,
|
||||
leftMargin: margin,
|
||||
text: "Next",
|
||||
visible: visible,
|
||||
});
|
||||
|
||||
this.reposition = function(force) {
|
||||
var newWindowDimensions = Controller.getViewportDimensions();
|
||||
if (force || newWindowDimensions.y != windowDimensions.y) {
|
||||
windowDimensions = newWindowDimensions;
|
||||
|
||||
position.x = 8;
|
||||
position.y = Math.floor(windowDimensions.y / 2) + 25 + 50 + 8;
|
||||
|
||||
Overlays.editOverlay(self.menuToggleButton, {
|
||||
x: position.x,
|
||||
y: position.y,
|
||||
});
|
||||
Overlays.editOverlay(self.background, {
|
||||
x: position.x + menuItemOffset.x,
|
||||
y: position.y + menuItemOffset.y - 2 * menuItemPadding + menuOffset,
|
||||
});
|
||||
for (var i = 0; i < pageSize; i++) {
|
||||
Overlays.editOverlay(self.menuItems[i].overlay, {
|
||||
x: position.x + menuItemOffset.x + menuItemPadding,
|
||||
y: position.y + menuItemOffset.y - menuItemPadding + (i * menuHeight) + menuOffset,
|
||||
});
|
||||
}
|
||||
Overlays.editOverlay(self.previousButton, {
|
||||
x: position.x + menuItemOffset.x + menuItemPadding,
|
||||
y: position.y + menuItemOffset.y - menuItemPadding + (pageSize * menuHeight) + menuOffset,
|
||||
});
|
||||
Overlays.editOverlay(self.nextButton, {
|
||||
x: position.x + menuItemOffset.x + menuItemPadding + (menuWidth / 2),
|
||||
y: position.y + menuItemOffset.y - menuItemPadding + (pageSize * menuHeight) + menuOffset,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this.updateLocations = function(locations) {
|
||||
this.locations = locations;
|
||||
this.numPages = Math.ceil(locations.length / pageSize);
|
||||
this.goToPage(0);
|
||||
}
|
||||
|
||||
this.setError = function() {
|
||||
Overlays.editOverlay(this.menuItems[0].overlay, { text: "Error loading data" });
|
||||
}
|
||||
|
||||
this.toggleMenu = function() {
|
||||
visible = !visible;
|
||||
for (var i = 0; i < this.menuItems.length; i++) {
|
||||
Overlays.editOverlay(this.menuItems[i].overlay, { visible: visible});
|
||||
}
|
||||
Overlays.editOverlay(this.previousButton, { visible: visible});
|
||||
Overlays.editOverlay(this.nextButton, { visible: visible});
|
||||
Overlays.editOverlay(this.background, { visible: visible});
|
||||
if (visible) {
|
||||
Overlays.editOverlay(this.menuToggleButton, { subImage: { x: 0, y: 0, width: toolWidth, height: toolHeight } }),
|
||||
} else {
|
||||
Overlays.editOverlay(this.menuToggleButton, { subImage: { x: 0, y: toolHeight, width: toolWidth, height: toolHeight } }),
|
||||
}
|
||||
}
|
||||
|
||||
this.goToPage = function(pageNumber) {
|
||||
if (pageNumber < 0 || pageNumber >= this.numPages) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.page = pageNumber;
|
||||
var start = pageNumber * pageSize;
|
||||
for (var i = 0; i < pageSize; i++) {
|
||||
var update = {};
|
||||
var location = null;
|
||||
if (start + i < this.locations.length) {
|
||||
location = this.locations[start + i];
|
||||
update.text = (start + i + 1) + ". " + location.username;
|
||||
update.backgroundColor = inactiveColor;
|
||||
} else {
|
||||
update.text = "";
|
||||
update.backgroundColor = disabledColor;
|
||||
}
|
||||
Overlays.editOverlay(this.menuItems[i].overlay, update);
|
||||
this.menuItems[i].location = location;
|
||||
}
|
||||
|
||||
this.previousEnabled = pageNumber > 0;
|
||||
this.nextEnabled = pageNumber < (this.numPages - 1);
|
||||
|
||||
Overlays.editOverlay(this.previousButton, { backgroundColor: this.previousEnabled ? prevNextColor : disabledColor});
|
||||
Overlays.editOverlay(this.nextButton, { backgroundColor: this.nextEnabled ? prevNextColor : disabledColor });
|
||||
}
|
||||
|
||||
this.mousePressEvent = function(event) {
|
||||
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y});
|
||||
|
||||
if (clickedOverlay == self.menuToggleButton) {
|
||||
self.toggleMenu();
|
||||
} else if (clickedOverlay == self.previousButton) {
|
||||
if (self.previousEnabled) {
|
||||
Overlays.editOverlay(clickedOverlay, { backgroundColor: activeColor });
|
||||
}
|
||||
} else if (clickedOverlay == self.nextButton) {
|
||||
if (self.nextEnabled) {
|
||||
Overlays.editOverlay(clickedOverlay, { backgroundColor: activeColor });
|
||||
}
|
||||
} else {
|
||||
for (var i = 0; i < self.menuItems.length; i++) {
|
||||
if (clickedOverlay == self.menuItems[i].overlay) {
|
||||
if (self.menuItems[i].location != null) {
|
||||
Overlays.editOverlay(clickedOverlay, { backgroundColor: activeColor });
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.mouseReleaseEvent = function(event) {
|
||||
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y});
|
||||
|
||||
if (clickedOverlay == self.previousButton) {
|
||||
if (self.previousEnabled) {
|
||||
Overlays.editOverlay(clickedOverlay, { backgroundColor: inactiveColor });
|
||||
self.goToPage(self.page - 1);
|
||||
}
|
||||
} else if (clickedOverlay == self.nextButton) {
|
||||
if (self.nextEnabled) {
|
||||
Overlays.editOverlay(clickedOverlay, { backgroundColor: inactiveColor });
|
||||
self.goToPage(self.page + 1);
|
||||
}
|
||||
} else {
|
||||
for (var i = 0; i < self.menuItems.length; i++) {
|
||||
if (clickedOverlay == self.menuItems[i].overlay) {
|
||||
if (self.menuItems[i].location != null) {
|
||||
Overlays.editOverlay(clickedOverlay, { backgroundColor: inactiveColor });
|
||||
var location = self.menuItems[i].location;
|
||||
Window.location = "hifi://" + location.domain + "/"
|
||||
+ location.x + "," + location.y + "," + location.z;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.cleanup = function() {
|
||||
for (var i = 0; i < self.menuItems.length; i++) {
|
||||
Overlays.deleteOverlay(self.menuItems[i].overlay);
|
||||
}
|
||||
Overlays.deleteOverlay(self.menuToggleButton);
|
||||
Overlays.deleteOverlay(self.previousButton);
|
||||
Overlays.deleteOverlay(self.nextButton);
|
||||
Overlays.deleteOverlay(self.background);
|
||||
}
|
||||
|
||||
Controller.mousePressEvent.connect(this.mousePressEvent);
|
||||
Controller.mouseReleaseEvent.connect(this.mouseReleaseEvent);
|
||||
Script.update.connect(this.reposition);
|
||||
Script.scriptEnding.connect(this.cleanup);
|
||||
|
||||
this.reposition(true);
|
||||
};
|
||||
|
||||
var locationMenu = new LocationMenu({ pageSize: 8 });
|
||||
|
||||
print("Loading strip data from " + scriptUrl);
|
||||
|
||||
var req = new XMLHttpRequest();
|
||||
req.responseType = 'json';
|
||||
|
||||
req.onreadystatechange = function() {
|
||||
if (req.readyState == req.DONE) {
|
||||
if (req.status == 200 && req.response != null) {
|
||||
for (var domain in req.response) {
|
||||
var locations = req.response[domain];
|
||||
var users = [];
|
||||
for (var i = 0; i < locations.length; i++) {
|
||||
var loc = locations[i];
|
||||
var x1 = loc[1],
|
||||
x2 = loc[2],
|
||||
y1 = loc[3],
|
||||
y2 = loc[4];
|
||||
users.push({
|
||||
domain: domain,
|
||||
username: loc[0],
|
||||
x: x1,
|
||||
y: 300,
|
||||
z: y1,
|
||||
});
|
||||
}
|
||||
locationMenu.updateLocations(users);
|
||||
}
|
||||
} else {
|
||||
print("Error loading data: " + req.status + " " + req.statusText + ", " + req.errorCode + ": " + req.responseText);
|
||||
locationMenu.setError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
req.open("GET", scriptUrl);
|
||||
req.send();
|
|
@ -1,27 +0,0 @@
|
|||
//
|
||||
// playSound.js
|
||||
// examples
|
||||
//
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
// Plays a sample audio file at the avatar's current location
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
|
||||
// First, load a sample sound from a URL
|
||||
var bird = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Animals/bushtit_1.raw");
|
||||
|
||||
function maybePlaySound(deltaTime) {
|
||||
if (Math.random() < 0.01) {
|
||||
// Set the location and other info for the sound to play
|
||||
Audio.playSound(bird, {
|
||||
position: MyAvatar.position,
|
||||
volume: 0.5
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Connect a call back that happens every frame
|
||||
Script.update.connect(maybePlaySound);
|
|
@ -1,43 +0,0 @@
|
|||
//
|
||||
// playSoundPath.js
|
||||
// examples
|
||||
//
|
||||
// Created by Craig Hansen-Sturm on 05/27/14.
|
||||
// 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
|
||||
//
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
|
||||
var soundClip = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Voxels/voxel create 3.raw");
|
||||
|
||||
var currentTime = 1.570079; // pi/2
|
||||
var deltaTime = 0.05;
|
||||
var distance = 1;
|
||||
var debug = 0;
|
||||
|
||||
function playSound() {
|
||||
currentTime += deltaTime;
|
||||
|
||||
var s = distance * Math.sin(currentTime);
|
||||
var c = distance * Math.cos(currentTime);
|
||||
|
||||
var soundOffset = { x:s, y:0, z:c };
|
||||
|
||||
if (debug) {
|
||||
print("t=" + currentTime + "offset=" + soundOffset.x + "," + soundOffset.y + "," + soundOffset.z);
|
||||
}
|
||||
|
||||
var avatarPosition = MyAvatar.position;
|
||||
var soundPosition = Vec3.sum(avatarPosition,soundOffset);
|
||||
|
||||
Audio.playSound(soundClip, {
|
||||
position: soundPosition
|
||||
});
|
||||
}
|
||||
|
||||
Script.setInterval(playSound, 250);
|
||||
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
//
|
||||
|
||||
|
||||
var buttonImageUrl = "https://worklist-prod.s3.amazonaws.com/attachment/0aca88e1-9bd8-5c1d.svg";
|
||||
var buttonImageUrl = "https://public.highfidelity.io/images/tools/sit.svg";
|
||||
|
||||
var windowDimensions = Controller.getViewportDimensions();
|
||||
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
var position = Vec3.sum(MyAvatar.position, { x: 0, y: -1, z: 0});
|
||||
|
||||
var scalingFactor = 0.01;
|
||||
|
||||
var sphereNaturalExtentsMin = { x: -1230, y: -1223, z: -1210 };
|
||||
var sphereNaturalExtentsMax = { x: 1230, y: 1229, z: 1223 };
|
||||
var panelsNaturalExtentsMin = { x: -1181, y: -326, z: 56 };
|
||||
var panelsNaturalExtentsMax = { x: 1181, y: 576, z: 1183 };
|
||||
|
||||
var sphereNaturalDimensions = Vec3.subtract(sphereNaturalExtentsMax, sphereNaturalExtentsMin);
|
||||
var panelsNaturalDimensions = Vec3.subtract(panelsNaturalExtentsMax, panelsNaturalExtentsMin);
|
||||
Vec3.print("sphereNaturalDimensions:", sphereNaturalDimensions);
|
||||
Vec3.print("panelsNaturalDimensions:", panelsNaturalDimensions);
|
||||
|
||||
var sphereNaturalCenter = Vec3.sum(sphereNaturalExtentsMin, Vec3.multiply(sphereNaturalDimensions, 0.5));
|
||||
var panelsNaturalCenter = Vec3.sum(panelsNaturalExtentsMin, Vec3.multiply(panelsNaturalDimensions, 0.5));
|
||||
Vec3.print("sphereNaturalCenter:", sphereNaturalCenter);
|
||||
Vec3.print("panelsNaturalCenter:", panelsNaturalCenter);
|
||||
|
||||
var sphereDimensions = Vec3.multiply(sphereNaturalDimensions, scalingFactor);
|
||||
var panelsDimensions = Vec3.multiply(panelsNaturalDimensions, scalingFactor);
|
||||
Vec3.print("sphereDimensions:", sphereDimensions);
|
||||
Vec3.print("panelsDimensions:", panelsDimensions);
|
||||
|
||||
var sphereCenter = Vec3.multiply(sphereNaturalCenter, scalingFactor);
|
||||
var panelsCenter = Vec3.multiply(panelsNaturalCenter, scalingFactor);
|
||||
Vec3.print("sphereCenter:", sphereCenter);
|
||||
Vec3.print("panelsCenter:", panelsCenter);
|
||||
|
||||
var centerShift = Vec3.subtract(panelsCenter, sphereCenter);
|
||||
Vec3.print("centerShift:", centerShift);
|
||||
|
||||
var spherePosition = position;
|
||||
Vec3.print("spherePosition:", spherePosition);
|
||||
var panelsPosition = Vec3.sum(spherePosition, centerShift);
|
||||
Vec3.print("panelsPosition:", panelsPosition);
|
||||
|
||||
|
||||
var screensOverlay = Overlays.addOverlay("model", {
|
||||
position: panelsPosition,
|
||||
dimensions: panelsDimensions,
|
||||
url: "https://s3.amazonaws.com/hifi-public/models/sets/Lobby/LobbyConcepts/Lobby5_IsolatedPanelsFreezeTransforms.fbx"
|
||||
});
|
||||
|
||||
|
||||
var structureOverlay = Overlays.addOverlay("model", {
|
||||
position: spherePosition,
|
||||
dimensions: sphereDimensions,
|
||||
url: "https://s3.amazonaws.com/hifi-public/models/sets/Lobby/LobbyConcepts/Lobby5_OrbShellOnly.fbx",
|
||||
ignoreRayIntersection: true, // we don't want to ray pick against any of this
|
||||
});
|
||||
|
||||
var statusText = Overlays.addOverlay("text", {
|
||||
x: 200,
|
||||
y: 100,
|
||||
width: 200,
|
||||
height: 20,
|
||||
backgroundColor: { red: 0, green: 0, blue: 0},
|
||||
alpha: 1.0,
|
||||
backgroundAlpha: 1.0,
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
topMargin: 4,
|
||||
leftMargin: 4,
|
||||
text: "",
|
||||
});
|
||||
|
||||
|
||||
Controller.mouseMoveEvent.connect(function(event){
|
||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||
var result = Overlays.findRayIntersection(pickRay);
|
||||
|
||||
if (result.intersects) {
|
||||
if (result.overlayID == screensOverlay) {
|
||||
Overlays.editOverlay(statusText, { text: "You are pointing at: " + result.extraInfo });
|
||||
} else {
|
||||
Overlays.editOverlay(statusText, { text: "You are not pointing at a panel..." });
|
||||
}
|
||||
} else {
|
||||
Overlays.editOverlay(statusText, { text: "You are not pointing at a panel..." });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Script.scriptEnding.connect(function(){
|
||||
Overlays.deleteOverlay(screensOverlay);
|
||||
Overlays.deleteOverlay(structureOverlay);
|
||||
Overlays.deleteOverlay(statusText);
|
||||
});
|
|
@ -1,25 +0,0 @@
|
|||
//
|
||||
// twoFallingEntities.js
|
||||
//
|
||||
// Creates a red 0.2 meter diameter ball right in front of your avatar that lives for 60 seconds
|
||||
//
|
||||
|
||||
var diameter = 0.2;
|
||||
var position = Vec3.sum(MyAvatar.position, Quat.getFront(MyAvatar.orientation));
|
||||
var properties = {
|
||||
type: "Sphere",
|
||||
position: position,
|
||||
velocity: { x: 0, y: 0, z: 0},
|
||||
gravity: { x: 0, y: -0.05, z: 0},
|
||||
dimensions: { x: diameter, y: diameter, z: diameter };
|
||||
damping: 0.00001,
|
||||
color: { red: 200, green: 0, blue: 0 },
|
||||
lifetime: 60
|
||||
};
|
||||
|
||||
var newEntity = Entities.addEntity(properties);
|
||||
position.x -= 0.5 * diameter;
|
||||
properties.position = position;
|
||||
var newEntityTwo = Entities.addEntity(properties);
|
||||
|
||||
Script.stop(); // no need to run anymore
|
|
@ -11,7 +11,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("Test.js");
|
||||
Script.include("../../libraries/unitTest.js");
|
||||
|
||||
test("Test default request values", function(finished) {
|
||||
var req = new XMLHttpRequest();
|
|
@ -11,7 +11,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
Script.include("../../libraries/globals.js");
|
||||
|
||||
var sound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/220Sine.wav");
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("libraries/globals.js");
|
||||
Script.include("../../libraries/globals.js");
|
||||
|
||||
// A few sample files you may want to try:
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("Test.js");
|
||||
Script.include("../../libraries/unitTest.js");
|
||||
|
||||
// e.g. extractbits([0xff, 0x80, 0x00, 0x00], 23, 30); inclusive
|
||||
function extractbits(bytes, lo, hi) {
|
|
@ -4,6 +4,8 @@
|
|||
//
|
||||
// Created by Andrzej Kapolka on 3/6/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Outputs the joint index of an avatar, this is useful for avatar procedural animations
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
@ -229,7 +229,7 @@ else (APPLE)
|
|||
# we're using static GLEW, so define GLEW_STATIC
|
||||
add_definitions(-DGLEW_STATIC)
|
||||
|
||||
target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}" "${NSIGHT_LIBRARIES}" wsock32.lib opengl32.lib Winmm.lib)
|
||||
target_link_libraries(${TARGET_NAME} ${GLEW_LIBRARIES} "${NSIGHT_LIBRARIES}" wsock32.lib opengl32.lib Winmm.lib)
|
||||
|
||||
# try to find the Nsight package and add it to the build if we find it
|
||||
find_package(NSIGHT)
|
||||
|
|
2
interface/external/rtmidi/readme.txt
vendored
2
interface/external/rtmidi/readme.txt
vendored
|
@ -3,7 +3,7 @@ Instructions for adding the RtMidi library to Interface
|
|||
Stephen Birarda, June 30, 2014
|
||||
|
||||
1. Download the RtMidi tarball from High Fidelity S3.
|
||||
http://highfidelity-public.s3.amazonaws.com/dependencies/rtmidi-2.1.0.tar.gz
|
||||
http://public.highfidelity.io/dependencies/rtmidi-2.1.0.tar.gz
|
||||
|
||||
2. Copy RtMidi.h to externals/rtmidi/include.
|
||||
|
||||
|
|
|
@ -3,11 +3,6 @@
|
|||
<TS version="2.1" language="en_US">
|
||||
<context>
|
||||
<name>Application</name>
|
||||
<message>
|
||||
<location filename="src/Application.cpp" line="1481"/>
|
||||
<source>Export Voxels</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/Application.cpp" line="1482"/>
|
||||
<source>Sparse Voxel Octree Files (*.svo)</source>
|
||||
|
@ -226,45 +221,23 @@
|
|||
<message>
|
||||
<location filename="ui/preferencesDialog.ui" line="1125"/>
|
||||
<location filename="../build/interface/ui_preferencesDialog.h" line="636"/>
|
||||
<source>Voxels</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="ui/preferencesDialog.ui" line="1157"/>
|
||||
<location filename="../build/interface/ui_preferencesDialog.h" line="637"/>
|
||||
<source>Maximum voxels</source>
|
||||
<source>Octree</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="ui/preferencesDialog.ui" line="1236"/>
|
||||
<location filename="../build/interface/ui_preferencesDialog.h" line="638"/>
|
||||
<source>Max voxels sent each second</source>
|
||||
<source>Max packets sent each second</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>QObject</name>
|
||||
<message>
|
||||
<location filename="src/ui/VoxelImportDialog.cpp" line="22"/>
|
||||
<location filename="src/ui/VoxelImportDialog.cpp" line="23"/>
|
||||
<source>Import Voxels</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/ui/VoxelImportDialog.cpp" line="24"/>
|
||||
<source>Loading ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/ui/VoxelImportDialog.cpp" line="25"/>
|
||||
<source>Place voxels</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/ui/VoxelImportDialog.cpp" line="26"/>
|
||||
<source><b>Import</b> %1 as voxels</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/ui/VoxelImportDialog.cpp" line="27"/>
|
||||
<source>Cancel</source>
|
||||
|
|
|
@ -535,12 +535,6 @@ void Application::initializeGL() {
|
|||
}*/
|
||||
#endif
|
||||
|
||||
// Before we render anything, let's set up our viewFrustumOffsetCamera with a sufficiently large
|
||||
// field of view and near and far clip to make it interesting.
|
||||
//viewFrustumOffsetCamera.setFieldOfView(90.0);
|
||||
_viewFrustumOffsetCamera.setNearClip(DEFAULT_NEAR_CLIP);
|
||||
_viewFrustumOffsetCamera.setFarClip(DEFAULT_FAR_CLIP);
|
||||
|
||||
initDisplay();
|
||||
qDebug( "Initialized Display.");
|
||||
|
||||
|
@ -627,32 +621,6 @@ void Application::paintGL() {
|
|||
_myCamera.update(1.0f / _fps);
|
||||
}
|
||||
|
||||
// Note: whichCamera is used to pick between the normal camera myCamera for our
|
||||
// main camera, vs, an alternate camera. The alternate camera we support right now
|
||||
// is the viewFrustumOffsetCamera. But theoretically, we could use this same mechanism
|
||||
// to add other cameras.
|
||||
//
|
||||
// Why have two cameras? Well, one reason is that because in the case of the renderViewFrustum()
|
||||
// code, we want to keep the state of "myCamera" intact, so we can render what the view frustum of
|
||||
// myCamera is. But we also want to do meaningful camera transforms on OpenGL for the offset camera
|
||||
Camera* whichCamera = &_myCamera;
|
||||
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum)) {
|
||||
|
||||
ViewFrustumOffset viewFrustumOffset = Menu::getInstance()->getViewFrustumOffset();
|
||||
|
||||
// set the camera to third-person view but offset so we can see the frustum
|
||||
glm::quat frustumRotation = glm::quat(glm::radians(glm::vec3(viewFrustumOffset.pitch, viewFrustumOffset.yaw, viewFrustumOffset.roll)));
|
||||
|
||||
_viewFrustumOffsetCamera.setPosition(_myCamera.getPosition() +
|
||||
frustumRotation * glm::vec3(0.0f, viewFrustumOffset.up, -viewFrustumOffset.distance));
|
||||
|
||||
_viewFrustumOffsetCamera.setRotation(_myCamera.getRotation() * frustumRotation);
|
||||
|
||||
_viewFrustumOffsetCamera.update(1.0f/_fps);
|
||||
whichCamera = &_viewFrustumOffsetCamera;
|
||||
}
|
||||
|
||||
if (Menu::getInstance()->getShadowsEnabled()) {
|
||||
updateShadowMap();
|
||||
}
|
||||
|
@ -663,16 +631,16 @@ void Application::paintGL() {
|
|||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
//When in mirror mode, use camera rotation. Otherwise, use body rotation
|
||||
if (whichCamera->getMode() == CAMERA_MODE_MIRROR) {
|
||||
OculusManager::display(whichCamera->getRotation(), whichCamera->getPosition(), *whichCamera);
|
||||
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||
OculusManager::display(_myCamera.getRotation(), _myCamera.getPosition(), _myCamera);
|
||||
} else {
|
||||
OculusManager::display(_myAvatar->getWorldAlignedOrientation(), _myAvatar->getDefaultEyePosition(), *whichCamera);
|
||||
OculusManager::display(_myAvatar->getWorldAlignedOrientation(), _myAvatar->getDefaultEyePosition(), _myCamera);
|
||||
}
|
||||
_myCamera.update(1.0f / _fps);
|
||||
|
||||
} else if (TV3DManager::isConnected()) {
|
||||
|
||||
TV3DManager::display(*whichCamera);
|
||||
TV3DManager::display(_myCamera);
|
||||
|
||||
} else {
|
||||
DependencyManager::get<GlowEffect>()->prepare();
|
||||
|
@ -684,7 +652,7 @@ void Application::paintGL() {
|
|||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
displaySide(*whichCamera);
|
||||
displaySide(_myCamera);
|
||||
glPopMatrix();
|
||||
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
|
||||
|
@ -721,7 +689,6 @@ void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height)
|
|||
}
|
||||
|
||||
void Application::resizeGL(int width, int height) {
|
||||
resetCamerasOnResizeGL(_viewFrustumOffsetCamera, width, height);
|
||||
resetCamerasOnResizeGL(_myCamera, width, height);
|
||||
|
||||
glViewport(0, 0, width, height); // shouldn't this account for the menu???
|
||||
|
@ -750,13 +717,6 @@ void Application::updateProjectionMatrix(Camera& camera, bool updateViewFrustum)
|
|||
if (updateViewFrustum) {
|
||||
loadViewFrustum(camera, _viewFrustum);
|
||||
_viewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
|
||||
|
||||
// If we're in Display Frustum mode, then we want to use the slightly adjust near/far clip values of the
|
||||
// _viewFrustumOffsetCamera, so that we can see more of the application content in the application's frustum
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum)) {
|
||||
nearVal = _viewFrustumOffsetCamera.getNearClip();
|
||||
farVal = _viewFrustumOffsetCamera.getFarClip();
|
||||
}
|
||||
} else {
|
||||
ViewFrustum tempViewFrustum;
|
||||
loadViewFrustum(camera, tempViewFrustum);
|
||||
|
@ -844,19 +804,6 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
bool isOption = event->modifiers().testFlag(Qt::AltModifier);
|
||||
switch (event->key()) {
|
||||
break;
|
||||
case Qt::Key_BracketLeft:
|
||||
case Qt::Key_BracketRight:
|
||||
case Qt::Key_BraceLeft:
|
||||
case Qt::Key_BraceRight:
|
||||
case Qt::Key_ParenLeft:
|
||||
case Qt::Key_ParenRight:
|
||||
case Qt::Key_Less:
|
||||
case Qt::Key_Greater:
|
||||
case Qt::Key_Comma:
|
||||
case Qt::Key_Period:
|
||||
case Qt::Key_QuoteDbl:
|
||||
Menu::getInstance()->handleViewFrustumOffsetKeyModifier(event->key());
|
||||
break;
|
||||
case Qt::Key_L:
|
||||
if (isShifted) {
|
||||
Menu::getInstance()->triggerOption(MenuOption::LodTools);
|
||||
|
@ -1058,19 +1005,9 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
case Qt::Key_Slash:
|
||||
Menu::getInstance()->triggerOption(MenuOption::UserInterface);
|
||||
break;
|
||||
case Qt::Key_F:
|
||||
if (isShifted) {
|
||||
Menu::getInstance()->triggerOption(MenuOption::DisplayFrustum);
|
||||
}
|
||||
break;
|
||||
case Qt::Key_P:
|
||||
Menu::getInstance()->triggerOption(MenuOption::FirstPerson);
|
||||
break;
|
||||
case Qt::Key_R:
|
||||
if (isShifted) {
|
||||
Menu::getInstance()->triggerOption(MenuOption::FrustumRenderMode);
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Percent:
|
||||
Menu::getInstance()->triggerOption(MenuOption::Stats);
|
||||
break;
|
||||
|
@ -2707,17 +2644,17 @@ QImage Application::renderAvatarBillboard() {
|
|||
return image;
|
||||
}
|
||||
|
||||
void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderArgs::RenderSide renderSide) {
|
||||
void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs::RenderSide renderSide) {
|
||||
PROFILE_RANGE(__FUNCTION__);
|
||||
PerformanceTimer perfTimer("display");
|
||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()");
|
||||
// transform by eye offset
|
||||
|
||||
// load the view frustum
|
||||
loadViewFrustum(whichCamera, _displayViewFrustum);
|
||||
loadViewFrustum(theCamera, _displayViewFrustum);
|
||||
|
||||
// flip x if in mirror mode (also requires reversing winding order for backface culling)
|
||||
if (whichCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||
if (theCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||
glScalef(-1.0f, 1.0f, 1.0f);
|
||||
glFrontFace(GL_CW);
|
||||
|
||||
|
@ -2725,32 +2662,32 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
|
|||
glFrontFace(GL_CCW);
|
||||
}
|
||||
|
||||
glm::vec3 eyeOffsetPos = whichCamera.getEyeOffsetPosition();
|
||||
glm::quat eyeOffsetOrient = whichCamera.getEyeOffsetOrientation();
|
||||
glm::vec3 eyeOffsetPos = theCamera.getEyeOffsetPosition();
|
||||
glm::quat eyeOffsetOrient = theCamera.getEyeOffsetOrientation();
|
||||
glm::vec3 eyeOffsetAxis = glm::axis(eyeOffsetOrient);
|
||||
glRotatef(-glm::degrees(glm::angle(eyeOffsetOrient)), eyeOffsetAxis.x, eyeOffsetAxis.y, eyeOffsetAxis.z);
|
||||
glTranslatef(-eyeOffsetPos.x, -eyeOffsetPos.y, -eyeOffsetPos.z);
|
||||
|
||||
// transform view according to whichCamera
|
||||
// transform view according to theCamera
|
||||
// could be myCamera (if in normal mode)
|
||||
// or could be viewFrustumOffsetCamera if in offset mode
|
||||
|
||||
glm::quat rotation = whichCamera.getRotation();
|
||||
glm::quat rotation = theCamera.getRotation();
|
||||
glm::vec3 axis = glm::axis(rotation);
|
||||
glRotatef(-glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
|
||||
|
||||
// store view matrix without translation, which we'll use for precision-sensitive objects
|
||||
updateUntranslatedViewMatrix(-whichCamera.getPosition());
|
||||
updateUntranslatedViewMatrix(-theCamera.getPosition());
|
||||
|
||||
// Equivalent to what is happening with _untranslatedViewMatrix and the _viewMatrixTranslation
|
||||
// the viewTransofmr object is updatded with the correct values and saved,
|
||||
// this is what is used for rendering the Entities and avatars
|
||||
Transform viewTransform;
|
||||
viewTransform.setTranslation(whichCamera.getPosition());
|
||||
viewTransform.setTranslation(theCamera.getPosition());
|
||||
viewTransform.setRotation(rotation);
|
||||
viewTransform.postTranslate(eyeOffsetPos);
|
||||
viewTransform.postRotate(eyeOffsetOrient);
|
||||
if (whichCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||
if (theCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||
viewTransform.setScale(Transform::Vec3(-1.0f, 1.0f, 1.0f));
|
||||
}
|
||||
if (renderSide != RenderArgs::MONO) {
|
||||
|
@ -2796,9 +2733,9 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
|
|||
// compute starfield alpha based on distance from atmosphere
|
||||
float alpha = 1.0f;
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
|
||||
const EnvironmentData& closestData = _environment.getClosestData(whichCamera.getPosition());
|
||||
float height = glm::distance(whichCamera.getPosition(),
|
||||
closestData.getAtmosphereCenter(whichCamera.getPosition()));
|
||||
const EnvironmentData& closestData = _environment.getClosestData(theCamera.getPosition());
|
||||
float height = glm::distance(theCamera.getPosition(),
|
||||
closestData.getAtmosphereCenter(theCamera.getPosition()));
|
||||
if (height < closestData.getAtmosphereInnerRadius()) {
|
||||
alpha = 0.0f;
|
||||
|
||||
|
@ -2809,7 +2746,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
|
|||
}
|
||||
|
||||
// finally render the starfield
|
||||
_stars.render(whichCamera.getFieldOfView(), whichCamera.getAspectRatio(), whichCamera.getNearClip(), alpha);
|
||||
_stars.render(theCamera.getFieldOfView(), theCamera.getAspectRatio(), theCamera.getNearClip(), alpha);
|
||||
}
|
||||
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Wireframe)) {
|
||||
|
@ -2821,7 +2758,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
|
|||
PerformanceTimer perfTimer("atmosphere");
|
||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||
"Application::displaySide() ... atmosphere...");
|
||||
_environment.renderAtmospheres(whichCamera);
|
||||
_environment.renderAtmospheres(theCamera);
|
||||
}
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
@ -2867,7 +2804,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
|
|||
|
||||
|
||||
|
||||
bool mirrorMode = (whichCamera.getMode() == CAMERA_MODE_MIRROR);
|
||||
bool mirrorMode = (theCamera.getMode() == CAMERA_MODE_MIRROR);
|
||||
{
|
||||
PerformanceTimer perfTimer("avatars");
|
||||
_avatarManager.renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE,
|
||||
|
@ -2896,20 +2833,12 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
|
|||
_nodeBoundsDisplay.draw();
|
||||
|
||||
// Render the world box
|
||||
if (whichCamera.getMode() != CAMERA_MODE_MIRROR && Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
|
||||
if (theCamera.getMode() != CAMERA_MODE_MIRROR && Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
|
||||
Menu::getInstance()->isOptionChecked(MenuOption::UserInterface)) {
|
||||
PerformanceTimer perfTimer("worldBox");
|
||||
renderWorldBox();
|
||||
}
|
||||
|
||||
// view frustum for debugging
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum) && whichCamera.getMode() != CAMERA_MODE_MIRROR) {
|
||||
PerformanceTimer perfTimer("viewFrustum");
|
||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||
"Application::displaySide() ... renderViewFrustum...");
|
||||
renderViewFrustum(_viewFrustum);
|
||||
}
|
||||
|
||||
// render octree fades if they exist
|
||||
if (_octreeFades.size() > 0) {
|
||||
PerformanceTimer perfTimer("octreeFades");
|
||||
|
@ -3136,167 +3065,6 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) {
|
|||
updateProjectionMatrix(_myCamera, updateViewFrustum);
|
||||
}
|
||||
|
||||
// renderViewFrustum()
|
||||
//
|
||||
// Description: this will render the view frustum bounds for EITHER the head
|
||||
// or the "myCamera".
|
||||
//
|
||||
// Frustum rendering mode. For debug purposes, we allow drawing the frustum in a couple of different ways.
|
||||
// We can draw it with each of these parts:
|
||||
// * Origin Direction/Up/Right vectors - these will be drawn at the point of the camera
|
||||
// * Near plane - this plane is drawn very close to the origin point.
|
||||
// * Right/Left planes - these two planes are drawn between the near and far planes.
|
||||
// * Far plane - the plane is drawn in the distance.
|
||||
// Modes - the following modes, will draw the following parts.
|
||||
// * All - draws all the parts listed above
|
||||
// * Planes - draws the planes but not the origin vectors
|
||||
// * Origin Vectors - draws the origin vectors ONLY
|
||||
// * Near Plane - draws only the near plane
|
||||
// * Far Plane - draws only the far plane
|
||||
void Application::renderViewFrustum(ViewFrustum& viewFrustum) {
|
||||
// Load it with the latest details!
|
||||
loadViewFrustum(_myCamera, viewFrustum);
|
||||
|
||||
glm::vec3 position = viewFrustum.getOffsetPosition();
|
||||
glm::vec3 direction = viewFrustum.getOffsetDirection();
|
||||
glm::vec3 up = viewFrustum.getOffsetUp();
|
||||
glm::vec3 right = viewFrustum.getOffsetRight();
|
||||
|
||||
// Get ready to draw some lines
|
||||
glDisable(GL_LIGHTING);
|
||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||
glLineWidth(1.0);
|
||||
glBegin(GL_LINES);
|
||||
|
||||
if (Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_ALL
|
||||
|| Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_VECTORS) {
|
||||
// Calculate the origin direction vectors
|
||||
glm::vec3 lookingAt = position + (direction * 0.2f);
|
||||
glm::vec3 lookingAtUp = position + (up * 0.2f);
|
||||
glm::vec3 lookingAtRight = position + (right * 0.2f);
|
||||
|
||||
// Looking At = white
|
||||
glColor3f(1,1,1);
|
||||
glVertex3f(position.x, position.y, position.z);
|
||||
glVertex3f(lookingAt.x, lookingAt.y, lookingAt.z);
|
||||
|
||||
// Looking At Up = purple
|
||||
glColor3f(1,0,1);
|
||||
glVertex3f(position.x, position.y, position.z);
|
||||
glVertex3f(lookingAtUp.x, lookingAtUp.y, lookingAtUp.z);
|
||||
|
||||
// Looking At Right = cyan
|
||||
glColor3f(0,1,1);
|
||||
glVertex3f(position.x, position.y, position.z);
|
||||
glVertex3f(lookingAtRight.x, lookingAtRight.y, lookingAtRight.z);
|
||||
}
|
||||
|
||||
if (Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_ALL
|
||||
|| Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_PLANES
|
||||
|| Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_NEAR_PLANE) {
|
||||
// Drawing the bounds of the frustum
|
||||
// viewFrustum.getNear plane - bottom edge
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f(viewFrustum.getNearBottomLeft().x, viewFrustum.getNearBottomLeft().y, viewFrustum.getNearBottomLeft().z);
|
||||
glVertex3f(viewFrustum.getNearBottomRight().x, viewFrustum.getNearBottomRight().y, viewFrustum.getNearBottomRight().z);
|
||||
|
||||
// viewFrustum.getNear plane - top edge
|
||||
glVertex3f(viewFrustum.getNearTopLeft().x, viewFrustum.getNearTopLeft().y, viewFrustum.getNearTopLeft().z);
|
||||
glVertex3f(viewFrustum.getNearTopRight().x, viewFrustum.getNearTopRight().y, viewFrustum.getNearTopRight().z);
|
||||
|
||||
// viewFrustum.getNear plane - right edge
|
||||
glVertex3f(viewFrustum.getNearBottomRight().x, viewFrustum.getNearBottomRight().y, viewFrustum.getNearBottomRight().z);
|
||||
glVertex3f(viewFrustum.getNearTopRight().x, viewFrustum.getNearTopRight().y, viewFrustum.getNearTopRight().z);
|
||||
|
||||
// viewFrustum.getNear plane - left edge
|
||||
glVertex3f(viewFrustum.getNearBottomLeft().x, viewFrustum.getNearBottomLeft().y, viewFrustum.getNearBottomLeft().z);
|
||||
glVertex3f(viewFrustum.getNearTopLeft().x, viewFrustum.getNearTopLeft().y, viewFrustum.getNearTopLeft().z);
|
||||
}
|
||||
|
||||
if (Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_ALL
|
||||
|| Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_PLANES
|
||||
|| Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_FAR_PLANE) {
|
||||
// viewFrustum.getFar plane - bottom edge
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(viewFrustum.getFarBottomLeft().x, viewFrustum.getFarBottomLeft().y, viewFrustum.getFarBottomLeft().z);
|
||||
glVertex3f(viewFrustum.getFarBottomRight().x, viewFrustum.getFarBottomRight().y, viewFrustum.getFarBottomRight().z);
|
||||
|
||||
// viewFrustum.getFar plane - top edge
|
||||
glVertex3f(viewFrustum.getFarTopLeft().x, viewFrustum.getFarTopLeft().y, viewFrustum.getFarTopLeft().z);
|
||||
glVertex3f(viewFrustum.getFarTopRight().x, viewFrustum.getFarTopRight().y, viewFrustum.getFarTopRight().z);
|
||||
|
||||
// viewFrustum.getFar plane - right edge
|
||||
glVertex3f(viewFrustum.getFarBottomRight().x, viewFrustum.getFarBottomRight().y, viewFrustum.getFarBottomRight().z);
|
||||
glVertex3f(viewFrustum.getFarTopRight().x, viewFrustum.getFarTopRight().y, viewFrustum.getFarTopRight().z);
|
||||
|
||||
// viewFrustum.getFar plane - left edge
|
||||
glVertex3f(viewFrustum.getFarBottomLeft().x, viewFrustum.getFarBottomLeft().y, viewFrustum.getFarBottomLeft().z);
|
||||
glVertex3f(viewFrustum.getFarTopLeft().x, viewFrustum.getFarTopLeft().y, viewFrustum.getFarTopLeft().z);
|
||||
}
|
||||
|
||||
if (Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_ALL
|
||||
|| Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_PLANES) {
|
||||
// RIGHT PLANE IS CYAN
|
||||
// right plane - bottom edge - viewFrustum.getNear to distant
|
||||
glColor3f(0,1,1);
|
||||
glVertex3f(viewFrustum.getNearBottomRight().x, viewFrustum.getNearBottomRight().y, viewFrustum.getNearBottomRight().z);
|
||||
glVertex3f(viewFrustum.getFarBottomRight().x, viewFrustum.getFarBottomRight().y, viewFrustum.getFarBottomRight().z);
|
||||
|
||||
// right plane - top edge - viewFrustum.getNear to distant
|
||||
glVertex3f(viewFrustum.getNearTopRight().x, viewFrustum.getNearTopRight().y, viewFrustum.getNearTopRight().z);
|
||||
glVertex3f(viewFrustum.getFarTopRight().x, viewFrustum.getFarTopRight().y, viewFrustum.getFarTopRight().z);
|
||||
|
||||
// LEFT PLANE IS BLUE
|
||||
// left plane - bottom edge - viewFrustum.getNear to distant
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f(viewFrustum.getNearBottomLeft().x, viewFrustum.getNearBottomLeft().y, viewFrustum.getNearBottomLeft().z);
|
||||
glVertex3f(viewFrustum.getFarBottomLeft().x, viewFrustum.getFarBottomLeft().y, viewFrustum.getFarBottomLeft().z);
|
||||
|
||||
// left plane - top edge - viewFrustum.getNear to distant
|
||||
glVertex3f(viewFrustum.getNearTopLeft().x, viewFrustum.getNearTopLeft().y, viewFrustum.getNearTopLeft().z);
|
||||
glVertex3f(viewFrustum.getFarTopLeft().x, viewFrustum.getFarTopLeft().y, viewFrustum.getFarTopLeft().z);
|
||||
|
||||
// focal plane - bottom edge
|
||||
glColor3f(1.0f, 0.0f, 1.0f);
|
||||
float focalProportion = (viewFrustum.getFocalLength() - viewFrustum.getNearClip()) /
|
||||
(viewFrustum.getFarClip() - viewFrustum.getNearClip());
|
||||
glm::vec3 focalBottomLeft = glm::mix(viewFrustum.getNearBottomLeft(), viewFrustum.getFarBottomLeft(), focalProportion);
|
||||
glm::vec3 focalBottomRight = glm::mix(viewFrustum.getNearBottomRight(),
|
||||
viewFrustum.getFarBottomRight(), focalProportion);
|
||||
glVertex3f(focalBottomLeft.x, focalBottomLeft.y, focalBottomLeft.z);
|
||||
glVertex3f(focalBottomRight.x, focalBottomRight.y, focalBottomRight.z);
|
||||
|
||||
// focal plane - top edge
|
||||
glm::vec3 focalTopLeft = glm::mix(viewFrustum.getNearTopLeft(), viewFrustum.getFarTopLeft(), focalProportion);
|
||||
glm::vec3 focalTopRight = glm::mix(viewFrustum.getNearTopRight(), viewFrustum.getFarTopRight(), focalProportion);
|
||||
glVertex3f(focalTopLeft.x, focalTopLeft.y, focalTopLeft.z);
|
||||
glVertex3f(focalTopRight.x, focalTopRight.y, focalTopRight.z);
|
||||
|
||||
// focal plane - left edge
|
||||
glVertex3f(focalBottomLeft.x, focalBottomLeft.y, focalBottomLeft.z);
|
||||
glVertex3f(focalTopLeft.x, focalTopLeft.y, focalTopLeft.z);
|
||||
|
||||
// focal plane - right edge
|
||||
glVertex3f(focalBottomRight.x, focalBottomRight.y, focalBottomRight.z);
|
||||
glVertex3f(focalTopRight.x, focalTopRight.y, focalTopRight.z);
|
||||
}
|
||||
glEnd();
|
||||
glEnable(GL_LIGHTING);
|
||||
|
||||
if (Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_ALL
|
||||
|| Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_KEYHOLE) {
|
||||
// Draw the keyhole
|
||||
float keyholeRadius = viewFrustum.getKeyholeRadius();
|
||||
if (keyholeRadius > 0.0f) {
|
||||
glPushMatrix();
|
||||
glColor4f(1, 1, 0, 1);
|
||||
glTranslatef(position.x, position.y, position.z); // where we actually want it!
|
||||
DependencyManager::get<GeometryCache>()->renderSphere(keyholeRadius, 20, 20, false);
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Application::resetSensors() {
|
||||
DependencyManager::get<Faceshift>()->reset();
|
||||
DependencyManager::get<Visage>()->reset();
|
||||
|
|
|
@ -417,7 +417,6 @@ private:
|
|||
|
||||
void updateShadowMap();
|
||||
void renderRearViewMirror(const QRect& region, bool billboard = false);
|
||||
void renderViewFrustum(ViewFrustum& viewFrustum);
|
||||
void checkBandwidthMeterClick();
|
||||
void setMenuShortcutsEnabled(bool enabled);
|
||||
|
||||
|
@ -481,7 +480,6 @@ private:
|
|||
PrioVR _prioVR;
|
||||
|
||||
Camera _myCamera; // My view onto the world
|
||||
Camera _viewFrustumOffsetCamera; // The camera we use to sometimes show the view frustum from an offset mode
|
||||
Camera _mirrorCamera; // Cammera for mirror view
|
||||
QRect _mirrorViewRect;
|
||||
RearMirrorTools* _rearMirrorTools;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue