mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into mouse_pick_in_oculus
This commit is contained in:
commit
469c958c98
16 changed files with 147 additions and 51 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
46
libraries/gpu/CMakeLists.txt
Normal file
46
libraries/gpu/CMakeLists.txt
Normal 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()
|
|
@ -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"
|
|
@ -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 {
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
#define hifi_gpu_Format_h
|
||||
|
||||
#include <assert.h>
|
||||
#include "InterfaceConfig.h"
|
||||
#include "GPUConfig.h"
|
||||
|
||||
|
||||
namespace gpu {
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include <QDebug>
|
||||
|
||||
#include "gpu/Batch.h"
|
||||
#include "Batch.h"
|
||||
|
||||
using namespace gpu;
|
||||
|
|
@ -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>
|
||||
|
||||
|
32
libraries/gpu/src/gpu/GPUConfig.h
Normal file
32
libraries/gpu/src/gpu/GPUConfig.h
Normal 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
|
|
@ -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>
|
||||
|
|
@ -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>
|
||||
|
Loading…
Reference in a new issue