Merge branch 'master' of https://github.com/highfidelity/hifi into modelRayPick

This commit is contained in:
ZappoMan 2014-12-06 15:28:54 -08:00
commit 91fd574eb5
17 changed files with 262 additions and 148 deletions

View file

@ -32,7 +32,7 @@ var startTimeInSeconds = new Date().getTime() / 1000;
var NATURAL_SIZE_OF_BUTTERFLY = { x: 1.0, y: 0.4, z: 0.2 };
var lifeTime = 3600; // One hour lifespan
var range = 5.0; // Over what distance in meters do you want the flock to fly around
var range = 7.0; // Over what distance in meters do you want the flock to fly around
var frame = 0;
var DISTANCE_IN_FRONT_OF_ME = 1.5;

View file

@ -11,6 +11,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
var gamepads = {};
var debug = false;
var willMove = false;
@ -19,7 +21,6 @@ var warpPosition = { x: 0, y: 0, z: 0 };
var hipsToEyes;
var restoreCountdownTimer;
var headTurningTimer = 0.0;
// Overlays to show target location
@ -62,13 +63,6 @@ function restoreCameraState() {
Camera.mode = oldMode;
}
function activateWarp() {
if (warpActive) return;
warpActive = true;
updateWarp();
}
var WATCH_AVATAR_DISTANCE = 2.5;
var sound = SoundCache.getSound("http://public.highfidelity.io/sounds/Footsteps/FootstepW2Right-12db.wav");
@ -132,6 +126,22 @@ function updateWarp() {
});
}
function activateWarp() {
if (warpActive) return;
warpActive = true;
movingWithHead = true;
hipsToEyes = MyAvatar.getEyePosition().y - MyAvatar.position.y;
headStartPosition = MyAvatar.getTrackedHeadPosition();
headStartDeltaPitch = MyAvatar.getHeadDeltaPitch();
headStartFinalPitch = MyAvatar.getHeadFinalPitch();
headStartRoll = MyAvatar.getHeadFinalRoll();
headStartYaw = MyAvatar.getHeadFinalYaw();
deltaYaw = 0.0;
warpPosition = MyAvatar.position;
warpPosition.y += hipsToEyes;
updateWarp();
}
function finishWarp() {
if (!warpActive) return;
warpActive = false;
@ -152,6 +162,9 @@ function finishWarp() {
cameraPosition = Vec3.subtract(MyAvatar.position, Vec3.multiplyQbyV(Camera.getOrientation(), { x: 0, y: -hipsToEyes, z: -hipsToEyes * WATCH_AVATAR_DISTANCE }));
Camera.setPosition(cameraPosition);
playSound();
if (watchAvatar) {
restoreCountdownTimer = RESTORE_TIME;
}
}
}
@ -169,35 +182,11 @@ function update(deltaTime) {
restoreCountDownTimer = 0.0;
}
}
var HEAD_TURN_TIME = 0.10;
var HEAD_TURN_DEGREES = 4.0;
var HEAD_TURN_START_ANGLE = 45.0;
var currentYaw = MyAvatar.getHeadFinalYaw();
if (Math.abs(currentYaw) > HEAD_TURN_START_ANGLE) {
headTurningTimer += deltaTime;
if (headTurningTimer > HEAD_TURN_TIME) {
headTurningTimer = 0.0;
MyAvatar.orientation = Quat.multiply(Quat.fromPitchYawRollDegrees(0, (currentYaw > 0) ? HEAD_TURN_DEGREES: -HEAD_TURN_DEGREES, 0),
MyAvatar.orientation);
}
} else {
headTurningTimer = 0.0;
}
}
Controller.keyPressEvent.connect(function(event) {
if (event.text == "SPACE" && !event.isAutoRepeat && !movingWithHead) {
keyDownTime = 0.0;
movingWithHead = true;
hipsToEyes = MyAvatar.getEyePosition().y - MyAvatar.position.y;
headStartPosition = MyAvatar.getTrackedHeadPosition();
headStartDeltaPitch = MyAvatar.getHeadDeltaPitch();
headStartFinalPitch = MyAvatar.getHeadFinalPitch();
headStartRoll = MyAvatar.getHeadFinalRoll();
headStartYaw = MyAvatar.getHeadFinalYaw();
deltaYaw = 0.0;
warpPosition = MyAvatar.position;
warpPosition.y += hipsToEyes;
activateWarp();
}
});
@ -223,11 +212,40 @@ Controller.keyReleaseEvent.connect(function(event) {
}
timeSinceLastUp = 0.0;
finishWarp();
if (watchAvatar) {
restoreCountdownTimer = RESTORE_TIME;
}
}
});
function reportButtonValue(button, newValue, oldValue) {
if (button == Joysticks.BUTTON_FACE_RIGHT) {
if (newValue) {
activateWarp();
} else {
finishWarp();
}
}
}
Script.update.connect(update);
function addJoystick(gamepad) {
gamepad.buttonStateChanged.connect(reportButtonValue);
gamepads[gamepad.instanceId] = gamepad;
print("Added gamepad: " + gamepad.name + " (" + gamepad.instanceId + ")");
}
function removeJoystick(gamepad) {
delete gamepads[gamepad.instanceId]
print("Removed gamepad: " + gamepad.name + " (" + gamepad.instanceId + ")");
}
var allJoysticks = Joysticks.getAllJoysticks();
for (var i = 0; i < allJoysticks.length; i++) {
addJoystick(allJoysticks[i]);
}
Joysticks.joystickAdded.connect(addJoystick);
Joysticks.joystickRemoved.connect(removeJoystick);

View file

@ -103,13 +103,14 @@
var elIgnoreForCollisions = document.getElementById("property-ignore-for-collisions");
var elCollisionsWillMove = document.getElementById("property-collisions-will-move");
var elLifetime = document.getElementById("property-lifetime");
var elScriptURL = document.getElementById("property-script-url");
var elBoxSection = document.getElementById("box-section");
var elBoxSections = document.querySelectorAll(".box-section");
var elBoxColorRed = document.getElementById("property-box-red");
var elBoxColorGreen = document.getElementById("property-box-green");
var elBoxColorBlue = document.getElementById("property-box-blue");
var elLightSection = document.getElementById('light-section');
var elLightSections = document.querySelectorAll(".light-section");
var elLightSpotLight = document.getElementById("property-light-spot-light");
var elLightDiffuseRed = document.getElementById("property-light-diffuse-red");
var elLightDiffuseGreen = document.getElementById("property-light-diffuse-green");
@ -129,14 +130,14 @@
var elLightExponent = document.getElementById("property-light-exponent");
var elLightCutoff = document.getElementById("property-light-cutoff");
var elModelSection = document.getElementById("model-section");
var elModelSections = document.querySelectorAll(".model-section");
var elModelURL = document.getElementById("property-model-url");
var elModelAnimationURL = document.getElementById("property-model-animation-url");
var elModelAnimationPlaying = document.getElementById("property-model-animation-playing");
var elModelAnimationFPS = document.getElementById("property-model-animation-fps");
var elModelAnimationFrame = document.getElementById("property-model-animation-frame");
var elTextSection = document.getElementById("text-section");
var elTextSections = document.querySelectorAll(".text-section");
var elTextText = document.getElementById("property-text-text");
var elTextLineHeight = document.getElementById("property-text-line-height");
var elTextTextColorRed = document.getElementById("property-text-text-color-red");
@ -198,11 +199,16 @@
elIgnoreForCollisions.checked = properties.ignoreForCollisions;
elCollisionsWillMove.checked = properties.collisionsWillMove;
elLifetime.value = properties.lifetime;
elScriptURL.value = properties.script;
if (properties.type != "Box") {
elBoxSection.style.display = 'none';
for (var i = 0; i < elBoxSections.length; i++) {
elBoxSections[i].style.display = 'none';
}
} else {
elBoxSection.style.display = 'block';
for (var i = 0; i < elBoxSections.length; i++) {
elBoxSections[i].style.display = 'table-row';
}
elBoxColorRed.value = properties.color.red;
elBoxColorGreen.value = properties.color.green;
@ -210,9 +216,14 @@
}
if (properties.type != "Model") {
elModelSection.style.display = 'none';
for (var i = 0; i < elModelSections.length; i++) {
elModelSections[i].style.display = 'none';
}
} else {
elModelSection.style.display = 'block';
for (var i = 0; i < elModelSections.length; i++) {
elModelSections[i].style.display = 'table-row';
}
elModelURL.value = properties.modelURL;
elModelAnimationURL.value = properties.animationURL;
elModelAnimationPlaying.checked = properties.animationIsPlaying;
@ -220,9 +231,13 @@
}
if (properties.type != "Text") {
elTextSection.style.display = 'none';
for (var i = 0; i < elTextSections.length; i++) {
elTextSections[i].style.display = 'none';
}
} else {
elTextSection.style.display = 'block';
for (var i = 0; i < elTextSections.length; i++) {
elTextSections[i].style.display = 'table-row';
}
elTextText.value = properties.text;
elTextLineHeight.value = properties.lineHeight;
@ -235,9 +250,13 @@
}
if (properties.type != "Light") {
elLightSection.style.display = 'none';
for (var i = 0; i < elLightSections.length; i++) {
elLightSections[i].style.display = 'none';
}
} else {
elLightSection.style.display = 'block';
for (var i = 0; i < elLightSections.length; i++) {
elLightSections[i].style.display = 'table-row';
}
elLightDiffuseRed.value = properties.diffuseColor.red;
elLightDiffuseGreen.value = properties.diffuseColor.green;
@ -307,6 +326,7 @@
elIgnoreForCollisions.addEventListener('change', createEmitCheckedPropertyUpdateFunction('ignoreForCollisions'));
elCollisionsWillMove.addEventListener('change', createEmitCheckedPropertyUpdateFunction('collisionsWillMove'));
elLifetime.addEventListener('change', createEmitNumberPropertyUpdateFunction('lifetime'));
elScriptURL.addEventListener('change', createEmitTextPropertyUpdateFunction('script'));
var boxColorChangeFunction = createEmitColorPropertyUpdateFunction(
'color', elBoxColorRed, elBoxColorGreen, elBoxColorBlue);
@ -437,7 +457,7 @@
<td>
<input type='checkbox' id="property-visible">
</td>
<tr>
</tr>
<tr>
<td class="label">Position</td>
@ -446,7 +466,7 @@
<div class="input-area">Y <input class="coord" type='number' id="property-pos-y"></input></div>
<div class="input-area">Z <input class="coord" type='number' id="property-pos-z"></input></div>
</td>
<tr>
</tr>
<tr>
<td class="label">Registration</td>
@ -455,55 +475,45 @@
<div class="input-area">Y <input class="coord" type='number' id="property-reg-y"></input></div>
<div class="input-area">Z <input class="coord" type='number' id="property-reg-z"></input></div>
</td>
<tr>
</tr>
<tr>
<td class="label">Width</td>
<td class="label">Dimensions</td>
<td>
<input class="coord" type='number' id="property-dim-x"></input>
<div class="input-area">X <input class="coord" type='number' id="property-dim-x"></input></div>
<div class="input-area">Y <input class="coord" type='number' id="property-dim-y"></input></div>
<div class="input-area">Z <input class="coord" type='number' id="property-dim-z"></input></div>
</td>
<tr>
<tr>
<td class="label">Height</td>
<td>
<input class="coord" type='number' id="property-dim-y"></input>
</td>
<tr>
<tr>
<td class="label">Depth</td>
<td>
<input class="coord" type='number' id="property-dim-z"></input>
</td>
<tr>
</tr>
<tr>
<td class="label">Linear</td>
<td class="label">Linear Velocity</td>
<td>
<div class="input-area">X <input class="coord" type='number' id="property-lvel-x"></input></div>
<div class="input-area">Y <input class="coord" type='number' id="property-lvel-y"></input></div>
<div class="input-area">Z <input class="coord" type='number' id="property-lvel-z"></input></div>
</td>
<tr>
</tr>
<tr>
<td class="label">Linear Damping</td>
<td>
<input class="coord" type='number' id="property-ldamping"></input>
</td>
</tr>
<tr>
<tr>
<td class="label">Angular</td>
<td class="label">Angular Velocity</td>
<td>
<div class="input-area">Pitch <input class="coord" type='number' id="property-avel-x"></input></div>
<div class="input-area">Yaw <input class="coord" type='number' id="property-avel-y"></input></div>
<div class="input-area">Roll <input class="coord" type='number' id="property-avel-z"></input></div>
</td>
<tr>
</tr>
<tr>
<td class="label">Angular Damping</td>
<td>
<input class="coord" type='number' id="property-adamping"></input>
</td>
<tr>
</tr>
<tr>
<td class="label">Gravity</td>
@ -512,168 +522,176 @@
<div class="input-area">Y <input class="coord" type='number' id="property-grav-y"></input></div>
<div class="input-area">Z <input class="coord" type='number' id="property-grav-z"></input></div>
</td>
<tr>
</tr>
<tr>
<td class="label">Mass</td>
<td>
<input type='number' id="property-mass"></input>
</td>
<tr>
</tr>
<tr>
<td class="label">Ignore For Collisions</td>
<td>
<input type='checkbox' id="property-ignore-for-collisions"></input>
</td>
<tr>
</tr>
<tr>
<td class="label">Collisions Will Move</td>
<td>
<input type='checkbox' id="property-collisions-will-move"></input>
</td>
<tr>
</tr>
<tr>
<td class="label">Lifetime</td>
<td>
<input type='number' id="property-lifetime"></input>
</td>
<tr>
</tr>
<tr>
<td class="label">Script URL</td>
<td>
<input id="property-script-url"></input>
</td>
</tr>
<tr class="box-section">
<td class="label">Color</td>
<td>
<div class="input-area">Red <input class="coord" type='number' id="property-box-red"></input></div>
<div class="input-area">Green <input class="coord" type='number' id="property-box-green"></input></div>
<div class="input-area">Blue <input class="coord" type='number' id="property-box-blue"></input></div>
<div class="input-area">R <input class="coord" type='number' id="property-box-red"></input></div>
<div class="input-area">G <input class="coord" type='number' id="property-box-green"></input></div>
<div class="input-area">B <input class="coord" type='number' id="property-box-blue"></input></div>
</td>
<tr>
</tr>
<tr>
<tr class="model-section">
<td class="label">Model URL</td>
<td>
<input type="text" id="property-model-url"></input>
</td>
<tr>
<tr>
</tr>
<tr class="model-section">
<td class="label">Animation URL</td>
<td>
<input type="text" id="property-model-animation-url"></input>
</td>
<tr>
<tr>
</tr>
<tr class="model-section">
<td class="label">Animation Playing</td>
<td>
<input type='checkbox' id="property-model-animation-playing">
</td>
<tr>
<tr>
</tr>
<tr class="model-section">
<td class="label">Animation FPS</td>
<td>
<input class="coord" type='number' id="property-model-animation-fps"></input>
</td>
<tr>
<tr>
</tr>
<tr class="model-section">
<td class="label">Animation Frame</td>
<td>
<input class="coord" type='number' id="property-model-animation-frame"></input>
</td>
<tr>
</tr>
<tr>
<tr class="text-section">
<td class="label">Text</td>
<td>
<input type="text" id="property-text-text"></input>
</td>
<tr>
<tr>
</tr>
<tr class="text-section">
<td class="label">Line Height</td>
<td>
<input class="coord" type='number' id="property-text-line-height"></input>
</td>
<tr>
<tr>
</tr>
<tr class="text-section">
<td class="label">Text Color</td>
<td>
<div class="input-area">Red <input class="coord" type='number' id="property-text-text-color-red"></input></div>
<div class="input-area">Green <input class="coord" type='number' id="property-text-text-color-green"></input></div>
<div class="input-area">Blue <input class="coord" type='number' id="property-text-text-color-blue"></input></div>
<div class="input-area">R <input class="coord" type='number' id="property-text-text-color-red"></input></div>
<div class="input-area">G <input class="coord" type='number' id="property-text-text-color-green"></input></div>
<div class="input-area">B <input class="coord" type='number' id="property-text-text-color-blue"></input></div>
</td>
<tr>
<tr>
</tr>
<tr class="text-section">
<td class="label">Background Color</td>
<td>
<div class="input-area">Red <input class="coord" type='number' id="property-text-background-color-red"></input></div>
<div class="input-area">Green <input class="coord" type='number' id="property-text-background-color-green"></input></div>
<div class="input-area">Blue <input class="coord" type='number' id="property-text-background-color-blue"></input></div>
<div class="input-area">R <input class="coord" type='number' id="property-text-background-color-red"></input></div>
<div class="input-area">G <input class="coord" type='number' id="property-text-background-color-green"></input></div>
<div class="input-area">B <input class="coord" type='number' id="property-text-background-color-blue"></input></div>
</td>
<tr>
</tr>
<tr>
<tr class="light-section">
<td class="label">Spot Light</td>
<td>
<input type='checkbox' id="property-light-spot-light">
</td>
<tr>
<tr>
</tr>
<tr class="light-section">
<td class="label">Diffuse</td>
<td>
<div class="input-area">Red <input class="coord" type='number' id="property-light-diffuse-red"></input></div>
<div class="input-area">Green <input class="coord" type='number' id="property-light-diffuse-green"></input></div>
<div class="input-area">Blue <input class="coord" type='number' id="property-light-diffuse-blue"></input></div>
<div class="input-area">R <input class="coord" type='number' id="property-light-diffuse-red"></input></div>
<div class="input-area">G <input class="coord" type='number' id="property-light-diffuse-green"></input></div>
<div class="input-area">B <input class="coord" type='number' id="property-light-diffuse-blue"></input></div>
</td>
<tr>
<tr>
</tr>
<tr class="light-section">
<td class="label">Ambient</td>
<td>
<div class="input-area">Red <input class="coord" type='number' id="property-light-ambient-red"></input></div>
<div class="input-area">Green <input class="coord" type='number' id="property-light-ambient-green"></input></div>
<div class="input-area">Blue <input class="coord" type='number' id="property-light-ambient-blue"></input></div>
<div class="input-area">R <input class="coord" type='number' id="property-light-ambient-red"></input></div>
<div class="input-area">G <input class="coord" type='number' id="property-light-ambient-green"></input></div>
<div class="input-area">B <input class="coord" type='number' id="property-light-ambient-blue"></input></div>
</td>
<tr>
<tr>
</tr>
<tr class="light-section">
<td class="label">Specular</td>
<td>
<div class="input-area">Red <input class="coord" type='number' id="property-light-specular-red"></input></div>
<div class="input-area">Green <input class="coord" type='number' id="property-light-specular-green"></input></div>
<div class="input-area">Blue <input class="coord" type='number' id="property-light-specular-blue"></input></div>
<div class="input-area">R <input class="coord" type='number' id="property-light-specular-red"></input></div>
<div class="input-area">G <input class="coord" type='number' id="property-light-specular-green"></input></div>
<div class="input-area">B <input class="coord" type='number' id="property-light-specular-blue"></input></div>
</td>
<tr>
<tr>
</tr>
<tr class="light-section">
<td class="label">Constant Attenuation</td>
<td>
<input class="coord" type='number' id="property-light-constant-attenuation"></input>
</td>
<tr>
<tr>
</tr>
<tr class="light-section">
<td class="label">Linear Attenuation</td>
<td>
<input class="coord" type='number' id="property-light-linear-attenuation"></input>
</td>
<tr>
<tr>
</tr>
<tr class="light-section">
<td class="label">Quadratic Attenuation</td>
<td>
<input class="coord" type='number' id="property-light-quadratic-attenuation"></input>
</td>
<tr>
<tr>
</tr>
<tr class="light-section">
<td class="label">Exponent</td>
<td>
<input class="coord" type='number' id="property-light-exponent"></input>
</td>
<tr>
<tr>
</tr>
<tr class="light-section">
<td class="label">Cutoff (degrees)</td>
<td>
<input class="coord" type='number' id="property-light-cutoff"></input>
</td>
<tr>
</tr>
</table>
</body>

View file

@ -107,7 +107,7 @@ endif()
add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM})
# link required hifi libraries
link_hifi_libraries(shared octree voxels fbx metavoxels networking entities avatars audio animation script-engine physics)
link_hifi_libraries(shared octree voxels gpu fbx metavoxels networking entities avatars audio animation script-engine physics)
# find any optional and required libraries
find_package(ZLIB REQUIRED)

View file

@ -0,0 +1,46 @@
set(TARGET_NAME gpu)
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
setup_hifi_library()
include_glm()
link_hifi_libraries(shared)
if (APPLE)
# link in required OS X frameworks and include the right GL headers
find_library(OpenGL OpenGL)
target_link_libraries(${TARGET_NAME} ${OpenGL})
else (APPLE)
find_package(OpenGL REQUIRED)
if (${OPENGL_INCLUDE_DIR})
include_directories(SYSTEM "${OPENGL_INCLUDE_DIR}")
endif ()
target_link_libraries(${TARGET_NAME} "${OPENGL_LIBRARY}")
# link target to external libraries
if (WIN32)
find_package(GLEW REQUIRED)
include_directories(${GLEW_INCLUDE_DIRS})
# we're using static GLEW, so define GLEW_STATIC
add_definitions(-DGLEW_STATIC)
target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}" "${NSIGHT_LIBRARIES}" opengl32.lib)
# try to find the Nsight package and add it to the build if we find it
find_package(NSIGHT)
if (NSIGHT_FOUND)
include_directories(${NSIGHT_INCLUDE_DIRS})
add_definitions(-DNSIGHT_FOUND)
target_link_libraries(${TARGET_NAME} "${NSIGHT_LIBRARIES}")
endif ()
endif()
endif (APPLE)
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()

View file

@ -12,13 +12,13 @@
#define hifi_gpu_Batch_h
#include <assert.h>
#include "InterfaceConfig.h"
#include "GPUConfig.h"
#include "Transform.h"
#include <vector>
#include "gpu/Stream.h"
#include "Stream.h"
#if defined(NSIGHT_FOUND)
#include "nvToolsExt.h"

View file

@ -12,9 +12,9 @@
#define hifi_gpu_Context_h
#include <assert.h>
#include "InterfaceConfig.h"
#include "GPUConfig.h"
#include "gpu/Resource.h"
#include "Resource.h"
namespace gpu {

View file

@ -12,7 +12,7 @@
#define hifi_gpu_Format_h
#include <assert.h>
#include "InterfaceConfig.h"
#include "GPUConfig.h"
namespace gpu {

View file

@ -12,7 +12,7 @@
#include <QDebug>
#include "gpu/Batch.h"
#include "Batch.h"
using namespace gpu;

View file

@ -12,10 +12,10 @@
#define hifi_gpu_GLBackend_h
#include <assert.h>
#include "InterfaceConfig.h"
#include "GPUConfig.h"
#include "gpu/Context.h"
#include "gpu/Batch.h"
#include "Context.h"
#include "Batch.h"
#include <bitset>

View file

@ -0,0 +1,32 @@
//
// GPUConfig.h
// libraries/gpu/src/gpu
//
// Created by Sam Gateau on 12/4/14.
// Copyright 2013 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
//
#ifndef gpu__GPUConfig__
#define gpu__GPUConfig__
#define GL_GLEXT_PROTOTYPES 1
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#elif defined(WIN32)
#include <GL/glew.h>
#include <GL/wglew.h>
#else
#include <GL/gl.h>
#include <GL/glext.h>
#endif
#endif

View file

@ -12,9 +12,9 @@
#define hifi_gpu_Resource_h
#include <assert.h>
#include "InterfaceConfig.h"
#include "GPUConfig.h"
#include "gpu/Format.h"
#include "Format.h"
#include <vector>

View file

@ -12,10 +12,10 @@
#define hifi_gpu_Stream_h
#include <assert.h>
#include "InterfaceConfig.h"
#include "GPUConfig.h"
#include "gpu/Resource.h"
#include "gpu/Format.h"
#include "Resource.h"
#include "Format.h"
#include <vector>
#include <map>