mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 05:04:00 +02:00
Merge branch 'master' into oculus
This commit is contained in:
commit
58ca2e4148
352 changed files with 10943 additions and 4371 deletions
9
.gitignore
vendored
9
.gitignore
vendored
|
@ -38,3 +38,12 @@ interface/resources/visage/*
|
|||
|
||||
# Ignore interfaceCache for Linux users
|
||||
interface/interfaceCache/
|
||||
|
||||
# ignore audio-client externals
|
||||
libraries/audio-client/external/*/*
|
||||
!libraries/audio-client/external/*/readme.txt
|
||||
|
||||
gvr-interface/assets/oculussig*
|
||||
gvr-interface/libs/*
|
||||
|
||||
TAGS
|
14
BUILD.md
14
BUILD.md
|
@ -1,18 +1,26 @@
|
|||
###Dependencies
|
||||
|
||||
* [cmake](http://www.cmake.org/cmake/resources/software.html) ~> 2.8.12.2
|
||||
* [Qt](http://qt-project.org/downloads) ~> 5.3.0
|
||||
* [glm](http://glm.g-truc.net/0.9.5/index.html) ~> 0.9.5.4
|
||||
* [Qt](http://qt-project.org/downloads) ~> 5.3.2
|
||||
* [OpenSSL](https://www.openssl.org/related/binaries.html) ~> 1.0.1g
|
||||
* IMPORTANT: OpenSSL 1.0.1g is critical to avoid a security vulnerability.
|
||||
* [Intel Threading Building Blocks](https://www.threadingbuildingblocks.org/) ~> 4.3
|
||||
* [Soxr](http://sourceforge.net/projects/soxr/) ~> 0.1.1
|
||||
* [Bullet Physics Engine](https://code.google.com/p/bullet/downloads/list) ~> 2.82
|
||||
* [Gverb](https://github.com/highfidelity/gverb/archive/master.zip) (direct download to latest version)
|
||||
|
||||
#### CMake External Project Dependencies
|
||||
|
||||
The following dependencies will be downloaded, built, linked and included automatically by CMake where we require them. The CMakeLists files that handle grabbing each of the following external dependencies can be found in the [cmake/externals folder](cmake/externals). The resulting downloads, source files and binaries will be placed in the `build` directory in each of the subfolders for each external project. These are not placed in your normal build tree when doing an out of source build so that they do not need to be re-downloaded and re-compiled every time the CMake build folder is cleared.
|
||||
|
||||
* [glm](http://glm.g-truc.net/0.9.5/index.html) ~> 0.9.5.4
|
||||
* [gverb](https://github.com/highfidelity/gverb)
|
||||
|
||||
### OS Specific Build Guides
|
||||
* [BUILD_WIN.md](BUILD_WIN.md) - additional instructions for Windows.
|
||||
* [BUILD_OSX.md](BUILD_OSX.md) - additional instructions for OS X.
|
||||
* [BUILD_LINUX.md](BUILD_LINUX.md) - additional instructions for Linux.
|
||||
* [BUILD_WIN.md](BUILD_WIN.md) - additional instructions for Windows.
|
||||
* [BUILD_ANDROID.md](BUILD_ANDROID.md) - additional instructions for Android
|
||||
|
||||
###CMake
|
||||
Hifi uses CMake to generate build files and project files for your platform.
|
||||
|
|
143
BUILD_ANDROID.md
Normal file
143
BUILD_ANDROID.md
Normal file
|
@ -0,0 +1,143 @@
|
|||
Please read the [general build guide](BUILD.md) for information on dependencies required for all platforms. Only Android specific instructions are found in this file.
|
||||
|
||||
###Android Dependencies
|
||||
|
||||
You will need the following tools to build our Android targets.
|
||||
|
||||
* [cmake](http://www.cmake.org/download/) ~> 3.1.0
|
||||
* Note that this is a newer version required than the minimum for hifi desktop targets.
|
||||
* [Qt](http://www.qt.io/download-open-source/#) ~> 5.4.0
|
||||
* Note that this is a newer version required than the minimum for hifi desktop targets.
|
||||
* [ant](http://ant.apache.org/bindownload.cgi) ~> 1.9.4
|
||||
* [Android NDK](https://developer.android.com/tools/sdk/ndk/index.html) = r10c
|
||||
* [Android SDK](http://developer.android.com/sdk/installing/index.html) ~> 24.0.2
|
||||
* Install the latest Platform-tools
|
||||
* Install the latest Build-tools
|
||||
* Install the SDK Platform for API Level 19
|
||||
* Install Sources for Android SDK for API Level 19
|
||||
* Install the ARM EABI v7a System Image if you want to run an emulator.
|
||||
|
||||
You will also need to cross-compile the dependencies required for all platforms for Android, and help CMake find these compiled libraries on your machine.
|
||||
|
||||
####Optional Components
|
||||
|
||||
* [Oculus Mobile SDK](https://developer.oculus.com/downloads/#sdk=mobile) ~> 0.4.2
|
||||
|
||||
####ANDROID_LIB_DIR
|
||||
|
||||
Since you won't be installing Android dependencies to system paths on your development machine, CMake will need a little help tracking down your Android dependencies.
|
||||
|
||||
This is most easily accomplished by installing all Android dependencies in the same folder. You can place this folder wherever you like on your machine. In this build guide and across our CMakeLists files this folder is referred to as `ANDROID_LIB_DIR`. You can set `ANDROID_LIB_DIR` in your environment or by passing when you run CMake.
|
||||
|
||||
####Qt
|
||||
|
||||
Install Qt 5.4 for Android for your host environment from the [Qt downloads page](http://www.qt.io/download/). Install Qt to ``$ANDROID_LIB_DIR/Qt``. This is required so that our root CMakeLists file can help CMake find your Android Qt installation.
|
||||
|
||||
The component required for the Android build is the `Android armv7` component.
|
||||
|
||||
If you would like to install Qt to a different location, or attempt to build with a different Qt version, you can pass `ANDROID_QT_CMAKE_PREFIX_PATH` to CMake. Point to the `cmake` folder inside `$VERSION_NUMBER/android_armv7/lib`. Otherwise, our root CMakeLists will set it to `$ANDROID_LIB_DIR/Qt/5.3/android_armv7/lib/cmake`.
|
||||
|
||||
####OpenSSL
|
||||
|
||||
Cross-compilation of OpenSSL has been tested from an OS X machine running 10.10 compiling OpenSSL 1.0.2. It is likely that the steps below will work for other OpenSSL versions than 1.0.2.
|
||||
|
||||
The original instructions to compile OpenSSL for Android from your host environment can be found [here](http://wiki.openssl.org/index.php/Android). We required some tweaks to get OpenSSL to successfully compile, those tweaks are explained below.
|
||||
|
||||
Download the [OpenSSL source](https://www.openssl.org/source/) and extract the tarball inside your `ANDROID_LIB_DIR`. Rename the extracted folder to `openssl`.
|
||||
|
||||
You will need the [setenv-android.sh script](http://wiki.openssl.org/index.php/File:Setenv-android.sh) from the OpenSSL wiki.
|
||||
|
||||
You must change three values at the top of the `setenv-android.sh` script - `_ANDROID_NDK`, `_ANDROID_EABI` and `_ANDROID_API`.
|
||||
`_ANDROID_NDK` should be `android-ndk-r10`, `_ANDROID_EABI` should be `arm-linux-androidebi-4.9` and `_ANDROID_API` should be `19`.
|
||||
|
||||
First, make sure `ANDROID_NDK_ROOT` is set in your env. This should be the path to the root of your Android NDK install. `setenv-android.sh` needs `ANDROID_NDK_ROOT` to set the environment variables required for building OpenSSL.
|
||||
|
||||
Source the `setenv-android.sh` script so it can set environment variables that OpenSSL will use while compiling. If you use zsh as your shell you may need to modify the `setenv-android.sh` for it to set the correct variables in your env.
|
||||
|
||||
```
|
||||
export ANDROID_NDK_ROOT=YOUR_NDK_ROOT
|
||||
source setenv-android.sh
|
||||
```
|
||||
|
||||
Then, from the OpenSSL directory, run the following commands.
|
||||
|
||||
```
|
||||
perl -pi -e 's/install: all install_docs install_sw/install: install_docs install_sw/g' Makefile.org
|
||||
./config shared -no-ssl2 -no-ssl3 -no-comp -no-hw -no-engine --openssldir=/usr/local/ssl/$ANDROID_API
|
||||
make depend
|
||||
make all
|
||||
```
|
||||
|
||||
This should generate libcrypto and libssl in the root of the OpenSSL directory. YOU MUST remove the `libssl.so` and `libcrypto.so` files that are generated. They are symlinks to `libssl.so.VER` and `libcrypto.so.VER` which Android does not know how to handle. By removing `libssl.so` and `libcrypto.so` the FindOpenSSL module will find the static libs and use those instead.
|
||||
|
||||
If you have been building other components it is possible that the OpenSSL compile will fail based on the values other cross-compilations (tbb, bullet) have set. Ensure that you are in a new terminal window to avoid compilation errors from previously set environment variables.
|
||||
|
||||
####Intel Threading Building Blocks
|
||||
|
||||
Download the [Intel Threading Building Blocks source](https://www.threadingbuildingblocks.org/download) and extract the tarball inside your `ANDROID_LIB_DIR`. Rename the extracted folder to `tbb`.
|
||||
|
||||
NOTE: BEFORE YOU ATTEMPT TO CROSS-COMPILE TBB, DISCONNECT ANY DEVICES ADB WOULD DETECT. The tbb build process asks adb for a couple of strings, and if a device is plugged in extra characters get added that will cause ndk-build to fail with an error.
|
||||
|
||||
From the tbb directory, execute the following commands. First, we build TBB using `ndk-build`. Then, the compiled libs are copied to a lib folder in the root of tbb directory.
|
||||
|
||||
```
|
||||
cd jni
|
||||
ndk-build target=android tbb tbbmalloc arch=arm
|
||||
cd ../
|
||||
mkdir lib
|
||||
cp `find . -name "*.so"` lib/
|
||||
```
|
||||
|
||||
####Soxr
|
||||
|
||||
Download the [Soxr source](http://sourceforge.net/projects/soxr/) and extract the tarball inside your `ANDROID_LIB_DIR`. Rename the extracted folder to `soxr`.
|
||||
|
||||
From the soxr directory, use cmake, along with the `android.toolchain.cmake` file (included in this repository under cmake/android) to cross-compile soxr for Android. Note that you will need ANDROID_NDK set in your environment before using the toolchain file.
|
||||
|
||||
The full set of commands to build soxr for Android is shown below. It is a long command, make sure you copy the entire command (up to `-DBUILD_TESTS=0`).
|
||||
|
||||
```
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=$FULL_PATH_TO_TOOLCHAIN -DCMAKE_INSTALL_PREFIX=. -DHAVE_WORDS_BIGENDIAN_EXITCODE=1 -DBUILD_TESTS=0
|
||||
make
|
||||
make install
|
||||
```
|
||||
|
||||
This will create the `lib` and `include` folders inside `ANDROID_LIB_DIR/soxr` that FindSoxr will look for.
|
||||
|
||||
####Oculus Mobile SDK
|
||||
|
||||
The Oculus Mobile SDK is optional, for Gear VR support. It is not required to compile gvr-interface.
|
||||
|
||||
Download the [Oculus Mobile SDK](https://developer.oculus.com/downloads/#sdk=mobile) and extract the archive inside your `ANDROID_LIB_DIR` folder. Rename the extracted folder to `libovr`.
|
||||
|
||||
From the VRLib directory, use ndk-build to build VrLib.
|
||||
|
||||
```
|
||||
cd VRLib
|
||||
ndk-build
|
||||
```
|
||||
|
||||
This will create the liboculus.a archive that our FindLibOVR module will look for when cmake is run.
|
||||
|
||||
#####Hybrid testing
|
||||
|
||||
Currently the 'vr_dual' mode that would allow us to run a hybrid app has limited support in the Oculus Mobile SDK. The best way to have an application we can launch without having to connect to the GearVR is to put the Gear VR Service into developer mode. This stops Oculus Home from taking over the device when it is plugged into the Gear VR headset, and allows the application to be launched from the Applications page.
|
||||
|
||||
To put the Gear VR Service into developer mode you need an application with an Oculus Signature File on your device. Generate an Oculus Signature File for your device on the [Oculus osig tool page](https://developer.oculus.com/tools/osig/). Place this file in the gvr-interface/assets directory. Cmake will automatically copy it into your apk in the right place when you execute `make gvr-interface-apk`.
|
||||
|
||||
Once the application is on your device, go to `Settings->Application Manager->Gear VR Service->Manage Storage`. Tap on `VR Service Version` six times. It will scan your device to verify that you have an osig file in an application on your device, and then it will let you enable Developer mode.
|
||||
|
||||
|
||||
###CMake
|
||||
|
||||
We use CMake to generate the makefiles that compile and deploy the Android APKs to your device. In order to create Makefiles for the Android targets, CMake requires that some environment variables are set, and that other variables are passed to it when it is run.
|
||||
|
||||
The following must be set in your environment:
|
||||
|
||||
* ANDROID_NDK - the root of your Android NDK install
|
||||
* ANDROID_HOME - the root of your Android SDK install
|
||||
* ANDROID_LIB_DIR - the directory containing cross-compiled versions of dependencies
|
||||
|
||||
The following must be passed to CMake when it is run:
|
||||
|
||||
* USE_ANDROID_TOOLCHAIN - set to true to build for Android
|
|
@ -4,7 +4,7 @@ Please read the [general build guide](BUILD.md) for information on dependencies
|
|||
[Homebrew](http://brew.sh/) is an excellent package manager for OS X. It makes install of all hifi dependencies very simple.
|
||||
|
||||
brew tap highfidelity/homebrew-formulas
|
||||
brew install cmake glm openssl tbb
|
||||
brew install cmake openssl tbb libsoxr
|
||||
brew install highfidelity/formulas/qt5
|
||||
brew link qt5 --force
|
||||
|
||||
|
|
41
BUILD_WIN.md
41
BUILD_WIN.md
|
@ -56,9 +56,6 @@ The recommended route for CMake to find the external dependencies is to place al
|
|||
-> bin
|
||||
-> include
|
||||
-> lib
|
||||
-> glm
|
||||
-> glm
|
||||
-> glm.hpp
|
||||
-> openssl
|
||||
-> bin
|
||||
-> include
|
||||
|
@ -129,26 +126,6 @@ Download the binary package: `glew-1.10.0-win32.zip`. Extract to %HIFI_LIB_DIR%\
|
|||
|
||||
Add to the PATH: `%HIFI_LIB_DIR%\glew\bin\Release\Win32`
|
||||
|
||||
###GLM
|
||||
|
||||
This package contains only headers, so there's nothing to add to the PATH.
|
||||
|
||||
Be careful with glm. For the folder other libraries would normally call 'include', the folder containing the headers, glm opts to use 'glm'. You will have a glm folder nested inside the top-level glm folder.
|
||||
|
||||
###Gverb
|
||||
|
||||
1. Go to https://github.com/highfidelity/gverb
|
||||
Or download the sources directly via this link:
|
||||
https://github.com/highfidelity/gverb/archive/master.zip
|
||||
|
||||
2. Extract the archive
|
||||
|
||||
3. Place the directories “include” and “src” in interface/external/gverb
|
||||
(Normally next to this readme)
|
||||
|
||||
4. Clear your build directory, run cmake, build and you should be all set.
|
||||
|
||||
|
||||
###Bullet
|
||||
|
||||
Bullet 2.82 source can be [downloaded here](https://code.google.com/p/bullet/downloads/detail?name=bullet-2.82-r2704.zip). Bullet does not come with prebuilt libraries, you need to make those yourself.
|
||||
|
@ -167,7 +144,7 @@ cmake .. -G "Visual Studio 12"
|
|||
msbuild BULLET_PHYSICS.sln /p:Configuration=Debug
|
||||
```
|
||||
|
||||
This will create Debug libraries in cmakebuild\lib\Debug you can replace Debug with Release in the msbuild command and that will generate Release libraries in cmakebuild\lib\Release.
|
||||
This will create Debug libraries in cmakebuild\lib\Debug. You can replace Debug with Release in the msbuild command and that will generate Release libraries in cmakebuild\lib\Release.
|
||||
|
||||
You now have Bullet libraries compiled, now you need to put them in the right place for hifi to find them:
|
||||
|
||||
|
@ -178,6 +155,22 @@ You now have Bullet libraries compiled, now you need to put them in the right pl
|
|||
|
||||
_Note that the INSTALL target should handle the copying of files into an install directory automatically, however, without modifications to Cmake, the install target didn't work right for me, please update this instructions if you get that working right - Leo <leo@highfidelity.io>_
|
||||
|
||||
###Soxr
|
||||
|
||||
Download the zip from the [soxr sourceforge page](http://sourceforge.net/projects/soxr/).
|
||||
|
||||
We recommend you install it to %HIFI_LIB_DIR%\soxr. This will help our FindSoxr cmake module find what it needs. You can place it wherever you like on your machine if you specify SOXR_ROOT_DIR as an environment variable or a variable passed when cmake is run.
|
||||
|
||||
Extract the soxr archive wherever you like. Then, inside the extracted folder, create a directory called `build`. From that build directory, the following commands will build and then install soxr to `%HIFI_LIB_DIR%`.
|
||||
|
||||
(Make sure to run the following inside Visual Studio)
|
||||
|
||||
```
|
||||
cmake .. -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%HIFI_LIB_DIR%/soxr
|
||||
nmake
|
||||
nmake install
|
||||
```
|
||||
|
||||
###Build High Fidelity using Visual Studio
|
||||
Follow the same build steps from the CMake section of [BUILD.md](BUILD.md), but pass a different generator to CMake.
|
||||
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
cmake_minimum_required(VERSION 2.8.12.2)
|
||||
|
||||
if (USE_ANDROID_TOOLCHAIN)
|
||||
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/android/android.toolchain.cmake")
|
||||
set(ANDROID_NATIVE_API_LEVEL 19)
|
||||
endif ()
|
||||
|
||||
if (WIN32)
|
||||
cmake_policy(SET CMP0020 NEW)
|
||||
endif (WIN32)
|
||||
|
@ -35,7 +40,7 @@ if (WIN32)
|
|||
elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
||||
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic")
|
||||
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unknown-pragmas")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-strict-aliasing")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-strict-aliasing -ggdb")
|
||||
endif(WIN32)
|
||||
|
||||
if (NOT MSVC12)
|
||||
|
@ -58,8 +63,27 @@ if (APPLE)
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --stdlib=libc++")
|
||||
endif ()
|
||||
|
||||
if (NOT QT_CMAKE_PREFIX_PATH)
|
||||
set(QT_CMAKE_PREFIX_PATH $ENV{QT_CMAKE_PREFIX_PATH})
|
||||
if (NOT ANDROID_LIB_DIR)
|
||||
set(ANDROID_LIB_DIR $ENV{ANDROID_LIB_DIR})
|
||||
endif ()
|
||||
|
||||
if (ANDROID)
|
||||
if (NOT ANDROID_QT_CMAKE_PREFIX_PATH)
|
||||
set(QT_CMAKE_PREFIX_PATH ${ANDROID_LIB_DIR}/Qt/5.4/android_armv7/lib/cmake)
|
||||
else ()
|
||||
set(QT_CMAKE_PREFIX_PATH ${ANDROID_QT_CMAKE_PREFIX_PATH})
|
||||
endif ()
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
|
||||
|
||||
if (ANDROID_LIB_DIR)
|
||||
list(APPEND CMAKE_FIND_ROOT_PATH ${ANDROID_LIB_DIR})
|
||||
endif ()
|
||||
else ()
|
||||
if (NOT QT_CMAKE_PREFIX_PATH)
|
||||
set(QT_CMAKE_PREFIX_PATH $ENV{QT_CMAKE_PREFIX_PATH})
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QT_CMAKE_PREFIX_PATH})
|
||||
|
@ -71,6 +95,8 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET 10.8)
|
|||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
# Instruct CMake to run moc automatically when needed.
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
# Instruct CMake to run rcc automatically when needed
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
set(HIFI_LIBRARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries")
|
||||
|
||||
|
@ -78,16 +104,30 @@ set(HIFI_LIBRARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries")
|
|||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/")
|
||||
|
||||
set(MACRO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macros")
|
||||
set(EXTERNAL_PROJECT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/externals")
|
||||
|
||||
file(GLOB HIFI_CUSTOM_MACROS "cmake/macros/*.cmake")
|
||||
foreach(CUSTOM_MACRO ${HIFI_CUSTOM_MACROS})
|
||||
include(${CUSTOM_MACRO})
|
||||
endforeach()
|
||||
|
||||
# targets on all platforms
|
||||
add_subdirectory(assignment-client)
|
||||
add_subdirectory(domain-server)
|
||||
add_subdirectory(ice-server)
|
||||
add_subdirectory(interface)
|
||||
add_subdirectory(tests)
|
||||
add_subdirectory(tools)
|
||||
if (ANDROID)
|
||||
file(GLOB ANDROID_CUSTOM_MACROS "cmake/android/*.cmake")
|
||||
foreach(CUSTOM_MACRO ${ANDROID_CUSTOM_MACROS})
|
||||
include(${CUSTOM_MACRO})
|
||||
endforeach()
|
||||
endif ()
|
||||
|
||||
# add subdirectories for all targets
|
||||
if (NOT ANDROID)
|
||||
add_subdirectory(assignment-client)
|
||||
add_subdirectory(domain-server)
|
||||
add_subdirectory(ice-server)
|
||||
add_subdirectory(interface)
|
||||
add_subdirectory(tests)
|
||||
add_subdirectory(tools)
|
||||
endif ()
|
||||
|
||||
if (ANDROID OR DESKTOP_GVR)
|
||||
add_subdirectory(gvr-interface)
|
||||
endif ()
|
|
@ -2,7 +2,9 @@ set(TARGET_NAME assignment-client)
|
|||
|
||||
setup_hifi_project(Core Gui Network Script Widgets)
|
||||
|
||||
include_glm()
|
||||
add_dependency_external_project(glm)
|
||||
find_package(GLM REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PRIVATE ${GLM_INCLUDE_DIRS})
|
||||
|
||||
# link in the shared libraries
|
||||
link_hifi_libraries(
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <QtNetwork/QNetworkRequest>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
|
||||
#include <AvatarData.h>
|
||||
#include <AvatarHashMap.h>
|
||||
#include <NetworkAccessManager.h>
|
||||
#include <NodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
|
@ -39,13 +39,14 @@ Agent::Agent(const QByteArray& packet) :
|
|||
_receivedAudioStream(AudioConstants::NETWORK_FRAME_SAMPLES_STEREO, RECEIVED_AUDIO_STREAM_CAPACITY_FRAMES,
|
||||
InboundAudioStream::Settings(0, false, RECEIVED_AUDIO_STREAM_CAPACITY_FRAMES, false,
|
||||
DEFAULT_WINDOW_STARVE_THRESHOLD, DEFAULT_WINDOW_SECONDS_FOR_DESIRED_CALC_ON_TOO_MANY_STARVES,
|
||||
DEFAULT_WINDOW_SECONDS_FOR_DESIRED_REDUCTION, false)),
|
||||
_avatarHashMap()
|
||||
DEFAULT_WINDOW_SECONDS_FOR_DESIRED_REDUCTION, false))
|
||||
{
|
||||
// be the parent of the script engine so it gets moved when we do
|
||||
_scriptEngine.setParent(this);
|
||||
|
||||
_scriptEngine.getEntityScriptingInterface()->setPacketSender(&_entityEditSender);
|
||||
|
||||
DependencyManager::set<ResouceCacheSharedItems>();
|
||||
}
|
||||
|
||||
void Agent::readPendingDatagrams() {
|
||||
|
@ -133,7 +134,7 @@ void Agent::readPendingDatagrams() {
|
|||
|| datagramPacketType == PacketTypeAvatarBillboard
|
||||
|| datagramPacketType == PacketTypeKillAvatar) {
|
||||
// let the avatar hash map process it
|
||||
_avatarHashMap.processAvatarMixerDatagram(receivedPacket, nodeList->sendingNodeForPacket(receivedPacket));
|
||||
DependencyManager::get<AvatarHashMap>()->processAvatarMixerDatagram(receivedPacket, nodeList->sendingNodeForPacket(receivedPacket));
|
||||
|
||||
// let this continue through to the NodeList so it updates last heard timestamp
|
||||
// for the sending avatar-mixer
|
||||
|
@ -200,14 +201,14 @@ void Agent::run() {
|
|||
|
||||
// give this AvatarData object to the script engine
|
||||
_scriptEngine.setAvatarData(&scriptedAvatar, "Avatar");
|
||||
_scriptEngine.setAvatarHashMap(&_avatarHashMap, "AvatarList");
|
||||
_scriptEngine.setAvatarHashMap(DependencyManager::get<AvatarHashMap>().data(), "AvatarList");
|
||||
|
||||
// register ourselves to the script engine
|
||||
_scriptEngine.registerGlobalObject("Agent", this);
|
||||
|
||||
_scriptEngine.init(); // must be done before we set up the viewers
|
||||
|
||||
_scriptEngine.registerGlobalObject("SoundCache", &SoundCache::getInstance());
|
||||
_scriptEngine.registerGlobalObject("SoundCache", DependencyManager::get<SoundCache>().data());
|
||||
|
||||
_scriptEngine.registerGlobalObject("EntityViewer", &_entityViewer);
|
||||
_entityViewer.setJurisdictionListener(_scriptEngine.getEntityScriptingInterface()->getJurisdictionListener());
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include <QtCore/QObject>
|
||||
#include <QtCore/QUrl>
|
||||
|
||||
#include <AvatarHashMap.h>
|
||||
#include <EntityEditPacketSender.h>
|
||||
#include <EntityTree.h>
|
||||
#include <EntityTreeHeadlessViewer.h>
|
||||
|
@ -63,8 +62,6 @@ private:
|
|||
|
||||
MixedAudioStream _receivedAudioStream;
|
||||
float _lastReceivedAudioLoudness;
|
||||
|
||||
AvatarHashMap _avatarHashMap;
|
||||
};
|
||||
|
||||
#endif // hifi_Agent_h
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <AccountManager.h>
|
||||
#include <AddressManager.h>
|
||||
#include <Assignment.h>
|
||||
#include <AvatarHashMap.h>
|
||||
#include <HifiConfigVariantMap.h>
|
||||
#include <LogHandler.h>
|
||||
#include <LogUtils.h>
|
||||
|
@ -55,6 +56,7 @@ AssignmentClient::AssignmentClient(int &argc, char **argv) :
|
|||
DependencyManager::registerInheritance<LimitedNodeList, NodeList>();
|
||||
auto addressManager = DependencyManager::set<AddressManager>();
|
||||
auto nodeList = DependencyManager::set<NodeList>(NodeType::Unassigned);
|
||||
auto avatarHashMap = DependencyManager::set<AvatarHashMap>();
|
||||
|
||||
// setup a shutdown event listener to handle SIGTERM or WM_CLOSE for us
|
||||
#ifdef _WIN32
|
||||
|
@ -134,7 +136,7 @@ AssignmentClient::AssignmentClient(int &argc, char **argv) :
|
|||
|
||||
// Create Singleton objects on main thread
|
||||
NetworkAccessManager::getInstance();
|
||||
SoundCache::getInstance();
|
||||
auto soundCache = DependencyManager::get<SoundCache>();
|
||||
}
|
||||
|
||||
void AssignmentClient::sendAssignmentRequest() {
|
||||
|
|
|
@ -648,6 +648,7 @@ void AudioMixer::run() {
|
|||
|
||||
// setup a QThread with us as parent that will house the AudioMixerDatagramProcessor
|
||||
_datagramProcessingThread = new QThread(this);
|
||||
_datagramProcessingThread->setObjectName("Datagram Processor Thread");
|
||||
|
||||
// create an AudioMixerDatagramProcessor and move it to that thread
|
||||
AudioMixerDatagramProcessor* datagramProcessor = new AudioMixerDatagramProcessor(nodeList->getNodeSocket(), thread());
|
||||
|
|
|
@ -147,3 +147,14 @@ void EntityServer::pruneDeletedEntities() {
|
|||
}
|
||||
}
|
||||
|
||||
void EntityServer::readAdditionalConfiguration(const QJsonObject& settingsSectionObject) {
|
||||
bool wantEditLogging = false;
|
||||
readOptionBool(QString("wantEditLogging"), settingsSectionObject, wantEditLogging);
|
||||
qDebug("wantEditLogging=%s", debug::valueOf(wantEditLogging));
|
||||
|
||||
|
||||
EntityTree* tree = static_cast<EntityTree*>(_tree);
|
||||
tree->setWantEditLogging(wantEditLogging);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ public:
|
|||
virtual int sendSpecialPacket(const SharedNodePointer& node, OctreeQueryNode* queryNode, int& packetsSent);
|
||||
|
||||
virtual void entityCreated(const EntityItem& newEntity, const SharedNodePointer& senderNode);
|
||||
virtual void readAdditionalConfiguration(const QJsonObject& settingsSectionObject);
|
||||
|
||||
public slots:
|
||||
void pruneDeletedEntities();
|
||||
|
|
|
@ -271,9 +271,10 @@ void MetavoxelSession::handleMessage(const QVariant& message) {
|
|||
_lodPacketNumber = _sequencer.getIncomingPacketNumber();
|
||||
|
||||
} else if (userType == MetavoxelEditMessage::Type) {
|
||||
QMetaObject::invokeMethod(_sender->getServer(), "applyEdit", Q_ARG(const MetavoxelEditMessage&,
|
||||
message.value<MetavoxelEditMessage>()));
|
||||
|
||||
if (_node->getCanAdjustLocks()) {
|
||||
QMetaObject::invokeMethod(_sender->getServer(), "applyEdit",
|
||||
Q_ARG(const MetavoxelEditMessage&, message.value<MetavoxelEditMessage>()));
|
||||
}
|
||||
} else if (userType == QMetaType::QVariantList) {
|
||||
foreach (const QVariant& element, message.toList()) {
|
||||
handleMessage(element);
|
||||
|
|
|
@ -879,6 +879,7 @@ void OctreeServer::setupDatagramProcessingThread() {
|
|||
|
||||
// setup a QThread with us as parent that will house the OctreeServerDatagramProcessor
|
||||
_datagramProcessingThread = new QThread(this);
|
||||
_datagramProcessingThread->setObjectName("Octree Datagram Processor");
|
||||
|
||||
// create an OctreeServerDatagramProcessor and move it to that thread
|
||||
OctreeServerDatagramProcessor* datagramProcessor = new OctreeServerDatagramProcessor(nodeList->getNodeSocket(), thread());
|
||||
|
|
82
cmake/android/AndroidManifest.xml.in
Executable file
82
cmake/android/AndroidManifest.xml.in
Executable file
|
@ -0,0 +1,82 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- IMPORTANT: Do not manually manipulate this automatically generated file, changes will be gone after the next build! -->
|
||||
|
||||
<manifest package="${ANDROID_APK_PACKAGE}" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="${ANDROID_APK_VERSION_NAME}" android:versionCode="${ANDROID_APK_VERSION_CODE}" android:installLocation="auto">
|
||||
<application
|
||||
android:hardwareAccelerated="true"
|
||||
android:name="org.qtproject.qt5.android.bindings.QtApplication"
|
||||
android:label="@string/AppDisplayName"
|
||||
android:icon="@drawable/icon"
|
||||
android:debuggable="${ANDROID_APK_DEBUGGABLE}">
|
||||
|
||||
<!-- VR MODE -->
|
||||
<meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only"/>
|
||||
|
||||
<activity
|
||||
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation"
|
||||
android:name="${ANDROID_ACTIVITY_NAME}"
|
||||
android:label="@string/AppDisplayName"
|
||||
android:screenOrientation="landscape"
|
||||
android:launchMode="singleTop"
|
||||
${ANDROID_APK_THEME}>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
|
||||
<meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
|
||||
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
|
||||
<meta-data android:name="android.app.repository" android:value="default"/>
|
||||
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
|
||||
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
|
||||
<!-- Deploy Qt libs as part of package -->
|
||||
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
|
||||
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
|
||||
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
|
||||
<!-- Run with local libs -->
|
||||
<meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
|
||||
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
|
||||
<meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
|
||||
<meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
|
||||
<meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
|
||||
<!-- Messages maps -->
|
||||
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
|
||||
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
|
||||
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
|
||||
<!-- Messages maps -->
|
||||
|
||||
<!-- Splash screen -->
|
||||
<!-- <meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/> -->
|
||||
|
||||
${ANDROID_EXTRA_ACTIVITY_XML}
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.oculusvr.vrlib.PlatformActivity"
|
||||
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="landscape"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden|keyboard">
|
||||
</activity>
|
||||
|
||||
${ANDROID_EXTRA_APPLICATION_XML}
|
||||
</application>
|
||||
<uses-sdk android:minSdkVersion="${ANDROID_API_LEVEL}" android:targetSdkVersion="${ANDROID_API_LEVEL}"/>
|
||||
|
||||
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
|
||||
Remove the comment if you do not require these default permissions. -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
|
||||
<!-- camera permission required for GEAR VR passthrough camera -->
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
|
||||
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
|
||||
Remove the comment if you do not require these default features. -->
|
||||
|
||||
<!-- Tell the system this app requires OpenGL ES 3.0. -->
|
||||
<uses-feature android:glEsVersion="0x00030000" android:required="true" />
|
||||
</manifest>
|
162
cmake/android/QtCreateAPK.cmake
Normal file
162
cmake/android/QtCreateAPK.cmake
Normal file
|
@ -0,0 +1,162 @@
|
|||
#
|
||||
# QtCreateAPK.cmake
|
||||
#
|
||||
# Created by Stephen Birarda on 11/18/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
|
||||
#
|
||||
|
||||
#
|
||||
# OPTIONS
|
||||
# These options will modify how QtCreateAPK behaves. May be useful if somebody wants to fork.
|
||||
# For High Fidelity purposes these should not need to be changed.
|
||||
#
|
||||
set(ANDROID_THIS_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) # Directory this CMake file is in
|
||||
|
||||
if (POLICY CMP0026)
|
||||
cmake_policy(SET CMP0026 OLD)
|
||||
endif ()
|
||||
|
||||
macro(qt_create_apk)
|
||||
if(ANDROID_APK_FULLSCREEN)
|
||||
set(ANDROID_APK_THEME "android:theme=\"@android:style/Theme.NoTitleBar.Fullscreen\"")
|
||||
else()
|
||||
set(ANDROID_APK_THEME "")
|
||||
endif()
|
||||
|
||||
if (CMAKE_BUILD_TYPE MATCHES RELEASE)
|
||||
set(ANDROID_APK_DEBUGGABLE "false")
|
||||
set(ANDROID_APK_RELEASE_LOCAL ${ANDROID_APK_RELEASE})
|
||||
else ()
|
||||
set(ANDROID_APK_DEBUGGABLE "true")
|
||||
set(ANDROID_APK_RELEASE_LOCAL "0")
|
||||
endif ()
|
||||
|
||||
# Create "AndroidManifest.xml"
|
||||
configure_file("${ANDROID_THIS_DIRECTORY}/AndroidManifest.xml.in" "${ANDROID_APK_BUILD_DIR}/AndroidManifest.xml")
|
||||
|
||||
# create "strings.xml"
|
||||
configure_file("${ANDROID_THIS_DIRECTORY}/strings.xml.in" "${ANDROID_APK_BUILD_DIR}/res/values/strings.xml")
|
||||
|
||||
# figure out where the qt dir is
|
||||
get_filename_component(QT_DIR "${QT_CMAKE_PREFIX_PATH}/../../" ABSOLUTE)
|
||||
|
||||
# find androiddeployqt
|
||||
find_program(ANDROID_DEPLOY_QT androiddeployqt HINTS "${QT_DIR}/bin")
|
||||
|
||||
# set the path to our app shared library
|
||||
set(EXECUTABLE_DESTINATION_PATH "${ANDROID_APK_OUTPUT_DIR}/libs/${ANDROID_ABI}/lib${TARGET_NAME}.so")
|
||||
|
||||
# add our dependencies to the deployment file
|
||||
get_property(_DEPENDENCIES TARGET ${TARGET_NAME} PROPERTY INTERFACE_LINK_LIBRARIES)
|
||||
|
||||
foreach(_IGNORE_COPY IN LISTS IGNORE_COPY_LIBS)
|
||||
list(REMOVE_ITEM _DEPENDENCIES ${_IGNORE_COPY})
|
||||
endforeach()
|
||||
|
||||
foreach(_DEP IN LISTS _DEPENDENCIES)
|
||||
if (NOT TARGET ${_DEP})
|
||||
list(APPEND _DEPS_LIST ${_DEP})
|
||||
else ()
|
||||
if(NOT _DEP MATCHES "Qt5::.*")
|
||||
get_property(_DEP_LOCATION TARGET ${_DEP} PROPERTY "LOCATION_${CMAKE_BUILD_TYPE}")
|
||||
|
||||
# recurisvely add libraries which are dependencies of this target
|
||||
get_property(_DEP_DEPENDENCIES TARGET ${_DEP} PROPERTY INTERFACE_LINK_LIBRARIES)
|
||||
|
||||
foreach(_SUB_DEP IN LISTS _DEP_DEPENDENCIES)
|
||||
if (NOT TARGET ${_SUB_DEP} AND NOT _SUB_DEP MATCHES "Qt5::.*")
|
||||
list(APPEND _DEPS_LIST ${_SUB_DEP})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
list(APPEND _DEPS_LIST ${_DEP_LOCATION})
|
||||
endif()
|
||||
endif ()
|
||||
endforeach()
|
||||
|
||||
list(REMOVE_DUPLICATES _DEPS_LIST)
|
||||
|
||||
# just copy static libs to apk libs folder - don't add to deps list
|
||||
foreach(_LOCATED_DEP IN LISTS _DEPS_LIST)
|
||||
if (_LOCATED_DEP MATCHES "\\.a$")
|
||||
add_custom_command(
|
||||
TARGET ${TARGET_NAME}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${_LOCATED_DEP} "${ANDROID_APK_OUTPUT_DIR}/libs/${ANDROID_ABI}"
|
||||
)
|
||||
list(REMOVE_ITEM _DEPS_LIST ${_LOCATED_DEP})
|
||||
endif ()
|
||||
endforeach()
|
||||
|
||||
string(REPLACE ";" "," _DEPS "${_DEPS_LIST}")
|
||||
|
||||
configure_file("${ANDROID_THIS_DIRECTORY}/deployment-file.json.in" "${TARGET_NAME}-deployment.json")
|
||||
|
||||
# copy the res folder from the target to the apk build dir
|
||||
add_custom_target(
|
||||
${TARGET_NAME}-copy-res
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/res" "${ANDROID_APK_BUILD_DIR}/res"
|
||||
)
|
||||
|
||||
# copy the assets folder from the target to the apk build dir
|
||||
add_custom_target(
|
||||
${TARGET_NAME}-copy-assets
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/assets" "${ANDROID_APK_BUILD_DIR}/assets"
|
||||
)
|
||||
|
||||
# copy the java folder from src to the apk build dir
|
||||
add_custom_target(
|
||||
${TARGET_NAME}-copy-java
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/src/java" "${ANDROID_APK_BUILD_DIR}/src"
|
||||
)
|
||||
|
||||
# copy the libs folder from src to the apk build dir
|
||||
add_custom_target(
|
||||
${TARGET_NAME}-copy-libs
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/libs" "${ANDROID_APK_BUILD_DIR}/libs"
|
||||
)
|
||||
|
||||
# handle setup for ndk-gdb
|
||||
add_custom_target(${TARGET_NAME}-gdb DEPENDS ${TARGET_NAME})
|
||||
|
||||
if (ANDROID_APK_DEBUGGABLE)
|
||||
get_property(TARGET_LOCATION TARGET ${TARGET_NAME} PROPERTY LOCATION)
|
||||
|
||||
set(GDB_SOLIB_PATH ${ANDROID_APK_BUILD_DIR}/obj/local/${ANDROID_NDK_ABI_NAME}/)
|
||||
|
||||
# generate essential Android Makefiles
|
||||
file(WRITE ${ANDROID_APK_BUILD_DIR}/jni/Android.mk "APP_ABI := ${ANDROID_NDK_ABI_NAME}\n")
|
||||
file(WRITE ${ANDROID_APK_BUILD_DIR}/jni/Application.mk "APP_ABI := ${ANDROID_NDK_ABI_NAME}\n")
|
||||
|
||||
# create gdb.setup
|
||||
get_directory_property(PROJECT_INCLUDES DIRECTORY ${PROJECT_SOURCE_DIR} INCLUDE_DIRECTORIES)
|
||||
string(REGEX REPLACE ";" " " PROJECT_INCLUDES "${PROJECT_INCLUDES}")
|
||||
file(WRITE ${ANDROID_APK_BUILD_DIR}/libs/${ANDROID_NDK_ABI_NAME}/gdb.setup "set solib-search-path ${GDB_SOLIB_PATH}\n")
|
||||
file(APPEND ${ANDROID_APK_BUILD_DIR}/libs/${ANDROID_NDK_ABI_NAME}/gdb.setup "directory ${PROJECT_INCLUDES}\n")
|
||||
|
||||
# copy lib to obj
|
||||
add_custom_command(TARGET ${TARGET_NAME}-gdb PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${GDB_SOLIB_PATH})
|
||||
add_custom_command(TARGET ${TARGET_NAME}-gdb PRE_BUILD COMMAND cp ${TARGET_LOCATION} ${GDB_SOLIB_PATH})
|
||||
|
||||
# strip symbols
|
||||
add_custom_command(TARGET ${TARGET_NAME}-gdb PRE_BUILD COMMAND ${CMAKE_STRIP} ${TARGET_LOCATION})
|
||||
endif ()
|
||||
|
||||
# use androiddeployqt to create the apk
|
||||
add_custom_target(${TARGET_NAME}-apk
|
||||
COMMAND ${ANDROID_DEPLOY_QT} --input "${TARGET_NAME}-deployment.json" --output "${ANDROID_APK_OUTPUT_DIR}" --android-platform android-${ANDROID_API_LEVEL} ${ANDROID_DEPLOY_QT_INSTALL} --verbose --deployment bundled "\\$(ARGS)"
|
||||
DEPENDS ${TARGET_NAME} ${TARGET_NAME}-copy-res ${TARGET_NAME}-copy-assets ${TARGET_NAME}-copy-java ${TARGET_NAME}-copy-libs ${TARGET_NAME}-gdb
|
||||
)
|
||||
|
||||
# rename the APK if the caller asked us to
|
||||
if (ANDROID_APK_CUSTOM_NAME)
|
||||
add_custom_command(
|
||||
TARGET ${TARGET_NAME}-apk
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E rename "${ANDROID_APK_OUTPUT_DIR}/bin/QtApp-debug.apk" "${ANDROID_APK_OUTPUT_DIR}/bin/${ANDROID_APK_CUSTOM_NAME}"
|
||||
)
|
||||
endif ()
|
||||
endmacro()
|
1753
cmake/android/android.toolchain.cmake
Executable file
1753
cmake/android/android.toolchain.cmake
Executable file
File diff suppressed because it is too large
Load diff
13
cmake/android/deployment-file.json.in
Normal file
13
cmake/android/deployment-file.json.in
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"qt": "@QT_DIR@",
|
||||
"sdk": "@ANDROID_SDK_ROOT@",
|
||||
"ndk": "@ANDROID_NDK@",
|
||||
"toolchain-prefix": "@ANDROID_TOOLCHAIN_MACHINE_NAME@",
|
||||
"tool-prefix": "@ANDROID_TOOLCHAIN_MACHINE_NAME@",
|
||||
"toolchain-version": "@ANDROID_COMPILER_VERSION@",
|
||||
"ndk-host": "@ANDROID_NDK_HOST_SYSTEM_NAME@",
|
||||
"target-architecture": "@ANDROID_ABI@",
|
||||
"application-binary": "@EXECUTABLE_DESTINATION_PATH@",
|
||||
"android-extra-libs": "@_DEPS@",
|
||||
"android-package-source-directory": "@ANDROID_APK_BUILD_DIR@"
|
||||
}
|
11
cmake/android/strings.xml.in
Normal file
11
cmake/android/strings.xml.in
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
|
||||
<!-- IMPORTANT: Do not manually manipulate this automatically generated file, changes will be gone after the next build! -->
|
||||
|
||||
<resources>
|
||||
<string name="AppDisplayName">${ANDROID_APP_DISPLAY_NAME}</string>
|
||||
|
||||
<string name="ministro_not_found_msg">Can\'t find Ministro service.\nThe application can\'t start.</string>
|
||||
<string name="ministro_needed_msg">This application requires Ministro service. Would you like to install it?</string>
|
||||
<string name="fatal_error_msg">Your application encountered a fatal error and cannot continue.</string>
|
||||
</resources>
|
15
cmake/externals/glm/CMakeLists.txt
vendored
Normal file
15
cmake/externals/glm/CMakeLists.txt
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
set(EXTERNAL_NAME glm)
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(
|
||||
${EXTERNAL_NAME}
|
||||
PREFIX ${EXTERNAL_NAME}
|
||||
URL http://pkgs.fedoraproject.org/repo/pkgs/glm/glm-0.9.5.4.zip/fab76fc982b256b46208e5c750ed456a/glm-0.9.5.4.zip
|
||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
||||
LOG_DOWNLOAD ON
|
||||
)
|
||||
|
||||
ExternalProject_Get_Property(${EXTERNAL_NAME} INSTALL_DIR)
|
||||
|
||||
string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER)
|
||||
set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${INSTALL_DIR}/include CACHE TYPE STRING)
|
25
cmake/externals/gverb/CMakeLists.txt
vendored
Normal file
25
cmake/externals/gverb/CMakeLists.txt
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
set(EXTERNAL_NAME gverb)
|
||||
|
||||
if (ANDROID)
|
||||
set(ANDROID_CMAKE_ARGS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" "-DANDROID_NATIVE_API_LEVEL=19")
|
||||
endif ()
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(
|
||||
${EXTERNAL_NAME}
|
||||
PREFIX ${EXTERNAL_NAME}
|
||||
GIT_REPOSITORY https://github.com/birarda/gverb.git
|
||||
CMAKE_ARGS ${ANDROID_CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
||||
LOG_DOWNLOAD ON
|
||||
)
|
||||
|
||||
ExternalProject_Get_Property(${EXTERNAL_NAME} INSTALL_DIR)
|
||||
|
||||
string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER)
|
||||
set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${INSTALL_DIR}/include CACHE TYPE STRING)
|
||||
|
||||
if (WIN32)
|
||||
set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${INSTALL_DIR}/lib/gverb.lib CACHE TYPE STRING)
|
||||
else ()
|
||||
set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${INSTALL_DIR}/lib/libgverb.a CACHE TYPE STRING)
|
||||
endif ()
|
25
cmake/macros/AddDependencyExternalProject.cmake
Normal file
25
cmake/macros/AddDependencyExternalProject.cmake
Normal file
|
@ -0,0 +1,25 @@
|
|||
#
|
||||
# SetupExternalProject.cmake
|
||||
# cmake/macros
|
||||
#
|
||||
# Copyright 2015 High Fidelity, Inc.
|
||||
# Created by Stephen Birarda on February 13, 2014
|
||||
#
|
||||
# Distributed under the Apache License, Version 2.0.
|
||||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
|
||||
macro(ADD_DEPENDENCY_EXTERNAL_PROJECT _PROJ_NAME)
|
||||
|
||||
string(TOUPPER ${_PROJ_NAME} _PROJ_NAME_UPPER)
|
||||
|
||||
if (NOT DEFINED GET_${_PROJ_NAME_UPPER} OR GET_${_PROJ_NAME_UPPER})
|
||||
if (NOT TARGET ${_PROJ_NAME})
|
||||
add_subdirectory(${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME} ${CMAKE_BINARY_DIR}/externals/${_PROJ_NAME})
|
||||
endif ()
|
||||
|
||||
add_dependencies(${TARGET_NAME} ${_PROJ_NAME})
|
||||
|
||||
endif ()
|
||||
|
||||
endmacro()
|
|
@ -13,5 +13,11 @@ macro(AUTO_MTC)
|
|||
|
||||
file(GLOB INCLUDE_FILES src/*.h)
|
||||
|
||||
add_custom_command(OUTPUT ${AUTOMTC_SRC} COMMAND mtc -o ${AUTOMTC_SRC} ${INCLUDE_FILES} DEPENDS mtc ${INCLUDE_FILES})
|
||||
if (NOT ANDROID)
|
||||
set(MTC_EXECUTABLE mtc)
|
||||
else ()
|
||||
set(MTC_EXECUTABLE $ENV{MTC_PATH}/mtc)
|
||||
endif ()
|
||||
|
||||
add_custom_command(OUTPUT ${AUTOMTC_SRC} COMMAND ${MTC_EXECUTABLE} -o ${AUTOMTC_SRC} ${INCLUDE_FILES} DEPENDS ${MTC_EXECUTABLE} ${INCLUDE_FILES})
|
||||
endmacro()
|
||||
|
|
|
@ -10,18 +10,21 @@
|
|||
|
||||
macro(HIFI_LIBRARY_SEARCH_HINTS LIBRARY_FOLDER)
|
||||
string(TOUPPER ${LIBRARY_FOLDER} LIBRARY_PREFIX)
|
||||
set(${LIBRARY_PREFIX}_SEARCH_DIRS "")
|
||||
|
||||
if (${LIBRARY_PREFIX}_ROOT_DIR)
|
||||
set(${LIBRARY_PREFIX}_SEARCH_DIRS "${${LIBRARY_PREFIX}_ROOT_DIR}")
|
||||
list(APPEND ${LIBRARY_PREFIX}_SEARCH_DIRS "${${LIBRARY_PREFIX}_ROOT_DIR}")
|
||||
endif ()
|
||||
|
||||
if (ANDROID)
|
||||
list(APPEND ${LIBRARY_PREFIX}_SEARCH_DIRS "/${LIBRARY_FOLDER}")
|
||||
endif ()
|
||||
|
||||
if (DEFINED ENV{${LIBRARY_PREFIX}_ROOT_DIR})
|
||||
set(${LIBRARY_PREFIX}_SEARCH_DIRS "${${LIBRARY_PREFIX}_SEARCH_DIRS}" "$ENV{${LIBRARY_PREFIX}_ROOT_DIR}")
|
||||
list(APPEND ${LIBRARY_PREFIX}_SEARCH_DIRS "$ENV{${LIBRARY_PREFIX}_ROOT_DIR}")
|
||||
endif ()
|
||||
|
||||
if (DEFINED ENV{HIFI_LIB_DIR})
|
||||
set(${LIBRARY_PREFIX}_SEARCH_DIRS "${${LIBRARY_PREFIX}_SEARCH_DIRS}" "$ENV{HIFI_LIB_DIR}/${LIBRARY_FOLDER}")
|
||||
list(APPEND ${LIBRARY_PREFIX}_SEARCH_DIRS "$ENV{HIFI_LIB_DIR}/${LIBRARY_FOLDER}")
|
||||
endif ()
|
||||
|
||||
endmacro(HIFI_LIBRARY_SEARCH_HINTS _library_folder)
|
|
@ -1,19 +0,0 @@
|
|||
#
|
||||
# IncludeGLM.cmake
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
macro(INCLUDE_GLM)
|
||||
|
||||
find_package(GLM REQUIRED)
|
||||
include_directories("${GLM_INCLUDE_DIRS}")
|
||||
|
||||
if (APPLE OR UNIX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${GLM_INCLUDE_DIRS}")
|
||||
endif ()
|
||||
|
||||
endmacro(INCLUDE_GLM)
|
|
@ -32,5 +32,4 @@ macro(LINK_HIFI_LIBRARIES)
|
|||
list(APPEND ${TARGET_NAME}_DEPENDENCY_INCLUDES ${LINKED_TARGET_DEPENDENCY_INCLUDES})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
endmacro(LINK_HIFI_LIBRARIES)
|
|
@ -9,14 +9,18 @@
|
|||
|
||||
macro(SETUP_HIFI_LIBRARY)
|
||||
|
||||
project(${TARGET_NAME})
|
||||
project(${TARGET_NAME})
|
||||
|
||||
# grab the implemenation and header files
|
||||
file(GLOB_RECURSE LIB_SRCS "src/*.h" "src/*.cpp")
|
||||
set(LIB_SRCS ${LIB_SRCS})
|
||||
list(APPEND ${TARGET_NAME}_SRCS ${LIB_SRCS})
|
||||
|
||||
# create a library and set the property so it can be referenced later
|
||||
add_library(${TARGET_NAME} ${LIB_SRCS} ${AUTOMTC_SRC} ${AUTOSCRIBE_SHADER_LIB_SRC})
|
||||
if (${${TARGET_NAME}_SHARED})
|
||||
add_library(${TARGET_NAME} SHARED ${LIB_SRCS} ${AUTOMTC_SRC} ${AUTOSCRIBE_SHADER_LIB_SRC} ${QT_RESOURCES_FILE})
|
||||
else ()
|
||||
add_library(${TARGET_NAME} ${LIB_SRCS} ${AUTOMTC_SRC} ${AUTOSCRIBE_SHADER_LIB_SRC} ${QT_RESOURCES_FILE})
|
||||
endif ()
|
||||
|
||||
set(${TARGET_NAME}_DEPENDENCY_QT_MODULES ${ARGN})
|
||||
list(APPEND ${TARGET_NAME}_DEPENDENCY_QT_MODULES Core)
|
||||
|
|
|
@ -35,27 +35,34 @@ include("${MACRO_DIR}/HifiLibrarySearchHints.cmake")
|
|||
hifi_library_search_hints("bullet")
|
||||
|
||||
macro(_FIND_BULLET_LIBRARY _var)
|
||||
find_library(${_var}
|
||||
NAMES
|
||||
${ARGN}
|
||||
set(_${_var}_NAMES ${ARGN})
|
||||
find_library(${_var}_LIBRARY_RELEASE
|
||||
NAMES ${_${_var}_NAMES}
|
||||
HINTS
|
||||
${BULLET_SEARCH_DIRS}
|
||||
$ENV{BULLET_ROOT_DIR}
|
||||
${BULLET_ROOT}
|
||||
${BULLET_ROOT}/out/release8/libs
|
||||
${BULLET_ROOT}/out/debug8/libs
|
||||
PATH_SUFFIXES lib lib/Release lib/Debug
|
||||
PATH_SUFFIXES lib lib/Release out/release8/libs
|
||||
)
|
||||
mark_as_advanced(${_var})
|
||||
endmacro()
|
||||
|
||||
macro(_BULLET_APPEND_LIBRARIES _list _release)
|
||||
set(_debug ${_release}_DEBUG)
|
||||
if(${_debug})
|
||||
set(${_list} ${${_list}} optimized ${${_release}} debug ${${_debug}})
|
||||
else()
|
||||
set(${_list} ${${_list}} ${${_release}})
|
||||
endif()
|
||||
|
||||
foreach(_NAME IN LISTS _${_var}_NAMES)
|
||||
list(APPEND _${_var}_DEBUG_NAMES "${_NAME}_Debug")
|
||||
list(APPEND _${_var}_DEBUG_NAMES "${_NAME}_d")
|
||||
endforeach()
|
||||
|
||||
find_library(${_var}_LIBRARY_DEBUG
|
||||
NAMES ${_${_var}_DEBUG_NAMES}
|
||||
HINTS
|
||||
${BULLET_SEARCH_DIRS}
|
||||
$ENV{BULLET_ROOT_DIR}
|
||||
${BULLET_ROOT}
|
||||
PATH_SUFFIXES lib lib/Debug out/debug8/libs
|
||||
)
|
||||
|
||||
select_library_configurations(${_var})
|
||||
|
||||
mark_as_advanced(${_var}_LIBRARY)
|
||||
mark_as_advanced(${_var}_LIBRARY)
|
||||
endmacro()
|
||||
|
||||
find_path(BULLET_INCLUDE_DIR NAMES btBulletCollisionCommon.h
|
||||
|
@ -69,25 +76,18 @@ find_path(BULLET_INCLUDE_DIR NAMES btBulletCollisionCommon.h
|
|||
|
||||
# Find the libraries
|
||||
|
||||
_FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY BulletDynamics)
|
||||
_FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY_DEBUG BulletDynamics_Debug BulletDynamics_d)
|
||||
_FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY BulletCollision)
|
||||
_FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY_DEBUG BulletCollision_Debug BulletCollision_d)
|
||||
_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY BulletMath LinearMath)
|
||||
_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY_DEBUG BulletMath_Debug BulletMath_d LinearMath_Debug LinearMath_d)
|
||||
_FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY BulletSoftBody)
|
||||
_FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY_DEBUG BulletSoftBody_Debug BulletSoftBody_d)
|
||||
_FIND_BULLET_LIBRARY(BULLET_DYNAMICS BulletDynamics)
|
||||
_FIND_BULLET_LIBRARY(BULLET_COLLISION BulletCollision)
|
||||
_FIND_BULLET_LIBRARY(BULLET_MATH BulletMath LinearMath)
|
||||
_FIND_BULLET_LIBRARY(BULLET_SOFTBODY BulletSoftBody)
|
||||
|
||||
set(BULLET_INCLUDE_DIRS ${BULLET_INCLUDE_DIR})
|
||||
set(BULLET_LIBRARIES ${BULLET_DYNAMICS_LIBRARY} ${BULLET_COLLISION_LIBRARY} ${BULLET_MATH_LIBRARY} ${BULLET_SOFTBODY_LIBRARY})
|
||||
|
||||
find_package_handle_standard_args(Bullet "Could NOT find Bullet, try to set the path to Bullet root folder in the system variable BULLET_ROOT_DIR"
|
||||
BULLET_DYNAMICS_LIBRARY BULLET_COLLISION_LIBRARY BULLET_MATH_LIBRARY
|
||||
BULLET_INCLUDE_DIR
|
||||
BULLET_INCLUDE_DIRS
|
||||
BULLET_LIBRARIES
|
||||
)
|
||||
|
||||
set(BULLET_INCLUDE_DIRS ${BULLET_INCLUDE_DIR})
|
||||
if(BULLET_FOUND)
|
||||
_BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_DYNAMICS_LIBRARY)
|
||||
_BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_COLLISION_LIBRARY)
|
||||
_BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_MATH_LIBRARY)
|
||||
_BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_SOFTBODY_LIBRARY)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -18,8 +18,7 @@ include("${MACRO_DIR}/HifiLibrarySearchHints.cmake")
|
|||
hifi_library_search_hints("glm")
|
||||
|
||||
# locate header
|
||||
find_path(GLM_INCLUDE_DIR "glm/glm.hpp" HINTS ${GLM_SEARCH_DIRS})
|
||||
set(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}")
|
||||
find_path(GLM_INCLUDE_DIRS "glm/glm.hpp" HINTS ${GLM_SEARCH_DIRS})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(GLM DEFAULT_MSG GLM_INCLUDE_DIRS)
|
||||
|
|
|
@ -15,25 +15,11 @@
|
|||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
|
||||
if (GVERB_INCLUDE_DIRS)
|
||||
# in cache already
|
||||
set(GVERB_FOUND TRUE)
|
||||
else (GVERB_INCLUDE_DIRS)
|
||||
include("${MACRO_DIR}/HifiLibrarySearchHints.cmake")
|
||||
hifi_library_search_hints("gverb")
|
||||
|
||||
include("${MACRO_DIR}/HifiLibrarySearchHints.cmake")
|
||||
hifi_library_search_hints("gverb")
|
||||
find_path(GVERB_INCLUDE_DIRS gverb.h PATH_SUFFIXES include HINTS ${GVERB_SEARCH_DIRS})
|
||||
find_library(GVERB_LIBRARIES gverb PATH_SUFFIXES lib HINTS ${GVERB_SEARCH_DIRS})
|
||||
|
||||
find_path(GVERB_INCLUDE_DIRS gverb.h PATH_SUFFIXES include HINTS ${GVERB_SEARCH_DIRS})
|
||||
find_path(GVERB_SRC_DIRS gverb.c PATH_SUFFIXES src HINTS ${GVERB_SEARCH_DIRS})
|
||||
|
||||
if (GVERB_INCLUDE_DIRS)
|
||||
set(GVERB_FOUND TRUE)
|
||||
endif (GVERB_INCLUDE_DIRS)
|
||||
|
||||
if (GVERB_FOUND)
|
||||
message(STATUS "Found Gverb: ${GVERB_INCLUDE_DIRS}")
|
||||
else (GVERB_FOUND)
|
||||
message(FATAL_ERROR "Could NOT find Gverb. Read ./interface/externals/gverb/readme.txt")
|
||||
endif (GVERB_FOUND)
|
||||
|
||||
endif(GVERB_INCLUDE_DIRS)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(GVERB DEFAULT_MSG GVERB_INCLUDE_DIRS GVERB_LIBRARIES)
|
|
@ -21,42 +21,60 @@
|
|||
include("${MACRO_DIR}/HifiLibrarySearchHints.cmake")
|
||||
hifi_library_search_hints("libovr")
|
||||
|
||||
find_path(LIBOVR_INCLUDE_DIRS OVR.h PATH_SUFFIXES Include HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
find_path(LIBOVR_SRC_DIR Util_Render_Stereo.h PATH_SUFFIXES Src/Util HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
|
||||
include(SelectLibraryConfigurations)
|
||||
|
||||
if (APPLE)
|
||||
find_library(LIBOVR_LIBRARY_DEBUG NAMES ovr PATH_SUFFIXES Lib/Mac/Debug HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
find_library(LIBOVR_LIBRARY_RELEASE NAMES ovr PATH_SUFFIXES Lib/Mac/Release HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
find_library(ApplicationServices ApplicationServices)
|
||||
find_library(IOKit IOKit)
|
||||
elseif (UNIX)
|
||||
find_library(UDEV_LIBRARY_RELEASE udev /usr/lib/x86_64-linux-gnu/)
|
||||
find_library(XINERAMA_LIBRARY_RELEASE Xinerama /usr/lib/x86_64-linux-gnu/)
|
||||
if (NOT ANDROID)
|
||||
|
||||
find_path(LIBOVR_INCLUDE_DIRS OVR.h PATH_SUFFIXES Include HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
find_path(LIBOVR_SRC_DIR Util_Render_Stereo.h PATH_SUFFIXES Src/Util HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
|
||||
if (CMAKE_CL_64)
|
||||
set(LINUX_ARCH_DIR "i386")
|
||||
else()
|
||||
set(LINUX_ARCH_DIR "x86_64")
|
||||
endif()
|
||||
if (APPLE)
|
||||
find_library(LIBOVR_LIBRARY_DEBUG NAMES ovr PATH_SUFFIXES Lib/Mac/Debug HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
find_library(LIBOVR_LIBRARY_RELEASE NAMES ovr PATH_SUFFIXES Lib/Mac/Release HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
find_library(ApplicationServices ApplicationServices)
|
||||
find_library(IOKit IOKit)
|
||||
elseif (UNIX)
|
||||
find_library(UDEV_LIBRARY_RELEASE udev /usr/lib/x86_64-linux-gnu/)
|
||||
find_library(XINERAMA_LIBRARY_RELEASE Xinerama /usr/lib/x86_64-linux-gnu/)
|
||||
|
||||
find_library(LIBOVR_LIBRARY_DEBUG NAMES ovr PATH_SUFFIXES Lib/Linux/Debug/${LINUX_ARCH_DIR} HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
find_library(LIBOVR_LIBRARY_RELEASE NAMES ovr PATH_SUFFIXES Lib/Linux/Release/${LINUX_ARCH_DIR} HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
if (CMAKE_CL_64)
|
||||
set(LINUX_ARCH_DIR "i386")
|
||||
else()
|
||||
set(LINUX_ARCH_DIR "x86_64")
|
||||
endif()
|
||||
|
||||
select_library_configurations(UDEV)
|
||||
select_library_configurations(XINERAMA)
|
||||
find_library(LIBOVR_LIBRARY_DEBUG NAMES ovr PATH_SUFFIXES Lib/Linux/Debug/${LINUX_ARCH_DIR} HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
find_library(LIBOVR_LIBRARY_RELEASE NAMES ovr PATH_SUFFIXES Lib/Linux/Release/${LINUX_ARCH_DIR} HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
|
||||
elseif (WIN32)
|
||||
if (MSVC10)
|
||||
find_library(LIBOVR_LIBRARY_DEBUG NAMES libovrd PATH_SUFFIXES Lib/Win32/VS2010 HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
find_library(LIBOVR_LIBRARY_RELEASE NAMES libovr PATH_SUFFIXES Lib/Win32/VS2010 HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
elseif (MSVC12)
|
||||
find_library(LIBOVR_LIBRARY_DEBUG NAMES libovrd PATH_SUFFIXES Lib/Win32/VS2013 HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
find_library(LIBOVR_LIBRARY_RELEASE NAMES libovr PATH_SUFFIXES Lib/Win32/VS2013 HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
select_library_configurations(UDEV)
|
||||
select_library_configurations(XINERAMA)
|
||||
|
||||
elseif (WIN32)
|
||||
if (MSVC10)
|
||||
find_library(LIBOVR_LIBRARY_DEBUG NAMES libovrd PATH_SUFFIXES Lib/Win32/VS2010 HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
find_library(LIBOVR_LIBRARY_RELEASE NAMES libovr PATH_SUFFIXES Lib/Win32/VS2010 HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
elseif (MSVC12)
|
||||
find_library(LIBOVR_LIBRARY_DEBUG NAMES libovrd PATH_SUFFIXES Lib/Win32/VS2013 HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
find_library(LIBOVR_LIBRARY_RELEASE NAMES libovr PATH_SUFFIXES Lib/Win32/VS2013 HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
endif ()
|
||||
find_package(ATL)
|
||||
endif ()
|
||||
find_package(ATL)
|
||||
endif ()
|
||||
|
||||
else (NOT ANDROID)
|
||||
set(_VRLIB_JNI_DIR "VRLib/jni")
|
||||
set(_VRLIB_LIBS_DIR "VRLib/obj/local/armeabi-v7a")
|
||||
|
||||
find_path(LIBOVR_VRLIB_DIR VRLib.vcxproj PATH_SUFFIXES VRLib HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
|
||||
find_path(LIBOVR_INCLUDE_DIRS OVR.h PATH_SUFFIXES ${_VRLIB_JNI_DIR}/LibOVR/Include HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
find_path(LIBOVR_SRC_DIR OVR_CAPI.h PATH_SUFFIXES ${_VRLIB_JNI_DIR}/LibOVR/Src HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
|
||||
find_path(MINIZIP_DIR minizip.c PATH_SUFFIXES ${_VRLIB_JNI_DIR}/3rdParty/minizip HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
find_path(JNI_DIR VrCommon.h PATH_SUFFIXES ${_VRLIB_JNI_DIR} HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
|
||||
find_library(LIBOVR_LIBRARY_RELEASE NAMES oculus PATH_SUFFIXES ${_VRLIB_LIBS_DIR} HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
find_library(TURBOJPEG_LIBRARY NAMES jpeg PATH_SUFFIXES 3rdParty/turbojpeg HINTS ${LIBOVR_SEARCH_DIRS})
|
||||
endif (NOT ANDROID)
|
||||
|
||||
select_library_configurations(LIBOVR)
|
||||
set(LIBOVR_LIBRARIES ${LIBOVR_LIBRARY})
|
||||
|
@ -66,6 +84,10 @@ list(APPEND LIBOVR_ARGS_LIST LIBOVR_INCLUDE_DIRS LIBOVR_SRC_DIR LIBOVR_LIBRARY)
|
|||
if (APPLE)
|
||||
list(APPEND LIBOVR_LIBRARIES ${IOKit} ${ApplicationServices})
|
||||
list(APPEND LIBOVR_ARGS_LIST IOKit ApplicationServices)
|
||||
elseif (ANDROID)
|
||||
|
||||
list(APPEND LIBOVR_ANDROID_LIBRARIES "-lGLESv3" "-lEGL" "-landroid" "-lOpenMAXAL" "-llog" "-lz" "-lOpenSLES")
|
||||
list(APPEND LIBOVR_ARGS_LIST LIBOVR_ANDROID_LIBRARIES LIBOVR_VRLIB_DIR MINIZIP_DIR JNI_DIR TURBOJPEG_LIBRARY)
|
||||
elseif (UNIX)
|
||||
list(APPEND LIBOVR_LIBRARIES "${UDEV_LIBRARY}" "${XINERAMA_LIBRARY}")
|
||||
list(APPEND LIBOVR_ARGS_LIST UDEV_LIBRARY XINERAMA_LIBRARY)
|
||||
|
@ -75,7 +97,10 @@ elseif (WIN32)
|
|||
endif ()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(LibOVR DEFAULT_MSG ${LIBOVR_ARGS_LIST})
|
||||
|
||||
if (ANDROID)
|
||||
list(APPEND LIBOVR_INCLUDE_DIRS ${LIBOVR_SRC_DIR} ${MINIZIP_DIR} ${JNI_DIR})
|
||||
endif ()
|
||||
|
||||
mark_as_advanced(LIBOVR_INCLUDE_DIRS LIBOVR_LIBRARIES LIBOVR_SEARCH_DIRS)
|
||||
|
|
|
@ -52,7 +52,9 @@ else ()
|
|||
set(_OPENSSL_ROOT_HINTS_AND_PATHS ${OPENSSL_SEARCH_DIRS})
|
||||
endif ()
|
||||
|
||||
find_path(OPENSSL_INCLUDE_DIR NAMES openssl/ssl.h HINTS ${_OPENSSL_ROOT_HINTS_AND_PATHS} ${_OPENSSL_INCLUDEDIR} PATH_SUFFIXES include)
|
||||
find_path(OPENSSL_INCLUDE_DIR NAMES openssl/ssl.h HINTS ${_OPENSSL_ROOT_HINTS_AND_PATHS} ${_OPENSSL_INCLUDEDIR}
|
||||
PATH_SUFFIXES include
|
||||
)
|
||||
|
||||
if (WIN32 AND NOT CYGWIN)
|
||||
if (MSVC)
|
||||
|
@ -133,7 +135,9 @@ else()
|
|||
PATH_SUFFIXES lib
|
||||
)
|
||||
|
||||
find_library(OPENSSL_CRYPTO_LIBRARY NAMES crypto HINTS ${_OPENSSL_ROOT_HINTS_AND_PATHS} ${_OPENSSL_LIBDIR} PATH_SUFFIXES lib)
|
||||
find_library(OPENSSL_CRYPTO_LIBRARY NAMES crypto HINTS ${_OPENSSL_ROOT_HINTS_AND_PATHS} ${_OPENSSL_LIBDIR}
|
||||
PATH_SUFFIXES lib
|
||||
)
|
||||
|
||||
mark_as_advanced(OPENSSL_CRYPTO_LIBRARY OPENSSL_SSL_LIBRARY)
|
||||
|
||||
|
@ -179,8 +183,8 @@ endfunction()
|
|||
if (OPENSSL_INCLUDE_DIR)
|
||||
if(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h")
|
||||
file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" openssl_version_str
|
||||
REGEX "^#define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])+.*")
|
||||
|
||||
REGEX "^#[ ]?define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])+.*")
|
||||
|
||||
# The version number is encoded as 0xMNNFFPPS: major minor fix patch status
|
||||
# The status gives if this is a developer or prerelease and is ignored here.
|
||||
# Major, minor, and fix directly translate into the version numbers shown in
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# FindRtMidd.cmake
|
||||
# FindRtMidi.cmake
|
||||
#
|
||||
# Try to find the RtMidi library
|
||||
#
|
||||
|
|
30
cmake/modules/FindSoxr.cmake
Normal file
30
cmake/modules/FindSoxr.cmake
Normal file
|
@ -0,0 +1,30 @@
|
|||
#
|
||||
# FindSoxr.cmake
|
||||
#
|
||||
# Try to find the libsoxr resampling library
|
||||
#
|
||||
# You can provide a LIBSOXR_ROOT_DIR which contains lib and include directories
|
||||
#
|
||||
# Once done this will define
|
||||
#
|
||||
# SOXR_FOUND - system found libsoxr
|
||||
# SOXR_INCLUDE_DIRS - the libsoxr include directory
|
||||
# SOXR_LIBRARIES - link to this to use libsoxr
|
||||
#
|
||||
# Created on 1/22/2015 by Stephen Birarda
|
||||
# Copyright 2015 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
|
||||
#
|
||||
|
||||
include("${MACRO_DIR}/HifiLibrarySearchHints.cmake")
|
||||
hifi_library_search_hints("soxr")
|
||||
|
||||
find_path(SOXR_INCLUDE_DIRS soxr.h PATH_SUFFIXES include HINTS ${SOXR_SEARCH_DIRS})
|
||||
find_library(SOXR_LIBRARIES NAMES soxr PATH_SUFFIXES lib HINTS ${SOXR_SEARCH_DIRS})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(SOXR DEFAULT_MSG SOXR_INCLUDE_DIRS SOXR_LIBRARIES)
|
||||
|
||||
mark_as_advanced(SOXR_INCLUDE_DIRS SOXR_LIBRARIES SOXR_SEARCH_DIRS)
|
|
@ -28,7 +28,7 @@ set(_TBB_LIB_MALLOC_NAME "${_TBB_LIB_NAME}malloc")
|
|||
|
||||
if (APPLE)
|
||||
set(_TBB_LIB_DIR "lib/libc++")
|
||||
elseif (UNIX)
|
||||
elseif (UNIX AND NOT ANDROID)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(_TBB_ARCH_DIR "intel64")
|
||||
else()
|
||||
|
@ -56,6 +56,13 @@ elseif (WIN32)
|
|||
endif()
|
||||
|
||||
set(_TBB_LIB_DIR "lib/${_TBB_ARCH_DIR}/vc12")
|
||||
elseif (ANDROID)
|
||||
set(_TBB_DEFAULT_INSTALL_DIR "/tbb")
|
||||
set(_TBB_LIB_NAME "tbb")
|
||||
set(_TBB_LIB_DIR "lib")
|
||||
set(_TBB_LIB_MALLOC_NAME "${_TBB_LIB_NAME}malloc")
|
||||
set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_NAME}_debug")
|
||||
set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_NAME}_debug")
|
||||
endif ()
|
||||
|
||||
find_library(TBB_LIBRARY_DEBUG NAMES ${_TBB_LIB_NAME}_debug PATH_SUFFIXES ${_TBB_LIB_DIR} HINTS ${TBB_SEARCH_DIRS})
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
{
|
||||
"name": "access_token",
|
||||
"label": "Access Token",
|
||||
"help": "This is an access token generated on the <a href='https://data.highfidelity.io/user/security' target='_blank'>My Security</a> page of your High Fidelity account.<br/>Generate a token with the 'domains' scope and paste it here.<br/>This is required to associate this domain-server with a domain in your account."
|
||||
"help": "This is an access token generated on the <a href='https://metaverse.highfidelity.io/user/security' target='_blank'>My Security</a> page of your High Fidelity account.<br/>Generate a token with the 'domains' scope and paste it here.<br/>This is required to associate this domain-server with a domain in your account."
|
||||
},
|
||||
{
|
||||
"name": "id",
|
||||
|
@ -30,7 +30,7 @@
|
|||
},
|
||||
{
|
||||
"value": "disabled",
|
||||
"label": "None: use the network information I have entered for this domain at data.highfidelity.io"
|
||||
"label": "None: use the network information I have entered for this domain at metaverse.highfidelity.io"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -73,6 +73,20 @@
|
|||
"can_set": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "allowed_editors",
|
||||
"type": "table",
|
||||
"label": "Allowed Editors",
|
||||
"help": "List the High Fidelity names for people you want to be able lock or unlock entities in this domain.<br/>An empty list means everyone.",
|
||||
"numbered": false,
|
||||
"columns": [
|
||||
{
|
||||
"name": "username",
|
||||
"label": "Username",
|
||||
"can_set": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -395,6 +409,13 @@
|
|||
"default": "",
|
||||
"advanced": true
|
||||
},
|
||||
{
|
||||
"name": "wantEditLogging",
|
||||
"type": "checkbox",
|
||||
"help": "Logging of all edits to entities",
|
||||
"default": true,
|
||||
"advanced": true
|
||||
},
|
||||
{
|
||||
"name": "verboseDebug",
|
||||
"type": "checkbox",
|
||||
|
@ -433,4 +454,4 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
|
|
|
@ -652,7 +652,7 @@ function chooseFromHighFidelityDomains(clickedButton) {
|
|||
clickedButton.attr('disabled', 'disabled')
|
||||
|
||||
// get a list of user domains from data-web
|
||||
data_web_domains_url = "https://data.highfidelity.io/api/v1/domains?access_token="
|
||||
data_web_domains_url = "https://metaverse.highfidelity.io/api/v1/domains?access_token="
|
||||
$.getJSON(data_web_domains_url + Settings.initialValues.metaverse.access_token, function(data){
|
||||
|
||||
modal_buttons = {
|
||||
|
@ -682,7 +682,7 @@ function chooseFromHighFidelityDomains(clickedButton) {
|
|||
modal_buttons["success"] = {
|
||||
label: 'Create new domain',
|
||||
callback: function() {
|
||||
window.open("https://data.highfidelity.io/user/domains", '_blank');
|
||||
window.open("https://metaverse.highfidelity.io/user/domains", '_blank');
|
||||
}
|
||||
}
|
||||
modal_body = "<p>You do not have any domains in your High Fidelity account." +
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <HTTPConnection.h>
|
||||
#include <LogUtils.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <ShutdownEventListener.h>
|
||||
#include <UUID.h>
|
||||
|
@ -41,6 +41,11 @@ int const DomainServer::EXIT_CODE_REBOOT = 234923;
|
|||
|
||||
const QString ICE_SERVER_DEFAULT_HOSTNAME = "ice.highfidelity.io";
|
||||
|
||||
|
||||
const QString ALLOWED_USERS_SETTINGS_KEYPATH = "security.allowed_users";
|
||||
const QString ALLOWED_EDITORS_SETTINGS_KEYPATH = "security.allowed_editors";
|
||||
|
||||
|
||||
DomainServer::DomainServer(int argc, char* argv[]) :
|
||||
QCoreApplication(argc, argv),
|
||||
_httpManager(DOMAIN_SERVER_HTTP_PORT, QString("%1/resources/web/").arg(QCoreApplication::applicationDirPath()), this),
|
||||
|
@ -638,10 +643,16 @@ void DomainServer::handleConnectRequest(const QByteArray& packet, const HifiSock
|
|||
// we got a packetUUID we didn't recognize, just add the node
|
||||
nodeUUID = QUuid::createUuid();
|
||||
}
|
||||
|
||||
|
||||
SharedNodePointer newNode = DependencyManager::get<LimitedNodeList>()->addOrUpdateNode(nodeUUID, nodeType,
|
||||
publicSockAddr, localSockAddr);
|
||||
// if this user is in the editors list (or if the editors list is empty) set the user's node's canAdjustLocks to true
|
||||
const QVariant* allowedEditorsVariant =
|
||||
valueForKeyPath(_settingsManager.getSettingsMap(), ALLOWED_EDITORS_SETTINGS_KEYPATH);
|
||||
QStringList allowedEditors = allowedEditorsVariant ? allowedEditorsVariant->toStringList() : QStringList();
|
||||
bool canAdjustLocks = allowedEditors.isEmpty() || allowedEditors.contains(username);
|
||||
|
||||
SharedNodePointer newNode =
|
||||
DependencyManager::get<LimitedNodeList>()->addOrUpdateNode(nodeUUID, nodeType,
|
||||
publicSockAddr, localSockAddr, canAdjustLocks);
|
||||
// when the newNode is created the linked data is also created
|
||||
// if this was a static assignment set the UUID, set the sendingSockAddr
|
||||
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(newNode->getLinkedData());
|
||||
|
@ -663,7 +674,6 @@ void DomainServer::handleConnectRequest(const QByteArray& packet, const HifiSock
|
|||
}
|
||||
}
|
||||
|
||||
const QString ALLOWED_USERS_SETTINGS_KEYPATH = "security.allowed_users";
|
||||
|
||||
bool DomainServer::shouldAllowConnectionFromNode(const QString& username,
|
||||
const QByteArray& usernameSignature,
|
||||
|
@ -842,6 +852,7 @@ void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const Hif
|
|||
// always send the node their own UUID back
|
||||
QDataStream broadcastDataStream(&broadcastPacket, QIODevice::Append);
|
||||
broadcastDataStream << node->getUUID();
|
||||
broadcastDataStream << node->getCanAdjustLocks();
|
||||
|
||||
int numBroadcastPacketLeadBytes = broadcastDataStream.device()->pos();
|
||||
|
||||
|
@ -906,10 +917,10 @@ void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const Hif
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
// always write the last broadcastPacket
|
||||
nodeList->writeDatagram(broadcastPacket, node, senderSockAddr);
|
||||
}
|
||||
|
||||
// always write the last broadcastPacket
|
||||
nodeList->writeDatagram(broadcastPacket, node, senderSockAddr);
|
||||
}
|
||||
|
||||
void DomainServer::readAvailableDatagrams() {
|
||||
|
@ -1925,7 +1936,7 @@ Headers DomainServer::setupCookieHeadersFromProfileReply(QNetworkReply* profileR
|
|||
|
||||
// persist the cookie to settings file so we can get it back on DS relaunch
|
||||
QStringList path = QStringList() << DS_SETTINGS_SESSIONS_GROUP << cookieUUID.toString();
|
||||
SettingHandles::SettingHandle<QVariant>(path).set(QVariant::fromValue(sessionData));
|
||||
Setting::Handle<QVariant>(path).set(QVariant::fromValue(sessionData));
|
||||
|
||||
// setup expiry for cookie to 1 month from today
|
||||
QDateTime cookieExpiry = QDateTime::currentDateTimeUtc().addMonths(1);
|
||||
|
|
|
@ -32,10 +32,4 @@ Script.update.connect(function() {
|
|||
injector = Audio.playSound(sound, audioOptions);
|
||||
print("Playing: " + injector);
|
||||
}
|
||||
});
|
||||
|
||||
Script.scriptEnding.connect(function() {
|
||||
if (injector !== null) {
|
||||
injector.stop();
|
||||
}
|
||||
});
|
|
@ -85,10 +85,10 @@ function checkHands(deltaTime) {
|
|||
var chord = Controller.getTriggerValue(chordHand);
|
||||
|
||||
if (volume > 1.0) volume = 1.0;
|
||||
if ((chord > 0.1) && Audio.isInjectorPlaying(soundPlaying)) {
|
||||
if ((chord > 0.1) && soundPlaying.isPlaying) {
|
||||
// If chord finger trigger pulled, stop current chord
|
||||
print("stopped sound");
|
||||
Audio.stopInjector(soundPlaying);
|
||||
soundPlaying.stop();
|
||||
}
|
||||
|
||||
var BUTTON_COUNT = 6;
|
||||
|
@ -132,16 +132,21 @@ function checkHands(deltaTime) {
|
|||
}
|
||||
|
||||
function playChord(position, volume) {
|
||||
if (Audio.isInjectorPlaying(soundPlaying)) {
|
||||
if (soundPlaying.isPlaying) {
|
||||
print("stopped sound");
|
||||
Audio.stopInjector(soundPlaying);
|
||||
soundPlaying.stop();
|
||||
}
|
||||
|
||||
print("Played sound: " + whichChord + " at volume " + options.volume);
|
||||
soundPlaying = Audio.playSound(chords[guitarSelector + whichChord], {
|
||||
position: position,
|
||||
volume: volume
|
||||
});
|
||||
if (!soundPlaying) {
|
||||
soundPlaying = Audio.playSound(chords[guitarSelector + whichChord], {
|
||||
position: position,
|
||||
volume: volume
|
||||
});
|
||||
} else {
|
||||
soundPlaying.restart();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function keyPressEvent(event) {
|
||||
|
|
248
examples/controllers/oculus/goTo.js
Normal file
248
examples/controllers/oculus/goTo.js
Normal file
|
@ -0,0 +1,248 @@
|
|||
//
|
||||
// goTo.js
|
||||
// examples
|
||||
//
|
||||
// Created by Thijs Wenker on 12/28/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Control a virtual keyboard using your favorite HMD.
|
||||
// Usage: Enable VR-mode and go to First person mode,
|
||||
// look at the key that you would like to press, and press the spacebar on your "REAL" keyboard.
|
||||
//
|
||||
// Enter a location URL using your HMD. Press Enter to pop-up the virtual keyboard and location input.
|
||||
// Press Space on the keyboard or the X button on your gamepad to press a key that you have selected.
|
||||
//
|
||||
// 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/virtualKeyboard.js");
|
||||
|
||||
const MAX_SHOW_INSTRUCTION_TIMES = 2;
|
||||
const INSTRUCTIONS_SETTING = "GoToInstructionsShowCounter"
|
||||
|
||||
var windowDimensions = Controller.getViewportDimensions();
|
||||
|
||||
function Instructions(imageURL, originalWidth, originalHeight) {
|
||||
var tthis = this;
|
||||
this.originalSize = {w: originalWidth, h: originalHeight};
|
||||
this.visible = false;
|
||||
this.overlay = Overlays.addOverlay("image", {
|
||||
imageURL: imageURL,
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: originalWidth,
|
||||
height: originalHeight,
|
||||
alpha: 1,
|
||||
visible: this.visible
|
||||
});
|
||||
|
||||
this.show = function() {
|
||||
var timesShown = Settings.getValue(INSTRUCTIONS_SETTING);
|
||||
timesShown = timesShown === "" ? 0 : parseInt(timesShown);
|
||||
print(timesShown);
|
||||
if (timesShown < MAX_SHOW_INSTRUCTION_TIMES) {
|
||||
Settings.setValue(INSTRUCTIONS_SETTING, timesShown + 1);
|
||||
tthis.visible = true;
|
||||
tthis.rescale();
|
||||
Overlays.editOverlay(tthis.overlay, {visible: tthis.visible});
|
||||
return;
|
||||
}
|
||||
tthis.remove();
|
||||
}
|
||||
|
||||
this.remove = function() {
|
||||
Overlays.deleteOverlay(tthis.overlay);
|
||||
tthis.visible = false;
|
||||
};
|
||||
|
||||
this.rescale = function() {
|
||||
var scale = Math.min(windowDimensions.x / tthis.originalSize.w, windowDimensions.y / tthis.originalSize.h);
|
||||
var newWidth = tthis.originalSize.w * scale;
|
||||
var newHeight = tthis.originalSize.h * scale;
|
||||
Overlays.editOverlay(tthis.overlay, {
|
||||
x: (windowDimensions.x / 2) - (newWidth / 2),
|
||||
y: (windowDimensions.y / 2) - (newHeight / 2),
|
||||
width: newWidth,
|
||||
height: newHeight
|
||||
});
|
||||
};
|
||||
this.rescale();
|
||||
};
|
||||
|
||||
var theInstruction = new Instructions(HIFI_PUBLIC_BUCKET + "images/tutorial-goTo.svg", 457, 284.1);
|
||||
|
||||
var firstControllerPlugged = false;
|
||||
|
||||
|
||||
var cursor = new Cursor({visible: false});
|
||||
var keyboard = new Keyboard({visible: false});
|
||||
var textFontSize = 9;
|
||||
var text = null;
|
||||
var locationURL = "";
|
||||
|
||||
function appendChar(char) {
|
||||
locationURL += char;
|
||||
updateTextOverlay();
|
||||
Overlays.editOverlay(text, {text: locationURL});
|
||||
}
|
||||
|
||||
function deleteChar() {
|
||||
if (locationURL.length > 0) {
|
||||
locationURL = locationURL.substring(0, locationURL.length - 1);
|
||||
updateTextOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
function updateTextOverlay() {
|
||||
var maxLineWidth = Overlays.textSize(text, locationURL).width;
|
||||
var suggestedFontSize = (windowDimensions.x / maxLineWidth) * textFontSize * 0.90;
|
||||
var maxFontSize = 140;
|
||||
textFontSize = (suggestedFontSize > maxFontSize) ? maxFontSize : suggestedFontSize;
|
||||
var topMargin = (250 - textFontSize) / 4;
|
||||
Overlays.editOverlay(text, {text: locationURL, font: {size: textFontSize}, topMargin: topMargin, visible: keyboard.visible});
|
||||
maxLineWidth = Overlays.textSize(text, locationURL).width;
|
||||
Overlays.editOverlay(text, {leftMargin: (windowDimensions.x - maxLineWidth) / 2});
|
||||
}
|
||||
|
||||
keyboard.onKeyPress = function(event) {
|
||||
if (event.event == 'keypress') {
|
||||
appendChar(event.char);
|
||||
}
|
||||
};
|
||||
|
||||
keyboard.onKeyRelease = function(event) {
|
||||
// you can cancel a key by releasing its focusing before releasing it
|
||||
if (event.focus) {
|
||||
if (event.event == 'delete') {
|
||||
deleteChar();
|
||||
} else if (event.event == 'submit' || event.event == 'enter') {
|
||||
print("going to hifi://" + locationURL);
|
||||
location = "hifi://" + locationURL;
|
||||
locationURL = "";
|
||||
keyboard.hide();
|
||||
cursor.hide();
|
||||
updateTextOverlay();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
keyboard.onFullyLoaded = function() {
|
||||
print("Virtual-keyboard fully loaded.");
|
||||
var dimensions = Controller.getViewportDimensions();
|
||||
text = Overlays.addOverlay("text", {
|
||||
x: 0,
|
||||
y: dimensions.y - keyboard.height() - 260,
|
||||
width: dimensions.x,
|
||||
height: 250,
|
||||
backgroundColor: { red: 255, green: 255, blue: 255},
|
||||
color: { red: 0, green: 0, blue: 0},
|
||||
topMargin: 5,
|
||||
leftMargin: 0,
|
||||
font: {size: textFontSize},
|
||||
text: "",
|
||||
alpha: 0.8,
|
||||
visible: keyboard.visible
|
||||
});
|
||||
updateTextOverlay();
|
||||
// the cursor is being loaded after the keyboard, else it will be on the background of the keyboard
|
||||
cursor.initialize();
|
||||
cursor.updateVisibility(keyboard.visible);
|
||||
cursor.onUpdate = function(position) {
|
||||
keyboard.setFocusPosition(position.x, position.y);
|
||||
};
|
||||
};
|
||||
|
||||
function keyPressEvent(event) {
|
||||
if (theInstruction.visible) {
|
||||
return;
|
||||
}
|
||||
if (event.key === SPACEBAR_CHARCODE) {
|
||||
keyboard.pressFocussedKey();
|
||||
} else if (event.key === ENTER_CHARCODE || event.key === RETURN_CHARCODE) {
|
||||
keyboard.toggle();
|
||||
if (cursor !== undefined) {
|
||||
cursor.updateVisibility(keyboard.visible);
|
||||
}
|
||||
Overlays.editOverlay(text, {visible: keyboard.visible});
|
||||
}
|
||||
}
|
||||
|
||||
function keyReleaseEvent(event) {
|
||||
if (theInstruction.visible) {
|
||||
return;
|
||||
}
|
||||
if (event.key === SPACEBAR_CHARCODE) {
|
||||
keyboard.releaseKeys();
|
||||
}
|
||||
}
|
||||
|
||||
function scriptEnding() {
|
||||
keyboard.remove();
|
||||
cursor.remove();
|
||||
Overlays.deleteOverlay(text);
|
||||
Overlays.deleteOverlay(textSizeMeasureOverlay);
|
||||
Controller.releaseKeyEvents({key: SPACEBAR_CHARCODE});
|
||||
Controller.releaseKeyEvents({key: RETURN_CHARCODE});
|
||||
Controller.releaseKeyEvents({key: ENTER_CHARCODE});
|
||||
theInstruction.remove();
|
||||
}
|
||||
|
||||
function reportButtonValue(button, newValue, oldValue) {
|
||||
if (theInstruction.visible) {
|
||||
if (button == Joysticks.BUTTON_FACE_BOTTOM && newValue) {
|
||||
theInstruction.remove();
|
||||
}
|
||||
} else if (button == Joysticks.BUTTON_FACE_BOTTOM) {
|
||||
if (newValue) {
|
||||
keyboard.pressFocussedKey();
|
||||
} else {
|
||||
keyboard.releaseKeys();
|
||||
}
|
||||
} else if (button == Joysticks.BUTTON_FACE_RIGHT && newValue) {
|
||||
deleteChar();
|
||||
} else if (button == Joysticks.BUTTON_FACE_LEFT && newValue) {
|
||||
keyboard.hide();
|
||||
if (cursor !== undefined) {
|
||||
cursor.hide();
|
||||
}
|
||||
Overlays.editOverlay(text, {visible: false});
|
||||
} else if (button == Joysticks.BUTTON_RIGHT_SHOULDER && newValue) {
|
||||
if (keyboard.visible) {
|
||||
print("going to hifi://" + locationURL);
|
||||
location = "hifi://" + locationURL;
|
||||
locationURL = "";
|
||||
keyboard.hide();
|
||||
cursor.hide();
|
||||
updateTextOverlay();
|
||||
return;
|
||||
}
|
||||
keyboard.show();
|
||||
if (cursor !== undefined) {
|
||||
cursor.show();
|
||||
}
|
||||
Overlays.editOverlay(text, {visible: true});
|
||||
}
|
||||
}
|
||||
|
||||
function addJoystick(gamepad) {
|
||||
gamepad.buttonStateChanged.connect(reportButtonValue);
|
||||
if (!firstControllerPlugged) {
|
||||
firstControllerPlugged = true;
|
||||
theInstruction.show();
|
||||
}
|
||||
}
|
||||
|
||||
var allJoysticks = Joysticks.getAllJoysticks();
|
||||
for (var i = 0; i < allJoysticks.length; i++) {
|
||||
addJoystick(allJoysticks[i]);
|
||||
}
|
||||
|
||||
Joysticks.joystickAdded.connect(addJoystick);
|
||||
Controller.captureKeyEvents({key: RETURN_CHARCODE});
|
||||
Controller.captureKeyEvents({key: ENTER_CHARCODE});
|
||||
Controller.captureKeyEvents({key: SPACEBAR_CHARCODE});
|
||||
Controller.keyPressEvent.connect(keyPressEvent);
|
||||
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
||||
Script.scriptEnding.connect(scriptEnding);
|
183
examples/controllers/oculus/virtualKeyboardTextEntityExample.js
Normal file
183
examples/controllers/oculus/virtualKeyboardTextEntityExample.js
Normal file
|
@ -0,0 +1,183 @@
|
|||
//
|
||||
// virtualKeyboardTextEntityExample.js
|
||||
// examples
|
||||
//
|
||||
// Created by Thijs Wenker on 12/28/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Control a virtual keyboard using your favorite HMD.
|
||||
// Usage: Enable VR-mode and go to First person mode,
|
||||
// look at the key that you would like to press, and press the spacebar on your "REAL" keyboard.
|
||||
//
|
||||
// leased some code from newEditEntities.js for Text Entity example
|
||||
//
|
||||
// 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/virtualKeyboard.js");
|
||||
|
||||
const SPAWN_DISTANCE = 1;
|
||||
const DEFAULT_TEXT_DIMENSION_Z = 0.02;
|
||||
|
||||
const TEXT_MARGIN_TOP = 0.15;
|
||||
const TEXT_MARGIN_LEFT = 0.15;
|
||||
const TEXT_MARGIN_RIGHT = 0.17;
|
||||
const TEXT_MARGIN_BOTTOM = 0.17;
|
||||
|
||||
var windowDimensions = Controller.getViewportDimensions();
|
||||
var cursor = new Cursor();
|
||||
var keyboard = new Keyboard();
|
||||
var textFontSize = 9;
|
||||
var text = null;
|
||||
var textText = "";
|
||||
var textSizeMeasureOverlay = Overlays.addOverlay("text3d", {visible: false});
|
||||
|
||||
function appendChar(char) {
|
||||
textText += char;
|
||||
updateTextOverlay();
|
||||
Overlays.editOverlay(text, {text: textText});
|
||||
}
|
||||
|
||||
function deleteChar() {
|
||||
if (textText.length > 0) {
|
||||
textText = textText.substring(0, textText.length - 1);
|
||||
updateTextOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
function updateTextOverlay() {
|
||||
var textLines = textText.split("\n");
|
||||
var suggestedFontSize = (windowDimensions.x / Overlays.textSize(text, textText).width) * textFontSize * 0.90;
|
||||
var maxFontSize = 170 / textLines.length;
|
||||
textFontSize = (suggestedFontSize > maxFontSize) ? maxFontSize : suggestedFontSize;
|
||||
var topMargin = (250 - (textFontSize * textLines.length)) / 4;
|
||||
Overlays.editOverlay(text, {text: textText, font: {size: textFontSize}, topMargin: topMargin});
|
||||
Overlays.editOverlay(text, {leftMargin: (windowDimensions.x - Overlays.textSize(text, textLines).width) / 2});
|
||||
}
|
||||
|
||||
keyboard.onKeyPress = function(event) {
|
||||
if (event.event == 'keypress') {
|
||||
appendChar(event.char);
|
||||
} else if (event.event == 'enter') {
|
||||
appendChar("\n");
|
||||
}
|
||||
};
|
||||
|
||||
keyboard.onKeyRelease = function(event) {
|
||||
print("Key release event test");
|
||||
// you can cancel a key by releasing its focusing before releasing it
|
||||
if (event.focus) {
|
||||
if (event.event == 'delete') {
|
||||
deleteChar();
|
||||
} else if (event.event == 'submit') {
|
||||
print(textText);
|
||||
|
||||
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
|
||||
|
||||
var textLines = textText.split("\n");
|
||||
var maxLineWidth = Overlays.textSize(textSizeMeasureOverlay, textText).width;
|
||||
var usernameLine = "--" + GlobalServices.myUsername;
|
||||
var usernameWidth = Overlays.textSize(textSizeMeasureOverlay, usernameLine).width;
|
||||
if (maxLineWidth < usernameWidth) {
|
||||
maxLineWidth = usernameWidth;
|
||||
} else {
|
||||
var spaceableWidth = maxLineWidth - usernameWidth;
|
||||
//TODO: WORKAROUND WARNING BELOW Fix this when spaces are not trimmed out of the textsize calculation anymore
|
||||
var spaceWidth = Overlays.textSize(textSizeMeasureOverlay, "| |").width
|
||||
- Overlays.textSize(textSizeMeasureOverlay, "||").width;
|
||||
var numberOfSpaces = Math.floor(spaceableWidth / spaceWidth);
|
||||
for (var i = 0; i < numberOfSpaces; i++) {
|
||||
usernameLine = " " + usernameLine;
|
||||
}
|
||||
}
|
||||
var dimension_x = maxLineWidth + TEXT_MARGIN_RIGHT + TEXT_MARGIN_LEFT;
|
||||
if (position.x > 0 && position.y > 0 && position.z > 0) {
|
||||
Entities.addEntity({
|
||||
type: "Text",
|
||||
rotation: MyAvatar.orientation,
|
||||
position: position,
|
||||
dimensions: { x: dimension_x, y: (textLines.length + 1) * 0.14 + TEXT_MARGIN_TOP + TEXT_MARGIN_BOTTOM, z: DEFAULT_TEXT_DIMENSION_Z },
|
||||
backgroundColor: { red: 0, green: 0, blue: 0 },
|
||||
textColor: { red: 255, green: 255, blue: 255 },
|
||||
text: textText + "\n" + usernameLine,
|
||||
lineHeight: 0.1
|
||||
});
|
||||
}
|
||||
textText = "";
|
||||
updateTextOverlay();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
keyboard.onFullyLoaded = function() {
|
||||
print("Virtual-keyboard fully loaded.");
|
||||
var dimensions = Controller.getViewportDimensions();
|
||||
text = Overlays.addOverlay("text", {
|
||||
x: 0,
|
||||
y: dimensions.y - keyboard.height() - 260,
|
||||
width: dimensions.x,
|
||||
height: 250,
|
||||
backgroundColor: { red: 255, green: 255, blue: 255},
|
||||
color: { red: 0, green: 0, blue: 0},
|
||||
topMargin: 5,
|
||||
leftMargin: 0,
|
||||
font: {size: textFontSize},
|
||||
text: "",
|
||||
alpha: 0.8
|
||||
});
|
||||
updateTextOverlay();
|
||||
// the cursor is being loaded after the keyboard, else it will be on the background of the keyboard
|
||||
cursor.initialize();
|
||||
cursor.onUpdate = function(position) {
|
||||
keyboard.setFocusPosition(position.x, position.y);
|
||||
};
|
||||
};
|
||||
|
||||
function keyPressEvent(event) {
|
||||
if (event.key === SPACEBAR_CHARCODE) {
|
||||
keyboard.pressFocussedKey();
|
||||
}
|
||||
}
|
||||
|
||||
function keyReleaseEvent(event) {
|
||||
if (event.key === SPACEBAR_CHARCODE) {
|
||||
keyboard.releaseKeys();
|
||||
}
|
||||
}
|
||||
|
||||
function scriptEnding() {
|
||||
keyboard.remove();
|
||||
cursor.remove();
|
||||
Overlays.deleteOverlay(text);
|
||||
Overlays.deleteOverlay(textSizeMeasureOverlay);
|
||||
Controller.releaseKeyEvents({key: SPACEBAR_CHARCODE});
|
||||
}
|
||||
|
||||
function reportButtonValue(button, newValue, oldValue) {
|
||||
if (button == Joysticks.BUTTON_FACE_BOTTOM) {
|
||||
if (newValue) {
|
||||
keyboard.pressFocussedKey();
|
||||
} else {
|
||||
keyboard.releaseKeys();
|
||||
}
|
||||
} else if (button == Joysticks.BUTTON_FACE_RIGHT && newValue) {
|
||||
deleteChar();
|
||||
}
|
||||
}
|
||||
|
||||
function addJoystick(gamepad) {
|
||||
gamepad.buttonStateChanged.connect(reportButtonValue);
|
||||
}
|
||||
|
||||
var allJoysticks = Joysticks.getAllJoysticks();
|
||||
for (var i = 0; i < allJoysticks.length; i++) {
|
||||
addJoystick(allJoysticks[i]);
|
||||
}
|
||||
|
||||
Joysticks.joystickAdded.connect(addJoystick);
|
||||
Controller.captureKeyEvents({key: SPACEBAR_CHARCODE});
|
||||
Controller.keyPressEvent.connect(keyPressEvent);
|
||||
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
||||
Script.scriptEnding.connect(scriptEnding);
|
|
@ -8,6 +8,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.load("progress.js");
|
||||
Script.load("lookWithTouch.js");
|
||||
Script.load("editEntities.js");
|
||||
Script.load("selectAudioDevice.js");
|
||||
|
@ -16,3 +17,4 @@ Script.load("headMove.js");
|
|||
Script.load("inspect.js");
|
||||
Script.load("lobby.js");
|
||||
Script.load("notifications.js");
|
||||
Script.load("lookWithMouse.js")
|
||||
|
|
109
examples/dice.js
Normal file
109
examples/dice.js
Normal file
|
@ -0,0 +1,109 @@
|
|||
//
|
||||
// dice.js
|
||||
// examples
|
||||
//
|
||||
// Created by Philip Rosedale on February 2, 2015
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Press the dice button to throw some dice from the center of the screen.
|
||||
// Change NUMBER_OF_DICE to change the number thrown (Yahtzee, anyone?)
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var isDice = false;
|
||||
var NUMBER_OF_DICE = 2;
|
||||
var dice = [];
|
||||
var DIE_SIZE = 0.20;
|
||||
|
||||
var madeSound = true; // Set false at start of throw to look for collision
|
||||
|
||||
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||
|
||||
var rollSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/dice/diceRoll.wav");
|
||||
|
||||
var screenSize = Controller.getViewportDimensions();
|
||||
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
|
||||
});
|
||||
var diceButton = Overlays.addOverlay("image", {
|
||||
x: screenSize.x - 48,
|
||||
y: 130,
|
||||
width: 32,
|
||||
height: 32,
|
||||
imageURL: HIFI_PUBLIC_BUCKET + "images/die.png",
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
var GRAVITY = -3.5;
|
||||
var LIFETIME = 300;
|
||||
function shootDice(position, velocity) {
|
||||
for (var i = 0; i < NUMBER_OF_DICE; i++) {
|
||||
dice.push(Entities.addEntity(
|
||||
{ type: "Model",
|
||||
modelURL: HIFI_PUBLIC_BUCKET + "models/props/Dice/goldDie.fbx",
|
||||
position: position,
|
||||
velocity: velocity,
|
||||
rotation: Quat.fromPitchYawRollDegrees(Math.random() * 360, Math.random() * 360, Math.random() * 360),
|
||||
lifetime: LIFETIME,
|
||||
gravity: { x: 0, y: GRAVITY, z: 0 },
|
||||
collisionsWillMove: true
|
||||
}));
|
||||
position = Vec3.sum(position, Vec3.multiply(DIE_SIZE, Vec3.normalize(Quat.getRight(Camera.getOrientation()))));
|
||||
}
|
||||
}
|
||||
|
||||
function deleteDice() {
|
||||
while(dice.length > 0) {
|
||||
Entities.deleteEntity(dice.pop());
|
||||
}
|
||||
}
|
||||
|
||||
function entityCollisionWithEntity(entity1, entity2, collision) {
|
||||
if (!madeSound) {
|
||||
// Is it one of our dice?
|
||||
for (var i = 0; i < dice.length; i++) {
|
||||
if (!dice[i].isKnownID) {
|
||||
dice[i] = Entities.identifyEntity(dice[i]);
|
||||
}
|
||||
if ((entity1.id == dice[i].id) || (entity2.id == dice[i].id)) {
|
||||
madeSound = true;
|
||||
Audio.playSound(rollSound, { position: collision.contactPoint });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function mousePressEvent(event) {
|
||||
var clickedText = false;
|
||||
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y});
|
||||
if (clickedOverlay == offButton) {
|
||||
deleteDice();
|
||||
} else if (clickedOverlay == diceButton) {
|
||||
var HOW_HARD = 2.0;
|
||||
var position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation()));
|
||||
var velocity = Vec3.multiply(HOW_HARD, Quat.getFront(Camera.getOrientation()));
|
||||
shootDice(position, velocity);
|
||||
madeSound = false;
|
||||
}
|
||||
}
|
||||
|
||||
function scriptEnding() {
|
||||
deleteDice();
|
||||
Overlays.deleteOverlay(offButton);
|
||||
Overlays.deleteOverlay(diceButton);
|
||||
|
||||
}
|
||||
|
||||
Entities.entityCollisionWithEntity.connect(entityCollisionWithEntity);
|
||||
Controller.mousePressEvent.connect(mousePressEvent);
|
||||
Script.scriptEnding.connect(scriptEnding);
|
|
@ -46,27 +46,8 @@ gridTool.setVisible(false);
|
|||
|
||||
var entityListTool = EntityListTool();
|
||||
|
||||
var hasShownPropertiesTool = false;
|
||||
|
||||
var entityListVisible = false;
|
||||
|
||||
selectionManager.addEventListener(function() {
|
||||
selectionDisplay.updateHandles();
|
||||
if (selectionManager.hasSelection() && !hasShownPropertiesTool) {
|
||||
// Open properties and model list, but force selection of model list tab
|
||||
propertiesTool.setVisible(false);
|
||||
entityListTool.setVisible(false);
|
||||
gridTool.setVisible(false);
|
||||
propertiesTool.setVisible(true);
|
||||
entityListTool.setVisible(true);
|
||||
gridTool.setVisible(true);
|
||||
hasShownPropertiesTool = true;
|
||||
}
|
||||
if (!selectionManager.hasSelection()) {
|
||||
toolBar.setActive(false);
|
||||
} else {
|
||||
toolBar.setActive(true);
|
||||
}
|
||||
});
|
||||
|
||||
var windowDimensions = Controller.getViewportDimensions();
|
||||
|
@ -93,9 +74,11 @@ var DEFAULT_DIMENSIONS = {
|
|||
};
|
||||
|
||||
var MENU_INSPECT_TOOL_ENABLED = "Inspect Tool";
|
||||
var MENU_AUTO_FOCUS_ON_SELECT = "Auto Focus on Select";
|
||||
var MENU_EASE_ON_FOCUS = "Ease Orientation on Focus";
|
||||
|
||||
var SETTING_INSPECT_TOOL_ENABLED = "inspectToolEnabled";
|
||||
var SETTING_AUTO_FOCUS_ON_SELECT = "autoFocusOnSelect";
|
||||
var SETTING_EASE_ON_FOCUS = "cameraEaseOnFocus";
|
||||
|
||||
var modelURLs = [
|
||||
|
@ -111,6 +94,7 @@ var modelURLs = [
|
|||
var mode = 0;
|
||||
var isActive = false;
|
||||
|
||||
var placingEntityID = null;
|
||||
|
||||
var toolBar = (function () {
|
||||
var that = {},
|
||||
|
@ -121,15 +105,7 @@ var toolBar = (function () {
|
|||
newSphereButton,
|
||||
newLightButton,
|
||||
newTextButton,
|
||||
browseModelsButton,
|
||||
loadURLMenuItem,
|
||||
loadFileMenuItem,
|
||||
menuItemWidth,
|
||||
menuItemOffset,
|
||||
menuItemHeight,
|
||||
menuItemMargin = 5,
|
||||
menuTextColor = { red: 255, green: 255, blue: 255 },
|
||||
menuBackgroundColor = { red: 18, green: 66, blue: 66 };
|
||||
browseModelsButton;
|
||||
|
||||
function initialize() {
|
||||
toolBar = new ToolBar(0, 0, ToolBar.VERTICAL);
|
||||
|
@ -137,10 +113,9 @@ var toolBar = (function () {
|
|||
// Hide active button for now - this may come back, so not deleting yet.
|
||||
activeButton = toolBar.addTool({
|
||||
imageURL: toolIconUrl + "models-tool.svg",
|
||||
// subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT },
|
||||
subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: 0, height: 0 },
|
||||
width: 0,//toolWidth,
|
||||
height: 0,//toolHeight,
|
||||
subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT },
|
||||
width: toolWidth,
|
||||
height: toolHeight,
|
||||
alpha: 0.9,
|
||||
visible: true
|
||||
}, true, false);
|
||||
|
@ -152,7 +127,7 @@ var toolBar = (function () {
|
|||
height: toolHeight,
|
||||
alpha: 0.9,
|
||||
visible: true
|
||||
}, true, false);
|
||||
});
|
||||
|
||||
browseModelsButton = toolBar.addTool({
|
||||
imageURL: toolIconUrl + "list-icon.svg",
|
||||
|
@ -162,34 +137,6 @@ var toolBar = (function () {
|
|||
visible: true
|
||||
});
|
||||
|
||||
menuItemOffset = toolBar.height / 3 + 2;
|
||||
menuItemHeight = Tool.IMAGE_HEIGHT / 2 - 2;
|
||||
|
||||
loadURLMenuItem = Overlays.addOverlay("text", {
|
||||
height: menuItemHeight,
|
||||
backgroundColor: menuBackgroundColor,
|
||||
topMargin: menuItemMargin,
|
||||
text: "Model URL",
|
||||
alpha: 0.9,
|
||||
backgroundAlpha: 0.9,
|
||||
visible: false
|
||||
});
|
||||
|
||||
loadFileMenuItem = Overlays.addOverlay("text", {
|
||||
height: menuItemHeight,
|
||||
backgroundColor: menuBackgroundColor,
|
||||
topMargin: menuItemMargin,
|
||||
text: "Model File",
|
||||
alpha: 0.9,
|
||||
backgroundAlpha: 0.9,
|
||||
visible: false
|
||||
});
|
||||
|
||||
menuItemWidth = Math.max(Overlays.textSize(loadURLMenuItem, "Model URL").width,
|
||||
Overlays.textSize(loadFileMenuItem, "Model File").width) + 20;
|
||||
Overlays.editOverlay(loadURLMenuItem, { width: menuItemWidth });
|
||||
Overlays.editOverlay(loadFileMenuItem, { width: menuItemWidth });
|
||||
|
||||
newCubeButton = toolBar.addTool({
|
||||
imageURL: toolIconUrl + "add-cube.svg",
|
||||
subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT },
|
||||
|
@ -228,17 +175,6 @@ var toolBar = (function () {
|
|||
|
||||
}
|
||||
|
||||
function toggleNewModelButton(active) {
|
||||
if (active === undefined) {
|
||||
active = !toolBar.toolSelected(newModelButton);
|
||||
}
|
||||
toolBar.selectTool(newModelButton, active);
|
||||
|
||||
Overlays.editOverlay(loadURLMenuItem, { visible: active });
|
||||
Overlays.editOverlay(loadFileMenuItem, { visible: active });
|
||||
}
|
||||
|
||||
|
||||
that.setActive = function(active) {
|
||||
if (active != isActive) {
|
||||
isActive = active;
|
||||
|
@ -252,14 +188,18 @@ var toolBar = (function () {
|
|||
} else {
|
||||
hasShownPropertiesTool = false;
|
||||
cameraManager.enable();
|
||||
entityListTool.setVisible(true);
|
||||
gridTool.setVisible(true);
|
||||
grid.setEnabled(true);
|
||||
propertiesTool.setVisible(true);
|
||||
Window.setFocus();
|
||||
}
|
||||
}
|
||||
toolBar.selectTool(activeButton, active);
|
||||
};
|
||||
|
||||
var RESIZE_INTERVAL = 50;
|
||||
var RESIZE_TIMEOUT = 20000;
|
||||
var RESIZE_TIMEOUT = 120000; // 2 minutes
|
||||
var RESIZE_MAX_CHECKS = RESIZE_TIMEOUT / RESIZE_INTERVAL;
|
||||
function addModel(url) {
|
||||
var position;
|
||||
|
@ -320,11 +260,10 @@ var toolBar = (function () {
|
|||
toolsY = (windowDimensions.y - toolBar.height) / 2;
|
||||
|
||||
toolBar.move(toolsX, toolsY);
|
||||
|
||||
Overlays.editOverlay(loadURLMenuItem, { x: toolsX - menuItemWidth, y: toolsY + menuItemOffset });
|
||||
Overlays.editOverlay(loadFileMenuItem, { x: toolsX - menuItemWidth, y: toolsY + menuItemOffset + menuItemHeight });
|
||||
};
|
||||
|
||||
var newModelButtonDown = false;
|
||||
var browseModelsButtonDown = false;
|
||||
that.mousePressEvent = function (event) {
|
||||
var clickedOverlay,
|
||||
url,
|
||||
|
@ -337,40 +276,14 @@ var toolBar = (function () {
|
|||
return true;
|
||||
}
|
||||
|
||||
// Handle these two buttons in the mouseRelease event handler so that we don't suppress a mouseRelease event from
|
||||
// occurring when showing a modal dialog.
|
||||
if (newModelButton === toolBar.clicked(clickedOverlay)) {
|
||||
toggleNewModelButton();
|
||||
newModelButtonDown = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (clickedOverlay === loadURLMenuItem) {
|
||||
toggleNewModelButton(false);
|
||||
url = Window.prompt("Model URL", modelURLs[Math.floor(Math.random() * modelURLs.length)]);
|
||||
if (url !== null && url !== "") {
|
||||
addModel(url);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (clickedOverlay === loadFileMenuItem) {
|
||||
toggleNewModelButton(false);
|
||||
|
||||
file = Window.browse("Select your model file ...",
|
||||
Settings.getValue("LastModelUploadLocation").path(),
|
||||
"Model files (*.fst *.fbx)");
|
||||
//"Model files (*.fst *.fbx *.svo)");
|
||||
if (file !== null) {
|
||||
Settings.setValue("LastModelUploadLocation", file);
|
||||
modelUploader.upload(file, addModel);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (browseModelsButton === toolBar.clicked(clickedOverlay)) {
|
||||
toggleNewModelButton(false);
|
||||
url = Window.s3Browse(".*(fbx|FBX)");
|
||||
if (url !== null && url !== "") {
|
||||
addModel(url);
|
||||
}
|
||||
browseModelsButtonDown = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -378,7 +291,7 @@ var toolBar = (function () {
|
|||
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
|
||||
|
||||
if (position.x > 0 && position.y > 0 && position.z > 0) {
|
||||
Entities.addEntity({
|
||||
placingEntityID = Entities.addEntity({
|
||||
type: "Box",
|
||||
position: grid.snapToSurface(grid.snapToGrid(position, false, DEFAULT_DIMENSIONS), DEFAULT_DIMENSIONS),
|
||||
dimensions: DEFAULT_DIMENSIONS,
|
||||
|
@ -395,7 +308,7 @@ var toolBar = (function () {
|
|||
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
|
||||
|
||||
if (position.x > 0 && position.y > 0 && position.z > 0) {
|
||||
Entities.addEntity({
|
||||
placingEntityID = Entities.addEntity({
|
||||
type: "Sphere",
|
||||
position: grid.snapToSurface(grid.snapToGrid(position, false, DEFAULT_DIMENSIONS), DEFAULT_DIMENSIONS),
|
||||
dimensions: DEFAULT_DIMENSIONS,
|
||||
|
@ -411,7 +324,7 @@ var toolBar = (function () {
|
|||
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
|
||||
|
||||
if (position.x > 0 && position.y > 0 && position.z > 0) {
|
||||
Entities.addEntity({
|
||||
placingEntityID = Entities.addEntity({
|
||||
type: "Light",
|
||||
position: grid.snapToSurface(grid.snapToGrid(position, false, DEFAULT_DIMENSIONS), DEFAULT_DIMENSIONS),
|
||||
dimensions: DEFAULT_DIMENSIONS,
|
||||
|
@ -432,18 +345,19 @@ var toolBar = (function () {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (newTextButton === toolBar.clicked(clickedOverlay)) {
|
||||
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
|
||||
|
||||
if (position.x > 0 && position.y > 0 && position.z > 0) {
|
||||
Entities.addEntity({
|
||||
placingEntityID = Entities.addEntity({
|
||||
type: "Text",
|
||||
position: grid.snapToSurface(grid.snapToGrid(position, false, DEFAULT_DIMENSIONS), DEFAULT_DIMENSIONS),
|
||||
dimensions: DEFAULT_DIMENSIONS,
|
||||
backgroundColor: { red: 0, green: 0, blue: 0 },
|
||||
dimensions: { x: 0.65, y: 0.3, z: 0.01 },
|
||||
backgroundColor: { red: 64, green: 64, blue: 64 },
|
||||
textColor: { red: 255, green: 255, blue: 255 },
|
||||
text: "some text",
|
||||
lineHight: "0.1"
|
||||
lineHeight: 0.06
|
||||
});
|
||||
} else {
|
||||
print("Can't create box: Text would be out of bounds.");
|
||||
|
@ -451,14 +365,39 @@ var toolBar = (function () {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
that.mouseReleaseEvent = function(event) {
|
||||
var handled = false;
|
||||
if (newModelButtonDown) {
|
||||
var clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
|
||||
if (newModelButton === toolBar.clicked(clickedOverlay)) {
|
||||
url = Window.prompt("Model URL", modelURLs[Math.floor(Math.random() * modelURLs.length)]);
|
||||
if (url !== null && url !== "") {
|
||||
addModel(url);
|
||||
}
|
||||
handled = true;
|
||||
}
|
||||
} else if (browseModelsButtonDown) {
|
||||
var clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
|
||||
if (browseModelsButton === toolBar.clicked(clickedOverlay)) {
|
||||
url = Window.s3Browse(".*(fbx|FBX)");
|
||||
if (url !== null && url !== "") {
|
||||
addModel(url);
|
||||
}
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
newModelButtonDown = false;
|
||||
browseModelsButtonDown = false;
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
that.cleanup = function () {
|
||||
toolBar.cleanup();
|
||||
Overlays.deleteOverlay(loadURLMenuItem);
|
||||
Overlays.deleteOverlay(loadFileMenuItem);
|
||||
};
|
||||
|
||||
return that;
|
||||
|
@ -548,8 +487,25 @@ var mouseCapturedByTool = false;
|
|||
var lastMousePosition = null;
|
||||
var idleMouseTimerId = null;
|
||||
var IDLE_MOUSE_TIMEOUT = 200;
|
||||
var DEFAULT_ENTITY_DRAG_DROP_DISTANCE = 2.0;
|
||||
|
||||
function mouseMoveEvent(event) {
|
||||
if (placingEntityID) {
|
||||
if (!placingEntityID.isKnownID) {
|
||||
placingEntityID = Entities.identifyEntity(placingEntityID);
|
||||
}
|
||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||
var distance = cameraManager.enabled ? cameraManager.zoomDistance : DEFAULT_ENTITY_DRAG_DROP_DISTANCE;
|
||||
var offset = Vec3.multiply(distance, pickRay.direction);
|
||||
var position = Vec3.sum(Camera.position, offset);
|
||||
Entities.editEntity(placingEntityID, {
|
||||
position: position,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!isActive) {
|
||||
return;
|
||||
}
|
||||
if (idleMouseTimerId) {
|
||||
Script.clearTimeout(idleMouseTimerId);
|
||||
}
|
||||
|
@ -602,6 +558,15 @@ function highlightEntityUnderCursor(position, accurateRay) {
|
|||
|
||||
|
||||
function mouseReleaseEvent(event) {
|
||||
if (toolBar.mouseReleaseEvent(event)) {
|
||||
return true;
|
||||
}
|
||||
if (placingEntityID) {
|
||||
if (isActive) {
|
||||
selectionManager.setSelections([placingEntityID]);
|
||||
}
|
||||
placingEntityID = null;
|
||||
}
|
||||
if (isActive && selectionManager.hasSelection()) {
|
||||
tooltip.show(false);
|
||||
}
|
||||
|
@ -617,7 +582,7 @@ function mouseReleaseEvent(event) {
|
|||
}
|
||||
|
||||
function mouseClickEvent(event) {
|
||||
if (!event.isRightButton) {
|
||||
if (!event.isLeftButton || !isActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -670,19 +635,21 @@ function mouseClickEvent(event) {
|
|||
orientation = MyAvatar.orientation;
|
||||
intersection = rayPlaneIntersection(pickRay, P, Quat.getFront(orientation));
|
||||
|
||||
if (!event.isShifted) {
|
||||
selectionManager.clearSelections();
|
||||
}
|
||||
|
||||
var toggle = event.isShifted;
|
||||
selectionManager.addEntity(foundEntity, toggle);
|
||||
if (!event.isShifted) {
|
||||
selectionManager.setSelections([foundEntity]);
|
||||
} else {
|
||||
selectionManager.addEntity(foundEntity, true);
|
||||
}
|
||||
|
||||
print("Model selected: " + foundEntity.id);
|
||||
selectionDisplay.select(selectedEntityID, event);
|
||||
|
||||
cameraManager.focus(selectionManager.worldPosition,
|
||||
selectionManager.worldDimensions,
|
||||
Menu.isOptionChecked(MENU_EASE_ON_FOCUS));
|
||||
if (Menu.isOptionChecked(MENU_AUTO_FOCUS_ON_SELECT)) {
|
||||
cameraManager.focus(selectionManager.worldPosition,
|
||||
selectionManager.worldDimensions,
|
||||
Menu.isOptionChecked(MENU_EASE_ON_FOCUS));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -724,7 +691,9 @@ function setupModelMenus() {
|
|||
Menu.addMenuItem({ menuName: "File", menuItemName: "Import Models", shortcutKey: "CTRL+META+I", afterItem: "Export Models" });
|
||||
|
||||
|
||||
Menu.addMenuItem({ menuName: "View", menuItemName: MENU_EASE_ON_FOCUS, afterItem: MENU_INSPECT_TOOL_ENABLED,
|
||||
Menu.addMenuItem({ menuName: "View", menuItemName: MENU_AUTO_FOCUS_ON_SELECT, afterItem: MENU_INSPECT_TOOL_ENABLED,
|
||||
isCheckable: true, isChecked: Settings.getValue(SETTING_AUTO_FOCUS_ON_SELECT) == "true" });
|
||||
Menu.addMenuItem({ menuName: "View", menuItemName: MENU_EASE_ON_FOCUS, afterItem: MENU_AUTO_FOCUS_ON_SELECT,
|
||||
isCheckable: true, isChecked: Settings.getValue(SETTING_EASE_ON_FOCUS) == "true" });
|
||||
|
||||
Entities.setLightsArePickable(false);
|
||||
|
@ -750,11 +719,12 @@ function cleanupModelMenus() {
|
|||
Menu.removeMenuItem("File", "Import Models");
|
||||
|
||||
Menu.removeMenuItem("View", MENU_INSPECT_TOOL_ENABLED);
|
||||
Menu.removeMenuItem("View", MENU_AUTO_FOCUS_ON_SELECT);
|
||||
Menu.removeMenuItem("View", MENU_EASE_ON_FOCUS);
|
||||
}
|
||||
|
||||
Script.scriptEnding.connect(function() {
|
||||
Settings.setValue(SETTING_INSPECT_TOOL_ENABLED, Menu.isOptionChecked(MENU_INSPECT_TOOL_ENABLED));
|
||||
Settings.setValue(SETTING_AUTO_FOCUS_ON_SELECT, Menu.isOptionChecked(MENU_AUTO_FOCUS_ON_SELECT));
|
||||
Settings.setValue(SETTING_EASE_ON_FOCUS, Menu.isOptionChecked(MENU_EASE_ON_FOCUS));
|
||||
|
||||
progressDialog.cleanup();
|
||||
|
@ -820,9 +790,7 @@ function handeMenuEvent(menuItem) {
|
|||
} else if (menuItem == "Import Models") {
|
||||
modelImporter.doImport();
|
||||
} else if (menuItem == "Entity List...") {
|
||||
if (isActive) {
|
||||
entityListTool.toggleVisible();
|
||||
}
|
||||
entityListTool.toggleVisible();
|
||||
}
|
||||
tooltip.show(false);
|
||||
}
|
||||
|
@ -1019,9 +987,18 @@ PropertiesTool = function(opts) {
|
|||
selectionManager.saveProperties();
|
||||
for (var i = 0; i < selectionManager.selections.length; i++) {
|
||||
var properties = selectionManager.savedProperties[selectionManager.selections[i].id];
|
||||
Entities.editEntity(selectionManager.selections[i], {
|
||||
dimensions: properties.naturalDimensions,
|
||||
});
|
||||
var naturalDimensions = properties.naturalDimensions;
|
||||
|
||||
// If any of the natural dimensions are not 0, resize
|
||||
if (properties.type == "Model" && naturalDimensions.x == 0
|
||||
&& naturalDimensions.y == 0 && naturalDimensions.z == 0) {
|
||||
Window.alert("Cannot reset entity to its natural dimensions: Model URL"
|
||||
+ " is invalid or the model has not yet been loaded.");
|
||||
} else {
|
||||
Entities.editEntity(selectionManager.selections[i], {
|
||||
dimensions: properties.naturalDimensions,
|
||||
});
|
||||
}
|
||||
}
|
||||
pushCommandForSelections();
|
||||
selectionManager._update();
|
||||
|
|
|
@ -48,7 +48,8 @@
|
|||
this.turnSounds = new Array();
|
||||
this.moveSound = null;
|
||||
this.turnSound = null;
|
||||
this.injector = null;
|
||||
this.moveInjector = null;
|
||||
this.turnInjector = null;
|
||||
|
||||
var debug = false;
|
||||
var displayRotateTargets = true; // change to false if you don't want the rotate targets
|
||||
|
@ -92,9 +93,14 @@
|
|||
}
|
||||
if (this.moveSound && this.moveSound.downloaded) {
|
||||
if (debug) {
|
||||
print("playMoveSound() --- calling this.injector = Audio.playSound(this.moveSound...)");
|
||||
print("playMoveSound() --- calling this.moveInjector = Audio.playSound(this.moveSound...)");
|
||||
}
|
||||
|
||||
if (!this.moveInjector) {
|
||||
this.moveInjector = Audio.playSound(this.moveSound, { position: this.properties.position, loop: true, volume: 0.1 });
|
||||
} else {
|
||||
this.moveInjector.restart();
|
||||
}
|
||||
this.injector = Audio.playSound(this.moveSound, { position: this.properties.position, loop: true, volume: 0.1 });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,9 +111,13 @@
|
|||
}
|
||||
if (this.turnSound && this.turnSound.downloaded) {
|
||||
if (debug) {
|
||||
print("playTurnSound() --- calling this.injector = Audio.playSound(this.turnSound...)");
|
||||
print("playTurnSound() --- calling this.turnInjector = Audio.playSound(this.turnSound...)");
|
||||
}
|
||||
if (!this.turnInjector) {
|
||||
this.turnInjector = Audio.playSound(this.turnSound, { position: this.properties.position, loop: true, volume: 0.1 });
|
||||
} else {
|
||||
this.turnInjector.restart();
|
||||
}
|
||||
this.injector = Audio.playSound(this.turnSound, { position: this.properties.position, loop: true, volume: 0.1 });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,9 +126,11 @@
|
|||
if (debug) {
|
||||
print("stopSound()");
|
||||
}
|
||||
if (this.injector) {
|
||||
Audio.stopInjector(this.injector);
|
||||
this.injector = null;
|
||||
if (this.turnInjector) {
|
||||
this.turnInjector.stop();
|
||||
}
|
||||
if (this.moveInjector) {
|
||||
this.moveInjector.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,7 +186,7 @@
|
|||
|
||||
this.move = function(mouseEvent) {
|
||||
this.updatePosition(mouseEvent);
|
||||
if (this.injector === null) {
|
||||
if (this.moveInjector === null || !this.moveInjector.isPlaying) {
|
||||
this.playMoveSound();
|
||||
}
|
||||
};
|
||||
|
@ -233,7 +245,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
if (this.injector === null) {
|
||||
if (this.turnInjector === null || !this.turnInjector.isPlaying) {
|
||||
this.playTurnSound();
|
||||
}
|
||||
};
|
||||
|
|
41
examples/entityScripts/portal.js
Normal file
41
examples/entityScripts/portal.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
(function(){
|
||||
var teleport;
|
||||
var portalDestination;
|
||||
|
||||
function playSound() {
|
||||
Audio.playSound(teleport, { volume: 0.40, localOnly: true });
|
||||
};
|
||||
|
||||
this.preload = function(entityID) {
|
||||
teleport = SoundCache.getSound("http://s3.amazonaws.com/hifi-public/birarda/teleport.raw");
|
||||
|
||||
var properties = Entities.getEntityProperties(entityID);
|
||||
portalDestination = properties.userData;
|
||||
|
||||
print("The portal destination is " + portalDestination);
|
||||
}
|
||||
|
||||
this.enterEntity = function(entityID) {
|
||||
if (portalDestination.length > 0) {
|
||||
print("Teleporting to hifi://" + portalDestination);
|
||||
Window.location = "hifi://" + portalDestination;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.leaveEntity = function(entityID) {
|
||||
Entities.editEntity(entityID, {
|
||||
animationURL: "http://hifi-public.s3.amazonaws.com/models/content/phonebooth.fbx",
|
||||
animationSettings: '{ "frameIndex": 1, "running": false }'
|
||||
});
|
||||
|
||||
playSound();
|
||||
};
|
||||
|
||||
this.hoverEnterEntity = function(entityID) {
|
||||
Entities.editEntity(entityID, {
|
||||
animationURL: "http://hifi-public.s3.amazonaws.com/models/content/phonebooth.fbx",
|
||||
animationSettings: '{ "fps": 24, "firstFrame": 1, "lastFrame": 25, "frameIndex": 1, "running": true, "hold": true }'
|
||||
});
|
||||
};
|
||||
})
|
|
@ -75,14 +75,14 @@ function maybePlaySound(deltaTime) {
|
|||
//print("number playing = " + numPlaying);
|
||||
}
|
||||
for (var i = 0; i < playing.length; i++) {
|
||||
if (!Audio.isInjectorPlaying(playing[i].audioId)) {
|
||||
if (!playing[i].audioId.isPlaying) {
|
||||
Entities.deleteEntity(playing[i].entityId);
|
||||
if (useLights) {
|
||||
Entities.deleteEntity(playing[i].lightId);
|
||||
}
|
||||
playing.splice(i, 1);
|
||||
} else {
|
||||
var loudness = Audio.getLoudness(playing[i].audioId);
|
||||
var loudness = playing[i].audioId.loudness;
|
||||
var newColor = { red: playing[i].color.red, green: playing[i].color.green, blue: playing[i].color.blue };
|
||||
if (loudness > 0.05) {
|
||||
newColor.red *= (1.0 - loudness);
|
||||
|
|
|
@ -76,9 +76,6 @@ function scriptEnding() {
|
|||
if (entity != null) {
|
||||
Entities.deleteEntity(entity);
|
||||
}
|
||||
if (injector != null) {
|
||||
injector.stop();
|
||||
}
|
||||
}
|
||||
|
||||
Script.update.connect(update);
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
//
|
||||
|
||||
|
||||
print("BUTTERFLIES START");
|
||||
|
||||
|
||||
var numButterflies = 25;
|
||||
|
||||
|
||||
|
@ -109,7 +112,7 @@ function updateButterflies(deltaTime) {
|
|||
var properties = Entities.getEntityProperties(butterflies[i]);
|
||||
if (Vec3.length(Vec3.subtract(properties.position, flockPosition)) > range) {
|
||||
Entities.editEntity(butterflies[i], { position: flockPosition } );
|
||||
} else if (properties.velocity.y < 0.0) {
|
||||
} else if (properties.velocity.y <= 0.0) {
|
||||
// If falling, Create a new direction and impulse
|
||||
var HORIZ_SCALE = 0.50;
|
||||
var VERT_SCALE = 0.50;
|
||||
|
@ -139,3 +142,5 @@ Script.scriptEnding.connect(function() {
|
|||
Entities.deleteEntity(butterflies[i]);
|
||||
}
|
||||
});
|
||||
|
||||
print("BUTTERFLIES END");
|
||||
|
|
|
@ -168,14 +168,16 @@
|
|||
</script>
|
||||
</head>
|
||||
<body onload='loaded();'>
|
||||
<div>
|
||||
<div id="entity-list-header">
|
||||
<input type="button" id="refresh" value="Refresh"></button>
|
||||
<input type="button" id="teleport" value="Teleport"></button>
|
||||
<input type="button" id="delete" style="background-color: rgb(244, 64, 64); float: right" value="Delete"></button>
|
||||
</div>
|
||||
|
||||
<div id="entity-list">
|
||||
<input type="text" class="search" id="filter" placeholder="Filter" />
|
||||
<div id="search-area">
|
||||
<input type="text" class="search" id="filter" placeholder="Filter" />
|
||||
</div>
|
||||
<table id="entity-table">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
|
@ -119,6 +119,7 @@
|
|||
var elCollisionsWillMove = document.getElementById("property-collisions-will-move");
|
||||
var elLifetime = document.getElementById("property-lifetime");
|
||||
var elScriptURL = document.getElementById("property-script-url");
|
||||
var elUserData = document.getElementById("property-user-data");
|
||||
|
||||
var elBoxSections = document.querySelectorAll(".box-section");
|
||||
var elBoxColorRed = document.getElementById("property-box-red");
|
||||
|
@ -154,6 +155,7 @@
|
|||
var elModelAnimationSettings = document.getElementById("property-model-animation-settings");
|
||||
var elModelTextures = document.getElementById("property-model-textures");
|
||||
var elModelOriginalTextures = document.getElementById("property-model-original-textures");
|
||||
var elModelShapeType = document.getElementById("property-model-shape");
|
||||
|
||||
var elTextSections = document.querySelectorAll(".text-section");
|
||||
var elTextText = document.getElementById("property-text-text");
|
||||
|
@ -224,6 +226,7 @@
|
|||
elCollisionsWillMove.checked = properties.collisionsWillMove;
|
||||
elLifetime.value = properties.lifetime;
|
||||
elScriptURL.value = properties.script;
|
||||
elUserData.value = properties.userData;
|
||||
|
||||
if (properties.type != "Box") {
|
||||
for (var i = 0; i < elBoxSections.length; i++) {
|
||||
|
@ -256,6 +259,7 @@
|
|||
elModelAnimationSettings.value = properties.animationSettings;
|
||||
elModelTextures.value = properties.textures;
|
||||
elModelOriginalTextures.value = properties.originalTextures;
|
||||
elModelShapeType.value = properties.shapeType;
|
||||
}
|
||||
|
||||
if (properties.type != "Text") {
|
||||
|
@ -361,6 +365,7 @@
|
|||
elCollisionsWillMove.addEventListener('change', createEmitCheckedPropertyUpdateFunction('collisionsWillMove'));
|
||||
elLifetime.addEventListener('change', createEmitNumberPropertyUpdateFunction('lifetime'));
|
||||
elScriptURL.addEventListener('change', createEmitTextPropertyUpdateFunction('script'));
|
||||
elUserData.addEventListener('change', createEmitTextPropertyUpdateFunction('userData'));
|
||||
|
||||
var boxColorChangeFunction = createEmitColorPropertyUpdateFunction(
|
||||
'color', elBoxColorRed, elBoxColorGreen, elBoxColorBlue);
|
||||
|
@ -401,6 +406,7 @@
|
|||
elModelAnimationFrame.addEventListener('change', createEmitNumberPropertyUpdateFunction('animationFrameIndex'));
|
||||
elModelAnimationSettings.addEventListener('change', createEmitTextPropertyUpdateFunction('animationSettings'));
|
||||
elModelTextures.addEventListener('change', createEmitTextPropertyUpdateFunction('textures'));
|
||||
elModelShapeType.addEventListener('change', createEmitNumberPropertyUpdateFunction('shapeType'));
|
||||
|
||||
elTextText.addEventListener('change', createEmitTextPropertyUpdateFunction('text'));
|
||||
elTextLineHeight.addEventListener('change', createEmitNumberPropertyUpdateFunction('lineHeight'));
|
||||
|
@ -559,13 +565,6 @@
|
|||
</div>
|
||||
|
||||
<div class="property">
|
||||
<div class="label">Mass</div>
|
||||
<div class="value">
|
||||
<input type='number' id="property-mass"></input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="label">Density</div>
|
||||
<div>
|
||||
<input type='number' id="property-density"></input>
|
||||
|
@ -600,6 +599,13 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="property">
|
||||
<div class="label">User Data</div>
|
||||
<div class="value">
|
||||
<textarea id="property-user-data"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="box-section property">
|
||||
<div class="label">Color</div>
|
||||
|
@ -645,7 +651,7 @@
|
|||
<div class="model-section property">
|
||||
<div class="label">Animation Settings</div>
|
||||
<div class="value">
|
||||
<textarea id="property-model-animation-settings" value='asdfasdf'></textarea>
|
||||
<textarea id="property-model-animation-settings"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="model-section property">
|
||||
|
@ -661,6 +667,17 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="model-section property">
|
||||
<div class="label">Shape Type</div>
|
||||
<div class="value">
|
||||
<select name="SelectShapeType" id="property-model-shape" name="SelectShapeType">
|
||||
<option value=0>None</option>
|
||||
<option value=1>Box</option>
|
||||
<option value=2>Sphere</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="text-section property">
|
||||
<div class="label">Text</div>
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
elPosY.value = origin.y.toFixed(2);
|
||||
}
|
||||
|
||||
if (data.minorGridSpacing !== undefined) {
|
||||
elMinorSpacing.value = data.minorGridSpacing;
|
||||
if (data.minorGridWidth !== undefined) {
|
||||
elMinorSpacing.value = data.minorGridWidth;
|
||||
}
|
||||
|
||||
if (data.majorGridEvery !== undefined) {
|
||||
|
@ -57,7 +57,7 @@
|
|||
origin: {
|
||||
y: elPosY.value,
|
||||
},
|
||||
minorGridSpacing: elMinorSpacing.value,
|
||||
minorGridWidth: elMinorSpacing.value,
|
||||
majorGridEvery: elMajorSpacing.value,
|
||||
gridColor: gridColor,
|
||||
colorIndex: gridColorIndex,
|
||||
|
|
|
@ -86,6 +86,20 @@ input[type=button] {
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
#entity-list-header {
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
#search-area {
|
||||
width: 100%;
|
||||
padding: 0.5em;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#search-area input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
textarea, input {
|
||||
margin: 0;
|
||||
padding: 1.5pt;
|
||||
|
@ -120,6 +134,7 @@ table#entity-table {
|
|||
}
|
||||
|
||||
#entity-table tr.selected {
|
||||
color: rgb(43, 43, 43);
|
||||
background-color: #AAA;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,11 +15,11 @@ var MOUSE_SENSITIVITY = 0.9;
|
|||
var SCROLL_SENSITIVITY = 0.05;
|
||||
var PAN_ZOOM_SCALE_RATIO = 0.4;
|
||||
|
||||
var KEY_ORBIT_SENSITIVITY = 40;
|
||||
var KEY_ZOOM_SENSITIVITY = 10;
|
||||
var KEY_ORBIT_SENSITIVITY = 90;
|
||||
var KEY_ZOOM_SENSITIVITY = 3;
|
||||
|
||||
// Scaling applied based on the size of the object being focused
|
||||
var FOCUS_ZOOM_SCALE = 1.3;
|
||||
// Scaling applied based on the size of the object being focused (Larger values focus further away)
|
||||
var FOCUS_ZOOM_SCALE = 2.3;
|
||||
|
||||
// Minimum zoom level when focusing on an object
|
||||
var FOCUS_MIN_ZOOM = 0.5;
|
||||
|
@ -433,8 +433,13 @@ CameraManager = function() {
|
|||
that.targetYaw += (actions.orbitRight - actions.orbitLeft) * dt * KEY_ORBIT_SENSITIVITY;
|
||||
that.targetPitch += (actions.orbitUp - actions.orbitDown) * dt * KEY_ORBIT_SENSITIVITY;
|
||||
that.targetPitch = clamp(that.targetPitch, -90, 90);
|
||||
that.targetZoomDistance += (actions.orbitBackward - actions.orbitForward) * dt * KEY_ZOOM_SENSITIVITY;
|
||||
that.targetZoomDistance = clamp(that.targetZoomDistance, MIN_ZOOM_DISTANCE, MAX_ZOOM_DISTANCE);
|
||||
|
||||
var dZoom = actions.orbitBackward - actions.orbitForward;
|
||||
if (dZoom) {
|
||||
dZoom *= that.targetZoomDistance * dt * KEY_ZOOM_SENSITIVITY;
|
||||
that.targetZoomDistance += dZoom;
|
||||
that.targetZoomDistance = clamp(that.targetZoomDistance, MIN_ZOOM_DISTANCE, MAX_ZOOM_DISTANCE);
|
||||
}
|
||||
|
||||
|
||||
if (easing) {
|
||||
|
|
|
@ -1221,7 +1221,7 @@ SelectionDisplay = (function () {
|
|||
x: selectionManager.worldDimensions.x,
|
||||
y: selectionManager.worldDimensions.z
|
||||
},
|
||||
rotation: Quat.fromPitchYawRollDegrees(0, 0, 0),
|
||||
rotation: Quat.fromPitchYawRollDegrees(90, 0, 0),
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ modelUploader = (function () {
|
|||
//svoBuffer,
|
||||
mapping,
|
||||
geometry,
|
||||
API_URL = "https://data.highfidelity.io/api/v1/models",
|
||||
API_URL = "https://metaverse.highfidelity.io/api/v1/models",
|
||||
MODEL_URL = "http://public.highfidelity.io/models/content",
|
||||
NAME_FIELD = "name",
|
||||
SCALE_FIELD = "scale",
|
||||
|
|
|
@ -9,179 +9,50 @@
|
|||
// Usage: Enable VR-mode and go to First person mode,
|
||||
// look at the key that you would like to press, and press the spacebar on your "REAL" keyboard.
|
||||
//
|
||||
// leased some code from newEditEntities.js for Text Entity example
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||
// experimental 3dmode
|
||||
THREE_D_MODE = false;
|
||||
|
||||
const KBD_UPPERCASE_DEFAULT = 0;
|
||||
const KBD_LOWERCASE_DEFAULT = 1;
|
||||
const KBD_UPPERCASE_HOVER = 2;
|
||||
const KBD_LOWERCASE_HOVER = 3;
|
||||
const KBD_BACKGROUND = 4;
|
||||
KBD_UPPERCASE_DEFAULT = 0;
|
||||
KBD_LOWERCASE_DEFAULT = 1;
|
||||
KBD_UPPERCASE_HOVER = 2;
|
||||
KBD_LOWERCASE_HOVER = 3;
|
||||
KBD_BACKGROUND = 4;
|
||||
|
||||
const KEYBOARD_URL = HIFI_PUBLIC_BUCKET + "images/keyboard.svg";
|
||||
const CURSOR_URL = HIFI_PUBLIC_BUCKET + "images/cursor.svg";
|
||||
KEYBOARD_URL = HIFI_PUBLIC_BUCKET + "images/keyboard.svg";
|
||||
CURSOR_URL = HIFI_PUBLIC_BUCKET + "images/cursor.svg";
|
||||
|
||||
const SPACEBAR_CHARCODE = 32;
|
||||
RETURN_CHARCODE = 0x01000004;
|
||||
ENTER_CHARCODE = 0x01000005;
|
||||
SPACEBAR_CHARCODE = 32;
|
||||
|
||||
const KEYBOARD_WIDTH = 1174.7;
|
||||
const KEYBOARD_HEIGHT = 434.1;
|
||||
KEYBOARD_WIDTH = 1174.7;
|
||||
KEYBOARD_HEIGHT = 434.1;
|
||||
|
||||
const CURSOR_WIDTH = 33.9;
|
||||
const CURSOR_HEIGHT = 33.9;
|
||||
CURSOR_WIDTH = 33.9;
|
||||
CURSOR_HEIGHT = 33.9;
|
||||
|
||||
KEYBOARD_SCALE_MULTIPLIER = 0.50;
|
||||
|
||||
// VIEW_ANGLE can be adjusted to your likings, the smaller the faster movement.
|
||||
// Try setting it to 60 if it goes too fast for you.
|
||||
const VIEW_ANGLE = 40.0;
|
||||
const VIEW_ANGLE_BY_TWO = VIEW_ANGLE / 2;
|
||||
|
||||
const SPAWN_DISTANCE = 1;
|
||||
const DEFAULT_TEXT_DIMENSION_Z = 0.02;
|
||||
|
||||
const BOUND_X = 0;
|
||||
const BOUND_Y = 1;
|
||||
const BOUND_W = 2;
|
||||
const BOUND_H = 3;
|
||||
|
||||
const KEY_STATE_LOWER = 0;
|
||||
const KEY_STATE_UPPER = 1;
|
||||
|
||||
const TEXT_MARGIN_TOP = 0.15;
|
||||
const TEXT_MARGIN_LEFT = 0.15;
|
||||
const TEXT_MARGIN_RIGHT = 0.17;
|
||||
const TEXT_MARGIN_BOTTOM = 0.17;
|
||||
KEY_STATE_LOWER = 0;
|
||||
KEY_STATE_UPPER = 1;
|
||||
|
||||
var windowDimensions = Controller.getViewportDimensions();
|
||||
var cursor = null;
|
||||
var keyboard = new Keyboard();
|
||||
var textFontSize = 9;
|
||||
var text = null;
|
||||
var textText = "";
|
||||
var textSizeMeasureOverlay = Overlays.addOverlay("text3d", {visible: false});
|
||||
|
||||
function appendChar(char) {
|
||||
textText += char;
|
||||
updateTextOverlay();
|
||||
Overlays.editOverlay(text, {text: textText});
|
||||
}
|
||||
|
||||
function deleteChar() {
|
||||
if (textText.length > 0) {
|
||||
textText = textText.substring(0, textText.length - 1);
|
||||
updateTextOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
function updateTextOverlay() {
|
||||
var textLines = textText.split("\n");
|
||||
var maxLineWidth = 0;
|
||||
for (textLine in textLines) {
|
||||
var lineWidth = Overlays.textSize(text, textLines[textLine]).width;
|
||||
if (lineWidth > maxLineWidth) {
|
||||
maxLineWidth = lineWidth;
|
||||
}
|
||||
}
|
||||
var suggestedFontSize = (windowDimensions.x / maxLineWidth) * textFontSize * 0.90;
|
||||
var maxFontSize = 190 / textLines.length;
|
||||
textFontSize = (suggestedFontSize > maxFontSize) ? maxFontSize : suggestedFontSize;
|
||||
var topMargin = (250 - (textFontSize * textLines.length)) / 4;
|
||||
Overlays.editOverlay(text, {text: textText, font: {size: textFontSize}, topMargin: topMargin});
|
||||
var maxLineWidth = 0;
|
||||
for (textLine in textLines) {
|
||||
var lineWidth = Overlays.textSize(text, textLines[textLine]).width;
|
||||
if (lineWidth > maxLineWidth) {
|
||||
maxLineWidth = lineWidth;
|
||||
}
|
||||
}
|
||||
Overlays.editOverlay(text, {leftMargin: (windowDimensions.x - maxLineWidth) / 2});
|
||||
}
|
||||
|
||||
keyboard.onKeyPress = function(event) {
|
||||
if (event.event == 'keypress') {
|
||||
appendChar(event.char);
|
||||
} else if (event.event == 'enter') {
|
||||
appendChar("\n");
|
||||
}
|
||||
};
|
||||
|
||||
keyboard.onKeyRelease = function(event) {
|
||||
print("Key release event test");
|
||||
// you can cancel a key by releasing its focusing before releasing it
|
||||
if (event.focus) {
|
||||
if (event.event == 'delete') {
|
||||
deleteChar();
|
||||
} else if (event.event == 'submit') {
|
||||
print(textText);
|
||||
|
||||
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
|
||||
|
||||
var textLines = textText.split("\n");
|
||||
var maxLineWidth = 0;
|
||||
for (textLine in textLines) {
|
||||
var lineWidth = Overlays.textSize(textSizeMeasureOverlay, textLines[textLine]).width;
|
||||
if (lineWidth > maxLineWidth) {
|
||||
maxLineWidth = lineWidth;
|
||||
}
|
||||
}
|
||||
var usernameLine = "--" + GlobalServices.myUsername;
|
||||
var usernameWidth = Overlays.textSize(textSizeMeasureOverlay, usernameLine).width;
|
||||
if (maxLineWidth < usernameWidth) {
|
||||
maxLineWidth = usernameWidth;
|
||||
} else {
|
||||
var spaceableWidth = maxLineWidth - usernameWidth;
|
||||
var spaceWidth = Overlays.textSize(textSizeMeasureOverlay, " ").width;
|
||||
var numberOfSpaces = Math.floor(spaceableWidth / spaceWidth);
|
||||
for (var i = 0; i < numberOfSpaces; i++) {
|
||||
usernameLine = " " + usernameLine;
|
||||
}
|
||||
}
|
||||
var dimension_x = maxLineWidth + TEXT_MARGIN_RIGHT + TEXT_MARGIN_LEFT;
|
||||
if (position.x > 0 && position.y > 0 && position.z > 0) {
|
||||
Entities.addEntity({
|
||||
type: "Text",
|
||||
rotation: MyAvatar.orientation,
|
||||
position: position,
|
||||
dimensions: { x: dimension_x, y: (textLines.length + 1) * 0.14 + TEXT_MARGIN_TOP + TEXT_MARGIN_BOTTOM, z: DEFAULT_TEXT_DIMENSION_Z },
|
||||
backgroundColor: { red: 0, green: 0, blue: 0 },
|
||||
textColor: { red: 255, green: 255, blue: 255 },
|
||||
text: textText + "\n" + usernameLine
|
||||
});
|
||||
}
|
||||
textText = "";
|
||||
updateTextOverlay();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
keyboard.onFullyLoaded = function() {
|
||||
print("Virtual-keyboard fully loaded.");
|
||||
var dimensions = Controller.getViewportDimensions();
|
||||
text = Overlays.addOverlay("text", {
|
||||
x: 0,
|
||||
y: dimensions.y - keyboard.height() - 260,
|
||||
width: dimensions.x,
|
||||
height: 250,
|
||||
backgroundColor: { red: 255, green: 255, blue: 255},
|
||||
color: { red: 0, green: 0, blue: 0},
|
||||
topMargin: 5,
|
||||
leftMargin: 0,
|
||||
font: {size: textFontSize},
|
||||
text: "",
|
||||
alpha: 0.8
|
||||
});
|
||||
updateTextOverlay();
|
||||
// the cursor is being loaded after the keyboard, else it will be on the background of the keyboard
|
||||
cursor = new Cursor();
|
||||
cursor.onUpdate = function(position) {
|
||||
keyboard.setFocusPosition(position.x, position.y);
|
||||
};
|
||||
};
|
||||
|
||||
function KeyboardKey(keyboard, keyProperties) {
|
||||
KeyboardKey = (function(keyboard, keyProperties) {
|
||||
var tthis = this;
|
||||
this._focus = false;
|
||||
this._beingPressed = false;
|
||||
|
@ -247,6 +118,11 @@ function KeyboardKey(keyboard, keyProperties) {
|
|||
});
|
||||
}
|
||||
};
|
||||
this.updateVisibility = function() {
|
||||
for (var i = 0; i < tthis.bounds.length; i++) {
|
||||
Overlays.editOverlay(tthis.overlays[i], {visible: tthis.keyboard.visible});
|
||||
}
|
||||
};
|
||||
this.rescale = function() {
|
||||
for (var i = 0; i < tthis.bounds.length; i++) {
|
||||
Overlays.editOverlay(tthis.overlays[i], {
|
||||
|
@ -271,24 +147,48 @@ function KeyboardKey(keyboard, keyProperties) {
|
|||
return true;
|
||||
};
|
||||
for (var i = 0; i < this.bounds.length; i++) {
|
||||
var newOverlay = Overlays.cloneOverlay(this.keyboard.background);
|
||||
Overlays.editOverlay(newOverlay, {
|
||||
x: this.keyboard.getX() + this.bounds[i][BOUND_X] * keyboard.scale,
|
||||
y: this.keyboard.getY() + this.bounds[i][BOUND_Y] * keyboard.scale,
|
||||
width: this.bounds[i][BOUND_W] * keyboard.scale,
|
||||
height: this.bounds[i][BOUND_H] * keyboard.scale,
|
||||
subImage: {width: this.bounds[i][BOUND_W], height: this.bounds[i][BOUND_H], x: this.bounds[i][BOUND_X], y: (KEYBOARD_HEIGHT * this.keyState) + this.bounds[i][BOUND_Y]},
|
||||
alpha: 1
|
||||
});
|
||||
this.overlays.push(newOverlay);
|
||||
if (THREE_D_MODE) {
|
||||
this.overlays.push(Overlays.addOverlay("billboard", {
|
||||
scale: 1,
|
||||
rotation: MyAvatar.rotation,
|
||||
isFacingAvatar: false,
|
||||
url: KEYBOARD_URL,
|
||||
alpha: 1,
|
||||
position: {
|
||||
x: MyAvatar.position.x,// + this.bounds[i][BOUND_X] * 0.01,// /*+ this.keyboard.getX()*/ + this.bounds[i][BOUND_X] * keyboard.scale,
|
||||
y: MyAvatar.position.y,// - this.bounds[i][BOUND_Y] * 0.01,// /*+ this.keyboard.getY()*/ + this.bounds[i][BOUND_Y] * keyboard.scale,
|
||||
z: MyAvatar.position.z
|
||||
},
|
||||
width: this.bounds[i][BOUND_W] * keyboard.scale,
|
||||
height: this.bounds[i][BOUND_H] * keyboard.scale,
|
||||
subImage: {width: this.bounds[i][BOUND_W], height: this.bounds[i][BOUND_H], x: this.bounds[i][BOUND_X], y: (KEYBOARD_HEIGHT * this.keyState) + this.bounds[i][BOUND_Y]},
|
||||
alpha: 1,
|
||||
visible: tthis.keyboard.visible
|
||||
}));
|
||||
} else {
|
||||
this.overlays.push(Overlays.addOverlay("image", {
|
||||
imageURL: KEYBOARD_URL,
|
||||
x: this.keyboard.getX() + this.bounds[i][BOUND_X] * keyboard.scale,
|
||||
y: this.keyboard.getY() + this.bounds[i][BOUND_Y] * keyboard.scale,
|
||||
width: this.bounds[i][BOUND_W] * keyboard.scale,
|
||||
height: this.bounds[i][BOUND_H] * keyboard.scale,
|
||||
subImage: {width: this.bounds[i][BOUND_W], height: this.bounds[i][BOUND_H], x: this.bounds[i][BOUND_X], y: (KEYBOARD_HEIGHT * this.keyState) + this.bounds[i][BOUND_Y]},
|
||||
alpha: 1,
|
||||
visible: tthis.keyboard.visible
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function Keyboard() {
|
||||
Keyboard = (function(params) {
|
||||
if (params === undefined) {
|
||||
params = {};
|
||||
}
|
||||
var tthis = this;
|
||||
this.focussed_key = -1;
|
||||
this.scale = windowDimensions.x / KEYBOARD_WIDTH;
|
||||
this.scale = (windowDimensions.x / KEYBOARD_WIDTH) * KEYBOARD_SCALE_MULTIPLIER;
|
||||
this.shift = false;
|
||||
this.visible = params.visible != undefined ? params.visible : true;
|
||||
this.width = function() {
|
||||
return KEYBOARD_WIDTH * tthis.scale;
|
||||
};
|
||||
|
@ -301,17 +201,33 @@ function Keyboard() {
|
|||
this.getY = function() {
|
||||
return windowDimensions.y - this.height();
|
||||
};
|
||||
this.background = Overlays.addOverlay("image", {
|
||||
x: this.getX(),
|
||||
y: this.getY(),
|
||||
width: this.width(),
|
||||
height: this.height(),
|
||||
subImage: {width: KEYBOARD_WIDTH, height: KEYBOARD_HEIGHT, y: KEYBOARD_HEIGHT * KBD_BACKGROUND},
|
||||
imageURL: KEYBOARD_URL,
|
||||
alpha: 1
|
||||
});
|
||||
if (THREE_D_MODE) {
|
||||
this.background = Overlays.addOverlay("billboard", {
|
||||
scale: 1,
|
||||
position: MyAvatar.position,
|
||||
rotation: MyAvatar.rotation,
|
||||
width: this.width(),
|
||||
height: this.height(),
|
||||
subImage: {width: KEYBOARD_WIDTH, height: KEYBOARD_HEIGHT, y: KEYBOARD_HEIGHT * KBD_BACKGROUND},
|
||||
isFacingAvatar: false,
|
||||
url: KEYBOARD_URL,
|
||||
alpha: 1,
|
||||
visible: this.visible
|
||||
});
|
||||
} else {
|
||||
this.background = Overlays.addOverlay("image", {
|
||||
x: this.getX(),
|
||||
y: this.getY(),
|
||||
width: this.width(),
|
||||
height: this.height(),
|
||||
subImage: {width: KEYBOARD_WIDTH, height: KEYBOARD_HEIGHT, y: KEYBOARD_HEIGHT * KBD_BACKGROUND},
|
||||
imageURL: KEYBOARD_URL,
|
||||
alpha: 1,
|
||||
visible: this.visible
|
||||
});
|
||||
}
|
||||
this.rescale = function() {
|
||||
this.scale = windowDimensions.x / KEYBOARD_WIDTH;
|
||||
this.scale = (windowDimensions.x / KEYBOARD_WIDTH) * KEYBOARD_SCALE_MULTIPLIER;
|
||||
Overlays.editOverlay(tthis.background, {
|
||||
x: this.getX(),
|
||||
y: this.getY(),
|
||||
|
@ -349,6 +265,9 @@ function Keyboard() {
|
|||
};
|
||||
|
||||
this.pressFocussedKey = function() {
|
||||
if (!tthis.visible) {
|
||||
return tthis;
|
||||
}
|
||||
if (tthis.focussed_key != -1) {
|
||||
if (tthis.keys[tthis.focussed_key].event == 'shift') {
|
||||
tthis.toggleShift();
|
||||
|
@ -402,6 +321,32 @@ function Keyboard() {
|
|||
for (var i = 0; i < this.keys.length; i++) {
|
||||
this.keys[i].remove();
|
||||
}
|
||||
// resets the cursor and magnifier
|
||||
this.updateVisibility(false);
|
||||
};
|
||||
|
||||
this.show = function() {
|
||||
tthis.updateVisibility(true);
|
||||
};
|
||||
|
||||
this.hide = function() {
|
||||
tthis.updateVisibility(false);
|
||||
};
|
||||
|
||||
this.toggle = function() {
|
||||
tthis.updateVisibility(!tthis.visible);
|
||||
};
|
||||
|
||||
this.updateVisibility = function(visible) {
|
||||
tthis.visible = visible;
|
||||
if (HMD.magnifier == visible) {
|
||||
HMD.toggleMagnifier();
|
||||
}
|
||||
Window.cursorVisible = !visible;
|
||||
Overlays.editOverlay(tthis.background, { visible: tthis.visible });
|
||||
for (var i = 0; i < this.keys.length; i++) {
|
||||
this.keys[i].updateVisibility();
|
||||
}
|
||||
};
|
||||
|
||||
this.onKeyPress = null;
|
||||
|
@ -502,97 +447,94 @@ function Keyboard() {
|
|||
|
||||
{bounds: [[899, 355, 263, 67]], event: 'submit'}
|
||||
];
|
||||
|
||||
for (var i = 0; i < keyProperties.length; i++) {
|
||||
this.keys.push(new KeyboardKey(this, keyProperties[i]));
|
||||
}
|
||||
this.keyboardTextureLoaded = function() {
|
||||
if (Overlays.isLoaded(tthis.background)) {
|
||||
Script.clearInterval(tthis.keyboardTextureLoaded_timer);
|
||||
for (var i = 0; i < keyProperties.length; i++) {
|
||||
tthis.keys.push(new KeyboardKey(tthis, keyProperties[i]));
|
||||
}
|
||||
if (keyboard.onFullyLoaded != null) {
|
||||
tthis.onFullyLoaded();
|
||||
}
|
||||
}
|
||||
};
|
||||
this.keyboardTextureLoaded_timer = Script.setInterval(this.keyboardTextureLoaded, 250);
|
||||
}
|
||||
});
|
||||
|
||||
function Cursor() {
|
||||
Cursor = (function(params) {
|
||||
if (params === undefined) {
|
||||
params = {};
|
||||
}
|
||||
var tthis = this;
|
||||
this.x = windowDimensions.x / 2;
|
||||
this.y = windowDimensions.y / 2;
|
||||
this.overlay = Overlays.addOverlay("image", {
|
||||
x: this.x,
|
||||
y: this.y,
|
||||
width: CURSOR_WIDTH,
|
||||
height: CURSOR_HEIGHT,
|
||||
imageURL: CURSOR_URL,
|
||||
alpha: 1
|
||||
});
|
||||
this.remove = function() {
|
||||
Overlays.deleteOverlay(this.overlay);
|
||||
this.initialize = function() {
|
||||
this.visible = params.visible != undefined ? params.visible : true;
|
||||
this.x = windowDimensions.x / 2;
|
||||
this.y = windowDimensions.y / 2;
|
||||
this.overlay = Overlays.addOverlay("image", {
|
||||
x: this.x,
|
||||
y: this.y,
|
||||
width: CURSOR_WIDTH,
|
||||
height: CURSOR_HEIGHT,
|
||||
imageURL: CURSOR_URL,
|
||||
alpha: 1,
|
||||
visible: this.visible
|
||||
});
|
||||
this.remove = function() {
|
||||
Overlays.deleteOverlay(this.overlay);
|
||||
};
|
||||
this.getPosition = function() {
|
||||
return {x: tthis.getX(), y: tthis.getY()};
|
||||
};
|
||||
this.getX = function() {
|
||||
return tthis.x;
|
||||
};
|
||||
this.getY = function() {
|
||||
return tthis.y;
|
||||
};
|
||||
this.show = function() {
|
||||
tthis.updateVisibility(true);
|
||||
};
|
||||
this.hide = function() {
|
||||
tthis.updateVisibility(false);
|
||||
};
|
||||
this.toggle = function() {
|
||||
tthis.updateVisibility(!tthis.visible);
|
||||
};
|
||||
this.updateVisibility = function(visible) {
|
||||
tthis.visible = visible;
|
||||
Overlays.editOverlay(this.overlay, { visible: tthis.visible });
|
||||
};
|
||||
this.onUpdate = null;
|
||||
this.update = function() {
|
||||
var newWindowDimensions = Controller.getViewportDimensions();
|
||||
if (newWindowDimensions.x != windowDimensions.x || newWindowDimensions.y != windowDimensions.y) {
|
||||
windowDimensions = newWindowDimensions;
|
||||
keyboard.rescale();
|
||||
Overlays.editOverlay(text, {
|
||||
y: windowDimensions.y - keyboard.height() - 260,
|
||||
width: windowDimensions.x
|
||||
});
|
||||
}
|
||||
var editobject = {};
|
||||
var hudLookatPosition = HMD.getHUDLookAtPosition2D();
|
||||
if (hudLookatPosition === null) {
|
||||
return;
|
||||
}
|
||||
if (tthis.x !== hudLookatPosition.x) {
|
||||
tthis.x = hudLookatPosition.x;
|
||||
editobject.x = tthis.x - (CURSOR_WIDTH / 2);
|
||||
}
|
||||
if (tthis.y !== hudLookatPosition.y) {
|
||||
tthis.y = hudLookatPosition.y;
|
||||
editobject.y = tthis.y - (CURSOR_HEIGHT / 2);
|
||||
}
|
||||
if (Object.keys(editobject).length > 0) {
|
||||
Overlays.editOverlay(tthis.overlay, editobject);
|
||||
if (tthis.onUpdate != null) {
|
||||
tthis.onUpdate(tthis.getPosition());
|
||||
}
|
||||
}
|
||||
};
|
||||
Script.update.connect(this.update);
|
||||
};
|
||||
this.getPosition = function() {
|
||||
return {x: tthis.getX(), y: tthis.getY()};
|
||||
};
|
||||
this.getX = function() {
|
||||
return tthis.x;
|
||||
};
|
||||
this.getY = function() {
|
||||
return tthis.y;
|
||||
};
|
||||
this.onUpdate = null;
|
||||
this.update = function() {
|
||||
var newWindowDimensions = Controller.getViewportDimensions();
|
||||
if (newWindowDimensions.x != windowDimensions.x || newWindowDimensions.y != windowDimensions.y) {
|
||||
windowDimensions = newWindowDimensions;
|
||||
keyboard.rescale();
|
||||
Overlays.editOverlay(text, {
|
||||
y: windowDimensions.y - keyboard.height() - 260,
|
||||
width: windowDimensions.x
|
||||
});
|
||||
}
|
||||
var editobject = {};
|
||||
if (MyAvatar.getHeadFinalYaw() <= VIEW_ANGLE_BY_TWO && MyAvatar.getHeadFinalYaw() >= -1 * VIEW_ANGLE_BY_TWO) {
|
||||
angle = ((-1 * MyAvatar.getHeadFinalYaw()) + VIEW_ANGLE_BY_TWO) / VIEW_ANGLE;
|
||||
tthis.x = angle * windowDimensions.x;
|
||||
editobject.x = tthis.x - (CURSOR_WIDTH / 2);
|
||||
}
|
||||
if (MyAvatar.getHeadFinalPitch() <= VIEW_ANGLE_BY_TWO && MyAvatar.getHeadFinalPitch() >= -1 * VIEW_ANGLE_BY_TWO) {
|
||||
angle = ((-1 * MyAvatar.getHeadFinalPitch()) + VIEW_ANGLE_BY_TWO) / VIEW_ANGLE;
|
||||
tthis.y = angle * windowDimensions.y;
|
||||
editobject.y = tthis.y - (CURSOR_HEIGHT / 2);
|
||||
}
|
||||
if (Object.keys(editobject).length > 0) {
|
||||
Overlays.editOverlay(tthis.overlay, editobject);
|
||||
if (tthis.onUpdate != null) {
|
||||
tthis.onUpdate(tthis.getPosition());
|
||||
}
|
||||
}
|
||||
};
|
||||
Script.update.connect(this.update);
|
||||
}
|
||||
|
||||
function keyPressEvent(event) {
|
||||
if (event.key === SPACEBAR_CHARCODE) {
|
||||
keyboard.pressFocussedKey();
|
||||
}
|
||||
}
|
||||
|
||||
function keyReleaseEvent(event) {
|
||||
if (event.key === SPACEBAR_CHARCODE) {
|
||||
keyboard.releaseKeys();
|
||||
}
|
||||
}
|
||||
|
||||
function scriptEnding() {
|
||||
keyboard.remove();
|
||||
cursor.remove();
|
||||
Overlays.deleteOverlay(text);
|
||||
Overlays.deleteOverlay(textSizeMeasureOverlay);
|
||||
Controller.releaseKeyEvents({key: SPACEBAR_CHARCODE});
|
||||
}
|
||||
Controller.captureKeyEvents({key: SPACEBAR_CHARCODE});
|
||||
Controller.keyPressEvent.connect(keyPressEvent);
|
||||
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
||||
Script.scriptEnding.connect(scriptEnding);
|
||||
});
|
|
@ -55,7 +55,9 @@ var droneSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/drone.st
|
|||
var currentDrone = null;
|
||||
|
||||
var latinSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/latin.stereo.raw")
|
||||
var latinInjector = null;
|
||||
var elevatorSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/elevator.stereo.raw")
|
||||
var elevatorInjector = null;
|
||||
var currentMuzakInjector = null;
|
||||
var currentSound = null;
|
||||
|
||||
|
@ -140,7 +142,11 @@ function drawLobby() {
|
|||
|
||||
if (droneSound.downloaded) {
|
||||
// start the drone sound
|
||||
currentDrone = Audio.playSound(droneSound, { stereo: true, loop: true, localOnly: true, volume: DRONE_VOLUME });
|
||||
if (!currentDrone) {
|
||||
currentDrone = Audio.playSound(droneSound, { stereo: true, loop: true, localOnly: true, volume: DRONE_VOLUME });
|
||||
} else {
|
||||
currentDrone.restart();
|
||||
}
|
||||
}
|
||||
|
||||
// start one of our muzak sounds
|
||||
|
@ -152,7 +158,7 @@ var places = {};
|
|||
|
||||
function changeLobbyTextures() {
|
||||
var req = new XMLHttpRequest();
|
||||
req.open("GET", "https://data.highfidelity.io/api/v1/places?limit=21", false);
|
||||
req.open("GET", "https://metaverse.highfidelity.io/api/v1/places?limit=21", false);
|
||||
req.send();
|
||||
|
||||
places = JSON.parse(req.responseText).data.places;
|
||||
|
@ -173,6 +179,26 @@ function changeLobbyTextures() {
|
|||
|
||||
var MUZAK_VOLUME = 0.1;
|
||||
|
||||
function playCurrentSound(secondOffset) {
|
||||
if (currentSound == latinSound) {
|
||||
if (!latinInjector) {
|
||||
latinInjector = Audio.playSound(latinSound, { localOnly: true, secondOffset: secondOffset, volume: MUZAK_VOLUME });
|
||||
} else {
|
||||
latinInjector.restart();
|
||||
}
|
||||
|
||||
currentMuzakInjector = latinInjector;
|
||||
} else if (currentSound == elevatorSound) {
|
||||
if (!elevatorInjector) {
|
||||
elevatorInjector = Audio.playSound(elevatorSound, { localOnly: true, secondOffset: secondOffset, volume: MUZAK_VOLUME });
|
||||
} else {
|
||||
elevatorInjector.restart();
|
||||
}
|
||||
|
||||
currentMuzakInjector = elevatorInjector;
|
||||
}
|
||||
}
|
||||
|
||||
function playNextMuzak() {
|
||||
if (panelWall) {
|
||||
if (currentSound == latinSound) {
|
||||
|
@ -184,8 +210,8 @@ function playNextMuzak() {
|
|||
currentSound = latinSound;
|
||||
}
|
||||
}
|
||||
|
||||
currentMuzakInjector = Audio.playSound(currentSound, { localOnly: true, volume: MUZAK_VOLUME });
|
||||
|
||||
playCurrentSound(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,10 +226,11 @@ function playRandomMuzak() {
|
|||
currentSound = elevatorSound;
|
||||
}
|
||||
|
||||
if (currentSound) {
|
||||
if (currentSound) {
|
||||
// pick a random number of seconds from 0-10 to offset the muzak
|
||||
var secondOffset = Math.random() * 10;
|
||||
currentMuzakInjector = Audio.playSound(currentSound, { localOnly: true, secondOffset: secondOffset, volume: MUZAK_VOLUME });
|
||||
|
||||
playCurrentSound(secondOffset);
|
||||
} else {
|
||||
currentMuzakInjector = null;
|
||||
}
|
||||
|
@ -227,10 +254,9 @@ function cleanupLobby() {
|
|||
panelWall = false;
|
||||
orbShell = false;
|
||||
|
||||
Audio.stopInjector(currentDrone);
|
||||
currentDrone = null;
|
||||
currentDrone.stop();
|
||||
currentMuzakInjector.stop();
|
||||
|
||||
Audio.stopInjector(currentMuzakInjector);
|
||||
currentMuzakInjector = null;
|
||||
|
||||
places = {};
|
||||
|
@ -354,7 +380,7 @@ function update(deltaTime) {
|
|||
Overlays.editOverlay(descriptionText, { position: textOverlayPosition() });
|
||||
|
||||
// if the reticle is up then we may need to play the next muzak
|
||||
if (currentMuzakInjector && !Audio.isInjectorPlaying(currentMuzakInjector)) {
|
||||
if (currentMuzakInjector && !currentMuzakInjector.isPlaying) {
|
||||
playNextMuzak();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,18 +80,9 @@ Controller.mousePressEvent.connect(mousePressEvent);
|
|||
Controller.mouseMoveEvent.connect(mouseMoveEvent);
|
||||
Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
|
||||
|
||||
// disable the standard application for mouse events
|
||||
Controller.captureMouseEvents();
|
||||
|
||||
function scriptEnding() {
|
||||
// re-enabled the standard application for mouse events
|
||||
Controller.releaseMouseEvents();
|
||||
}
|
||||
|
||||
MyAvatar.bodyYaw = 0;
|
||||
MyAvatar.bodyPitch = 0;
|
||||
MyAvatar.bodyRoll = 0;
|
||||
|
||||
// would be nice to change to update
|
||||
Script.update.connect(update);
|
||||
Script.scriptEnding.connect(scriptEnding);
|
||||
|
|
121
examples/planets.js
Normal file
121
examples/planets.js
Normal file
|
@ -0,0 +1,121 @@
|
|||
//
|
||||
// planets.js
|
||||
//
|
||||
// Created by Philip Rosedale on January 26, 2015
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Some planets are created in front of you. A physical object shot or thrown between them will move
|
||||
// correctly.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var MAX_RANGE = 75.0;
|
||||
var MAX_TRANSLATION = MAX_RANGE / 20.0;
|
||||
|
||||
var LIFETIME = 600;
|
||||
var DAMPING = 0.0;
|
||||
var G = 3.0;
|
||||
|
||||
// In this section, setup where you want your 'Planets' that will exert gravity on the
|
||||
// smaller test particles. Use the first one for the simplest 'planets around sun' simulation.
|
||||
// Add additional planets to make things a lot more complicated!
|
||||
|
||||
var planetTypes = [];
|
||||
planetTypes.push({ radius: 15, red: 0, green: 0, blue: 255, x: 0.0, y:0, z: 0.0 });
|
||||
//planetTypes.push({ radius: 10, red: 0, green: 255, blue: 0, x: 0.60, y:0, z: 0.60 });
|
||||
//planetTypes.push({ radius: 10, red: 0, green: 0, blue: 255, x: 0.75, y:0, z: 0.75 });
|
||||
//planetTypes.push({ radius: 5, red: 255, green: 0, blue: 0, x: 0.25, y:0, z: 0.25 });
|
||||
//planetTypes.push({ radius: 5, red: 0, green: 255, blue: 255, x: 0, y:0, z: 0 });
|
||||
|
||||
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(MAX_RANGE, Quat.getFront(Camera.getOrientation())));
|
||||
|
||||
var NUM_INITIAL_PARTICLES = 200;
|
||||
var PARTICLE_MIN_SIZE = 0.50;
|
||||
var PARTICLE_MAX_SIZE = 1.50;
|
||||
var INITIAL_VELOCITY = 5.0;
|
||||
|
||||
var planets = [];
|
||||
var particles = [];
|
||||
|
||||
// Create planets that will extert gravity on test particles
|
||||
for (var i = 0; i < planetTypes.length; i++) {
|
||||
var rotationalVelocity = 10 + Math.random() * 60;
|
||||
var position = { x: planetTypes[i].x, y: planetTypes[i].y, z: planetTypes[i].z };
|
||||
position = Vec3.multiply(MAX_RANGE / 2, position);
|
||||
position = Vec3.sum(center, position);
|
||||
|
||||
planets.push(Entities.addEntity(
|
||||
{ type: "Sphere",
|
||||
position: position,
|
||||
dimensions: { x: planetTypes[i].radius, y: planetTypes[i].radius, z: planetTypes[i].radius },
|
||||
color: { red: planetTypes[i].red, green: planetTypes[i].green, blue: planetTypes[i].blue },
|
||||
gravity: { x: 0, y: 0, z: 0 },
|
||||
angularVelocity: { x: 0, y: rotationalVelocity, z: 0 },
|
||||
angularDamping: 0.0,
|
||||
ignoreCollisions: false,
|
||||
lifetime: LIFETIME,
|
||||
collisionsWillMove: false }));
|
||||
}
|
||||
|
||||
Script.setTimeout(createParticles, 1000);
|
||||
|
||||
function createParticles() {
|
||||
// Create initial test particles that will move according to gravity from the planets
|
||||
for (var i = 0; i < NUM_INITIAL_PARTICLES; i++) {
|
||||
var radius = PARTICLE_MIN_SIZE + Math.random() * PARTICLE_MAX_SIZE;
|
||||
var gray = Math.random() * 155;
|
||||
var whichPlanet = Math.floor(Math.random() * planets.length);
|
||||
var position = { x: (Math.random() - 0.5) * MAX_RANGE, y: (Math.random() - 0.5) * MAX_TRANSLATION, z: (Math.random() - 0.5) * MAX_RANGE };
|
||||
var separation = Vec3.length(position);
|
||||
particles.push(Entities.addEntity(
|
||||
{ type: "Sphere",
|
||||
position: Vec3.sum(center, position),
|
||||
dimensions: { x: radius, y: radius, z: radius },
|
||||
color: { red: 100 + gray, green: 100 + gray, blue: 100 + gray },
|
||||
gravity: { x: 0, y: 0, z: 0 },
|
||||
angularVelocity: { x: 0, y: 0, z: 0 },
|
||||
velocity: Vec3.multiply(INITIAL_VELOCITY * Math.sqrt(separation), Vec3.normalize(Vec3.cross(position, { x: 0, y: 1, z: 0 }))),
|
||||
ignoreCollisions: false,
|
||||
damping: DAMPING,
|
||||
lifetime: LIFETIME,
|
||||
collisionsWillMove: true }));
|
||||
}
|
||||
Script.update.connect(update);
|
||||
}
|
||||
|
||||
function scriptEnding() {
|
||||
for (var i = 0; i < planetTypes.length; i++) {
|
||||
Entities.deleteEntity(planets[i]);
|
||||
}
|
||||
for (var i = 0; i < particles.length; i++) {
|
||||
Entities.deleteEntity(particles[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function update(deltaTime) {
|
||||
// Apply gravitational force from planets
|
||||
for (var t = 0; t < particles.length; t++) {
|
||||
var properties1 = Entities.getEntityProperties(particles[t]);
|
||||
var velocity = properties1.velocity;
|
||||
var vColor = Vec3.length(velocity) / 50 * 255;
|
||||
var dV = { x:0, y:0, z:0 };
|
||||
var mass1 = Math.pow(properties1.dimensions.x / 2.0, 3.0);
|
||||
for (var p = 0; p < planets.length; p++) {
|
||||
var properties2 = Entities.getEntityProperties(planets[p]);
|
||||
var mass2 = Math.pow(properties2.dimensions.x / 2.0, 3.0);
|
||||
var between = Vec3.subtract(properties1.position, properties2.position);
|
||||
var separation = Vec3.length(between);
|
||||
dV = Vec3.sum(dV, Vec3.multiply(-G * mass1 * mass2 / separation, Vec3.normalize(between)));
|
||||
}
|
||||
if (Math.random() < 0.1) {
|
||||
Entities.editEntity(particles[t], { color: { red: vColor, green: 100, blue: (255 - vColor) }, velocity: Vec3.sum(velocity, Vec3.multiply(deltaTime, dV))});
|
||||
} else {
|
||||
Entities.editEntity(particles[t], { velocity: Vec3.sum(velocity, Vec3.multiply(deltaTime, dV))});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Script.scriptEnding.connect(scriptEnding);
|
265
examples/progress.js
Normal file
265
examples/progress.js
Normal file
|
@ -0,0 +1,265 @@
|
|||
//
|
||||
// progress.js
|
||||
// examples
|
||||
//
|
||||
// Created by David Rowe on 29 Jan 2015.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// This script displays a progress download indicator when downloads are in progress.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
(function () {
|
||||
|
||||
var progress = 100, // %
|
||||
alpha = 0.0,
|
||||
alphaDelta = 0.0, // > 0 if fading in; < 0 if fading out/
|
||||
ALPHA_DELTA_IN = 0.15,
|
||||
ALPHA_DELTA_OUT = -0.02,
|
||||
fadeTimer = null,
|
||||
FADE_INTERVAL = 30, // ms between changes in alpha.
|
||||
fadeWaitTimer = null,
|
||||
FADE_OUT_WAIT = 1000, // Wait before starting to fade out after progress 100%.
|
||||
visible = false,
|
||||
BAR_WIDTH = 320, // Nominal dimension of SVG in pixels of visible portion (half) of the bar.
|
||||
BAR_HEIGHT = 20,
|
||||
BAR_URL = "http://hifi-public.s3.amazonaws.com/images/progress-bar.svg",
|
||||
BACKGROUND_WIDTH = 360,
|
||||
BACKGROUND_HEIGHT = 60,
|
||||
BACKGROUND_URL = "http://hifi-public.s3.amazonaws.com/images/progress-bar-background.svg",
|
||||
isOnHMD = false,
|
||||
windowWidth = 0,
|
||||
windowHeight = 0,
|
||||
background2D = {},
|
||||
bar2D = {},
|
||||
SCALE_2D = 0.55, // Scale the SVGs for 2D display.
|
||||
background3D = {},
|
||||
bar3D = {},
|
||||
ENABLE_VR_MODE_MENU_ITEM = "Enable VR Mode",
|
||||
PROGRESS_3D_DIRECTION = 0.0, // Degrees from avatar orientation.
|
||||
PROGRESS_3D_DISTANCE = 0.602, // Horizontal distance from avatar position.
|
||||
PROGRESS_3D_ELEVATION = -0.8, // Height of top middle of top notification relative to avatar eyes.
|
||||
PROGRESS_3D_YAW = 0.0, // Degrees relative to notifications direction.
|
||||
PROGRESS_3D_PITCH = -60.0, // Degrees from vertical.
|
||||
SCALE_3D = 0.0017, // Scale the bar SVG for 3D display.
|
||||
BACKGROUND_3D_SIZE = { x: 0.76, y: 0.08 }, // Match up with the 3D background with those of notifications.js notices.
|
||||
BACKGROUND_3D_COLOR = { red: 2, green: 2, blue: 2 },
|
||||
BACKGROUND_3D_ALPHA = 0.7;
|
||||
|
||||
function fade() {
|
||||
|
||||
alpha = alpha + alphaDelta;
|
||||
|
||||
if (alpha < 0) {
|
||||
alpha = 0;
|
||||
}
|
||||
|
||||
if (alpha > 1) {
|
||||
alpha = 1;
|
||||
}
|
||||
|
||||
if (alpha === 0 || alpha === 1) { // Finished fading in or out
|
||||
alphaDelta = 0;
|
||||
Script.clearInterval(fadeTimer);
|
||||
}
|
||||
|
||||
if (alpha === 0) { // Finished fading out
|
||||
visible = false;
|
||||
}
|
||||
|
||||
if (isOnHMD) {
|
||||
Overlays.editOverlay(background3D.overlay, {
|
||||
backgroundAlpha: alpha * BACKGROUND_3D_ALPHA,
|
||||
visible: visible
|
||||
});
|
||||
} else {
|
||||
Overlays.editOverlay(background2D.overlay, {
|
||||
alpha: alpha,
|
||||
visible: visible
|
||||
});
|
||||
}
|
||||
Overlays.editOverlay(isOnHMD ? bar3D.overlay : bar2D.overlay, {
|
||||
alpha: alpha,
|
||||
visible: visible
|
||||
});
|
||||
}
|
||||
|
||||
function onDownloadInfoChanged(info) {
|
||||
var i;
|
||||
|
||||
// Calculate progress
|
||||
if (info.downloading.length + info.pending === 0) {
|
||||
progress = 100;
|
||||
} else {
|
||||
progress = 0;
|
||||
for (i = 0; i < info.downloading.length; i += 1) {
|
||||
progress += info.downloading[i];
|
||||
}
|
||||
progress = progress / (info.downloading.length + info.pending);
|
||||
}
|
||||
|
||||
// Update state
|
||||
if (!visible) { // Not visible because no recent downloads
|
||||
if (progress < 100) { // Have started downloading so fade in
|
||||
visible = true;
|
||||
alphaDelta = ALPHA_DELTA_IN;
|
||||
fadeTimer = Script.setInterval(fade, FADE_INTERVAL);
|
||||
}
|
||||
} else if (alphaDelta !== 0.0) { // Fading in or out
|
||||
if (alphaDelta > 0) {
|
||||
if (progress === 100) { // Was donloading but now have finished so fade out
|
||||
alphaDelta = ALPHA_DELTA_OUT;
|
||||
}
|
||||
} else {
|
||||
if (progress < 100) { // Was finished downloading but have resumed so fade in
|
||||
alphaDelta = ALPHA_DELTA_IN;
|
||||
}
|
||||
}
|
||||
} else { // Fully visible because downloading or recently so
|
||||
if (fadeWaitTimer === null) {
|
||||
if (progress === 100) { // Was downloading but have finished so fade out soon
|
||||
fadeWaitTimer = Script.setTimeout(function () {
|
||||
alphaDelta = ALPHA_DELTA_OUT;
|
||||
fadeTimer = Script.setInterval(fade, FADE_INTERVAL);
|
||||
fadeWaitTimer = null;
|
||||
}, FADE_OUT_WAIT);
|
||||
}
|
||||
} else {
|
||||
if (progress < 100) { // Was finished and waiting to fade out but have resumed downloading so don't fade out
|
||||
Script.clearInterval(fadeWaitTimer);
|
||||
fadeWaitTimer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update progress bar
|
||||
if (visible) {
|
||||
Overlays.editOverlay(isOnHMD ? bar3D.overlay : bar2D.overlay, {
|
||||
subImage: { x: BAR_WIDTH * (1 - progress / 100), y: 0, width: BAR_WIDTH, height: BAR_HEIGHT }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function createOverlays() {
|
||||
if (isOnHMD) {
|
||||
|
||||
background3D.overlay = Overlays.addOverlay("rectangle3d", {
|
||||
size: BACKGROUND_3D_SIZE,
|
||||
color: BACKGROUND_3D_COLOR,
|
||||
alpha: BACKGROUND_3D_ALPHA,
|
||||
solid: true,
|
||||
isFacingAvatar: false,
|
||||
visible: false,
|
||||
ignoreRayIntersection: true
|
||||
});
|
||||
bar3D.overlay = Overlays.addOverlay("billboard", {
|
||||
url: BAR_URL,
|
||||
subImage: { x: BAR_WIDTH, y: 0, width: BAR_WIDTH, height: BAR_HEIGHT },
|
||||
scale: SCALE_3D * BAR_WIDTH,
|
||||
isFacingAvatar: false,
|
||||
visible: false,
|
||||
alpha: 0.0,
|
||||
ignoreRayIntersection: true
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
background2D.overlay = Overlays.addOverlay("image", {
|
||||
imageURL: BACKGROUND_URL,
|
||||
width: background2D.width,
|
||||
height: background2D.height,
|
||||
visible: false,
|
||||
alpha: 0.0
|
||||
});
|
||||
bar2D.overlay = Overlays.addOverlay("image", {
|
||||
imageURL: BAR_URL,
|
||||
subImage: { x: BAR_WIDTH, y: 0, width: BAR_WIDTH, height: BAR_HEIGHT },
|
||||
width: bar2D.width,
|
||||
height: bar2D.height,
|
||||
visible: false,
|
||||
alpha: 0.0
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function deleteOverlays() {
|
||||
Overlays.deleteOverlay(isOnHMD ? background3D.overlay : background2D.overlay);
|
||||
Overlays.deleteOverlay(isOnHMD ? bar3D.overlay : bar2D.overlay);
|
||||
}
|
||||
|
||||
function update() {
|
||||
var viewport,
|
||||
eyePosition,
|
||||
avatarOrientation;
|
||||
|
||||
if (isOnHMD !== Menu.isOptionChecked(ENABLE_VR_MODE_MENU_ITEM)) {
|
||||
deleteOverlays();
|
||||
isOnHMD = !isOnHMD;
|
||||
createOverlays();
|
||||
}
|
||||
|
||||
if (visible) {
|
||||
if (isOnHMD) {
|
||||
// Update 3D overlays to maintain positions relative to avatar
|
||||
eyePosition = MyAvatar.getDefaultEyePosition();
|
||||
avatarOrientation = MyAvatar.orientation;
|
||||
|
||||
Overlays.editOverlay(background3D.overlay, {
|
||||
position: Vec3.sum(eyePosition, Vec3.multiplyQbyV(avatarOrientation, background3D.offset)),
|
||||
rotation: Quat.multiply(avatarOrientation, background3D.orientation)
|
||||
});
|
||||
Overlays.editOverlay(bar3D.overlay, {
|
||||
position: Vec3.sum(eyePosition, Vec3.multiplyQbyV(avatarOrientation, bar3D.offset)),
|
||||
rotation: Quat.multiply(avatarOrientation, bar3D.orientation)
|
||||
});
|
||||
|
||||
} else {
|
||||
// Update 2D overlays to maintain positions at bottom middle of window
|
||||
viewport = Controller.getViewportDimensions();
|
||||
|
||||
if (viewport.x !== windowWidth || viewport.y !== windowHeight) {
|
||||
windowWidth = viewport.x;
|
||||
windowHeight = viewport.y;
|
||||
|
||||
Overlays.editOverlay(background2D.overlay, {
|
||||
x: windowWidth / 2 - background2D.width / 2,
|
||||
y: windowHeight - background2D.height - bar2D.height
|
||||
});
|
||||
|
||||
Overlays.editOverlay(bar2D.overlay, {
|
||||
x: windowWidth / 2 - bar2D.width / 2,
|
||||
y: windowHeight - background2D.height - bar2D.height + (background2D.height - bar2D.height) / 2
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
background2D.width = SCALE_2D * BACKGROUND_WIDTH;
|
||||
background2D.height = SCALE_2D * BACKGROUND_HEIGHT;
|
||||
bar2D.width = SCALE_2D * BAR_WIDTH;
|
||||
bar2D.height = SCALE_2D * BAR_HEIGHT;
|
||||
|
||||
background3D.offset = Vec3.multiplyQbyV(Quat.fromPitchYawRollDegrees(0, PROGRESS_3D_DIRECTION, 0),
|
||||
{ x: 0, y: 0, z: -PROGRESS_3D_DISTANCE });
|
||||
background3D.offset.y += PROGRESS_3D_ELEVATION;
|
||||
background3D.orientation = Quat.fromPitchYawRollDegrees(PROGRESS_3D_PITCH, PROGRESS_3D_DIRECTION + PROGRESS_3D_YAW, 0);
|
||||
bar3D.offset = Vec3.sum(background3D.offset, { x: 0, y: 0, z: 0.001 }); // Just in front of background
|
||||
bar3D.orientation = background3D.orientation;
|
||||
|
||||
createOverlays();
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
deleteOverlays();
|
||||
}
|
||||
|
||||
setUp();
|
||||
GlobalServices.downloadInfoChanged.connect(onDownloadInfoChanged);
|
||||
GlobalServices.updateDownloadInfo();
|
||||
Script.update.connect(update);
|
||||
Script.scriptEnding.connect(tearDown);
|
||||
}());
|
|
@ -21,20 +21,13 @@ var offset = Vec3.normalize(Quat.getFront(MyAvatar.orientation));
|
|||
var position = Vec3.sum(MyAvatar.position, offset);
|
||||
|
||||
function update(deltaTime) {
|
||||
if (!Audio.isInjectorPlaying(soundPlaying)) {
|
||||
soundPlaying = Audio.playSound(sound, {
|
||||
position: position,
|
||||
loop: true
|
||||
});
|
||||
print("Started sound loop");
|
||||
}
|
||||
}
|
||||
|
||||
function scriptEnding() {
|
||||
if (Audio.isInjectorPlaying(soundPlaying)) {
|
||||
Audio.stopInjector(soundPlaying);
|
||||
print("Stopped sound loop");
|
||||
}
|
||||
if (sound.downloaded && !soundPlaying) {
|
||||
print("Started sound loop");
|
||||
soundPlaying = Audio.playSound(sound, {
|
||||
position: position,
|
||||
loop: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Script.update.connect(update);
|
||||
|
|
|
@ -32,14 +32,13 @@ var sound = Audio.playSound(soundClip, { position: orbitCenter, loop: true, volu
|
|||
function update(deltaTime) {
|
||||
time += deltaTime;
|
||||
currentPosition = { x: orbitCenter.x + Math.cos(time * SPEED) * RADIUS, y: orbitCenter.y, z: orbitCenter.z + Math.sin(time * SPEED) * RADIUS };
|
||||
trailingLoudness = 0.9 * trailingLoudness + 0.1 * Audio.getLoudness(sound);
|
||||
trailingLoudness = 0.9 * trailingLoudness + 0.1 * sound.loudness;
|
||||
Entities.editEntity( objectId, { position: currentPosition, color: { red: Math.min(trailingLoudness * 2000, 255), green: 0, blue: 0 } } );
|
||||
Audio.setInjectorOptions(sound, { position: currentPosition });
|
||||
sound.setOptions({ position: currentPosition });
|
||||
}
|
||||
|
||||
Script.scriptEnding.connect(function() {
|
||||
Entities.deleteEntity(objectId);
|
||||
Audio.stopInjector(sound);
|
||||
});
|
||||
|
||||
Script.update.connect(update);
|
|
@ -30,7 +30,7 @@ var playing = false;
|
|||
var ball = false;
|
||||
|
||||
function maybePlaySound(deltaTime) {
|
||||
if (sound.downloaded) {
|
||||
if (sound.downloaded && !soundPlaying) {
|
||||
var properties = {
|
||||
type: "Sphere",
|
||||
position: options.position,
|
||||
|
@ -45,11 +45,9 @@ function maybePlaySound(deltaTime) {
|
|||
}
|
||||
|
||||
function scriptEnding() {
|
||||
if (Audio.isInjectorPlaying(soundPlaying)) {
|
||||
Audio.stopInjector(soundPlaying);
|
||||
Entities.deleteEntity(ball);
|
||||
print("Stopped sound.");
|
||||
}
|
||||
if (ball) {
|
||||
Entities.deleteEntity(ball);
|
||||
}
|
||||
}
|
||||
|
||||
// Connect a call back that happens every frame
|
||||
|
|
90
gvr-interface/CMakeLists.txt
Normal file
90
gvr-interface/CMakeLists.txt
Normal file
|
@ -0,0 +1,90 @@
|
|||
set(TARGET_NAME gvr-interface)
|
||||
|
||||
if (ANDROID)
|
||||
set(ANDROID_APK_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/apk-build")
|
||||
set(ANDROID_APK_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/apk")
|
||||
|
||||
set(ANDROID_SDK_ROOT $ENV{ANDROID_HOME})
|
||||
set(ANDROID_APP_DISPLAY_NAME Interface)
|
||||
set(ANDROID_API_LEVEL 19)
|
||||
set(ANDROID_APK_PACKAGE io.highfidelity.gvrinterface)
|
||||
set(ANDROID_ACTIVITY_NAME io.highfidelity.gvrinterface.InterfaceActivity)
|
||||
set(ANDROID_APK_VERSION_NAME "0.1")
|
||||
set(ANDROID_APK_VERSION_CODE 1)
|
||||
set(ANDROID_APK_FULLSCREEN TRUE)
|
||||
set(ANDROID_DEPLOY_QT_INSTALL "--install")
|
||||
|
||||
set(BUILD_SHARED_LIBS ON)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${ANDROID_APK_OUTPUT_DIR}/libs/${ANDROID_ABI}")
|
||||
|
||||
setup_hifi_library(Gui Widgets AndroidExtras)
|
||||
else ()
|
||||
setup_hifi_project(Gui Widgets)
|
||||
endif ()
|
||||
|
||||
include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
|
||||
|
||||
add_dependency_external_project(glm)
|
||||
find_package(GLM REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PRIVATE ${GLM_INCLUDE_DIRS})
|
||||
|
||||
link_hifi_libraries(shared networking audio-client avatars)
|
||||
include_dependency_includes()
|
||||
|
||||
if (ANDROID)
|
||||
find_package(LibOVR)
|
||||
|
||||
if (LIBOVR_FOUND)
|
||||
add_definitions(-DHAVE_LIBOVR)
|
||||
target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES} ${LIBOVR_ANDROID_LIBRARIES} ${TURBOJPEG_LIBRARY})
|
||||
include_directories(SYSTEM ${LIBOVR_INCLUDE_DIRS})
|
||||
|
||||
# we need VRLib, so add a project.properties to our apk build folder that says that
|
||||
file(RELATIVE_PATH RELATIVE_VRLIB_PATH ${ANDROID_APK_OUTPUT_DIR} "${LIBOVR_VRLIB_DIR}")
|
||||
file(WRITE "${ANDROID_APK_BUILD_DIR}/project.properties" "android.library.reference.1=${RELATIVE_VRLIB_PATH}")
|
||||
|
||||
list(APPEND IGNORE_COPY_LIBS ${LIBOVR_ANDROID_LIBRARIES})
|
||||
endif ()
|
||||
|
||||
endif ()
|
||||
|
||||
# the presence of a HOCKEY_APP_ID means we are making a beta build
|
||||
if (ANDROID AND HOCKEY_APP_ID)
|
||||
set(HOCKEY_APP_ENABLED true)
|
||||
set(HOCKEY_APP_ACTIVITY "<activity android:name='net.hockeyapp.android.UpdateActivity' />\n")
|
||||
set(ANDROID_ACTIVITY_NAME io.highfidelity.gvrinterface.InterfaceBetaActivity)
|
||||
set(ANDROID_DEPLOY_QT_INSTALL "")
|
||||
set(ANDROID_APK_CUSTOM_NAME "Interface-beta.apk")
|
||||
|
||||
# set the ANDROID_APK_VERSION_CODE to the number of git commits
|
||||
execute_process(
|
||||
COMMAND git rev-list --first-parent --count HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_COMMIT_COUNT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
set(ANDROID_APK_VERSION_CODE ${GIT_COMMIT_COUNT})
|
||||
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/templates/InterfaceBetaActivity.java.in" "${ANDROID_APK_BUILD_DIR}/src/io/highfidelity/gvrinterface/InterfaceBetaActivity.java")
|
||||
elseif (ANDROID)
|
||||
set(HOCKEY_APP_ENABLED false)
|
||||
endif ()
|
||||
|
||||
if (ANDROID)
|
||||
|
||||
set(HIFI_URL_INTENT "<intent-filter>\
|
||||
\n <action android:name='android.intent.action.VIEW' />\
|
||||
\n <category android:name='android.intent.category.DEFAULT' />\
|
||||
\n <category android:name='android.intent.category.BROWSABLE' />\
|
||||
\n <data android:scheme='hifi' />\
|
||||
\n </intent-filter>"
|
||||
)
|
||||
|
||||
set(ANDROID_EXTRA_APPLICATION_XML "${HOCKEY_APP_ACTIVITY}")
|
||||
set(ANDROID_EXTRA_ACTIVITY_XML "${HIFI_URL_INTENT}")
|
||||
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/templates/hockeyapp.xml.in" "${ANDROID_APK_BUILD_DIR}/res/values/hockeyapp.xml")
|
||||
qt_create_apk()
|
||||
|
||||
endif (ANDROID)
|
BIN
gvr-interface/res/drawable/icon.png
Normal file
BIN
gvr-interface/res/drawable/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.7 KiB |
73
gvr-interface/src/Client.cpp
Normal file
73
gvr-interface/src/Client.cpp
Normal file
|
@ -0,0 +1,73 @@
|
|||
//
|
||||
// Client.cpp
|
||||
// gvr-interface/src
|
||||
//
|
||||
// Created by Stephen Birarda on 1/20/15.
|
||||
// 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
|
||||
//
|
||||
|
||||
#include <AccountManager.h>
|
||||
#include <AddressManager.h>
|
||||
#include <HifiSockAddr.h>
|
||||
#include <NodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
|
||||
#include "Client.h"
|
||||
|
||||
Client::Client(QObject* parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
// we need to make sure that required dependencies are created
|
||||
DependencyManager::set<AddressManager>();
|
||||
|
||||
setupNetworking();
|
||||
}
|
||||
|
||||
void Client::setupNetworking() {
|
||||
// once Application order of instantiation is fixed this should be done from AccountManager
|
||||
AccountManager::getInstance().setAuthURL(DEFAULT_NODE_AUTH_URL);
|
||||
|
||||
// setup the NodeList for this client
|
||||
DependencyManager::registerInheritance<LimitedNodeList, NodeList>();
|
||||
auto nodeList = DependencyManager::set<NodeList>(NodeType::Agent, 0);
|
||||
|
||||
// while datagram processing remains simple for targets using Client, we'll handle datagrams
|
||||
connect(&nodeList->getNodeSocket(), &QUdpSocket::readyRead, this, &Client::processDatagrams);
|
||||
|
||||
// every second, ask the NodeList to check in with the domain server
|
||||
QTimer* domainCheckInTimer = new QTimer(this);
|
||||
domainCheckInTimer->setInterval(DOMAIN_SERVER_CHECK_IN_MSECS);
|
||||
connect(domainCheckInTimer, &QTimer::timeout, nodeList.data(), &NodeList::sendDomainServerCheckIn);
|
||||
|
||||
// TODO: once the Client knows its Address on start-up we should be able to immediately send a check in here
|
||||
domainCheckInTimer->start();
|
||||
|
||||
// handle the case where the domain stops talking to us
|
||||
// TODO: can we just have the nodelist do this when it sets up? Is there a user of the NodeList that wouldn't want this?
|
||||
connect(nodeList.data(), &NodeList::limitOfSilentDomainCheckInsReached, nodeList.data(), &NodeList::reset);
|
||||
}
|
||||
|
||||
void Client::processVerifiedPacket(const HifiSockAddr& senderSockAddr, const QByteArray& incomingPacket) {
|
||||
DependencyManager::get<NodeList>()->processNodeData(senderSockAddr, incomingPacket);
|
||||
}
|
||||
|
||||
void Client::processDatagrams() {
|
||||
HifiSockAddr senderSockAddr;
|
||||
|
||||
static QByteArray incomingPacket;
|
||||
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
|
||||
while (DependencyManager::get<NodeList>()->getNodeSocket().hasPendingDatagrams()) {
|
||||
incomingPacket.resize(nodeList->getNodeSocket().pendingDatagramSize());
|
||||
nodeList->getNodeSocket().readDatagram(incomingPacket.data(), incomingPacket.size(),
|
||||
senderSockAddr.getAddressPointer(), senderSockAddr.getPortPointer());
|
||||
|
||||
if (nodeList->packetVersionAndHashMatch(incomingPacket)) {
|
||||
processVerifiedPacket(senderSockAddr, incomingPacket);
|
||||
}
|
||||
}
|
||||
}
|
33
gvr-interface/src/Client.h
Normal file
33
gvr-interface/src/Client.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
//
|
||||
// Client.h
|
||||
// gvr-interface/src
|
||||
//
|
||||
// Created by Stephen Birarda on 1/20/15.
|
||||
// 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 hifi_Client_h
|
||||
#define hifi_Client_h
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
#include <HifiSockAddr.h>
|
||||
|
||||
class Client : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Client(QObject* parent = 0);
|
||||
|
||||
virtual void cleanupBeforeQuit() = 0;
|
||||
protected:
|
||||
|
||||
void setupNetworking();
|
||||
virtual void processVerifiedPacket(const HifiSockAddr& senderSockAddr, const QByteArray& incomingPacket);
|
||||
private slots:
|
||||
void processDatagrams();
|
||||
};
|
||||
|
||||
#endif // hifi_Client_h
|
191
gvr-interface/src/GVRInterface.cpp
Normal file
191
gvr-interface/src/GVRInterface.cpp
Normal file
|
@ -0,0 +1,191 @@
|
|||
//
|
||||
// GVRInterface.cpp
|
||||
// gvr-interface/src
|
||||
//
|
||||
// Created by Stephen Birarda on 11/18/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
|
||||
//
|
||||
|
||||
#ifdef ANDROID
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
#include <QtAndroidExtras/QAndroidJniEnvironment>
|
||||
#include <QtAndroidExtras/QAndroidJniObject>
|
||||
|
||||
#ifdef HAVE_LIBOVR
|
||||
|
||||
#include <KeyState.h>
|
||||
#include <VrApi/VrApi.h>
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtGui/QKeyEvent>
|
||||
#include <QtWidgets/QMenuBar>
|
||||
|
||||
#include "GVRMainWindow.h"
|
||||
#include "RenderingClient.h"
|
||||
|
||||
#include "GVRInterface.h"
|
||||
|
||||
static QString launchURLString = QString();
|
||||
|
||||
#ifdef ANDROID
|
||||
|
||||
extern "C" {
|
||||
|
||||
JNIEXPORT void Java_io_highfidelity_gvrinterface_InterfaceActivity_handleHifiURL(JNIEnv *jni, jclass clazz, jstring hifiURLString) {
|
||||
launchURLString = QAndroidJniObject(hifiURLString).toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
GVRInterface::GVRInterface(int argc, char* argv[]) :
|
||||
QApplication(argc, argv),
|
||||
_mainWindow(NULL),
|
||||
_inVRMode(false)
|
||||
{
|
||||
setApplicationName("gvr-interface");
|
||||
setOrganizationName("highfidelity");
|
||||
setOrganizationDomain("io");
|
||||
|
||||
if (!launchURLString.isEmpty()) {
|
||||
// did we get launched with a lookup URL? If so it is time to give that to the AddressManager
|
||||
qDebug() << "We were opened via a hifi URL -" << launchURLString;
|
||||
}
|
||||
|
||||
_client = new RenderingClient(this, launchURLString);
|
||||
|
||||
launchURLString = QString();
|
||||
|
||||
connect(this, &QGuiApplication::applicationStateChanged, this, &GVRInterface::handleApplicationStateChange);
|
||||
|
||||
#if defined(ANDROID) && defined(HAVE_LIBOVR)
|
||||
QAndroidJniEnvironment jniEnv;
|
||||
|
||||
QPlatformNativeInterface* interface = QApplication::platformNativeInterface();
|
||||
jobject activity = (jobject) interface->nativeResourceForIntegration("QtActivity");
|
||||
|
||||
ovr_RegisterHmtReceivers(&*jniEnv, activity);
|
||||
|
||||
// PLATFORMACTIVITY_REMOVAL: Temp workaround for PlatformActivity being
|
||||
// stripped from UnityPlugin. Alternate is to use LOCAL_WHOLE_STATIC_LIBRARIES
|
||||
// but that increases the size of the plugin by ~1MiB
|
||||
OVR::linkerPlatformActivity++;
|
||||
#endif
|
||||
|
||||
// call our idle function whenever we can
|
||||
QTimer* idleTimer = new QTimer(this);
|
||||
connect(idleTimer, &QTimer::timeout, this, &GVRInterface::idle);
|
||||
idleTimer->start(0);
|
||||
|
||||
// call our quit handler before we go down
|
||||
connect(this, &QCoreApplication::aboutToQuit, this, &GVRInterface::handleApplicationQuit);
|
||||
}
|
||||
|
||||
void GVRInterface::handleApplicationQuit() {
|
||||
_client->cleanupBeforeQuit();
|
||||
}
|
||||
|
||||
void GVRInterface::idle() {
|
||||
#if defined(ANDROID) && defined(HAVE_LIBOVR)
|
||||
if (!_inVRMode && ovr_IsHeadsetDocked()) {
|
||||
qDebug() << "The headset just got docked - enter VR mode.";
|
||||
enterVRMode();
|
||||
} else if (_inVRMode) {
|
||||
|
||||
if (ovr_IsHeadsetDocked()) {
|
||||
static int counter = 0;
|
||||
|
||||
// Get the latest head tracking state, predicted ahead to the midpoint of the time
|
||||
// it will be displayed. It will always be corrected to the real values by
|
||||
// time warp, but the closer we get, the less black will be pulled in at the edges.
|
||||
const double now = ovr_GetTimeInSeconds();
|
||||
static double prev;
|
||||
const double rawDelta = now - prev;
|
||||
prev = now;
|
||||
const double clampedPrediction = std::min( 0.1, rawDelta * 2);
|
||||
ovrSensorState sensor = ovrHmd_GetSensorState(OvrHmd, now + clampedPrediction, true );
|
||||
|
||||
auto ovrOrientation = sensor.Predicted.Pose.Orientation;
|
||||
glm::quat newOrientation(ovrOrientation.w, ovrOrientation.x, ovrOrientation.y, ovrOrientation.z);
|
||||
_client->setOrientation(newOrientation);
|
||||
|
||||
if (counter++ % 100000 == 0) {
|
||||
qDebug() << "GetSensorState in frame" << counter << "-"
|
||||
<< ovrOrientation.x << ovrOrientation.y << ovrOrientation.z << ovrOrientation.w;
|
||||
}
|
||||
} else {
|
||||
qDebug() << "The headset was undocked - leaving VR mode.";
|
||||
|
||||
leaveVRMode();
|
||||
}
|
||||
}
|
||||
|
||||
OVR::KeyState& backKeyState = _mainWindow->getBackKeyState();
|
||||
auto backEvent = backKeyState.Update(ovr_GetTimeInSeconds());
|
||||
|
||||
if (backEvent == OVR::KeyState::KEY_EVENT_LONG_PRESS) {
|
||||
qDebug() << "Attemping to start the Platform UI Activity.";
|
||||
ovr_StartPackageActivity(_ovr, PUI_CLASS_NAME, PUI_GLOBAL_MENU);
|
||||
} else if (backEvent == OVR::KeyState::KEY_EVENT_DOUBLE_TAP || backEvent == OVR::KeyState::KEY_EVENT_SHORT_PRESS) {
|
||||
qDebug() << "Got an event we should cancel for!";
|
||||
} else if (backEvent == OVR::KeyState::KEY_EVENT_DOUBLE_TAP) {
|
||||
qDebug() << "The button is down!";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void GVRInterface::handleApplicationStateChange(Qt::ApplicationState state) {
|
||||
switch(state) {
|
||||
case Qt::ApplicationActive:
|
||||
qDebug() << "The application is active.";
|
||||
break;
|
||||
case Qt::ApplicationSuspended:
|
||||
qDebug() << "The application is being suspended.";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void GVRInterface::enterVRMode() {
|
||||
#if defined(ANDROID) && defined(HAVE_LIBOVR)
|
||||
// Default vrModeParms
|
||||
ovrModeParms vrModeParms;
|
||||
vrModeParms.AsynchronousTimeWarp = true;
|
||||
vrModeParms.AllowPowerSave = true;
|
||||
vrModeParms.DistortionFileName = NULL;
|
||||
vrModeParms.EnableImageServer = false;
|
||||
vrModeParms.CpuLevel = 2;
|
||||
vrModeParms.GpuLevel = 2;
|
||||
vrModeParms.GameThreadTid = 0;
|
||||
|
||||
QAndroidJniEnvironment jniEnv;
|
||||
|
||||
QPlatformNativeInterface* interface = QApplication::platformNativeInterface();
|
||||
jobject activity = (jobject) interface->nativeResourceForIntegration("QtActivity");
|
||||
|
||||
vrModeParms.ActivityObject = activity;
|
||||
|
||||
ovrHmdInfo hmdInfo;
|
||||
_ovr = ovr_EnterVrMode(vrModeParms, &hmdInfo);
|
||||
|
||||
_inVRMode = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void GVRInterface::leaveVRMode() {
|
||||
#if defined(ANDROID) && defined(HAVE_LIBOVR)
|
||||
ovr_LeaveVrMode(_ovr);
|
||||
_inVRMode = false;
|
||||
#endif
|
||||
}
|
72
gvr-interface/src/GVRInterface.h
Normal file
72
gvr-interface/src/GVRInterface.h
Normal file
|
@ -0,0 +1,72 @@
|
|||
//
|
||||
// GVRInterface.h
|
||||
// gvr-interface/src
|
||||
//
|
||||
// Created by Stephen Birarda on 11/18/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 hifi_GVRInterface_h
|
||||
#define hifi_GVRInterface_h
|
||||
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
#if defined(ANDROID) && defined(HAVE_LIBOVR)
|
||||
class ovrMobile;
|
||||
class ovrHmdInfo;
|
||||
|
||||
// This is set by JNI_OnLoad() when the .so is initially loaded.
|
||||
// Must use to attach each thread that will use JNI:
|
||||
namespace OVR {
|
||||
// PLATFORMACTIVITY_REMOVAL: Temp workaround for PlatformActivity being
|
||||
// stripped from UnityPlugin. Alternate is to use LOCAL_WHOLE_STATIC_LIBRARIES
|
||||
// but that increases the size of the plugin by ~1MiB
|
||||
extern int linkerPlatformActivity;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
class GVRMainWindow;
|
||||
class RenderingClient;
|
||||
class QKeyEvent;
|
||||
|
||||
#if defined(qApp)
|
||||
#undef qApp
|
||||
#endif
|
||||
#define qApp (static_cast<GVRInterface*>(QApplication::instance()))
|
||||
|
||||
class GVRInterface : public QApplication {
|
||||
Q_OBJECT
|
||||
public:
|
||||
GVRInterface(int argc, char* argv[]);
|
||||
RenderingClient* getClient() { return _client; }
|
||||
|
||||
void setMainWindow(GVRMainWindow* mainWindow) { _mainWindow = mainWindow; }
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
|
||||
private slots:
|
||||
void handleApplicationStateChange(Qt::ApplicationState state);
|
||||
void idle();
|
||||
private:
|
||||
void handleApplicationQuit();
|
||||
|
||||
void enterVRMode();
|
||||
void leaveVRMode();
|
||||
|
||||
#if defined(ANDROID) && defined(HAVE_LIBOVR)
|
||||
ovrMobile* _ovr;
|
||||
ovrHmdInfo* _hmdInfo;
|
||||
#endif
|
||||
|
||||
GVRMainWindow* _mainWindow;
|
||||
|
||||
RenderingClient* _client;
|
||||
bool _inVRMode;
|
||||
};
|
||||
|
||||
#endif // hifi_GVRInterface_h
|
176
gvr-interface/src/GVRMainWindow.cpp
Normal file
176
gvr-interface/src/GVRMainWindow.cpp
Normal file
|
@ -0,0 +1,176 @@
|
|||
//
|
||||
// GVRMainWindow.cpp
|
||||
// gvr-interface/src
|
||||
//
|
||||
// Created by Stephen Birarda on 1/20/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
|
||||
//
|
||||
|
||||
#include <QtGui/QKeyEvent>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QInputDialog>
|
||||
#include <QtWidgets/QLabel>
|
||||
#include <QtWidgets/QLineEdit>
|
||||
#include <QtWidgets/QMenuBar>
|
||||
#include <QtWidgets/QMessageBox>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
|
||||
#ifndef ANDROID
|
||||
|
||||
#include <QtWidgets/QDesktopWidget>
|
||||
|
||||
#elif defined(HAVE_LIBOVR)
|
||||
|
||||
#include <OVR_CAPI.h>
|
||||
|
||||
const float LIBOVR_DOUBLE_TAP_DURATION = 0.25f;
|
||||
const float LIBOVR_LONG_PRESS_DURATION = 0.75f;
|
||||
|
||||
#endif
|
||||
|
||||
#include <AddressManager.h>
|
||||
|
||||
#include "InterfaceView.h"
|
||||
#include "LoginDialog.h"
|
||||
#include "RenderingClient.h"
|
||||
|
||||
#include "GVRMainWindow.h"
|
||||
|
||||
|
||||
|
||||
GVRMainWindow::GVRMainWindow(QWidget* parent) :
|
||||
QMainWindow(parent),
|
||||
#if defined(ANDROID) && defined(HAVE_LIBOVR)
|
||||
_backKeyState(LIBOVR_DOUBLE_TAP_DURATION, LIBOVR_LONG_PRESS_DURATION),
|
||||
_wasBackKeyDown(false),
|
||||
#endif
|
||||
_mainLayout(NULL),
|
||||
_menuBar(NULL),
|
||||
_loginAction(NULL)
|
||||
{
|
||||
|
||||
#ifndef ANDROID
|
||||
const int NOTE_4_WIDTH = 2560;
|
||||
const int NOTE_4_HEIGHT = 1440;
|
||||
setFixedSize(NOTE_4_WIDTH / 2, NOTE_4_HEIGHT / 2);
|
||||
#endif
|
||||
|
||||
setupMenuBar();
|
||||
|
||||
QWidget* baseWidget = new QWidget(this);
|
||||
|
||||
// setup a layout so we can vertically align to top
|
||||
_mainLayout = new QVBoxLayout(baseWidget);
|
||||
_mainLayout->setAlignment(Qt::AlignTop);
|
||||
|
||||
// set the layout on the base widget
|
||||
baseWidget->setLayout(_mainLayout);
|
||||
|
||||
setCentralWidget(baseWidget);
|
||||
|
||||
// add the interface view
|
||||
new InterfaceView(baseWidget);
|
||||
}
|
||||
|
||||
GVRMainWindow::~GVRMainWindow() {
|
||||
delete _menuBar;
|
||||
}
|
||||
|
||||
void GVRMainWindow::keyPressEvent(QKeyEvent* event) {
|
||||
#ifdef ANDROID
|
||||
if (event->key() == Qt::Key_Back) {
|
||||
// got the Android back key, hand off to OVR KeyState
|
||||
_backKeyState.HandleEvent(ovr_GetTimeInSeconds(), true, (_wasBackKeyDown ? 1 : 0));
|
||||
_wasBackKeyDown = true;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void GVRMainWindow::keyReleaseEvent(QKeyEvent* event) {
|
||||
#ifdef ANDROID
|
||||
if (event->key() == Qt::Key_Back) {
|
||||
// release on the Android back key, hand off to OVR KeyState
|
||||
_backKeyState.HandleEvent(ovr_GetTimeInSeconds(), false, 0);
|
||||
_wasBackKeyDown = false;
|
||||
}
|
||||
#endif
|
||||
QWidget::keyReleaseEvent(event);
|
||||
}
|
||||
|
||||
void GVRMainWindow::setupMenuBar() {
|
||||
QMenu* fileMenu = new QMenu("File");
|
||||
QMenu* helpMenu = new QMenu("Help");
|
||||
|
||||
_menuBar = new QMenuBar(0);
|
||||
|
||||
_menuBar->addMenu(fileMenu);
|
||||
_menuBar->addMenu(helpMenu);
|
||||
|
||||
QAction* goToAddress = new QAction("Go to Address", fileMenu);
|
||||
connect(goToAddress, &QAction::triggered, this, &GVRMainWindow::showAddressBar);
|
||||
fileMenu->addAction(goToAddress);
|
||||
|
||||
_loginAction = new QAction("Login", fileMenu);
|
||||
fileMenu->addAction(_loginAction);
|
||||
|
||||
// change the login action depending on our logged in/out state
|
||||
AccountManager& accountManager = AccountManager::getInstance();
|
||||
connect(&accountManager, &AccountManager::loginComplete, this, &GVRMainWindow::refreshLoginAction);
|
||||
connect(&accountManager, &AccountManager::logoutComplete, this, &GVRMainWindow::refreshLoginAction);
|
||||
|
||||
// refresh the state now
|
||||
refreshLoginAction();
|
||||
|
||||
QAction* aboutQt = new QAction("About Qt", helpMenu);
|
||||
connect(aboutQt, &QAction::triggered, qApp, &QApplication::aboutQt);
|
||||
helpMenu->addAction(aboutQt);
|
||||
|
||||
setMenuBar(_menuBar);
|
||||
}
|
||||
|
||||
void GVRMainWindow::showAddressBar() {
|
||||
// setup the address QInputDialog
|
||||
QInputDialog* addressDialog = new QInputDialog(this);
|
||||
addressDialog->setLabelText("Address");
|
||||
|
||||
// add the address dialog to the main layout
|
||||
_mainLayout->addWidget(addressDialog);
|
||||
|
||||
connect(addressDialog, &QInputDialog::textValueSelected,
|
||||
DependencyManager::get<AddressManager>().data(), &AddressManager::handleLookupString);
|
||||
}
|
||||
|
||||
void GVRMainWindow::showLoginDialog() {
|
||||
LoginDialog* loginDialog = new LoginDialog(this);
|
||||
|
||||
// have the acccount manager handle credentials from LoginDialog
|
||||
AccountManager& accountManager = AccountManager::getInstance();
|
||||
connect(loginDialog, &LoginDialog::credentialsEntered, &accountManager, &AccountManager::requestAccessToken);
|
||||
connect(&accountManager, &AccountManager::loginFailed, this, &GVRMainWindow::showLoginFailure);
|
||||
|
||||
_mainLayout->addWidget(loginDialog);
|
||||
}
|
||||
|
||||
void GVRMainWindow::showLoginFailure() {
|
||||
QMessageBox::warning(this, "Login Failed",
|
||||
"Could not log in with that username and password. Please try again!");
|
||||
}
|
||||
|
||||
void GVRMainWindow::refreshLoginAction() {
|
||||
AccountManager& accountManager = AccountManager::getInstance();
|
||||
disconnect(_loginAction, &QAction::triggered, &accountManager, 0);
|
||||
|
||||
if (accountManager.isLoggedIn()) {
|
||||
_loginAction->setText("Logout");
|
||||
connect(_loginAction, &QAction::triggered, &accountManager, &AccountManager::logout);
|
||||
} else {
|
||||
_loginAction->setText("Login");
|
||||
connect(_loginAction, &QAction::triggered, this, &GVRMainWindow::showLoginDialog);
|
||||
}
|
||||
|
||||
}
|
58
gvr-interface/src/GVRMainWindow.h
Normal file
58
gvr-interface/src/GVRMainWindow.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
//
|
||||
// GVRMainWindow.h
|
||||
// gvr-interface/src
|
||||
//
|
||||
// Created by Stephen Birarda on 1/20/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 hifi_GVRMainWindow_h
|
||||
#define hifi_GVRMainWindow_h
|
||||
|
||||
#include <QtWidgets/QMainWindow>
|
||||
|
||||
#if defined(ANDROID) && defined(HAVE_LIBOVR)
|
||||
#include <KeyState.h>
|
||||
#endif
|
||||
|
||||
class QKeyEvent;
|
||||
class QMenuBar;
|
||||
class QVBoxLayout;
|
||||
|
||||
class GVRMainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
GVRMainWindow(QWidget* parent = 0);
|
||||
~GVRMainWindow();
|
||||
public slots:
|
||||
void showAddressBar();
|
||||
void showLoginDialog();
|
||||
|
||||
void showLoginFailure();
|
||||
|
||||
#if defined(ANDROID) && defined(HAVE_LIBOVR)
|
||||
OVR::KeyState& getBackKeyState() { return _backKeyState; }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
void keyReleaseEvent(QKeyEvent* event);
|
||||
private slots:
|
||||
void refreshLoginAction();
|
||||
private:
|
||||
void setupMenuBar();
|
||||
|
||||
#if defined(ANDROID) && defined(HAVE_LIBOVR)
|
||||
OVR::KeyState _backKeyState;
|
||||
bool _wasBackKeyDown;
|
||||
#endif
|
||||
|
||||
QVBoxLayout* _mainLayout;
|
||||
QMenuBar* _menuBar;
|
||||
QAction* _loginAction;
|
||||
};
|
||||
|
||||
#endif // hifi_GVRMainWindow_h
|
18
gvr-interface/src/InterfaceView.cpp
Normal file
18
gvr-interface/src/InterfaceView.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
//
|
||||
// InterfaceView.cpp
|
||||
// gvr-interface/src
|
||||
//
|
||||
// Created by Stephen Birarda on 1/28/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
|
||||
//
|
||||
|
||||
#include "InterfaceView.h"
|
||||
|
||||
InterfaceView::InterfaceView(QWidget* parent, Qt::WindowFlags flags) :
|
||||
QOpenGLWidget(parent, flags)
|
||||
{
|
||||
|
||||
}
|
23
gvr-interface/src/InterfaceView.h
Normal file
23
gvr-interface/src/InterfaceView.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// InterfaceView.h
|
||||
// gvr-interface/src
|
||||
//
|
||||
// Created by Stephen Birarda on 1/28/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 hifi_InterfaceView_h
|
||||
#define hifi_InterfaceView_h
|
||||
|
||||
#include <QtWidgets/QOpenGLWidget>
|
||||
|
||||
class InterfaceView : public QOpenGLWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
InterfaceView(QWidget* parent = 0, Qt::WindowFlags flags = 0);
|
||||
};
|
||||
|
||||
#endif // hifi_InterfaceView_h
|
69
gvr-interface/src/LoginDialog.cpp
Normal file
69
gvr-interface/src/LoginDialog.cpp
Normal file
|
@ -0,0 +1,69 @@
|
|||
//
|
||||
// LoginDialog.cpp
|
||||
// gvr-interface/src
|
||||
//
|
||||
// Created by Stephen Birarda on 2015-02-03.
|
||||
// Copyright 2015 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
|
||||
//
|
||||
|
||||
#include <QtWidgets/QDialogButtonBox>
|
||||
#include <QtWidgets/QGridLayout>
|
||||
#include <QtWidgets/QLabel>
|
||||
#include <QtWidgets/QLineEdit>
|
||||
#include <QtWidgets/QPushButton>
|
||||
|
||||
#include "LoginDialog.h"
|
||||
|
||||
LoginDialog::LoginDialog(QWidget* parent) :
|
||||
QDialog(parent)
|
||||
{
|
||||
setupGUI();
|
||||
setWindowTitle("Login");
|
||||
setModal(true);
|
||||
}
|
||||
|
||||
void LoginDialog::setupGUI() {
|
||||
// setup a grid layout
|
||||
QGridLayout* formGridLayout = new QGridLayout(this);
|
||||
|
||||
_usernameLineEdit = new QLineEdit(this);
|
||||
|
||||
QLabel* usernameLabel = new QLabel(this);
|
||||
usernameLabel->setText("Username");
|
||||
usernameLabel->setBuddy(_usernameLineEdit);
|
||||
|
||||
formGridLayout->addWidget(usernameLabel, 0, 0);
|
||||
formGridLayout->addWidget(_usernameLineEdit, 1, 0);
|
||||
|
||||
_passwordLineEdit = new QLineEdit(this);
|
||||
_passwordLineEdit->setEchoMode(QLineEdit::Password);
|
||||
|
||||
QLabel* passwordLabel = new QLabel(this);
|
||||
passwordLabel->setText("Password");
|
||||
passwordLabel->setBuddy(_passwordLineEdit);
|
||||
|
||||
formGridLayout->addWidget(passwordLabel, 2, 0);
|
||||
formGridLayout->addWidget(_passwordLineEdit, 3, 0);
|
||||
|
||||
QDialogButtonBox* buttons = new QDialogButtonBox(this);
|
||||
|
||||
QPushButton* okButton = buttons->addButton(QDialogButtonBox::Ok);
|
||||
QPushButton* cancelButton = buttons->addButton(QDialogButtonBox::Cancel);
|
||||
|
||||
okButton->setText("Login");
|
||||
|
||||
connect(cancelButton, &QPushButton::clicked, this, &QDialog::close);
|
||||
connect(okButton, &QPushButton::clicked, this, &LoginDialog::loginButtonClicked);
|
||||
|
||||
formGridLayout->addWidget(buttons, 4, 0, 1, 2);
|
||||
|
||||
setLayout(formGridLayout);
|
||||
}
|
||||
|
||||
void LoginDialog::loginButtonClicked() {
|
||||
emit credentialsEntered(_usernameLineEdit->text(), _passwordLineEdit->text());
|
||||
close();
|
||||
}
|
34
gvr-interface/src/LoginDialog.h
Normal file
34
gvr-interface/src/LoginDialog.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
//
|
||||
// LoginDialog.h
|
||||
// gvr-interface/src
|
||||
//
|
||||
// Created by Stephen Birarda on 2015-02-03.
|
||||
// Copyright 2015 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 hifi_LoginDialog_h
|
||||
#define hifi_LoginDialog_h
|
||||
|
||||
#include <QtWidgets/QDialog>
|
||||
|
||||
class QLineEdit;
|
||||
|
||||
class LoginDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
LoginDialog(QWidget* parent = 0);
|
||||
signals:
|
||||
void credentialsEntered(const QString& username, const QString& password);
|
||||
private slots:
|
||||
void loginButtonClicked();
|
||||
private:
|
||||
void setupGUI();
|
||||
|
||||
QLineEdit* _usernameLineEdit;
|
||||
QLineEdit* _passwordLineEdit;
|
||||
};
|
||||
|
||||
#endif // hifi_LoginDialog_h
|
167
gvr-interface/src/RenderingClient.cpp
Normal file
167
gvr-interface/src/RenderingClient.cpp
Normal file
|
@ -0,0 +1,167 @@
|
|||
//
|
||||
// RenderingClient.cpp
|
||||
// gvr-interface/src
|
||||
//
|
||||
// Created by Stephen Birarda on 1/20/15.
|
||||
// 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
|
||||
//
|
||||
|
||||
#include <QtCore/QThread>
|
||||
#include <QtWidgets/QInputDialog>
|
||||
|
||||
#include <AddressManager.h>
|
||||
#include <AudioClient.h>
|
||||
#include <AvatarHashMap.h>
|
||||
#include <NodeList.h>
|
||||
|
||||
#include "RenderingClient.h"
|
||||
|
||||
RenderingClient* RenderingClient::_instance = NULL;
|
||||
|
||||
RenderingClient::RenderingClient(QObject *parent, const QString& launchURLString) :
|
||||
Client(parent)
|
||||
{
|
||||
_instance = this;
|
||||
|
||||
// connect to AddressManager and pass it the launch URL, if we have one
|
||||
auto addressManager = DependencyManager::get<AddressManager>();
|
||||
connect(addressManager.data(), &AddressManager::locationChangeRequired, this, &RenderingClient::goToLocation);
|
||||
addressManager->loadSettings(launchURLString);
|
||||
|
||||
// tell the NodeList which node types all rendering clients will want to know about
|
||||
DependencyManager::get<NodeList>()->addSetOfNodeTypesToNodeInterestSet(NodeSet() << NodeType::AudioMixer << NodeType::AvatarMixer);
|
||||
|
||||
DependencyManager::set<AvatarHashMap>();
|
||||
|
||||
// get our audio client setup on its own thread
|
||||
QThread* audioThread = new QThread();
|
||||
auto audioClient = DependencyManager::set<AudioClient>();
|
||||
|
||||
audioClient->setPositionGetter(getPositionForAudio);
|
||||
audioClient->setOrientationGetter(getOrientationForAudio);
|
||||
|
||||
audioClient->moveToThread(audioThread);
|
||||
connect(audioThread, &QThread::started, audioClient.data(), &AudioClient::start);
|
||||
connect(audioClient.data(), &AudioClient::destroyed, audioThread, &QThread::quit);
|
||||
connect(audioThread, &QThread::finished, audioThread, &QThread::deleteLater);
|
||||
|
||||
audioThread->start();
|
||||
|
||||
|
||||
connect(&_avatarTimer, &QTimer::timeout, this, &RenderingClient::sendAvatarPacket);
|
||||
_avatarTimer.setInterval(16); // 60 FPS
|
||||
_avatarTimer.start();
|
||||
_fakeAvatar.setDisplayName("GearVR");
|
||||
_fakeAvatar.setFaceModelURL(QUrl(DEFAULT_HEAD_MODEL_URL));
|
||||
_fakeAvatar.setSkeletonModelURL(QUrl(DEFAULT_BODY_MODEL_URL));
|
||||
_fakeAvatar.toByteArray(); // Creates HeadData
|
||||
}
|
||||
|
||||
void RenderingClient::sendAvatarPacket() {
|
||||
_fakeAvatar.setPosition(_position);
|
||||
_fakeAvatar.setHeadOrientation(_orientation);
|
||||
|
||||
QByteArray packet = byteArrayWithPopulatedHeader(PacketTypeAvatarData);
|
||||
packet.append(_fakeAvatar.toByteArray());
|
||||
DependencyManager::get<NodeList>()->broadcastToNodes(packet, NodeSet() << NodeType::AvatarMixer);
|
||||
_fakeAvatar.sendIdentityPacket();
|
||||
}
|
||||
|
||||
void RenderingClient::cleanupBeforeQuit() {
|
||||
|
||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
|
||||
"stop", Qt::BlockingQueuedConnection);
|
||||
|
||||
// destroy the AudioClient so it and its thread will safely go down
|
||||
DependencyManager::destroy<AudioClient>();
|
||||
}
|
||||
|
||||
void RenderingClient::processVerifiedPacket(const HifiSockAddr& senderSockAddr, const QByteArray& incomingPacket) {
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
PacketType incomingType = packetTypeForPacket(incomingPacket);
|
||||
|
||||
switch (incomingType) {
|
||||
case PacketTypeAudioEnvironment:
|
||||
case PacketTypeAudioStreamStats:
|
||||
case PacketTypeMixedAudio:
|
||||
case PacketTypeSilentAudioFrame: {
|
||||
|
||||
if (incomingType == PacketTypeAudioStreamStats) {
|
||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "parseAudioStreamStatsPacket",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(QByteArray, incomingPacket));
|
||||
} else if (incomingType == PacketTypeAudioEnvironment) {
|
||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "parseAudioEnvironmentData",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(QByteArray, incomingPacket));
|
||||
} else {
|
||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "addReceivedAudioToStream",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(QByteArray, incomingPacket));
|
||||
}
|
||||
|
||||
// update having heard from the audio-mixer and record the bytes received
|
||||
SharedNodePointer audioMixer = nodeList->sendingNodeForPacket(incomingPacket);
|
||||
|
||||
if (audioMixer) {
|
||||
audioMixer->setLastHeardMicrostamp(usecTimestampNow());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case PacketTypeBulkAvatarData:
|
||||
case PacketTypeKillAvatar:
|
||||
case PacketTypeAvatarIdentity:
|
||||
case PacketTypeAvatarBillboard: {
|
||||
// update having heard from the avatar-mixer and record the bytes received
|
||||
SharedNodePointer avatarMixer = nodeList->sendingNodeForPacket(incomingPacket);
|
||||
|
||||
if (avatarMixer) {
|
||||
avatarMixer->setLastHeardMicrostamp(usecTimestampNow());
|
||||
|
||||
QMetaObject::invokeMethod(DependencyManager::get<AvatarHashMap>().data(),
|
||||
"processAvatarMixerDatagram",
|
||||
Q_ARG(const QByteArray&, incomingPacket),
|
||||
Q_ARG(const QWeakPointer<Node>&, avatarMixer));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Client::processVerifiedPacket(senderSockAddr, incomingPacket);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void RenderingClient::goToLocation(const glm::vec3& newPosition,
|
||||
bool hasOrientationChange, const glm::quat& newOrientation,
|
||||
bool shouldFaceLocation) {
|
||||
qDebug().nospace() << "RenderingClient goToLocation - moving to " << newPosition.x << ", "
|
||||
<< newPosition.y << ", " << newPosition.z;
|
||||
|
||||
glm::vec3 shiftedPosition = newPosition;
|
||||
|
||||
if (hasOrientationChange) {
|
||||
qDebug().nospace() << "RenderingClient goToLocation - new orientation is "
|
||||
<< newOrientation.x << ", " << newOrientation.y << ", " << newOrientation.z << ", " << newOrientation.w;
|
||||
|
||||
// orient the user to face the target
|
||||
glm::quat quatOrientation = newOrientation;
|
||||
|
||||
if (shouldFaceLocation) {
|
||||
|
||||
quatOrientation = newOrientation * glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
|
||||
// move the user a couple units away
|
||||
const float DISTANCE_TO_USER = 2.0f;
|
||||
shiftedPosition = newPosition - quatOrientation * glm::vec3( 0.0f, 0.0f,-1.0f) * DISTANCE_TO_USER;
|
||||
}
|
||||
|
||||
_orientation = quatOrientation;
|
||||
}
|
||||
|
||||
_position = shiftedPosition;
|
||||
|
||||
}
|
57
gvr-interface/src/RenderingClient.h
Normal file
57
gvr-interface/src/RenderingClient.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
//
|
||||
// RenderingClient.h
|
||||
// gvr-interface/src
|
||||
//
|
||||
// Created by Stephen Birarda on 1/20/15.
|
||||
// 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 hifi_RenderingClient_h
|
||||
#define hifi_RenderingClient_h
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
#include <AvatarData.h>
|
||||
|
||||
#include "Client.h"
|
||||
|
||||
class RenderingClient : public Client {
|
||||
Q_OBJECT
|
||||
public:
|
||||
RenderingClient(QObject* parent = 0, const QString& launchURLString = QString());
|
||||
|
||||
const glm::vec3& getPosition() const { return _position; }
|
||||
const glm::quat& getOrientation() const { return _orientation; }
|
||||
void setOrientation(const glm::quat& orientation) { _orientation = orientation; }
|
||||
|
||||
static glm::vec3 getPositionForAudio() { return _instance->getPosition(); }
|
||||
static glm::quat getOrientationForAudio() { return _instance->getOrientation(); }
|
||||
|
||||
virtual void cleanupBeforeQuit();
|
||||
|
||||
private slots:
|
||||
void goToLocation(const glm::vec3& newPosition,
|
||||
bool hasOrientationChange, const glm::quat& newOrientation,
|
||||
bool shouldFaceLocation);
|
||||
void sendAvatarPacket();
|
||||
|
||||
private:
|
||||
virtual void processVerifiedPacket(const HifiSockAddr& senderSockAddr, const QByteArray& incomingPacket);
|
||||
|
||||
static RenderingClient* _instance;
|
||||
|
||||
glm::vec3 _position;
|
||||
glm::quat _orientation;
|
||||
|
||||
QTimer _avatarTimer;
|
||||
AvatarData _fakeAvatar;
|
||||
};
|
||||
|
||||
#endif // hifi_RenderingClient_h
|
|
@ -0,0 +1,41 @@
|
|||
//
|
||||
// InterfaceActivity.java
|
||||
// gvr-interface/java
|
||||
//
|
||||
// Created by Stephen Birarda on 1/26/15.
|
||||
// Copyright 2015 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
|
||||
//
|
||||
|
||||
package io.highfidelity.gvrinterface;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.WindowManager;
|
||||
import android.util.Log;
|
||||
import org.qtproject.qt5.android.bindings.QtActivity;
|
||||
|
||||
public class InterfaceActivity extends QtActivity {
|
||||
|
||||
public static native void handleHifiURL(String hifiURLString);
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
|
||||
// Get the intent that started this activity in case we have a hifi:// URL to parse
|
||||
Intent intent = getIntent();
|
||||
if (intent.getAction() == Intent.ACTION_VIEW) {
|
||||
Uri data = intent.getData();
|
||||
|
||||
if (data.getScheme().equals("hifi")) {
|
||||
handleHifiURL(data.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
28
gvr-interface/src/main.cpp
Normal file
28
gvr-interface/src/main.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
//
|
||||
// main.cpp
|
||||
// gvr-interface/src
|
||||
//
|
||||
// Created by Stephen Birarda on 11/17/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
|
||||
//
|
||||
|
||||
#include "GVRMainWindow.h"
|
||||
#include "GVRInterface.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
GVRInterface app(argc, argv);
|
||||
|
||||
GVRMainWindow mainWindow;
|
||||
#ifdef ANDROID
|
||||
mainWindow.showFullScreen();
|
||||
#else
|
||||
mainWindow.showMaximized();
|
||||
#endif
|
||||
|
||||
app.setMainWindow(&mainWindow);
|
||||
|
||||
return app.exec();
|
||||
}
|
51
gvr-interface/templates/InterfaceBetaActivity.java.in
Normal file
51
gvr-interface/templates/InterfaceBetaActivity.java.in
Normal file
|
@ -0,0 +1,51 @@
|
|||
//
|
||||
// InterfaceBetaActivity.java
|
||||
// gvr-interface/java
|
||||
//
|
||||
// Created by Stephen Birarda on 1/27/15.
|
||||
// Copyright 2015 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
|
||||
//
|
||||
|
||||
package io.highfidelity.gvrinterface;
|
||||
|
||||
import android.os.Bundle;
|
||||
import net.hockeyapp.android.CrashManager;
|
||||
import net.hockeyapp.android.UpdateManager;
|
||||
|
||||
public class InterfaceBetaActivity extends InterfaceActivity {
|
||||
|
||||
public String _hockeyAppID;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
_hockeyAppID = getString(R.string.HockeyAppID);
|
||||
|
||||
checkForUpdates();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
UpdateManager.unregister();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
checkForCrashes();
|
||||
}
|
||||
|
||||
private void checkForCrashes() {
|
||||
CrashManager.register(this, _hockeyAppID);
|
||||
}
|
||||
|
||||
private void checkForUpdates() {
|
||||
// Remove this for store / production builds!
|
||||
UpdateManager.register(this, _hockeyAppID);
|
||||
}
|
||||
}
|
5
gvr-interface/templates/hockeyapp.xml.in
Normal file
5
gvr-interface/templates/hockeyapp.xml.in
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<resources>
|
||||
<string name="HockeyAppID">${HOCKEY_APP_ID}</string>
|
||||
<bool name="HockeyAppEnabled">${HOCKEY_APP_ENABLED}</bool>
|
||||
</resources>
|
|
@ -2,7 +2,7 @@ set(TARGET_NAME interface)
|
|||
project(${TARGET_NAME})
|
||||
|
||||
# set a default root dir for each of our optional externals if it was not passed
|
||||
set(OPTIONAL_EXTERNALS "Faceshift" "LibOVR" "PrioVR" "Sixense" "LeapMotion" "RtMidi" "Qxmpp" "SDL2" "Gverb" "RSSDK")
|
||||
set(OPTIONAL_EXTERNALS "Faceshift" "LibOVR" "PrioVR" "Sixense" "LeapMotion" "RtMidi" "Qxmpp" "SDL2" "RSSDK")
|
||||
foreach(EXTERNAL ${OPTIONAL_EXTERNALS})
|
||||
string(TOUPPER ${EXTERNAL} ${EXTERNAL}_UPPERCASE)
|
||||
if (NOT ${${EXTERNAL}_UPPERCASE}_ROOT_DIR)
|
||||
|
@ -14,10 +14,6 @@ endforeach()
|
|||
find_package(Qt5LinguistTools REQUIRED)
|
||||
find_package(Qt5LinguistToolsMacros)
|
||||
|
||||
|
||||
# As Gverb is currently the only reverb library, it's required.
|
||||
find_package(Gverb REQUIRED)
|
||||
|
||||
if (DEFINED ENV{JOB_ID})
|
||||
set(BUILD_SEQ $ENV{JOB_ID})
|
||||
else ()
|
||||
|
@ -36,8 +32,6 @@ elseif (WIN32)
|
|||
set(GL_HEADERS "#include <windowshacks.h>\n#include <GL/glew.h>\n#include <GL/wglew.h>")
|
||||
endif ()
|
||||
|
||||
# set up the external glm library
|
||||
include_glm()
|
||||
include_bullet()
|
||||
|
||||
# create the InterfaceConfig.h file based on GL_HEADERS above
|
||||
|
@ -113,8 +107,14 @@ endif()
|
|||
# create the executable, make it a bundle on OS X
|
||||
add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM})
|
||||
|
||||
# set up the external glm library
|
||||
add_dependency_external_project(glm)
|
||||
find_package(GLM REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PRIVATE ${GLM_INCLUDE_DIRS})
|
||||
|
||||
# link required hifi libraries
|
||||
link_hifi_libraries(shared octree environment gpu model fbx metavoxels networking entities avatars audio animation script-engine physics
|
||||
link_hifi_libraries(shared octree environment gpu model fbx metavoxels networking entities avatars
|
||||
audio audio-client animation script-engine physics
|
||||
render-utils entities-renderer)
|
||||
|
||||
# find any optional and required libraries
|
||||
|
@ -179,13 +179,6 @@ if (QXMPP_FOUND AND NOT DISABLE_QXMPP AND WIN32)
|
|||
add_definitions(-DQXMPP_STATIC)
|
||||
endif ()
|
||||
|
||||
if (GVERB_FOUND)
|
||||
file(GLOB GVERB_SRCS ${GVERB_SRC_DIRS}/*.c)
|
||||
include_directories(${GVERB_INCLUDE_DIRS})
|
||||
add_library(gverb STATIC ${GVERB_SRCS})
|
||||
target_link_libraries(${TARGET_NAME} gverb)
|
||||
endif (GVERB_FOUND)
|
||||
|
||||
# include headers for interface and InterfaceConfig.
|
||||
include_directories("${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}/includes")
|
||||
|
||||
|
@ -199,12 +192,10 @@ add_definitions(-DQT_NO_BEARERMANAGEMENT)
|
|||
|
||||
if (APPLE)
|
||||
# link in required OS X frameworks and include the right GL headers
|
||||
find_library(CoreAudio CoreAudio)
|
||||
find_library(CoreFoundation CoreFoundation)
|
||||
find_library(OpenGL OpenGL)
|
||||
find_library(AppKit AppKit)
|
||||
|
||||
target_link_libraries(${TARGET_NAME} ${CoreAudio} ${CoreFoundation} ${OpenGL} ${AppKit})
|
||||
target_link_libraries(${TARGET_NAME} ${OpenGL} ${AppKit})
|
||||
|
||||
# install command for OS X bundle
|
||||
INSTALL(TARGETS ${TARGET_NAME}
|
||||
|
@ -238,7 +229,7 @@ else (APPLE)
|
|||
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)
|
||||
find_package(NSIGHT)
|
||||
if (NSIGHT_FOUND)
|
||||
include_directories(${NSIGHT_INCLUDE_DIRS})
|
||||
add_definitions(-DNSIGHT_FOUND)
|
||||
|
|
15
interface/external/gverb/readme.txt
vendored
15
interface/external/gverb/readme.txt
vendored
|
@ -1,15 +0,0 @@
|
|||
|
||||
Instructions for adding the Gverb library to Interface
|
||||
(This is a required library)
|
||||
Clément Brisset, October 22nd, 2014
|
||||
|
||||
1. Go to https://github.com/highfidelity/gverb
|
||||
Or download the sources directly via this link:
|
||||
https://github.com/highfidelity/gverb/archive/master.zip
|
||||
|
||||
2. Extract the archive
|
||||
|
||||
3. Place the directories “include” and “src” in interface/external/gverb
|
||||
(Normally next to this readme)
|
||||
|
||||
4. Clear your build directory, run cmake, build and you should be all set.
|
|
@ -23,6 +23,7 @@
|
|||
// include this before QGLWidget, which includes an earlier version of OpenGL
|
||||
#include "InterfaceConfig.h"
|
||||
|
||||
#include <QAbstractNativeEventFilter>
|
||||
#include <QActionGroup>
|
||||
#include <QColorDialog>
|
||||
#include <QDesktopWidget>
|
||||
|
@ -64,6 +65,7 @@
|
|||
#include <HFBackEvent.h>
|
||||
#include <LogHandler.h>
|
||||
#include <MainWindow.h>
|
||||
#include <ModelEntityItem.h>
|
||||
#include <NetworkAccessManager.h>
|
||||
#include <OctalCode.h>
|
||||
#include <OctreeSceneStats.h>
|
||||
|
@ -73,20 +75,23 @@
|
|||
#include <PhysicsEngine.h>
|
||||
#include <ProgramObject.h>
|
||||
#include <ResourceCache.h>
|
||||
#include <Settings.h>
|
||||
#include <ScriptCache.h>
|
||||
#include <SettingHandle.h>
|
||||
#include <SoundCache.h>
|
||||
#include <TextRenderer.h>
|
||||
#include <UserActivityLogger.h>
|
||||
#include <UUID.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "Audio.h"
|
||||
#include "AudioClient.h"
|
||||
#include "InterfaceVersion.h"
|
||||
#include "LODManager.h"
|
||||
#include "Menu.h"
|
||||
#include "ModelUploader.h"
|
||||
#include "Util.h"
|
||||
|
||||
#include "avatar/AvatarManager.h"
|
||||
|
||||
#include "audio/AudioToolBox.h"
|
||||
#include "audio/AudioIOStatsRenderer.h"
|
||||
#include "audio/AudioScope.h"
|
||||
|
@ -106,6 +111,7 @@
|
|||
#include "scripting/AccountScriptingInterface.h"
|
||||
#include "scripting/AudioDeviceScriptingInterface.h"
|
||||
#include "scripting/ClipboardScriptingInterface.h"
|
||||
#include "scripting/HMDScriptingInterface.h"
|
||||
#include "scripting/JoystickScriptingInterface.h"
|
||||
#include "scripting/GlobalServicesScriptingInterface.h"
|
||||
#include "scripting/LocationScriptingInterface.h"
|
||||
|
@ -126,17 +132,12 @@
|
|||
#include "ui/StandAloneJSConsole.h"
|
||||
#include "ui/Stats.h"
|
||||
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
// Starfield information
|
||||
static unsigned STARFIELD_NUM_STARS = 50000;
|
||||
static unsigned STARFIELD_SEED = 1;
|
||||
|
||||
static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored
|
||||
|
||||
|
||||
const qint64 MAXIMUM_CACHE_SIZE = 10737418240; // 10GB
|
||||
|
||||
static QTimer* idleTimer = NULL;
|
||||
|
@ -146,11 +147,45 @@ const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::D
|
|||
|
||||
const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js";
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<bool> firstRun("firstRun", true);
|
||||
const SettingHandle<QString> lastScriptLocation("LastScriptLocation");
|
||||
const SettingHandle<QString> scriptsLocation("scriptsLocation");
|
||||
}
|
||||
#ifdef Q_OS_WIN
|
||||
class MyNativeEventFilter : public QAbstractNativeEventFilter {
|
||||
public:
|
||||
static MyNativeEventFilter& getInstance() {
|
||||
static MyNativeEventFilter staticInstance;
|
||||
return staticInstance;
|
||||
}
|
||||
|
||||
bool nativeEventFilter(const QByteArray &eventType, void* msg, long* result) Q_DECL_OVERRIDE {
|
||||
if (eventType == "windows_generic_MSG") {
|
||||
MSG* message = (MSG*)msg;
|
||||
|
||||
if (message->message == UWM_IDENTIFY_INSTANCES) {
|
||||
*result = UWM_IDENTIFY_INSTANCES;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (message->message == UWM_SHOW_APPLICATION) {
|
||||
MainWindow* applicationWindow = Application::getInstance()->getWindow();
|
||||
if (applicationWindow->isMinimized()) {
|
||||
applicationWindow->showNormal(); // Restores to windowed or maximized state appropriately.
|
||||
}
|
||||
Application::getInstance()->setActiveWindow(applicationWindow); // Flashes the taskbar icon if not focus.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (message->message == WM_COPYDATA) {
|
||||
COPYDATASTRUCT* pcds = (COPYDATASTRUCT*)(message->lParam);
|
||||
QUrl url = QUrl((const char*)(pcds->lpData));
|
||||
if (url.isValid() && url.scheme() == HIFI_URL_SCHEME) {
|
||||
DependencyManager::get<AddressManager>()->handleLookupString(url.toString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
|
||||
QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message);
|
||||
|
@ -167,27 +202,22 @@ bool setupEssentials(int& argc, char** argv) {
|
|||
if (portStr) {
|
||||
listenPort = atoi(portStr);
|
||||
}
|
||||
|
||||
// read the ApplicationInfo.ini file for Name/Version/Domain information
|
||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||
QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
|
||||
// set the associated application properties
|
||||
applicationInfo.beginGroup("INFO");
|
||||
QApplication::setApplicationName(applicationInfo.value("name").toString());
|
||||
QApplication::setApplicationVersion(BUILD_VERSION);
|
||||
QApplication::setOrganizationName(applicationInfo.value("organizationName").toString());
|
||||
QApplication::setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
|
||||
// Set build version
|
||||
QCoreApplication::setApplicationVersion(BUILD_VERSION);
|
||||
|
||||
DependencyManager::registerInheritance<LimitedNodeList, NodeList>();
|
||||
DependencyManager::registerInheritance<AvatarHashMap, AvatarManager>();
|
||||
|
||||
// Set dependencies
|
||||
auto glCanvas = DependencyManager::set<GLCanvas>();
|
||||
auto addressManager = DependencyManager::set<AddressManager>();
|
||||
auto nodeList = DependencyManager::set<NodeList>(NodeType::Agent, listenPort);
|
||||
auto geometryCache = DependencyManager::set<GeometryCache>();
|
||||
auto scriptCache = DependencyManager::set<ScriptCache>();
|
||||
auto soundCache = DependencyManager::set<SoundCache>();
|
||||
auto glowEffect = DependencyManager::set<GlowEffect>();
|
||||
auto faceshift = DependencyManager::set<Faceshift>();
|
||||
auto audio = DependencyManager::set<Audio>();
|
||||
auto audio = DependencyManager::set<AudioClient>();
|
||||
auto audioScope = DependencyManager::set<AudioScope>();
|
||||
auto audioIOStatsRenderer = DependencyManager::set<AudioIOStatsRenderer>();
|
||||
auto deferredLightingEffect = DependencyManager::set<DeferredLightingEffect>();
|
||||
|
@ -198,9 +228,12 @@ bool setupEssentials(int& argc, char** argv) {
|
|||
auto ddeFaceTracker = DependencyManager::set<DdeFaceTracker>();
|
||||
auto modelBlender = DependencyManager::set<ModelBlender>();
|
||||
auto audioToolBox = DependencyManager::set<AudioToolBox>();
|
||||
auto avatarManager = DependencyManager::set<AvatarManager>();
|
||||
auto lodManager = DependencyManager::set<LODManager>();
|
||||
auto jsConsole = DependencyManager::set<StandAloneJSConsole>();
|
||||
auto dialogsManager = DependencyManager::set<DialogsManager>();
|
||||
auto bandwidthRecorder = DependencyManager::set<BandwidthRecorder>();
|
||||
auto resouceCacheSharedItems = DependencyManager::set<ResouceCacheSharedItems>();
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
||||
auto speechRecognizer = DependencyManager::set<SpeechRecognizer>();
|
||||
#endif
|
||||
|
@ -208,7 +241,6 @@ bool setupEssentials(int& argc, char** argv) {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||
QApplication(argc, argv),
|
||||
_dependencyManagerIsSetup(setupEssentials(argc, argv)),
|
||||
|
@ -229,10 +261,15 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
_lastQueriedViewFrustum(),
|
||||
_lastQueriedTime(usecTimestampNow()),
|
||||
_mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)),
|
||||
_firstRun("firstRun", true),
|
||||
_previousScriptLocation("LastScriptLocation"),
|
||||
_scriptsLocationHandle("scriptsLocation"),
|
||||
_fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES),
|
||||
_viewTransform(),
|
||||
_scaleMirror(1.0f),
|
||||
_rotateMirror(0.0f),
|
||||
_raiseMirror(0.0f),
|
||||
_cursorVisible(true),
|
||||
_lastMouseMove(usecTimestampNow()),
|
||||
_lastMouseMoveWasSimulated(false),
|
||||
_touchAvgX(0.0f),
|
||||
|
@ -241,12 +278,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
_mousePressed(false),
|
||||
_enableProcessOctreeThread(true),
|
||||
_octreeProcessor(),
|
||||
_inPacketsPerSecond(0),
|
||||
_outPacketsPerSecond(0),
|
||||
_inBytesPerSecond(0),
|
||||
_outBytesPerSecond(0),
|
||||
_nodeBoundsDisplay(this),
|
||||
_previousScriptLocation(),
|
||||
_applicationOverlay(),
|
||||
_runningScriptsWidget(NULL),
|
||||
_runningScriptsWidgetWasVisible(false),
|
||||
|
@ -254,11 +286,16 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
_lastNackTime(usecTimestampNow()),
|
||||
_lastSendDownstreamAudioStats(usecTimestampNow()),
|
||||
_isVSyncOn(true),
|
||||
_aboutToQuit(false)
|
||||
_aboutToQuit(false),
|
||||
_notifiedPacketVersionMismatchThisDomain(false)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
installNativeEventFilter(&MyNativeEventFilter::getInstance());
|
||||
#endif
|
||||
|
||||
_logger = new FileLogger(this); // After setting organization name in order to get correct directory
|
||||
qInstallMessageHandler(messageHandler);
|
||||
|
||||
|
||||
QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf");
|
||||
_window->setWindowTitle("Interface");
|
||||
|
||||
|
@ -267,7 +304,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
auto glCanvas = DependencyManager::get<GLCanvas>();
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
|
||||
_myAvatar = _avatarManager.getMyAvatar();
|
||||
_myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
||||
|
||||
_applicationStartupTime = startup_time;
|
||||
|
||||
|
@ -281,6 +318,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
_runningScriptsWidget = new RunningScriptsWidget(_window);
|
||||
|
||||
// start the nodeThread so its event loop is running
|
||||
_nodeThread->setObjectName("Datagram Processor Thread");
|
||||
_nodeThread->start();
|
||||
|
||||
// make sure the node thread is given highest priority
|
||||
|
@ -294,12 +332,19 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), &_datagramProcessor, SLOT(processDatagrams()));
|
||||
|
||||
// put the audio processing on a separate thread
|
||||
QThread* audioThread = new QThread(this);
|
||||
QThread* audioThread = new QThread();
|
||||
audioThread->setObjectName("Audio Thread");
|
||||
|
||||
auto audioIO = DependencyManager::get<AudioClient>();
|
||||
|
||||
audioIO->setPositionGetter(getPositionForAudio);
|
||||
audioIO->setOrientationGetter(getOrientationForAudio);
|
||||
|
||||
auto audioIO = DependencyManager::get<Audio>();
|
||||
audioIO->moveToThread(audioThread);
|
||||
connect(audioThread, &QThread::started, audioIO.data(), &Audio::start);
|
||||
connect(audioIO.data(), SIGNAL(muteToggled()), this, SLOT(audioMuteToggled()));
|
||||
connect(audioThread, &QThread::started, audioIO.data(), &AudioClient::start);
|
||||
connect(audioIO.data(), &AudioClient::destroyed, audioThread, &QThread::quit);
|
||||
connect(audioThread, &QThread::finished, audioThread, &QThread::deleteLater);
|
||||
connect(audioIO.data(), &AudioClient::muteToggled, this, &Application::audioMuteToggled);
|
||||
|
||||
audioThread->start();
|
||||
|
||||
|
@ -326,6 +371,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
connect(nodeList.data(), SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer)));
|
||||
connect(nodeList.data(), &NodeList::uuidChanged, _myAvatar, &MyAvatar::setSessionUUID);
|
||||
connect(nodeList.data(), &NodeList::limitOfSilentDomainCheckInsReached, nodeList.data(), &NodeList::reset);
|
||||
connect(nodeList.data(), &NodeList::packetVersionMismatch, this, &Application::notifyPacketVersionMismatch);
|
||||
|
||||
// connect to appropriate slots on AccountManager
|
||||
AccountManager& accountManager = AccountManager::getInstance();
|
||||
|
@ -341,9 +387,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
auto dialogsManager = DependencyManager::get<DialogsManager>();
|
||||
connect(&accountManager, &AccountManager::authRequired, dialogsManager.data(), &DialogsManager::showLoginDialog);
|
||||
connect(&accountManager, &AccountManager::usernameChanged, this, &Application::updateWindowTitle);
|
||||
|
||||
// once we have a profile in account manager make sure we generate a new keypair
|
||||
connect(&accountManager, &AccountManager::profileChanged, &accountManager, &AccountManager::generateNewKeypair);
|
||||
|
||||
// set the account manager's root URL and trigger a login request if we don't have the access token
|
||||
accountManager.setAuthURL(DEFAULT_NODE_AUTH_URL);
|
||||
|
@ -433,27 +476,31 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
connect(this, SIGNAL(aboutToQuit()), this, SLOT(saveScripts()));
|
||||
connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()));
|
||||
|
||||
// hook up bandwidth estimator
|
||||
QSharedPointer<BandwidthRecorder> bandwidthRecorder = DependencyManager::get<BandwidthRecorder>();
|
||||
connect(nodeList.data(), SIGNAL(dataSent(const quint8, const int)),
|
||||
bandwidthRecorder.data(), SLOT(updateOutboundData(const quint8, const int)));
|
||||
connect(nodeList.data(), SIGNAL(dataReceived(const quint8, const int)),
|
||||
bandwidthRecorder.data(), SLOT(updateInboundData(const quint8, const int)));
|
||||
|
||||
// check first run...
|
||||
bool firstRun = SettingHandles::firstRun.get();
|
||||
if (firstRun) {
|
||||
if (_firstRun.get()) {
|
||||
qDebug() << "This is a first run...";
|
||||
// clear the scripts, and set out script to our default scripts
|
||||
clearScriptsBeforeRunning();
|
||||
loadScript(DEFAULT_SCRIPTS_JS_URL);
|
||||
|
||||
SettingHandles::firstRun.set(false);
|
||||
_firstRun.set(false);
|
||||
} else {
|
||||
// do this as late as possible so that all required subsystems are initialized
|
||||
loadScripts();
|
||||
|
||||
_previousScriptLocation = SettingHandles::lastScriptLocation.get();
|
||||
}
|
||||
|
||||
loadSettings();
|
||||
int SAVE_SETTINGS_INTERVAL = 10 * MSECS_PER_SECOND; // Let's save every seconds for now
|
||||
connect(&_settingsTimer, &QTimer::timeout, this, &Application::saveSettings);
|
||||
connect(&_settingsThread, SIGNAL(started), &_settingsTimer, SLOT(start));
|
||||
connect(&_settingsThread, &QThread::finished, &_settingsTimer, &QTimer::deleteLater);
|
||||
connect(&_settingsThread, SIGNAL(started()), &_settingsTimer, SLOT(start()));
|
||||
connect(&_settingsThread, SIGNAL(finished()), &_settingsTimer, SLOT(stop()));
|
||||
_settingsTimer.moveToThread(&_settingsThread);
|
||||
_settingsTimer.setSingleShot(false);
|
||||
_settingsTimer.setInterval(SAVE_SETTINGS_INTERVAL);
|
||||
|
@ -475,50 +522,65 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
|
||||
void Application::aboutToQuit() {
|
||||
_aboutToQuit = true;
|
||||
setFullscreen(false); // if you exit while in full screen, you'll get bad behavior when you restart.
|
||||
|
||||
cleanupBeforeQuit();
|
||||
}
|
||||
|
||||
Application::~Application() {
|
||||
saveSettings();
|
||||
|
||||
_entities.getTree()->setSimulation(NULL);
|
||||
qInstallMessageHandler(NULL);
|
||||
|
||||
_window->saveGeometry();
|
||||
|
||||
int DELAY_TIME = 1000;
|
||||
UserActivityLogger::getInstance().close(DELAY_TIME);
|
||||
|
||||
void Application::cleanupBeforeQuit() {
|
||||
// make sure we don't call the idle timer any more
|
||||
delete idleTimer;
|
||||
|
||||
// save state
|
||||
QMetaObject::invokeMethod(&_settingsTimer, "stop", Qt::BlockingQueuedConnection);
|
||||
_settingsThread.quit();
|
||||
saveSettings();
|
||||
_window->saveGeometry();
|
||||
|
||||
// TODO: now that this is in cleanupBeforeQuit do we really need it to stop and force
|
||||
// an event loop to send the packet?
|
||||
UserActivityLogger::getInstance().close();
|
||||
|
||||
// let the avatar mixer know we're out
|
||||
MyAvatar::sendKillAvatar();
|
||||
|
||||
// stop the AudioClient
|
||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
|
||||
"stop", Qt::BlockingQueuedConnection);
|
||||
|
||||
// destroy the AudioClient so it and its thread have a chance to go down safely
|
||||
DependencyManager::destroy<AudioClient>();
|
||||
}
|
||||
|
||||
Application::~Application() {
|
||||
EntityTree* tree = _entities.getTree();
|
||||
tree->lockForWrite();
|
||||
_entities.getTree()->setSimulation(NULL);
|
||||
tree->unlock();
|
||||
|
||||
qInstallMessageHandler(NULL);
|
||||
|
||||
// ask the datagram processing thread to quit and wait until it is done
|
||||
_nodeThread->quit();
|
||||
_nodeThread->wait();
|
||||
|
||||
// kill any audio injectors that are still around
|
||||
AudioScriptingInterface::getInstance().stopAllInjectors();
|
||||
|
||||
auto audioIO = DependencyManager::get<Audio>();
|
||||
|
||||
// stop the audio process
|
||||
QMetaObject::invokeMethod(audioIO.data(), "stop", Qt::BlockingQueuedConnection);
|
||||
|
||||
// ask the audio thread to quit and wait until it is done
|
||||
audioIO->thread()->quit();
|
||||
audioIO->thread()->wait();
|
||||
|
||||
_octreeProcessor.terminate();
|
||||
_entityEditSender.terminate();
|
||||
|
||||
Menu::getInstance()->deleteLater();
|
||||
|
||||
_myAvatar = NULL;
|
||||
|
||||
ModelEntityItem::cleanupLoadedAnimations() ;
|
||||
|
||||
DependencyManager::destroy<GLCanvas>();
|
||||
|
||||
qDebug() << "start destroying ResourceCaches Application::~Application() line:" << __LINE__;
|
||||
DependencyManager::destroy<AnimationCache>();
|
||||
DependencyManager::destroy<TextureCache>();
|
||||
DependencyManager::destroy<GeometryCache>();
|
||||
DependencyManager::destroy<ScriptCache>();
|
||||
DependencyManager::destroy<SoundCache>();
|
||||
qDebug() << "done destroying ResourceCaches Application::~Application() line:" << __LINE__;
|
||||
}
|
||||
|
||||
void Application::initializeGL() {
|
||||
|
@ -564,6 +626,7 @@ void Application::initializeGL() {
|
|||
|
||||
// create thread for parsing of octee data independent of the main network and rendering threads
|
||||
_octreeProcessor.initialize(_enableProcessOctreeThread);
|
||||
connect(&_octreeProcessor, &OctreePacketProcessor::packetVersionMismatch, this, &Application::notifyPacketVersionMismatch);
|
||||
_entityEditSender.initialize(_enableProcessOctreeThread);
|
||||
|
||||
// call our timer function every second
|
||||
|
@ -705,7 +768,7 @@ void Application::runTests() {
|
|||
void Application::audioMuteToggled() {
|
||||
QAction* muteAction = Menu::getInstance()->getActionForOption(MenuOption::MuteAudio);
|
||||
Q_CHECK_PTR(muteAction);
|
||||
muteAction->setChecked(DependencyManager::get<Audio>()->isMuted());
|
||||
muteAction->setChecked(DependencyManager::get<AudioClient>()->isMuted());
|
||||
}
|
||||
|
||||
void Application::aboutApp() {
|
||||
|
@ -723,7 +786,7 @@ void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height)
|
|||
TV3DManager::configureCamera(camera, width, height);
|
||||
} else {
|
||||
camera.setAspectRatio((float)width / height);
|
||||
camera.setFieldOfView(_viewFrustum.getFieldOfView());
|
||||
camera.setFieldOfView(_fieldOfView.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -771,25 +834,8 @@ void Application::updateProjectionMatrix(Camera& camera, bool updateViewFrustum)
|
|||
|
||||
void Application::controlledBroadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes) {
|
||||
foreach(NodeType_t type, destinationNodeTypes) {
|
||||
|
||||
// Perform the broadcast for one type
|
||||
int nReceivingNodes = DependencyManager::get<NodeList>()->broadcastToNodes(packet, NodeSet() << type);
|
||||
|
||||
// Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise)
|
||||
double bandwidth_amount = nReceivingNodes * packet.size();
|
||||
switch (type) {
|
||||
case NodeType::Agent:
|
||||
case NodeType::AvatarMixer:
|
||||
_bandwidthRecorder.avatarsChannel->output.updateValue(bandwidth_amount);
|
||||
_bandwidthRecorder.totalChannel->input.updateValue(bandwidth_amount);
|
||||
break;
|
||||
case NodeType::EntityServer:
|
||||
_bandwidthRecorder.octreeChannel->output.updateValue(bandwidth_amount);
|
||||
_bandwidthRecorder.totalChannel->output.updateValue(bandwidth_amount);
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
DependencyManager::get<NodeList>()->broadcastToNodes(packet, NodeSet() << type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1390,15 +1436,8 @@ void Application::timer() {
|
|||
float diffTime = (float)_timerStart.nsecsElapsed() / 1000000000.0f;
|
||||
|
||||
_fps = (float)_frameCount / diffTime;
|
||||
|
||||
_inPacketsPerSecond = (float) _datagramProcessor.getInPacketCount() / diffTime;
|
||||
_outPacketsPerSecond = (float) _datagramProcessor.getOutPacketCount() / diffTime;
|
||||
_inBytesPerSecond = (float) _datagramProcessor.getInByteCount() / diffTime;
|
||||
_outBytesPerSecond = (float) _datagramProcessor.getOutByteCount() / diffTime;
|
||||
_frameCount = 0;
|
||||
|
||||
_datagramProcessor.resetCounters();
|
||||
|
||||
_timerStart.start();
|
||||
|
||||
// ask the node list to check in with the domain server
|
||||
|
@ -1501,6 +1540,8 @@ void Application::setEnableVRMode(bool enableVRMode) {
|
|||
|
||||
auto glCanvas = DependencyManager::get<GLCanvas>();
|
||||
resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
|
||||
|
||||
updateCursorVisibility();
|
||||
}
|
||||
|
||||
void Application::setLowVelocityFilter(bool lowVelocityFilter) {
|
||||
|
@ -1587,15 +1628,16 @@ bool Application::exportEntities(const QString& filename, float x, float y, floa
|
|||
}
|
||||
|
||||
void Application::loadSettings() {
|
||||
DependencyManager::get<Audio>()->loadSettings();
|
||||
DependencyManager::get<LODManager>()->loadSettings();
|
||||
|
||||
DependencyManager::get<AudioClient>()->loadSettings();
|
||||
|
||||
Menu::getInstance()->loadSettings();
|
||||
_myAvatar->loadData();
|
||||
}
|
||||
|
||||
void Application::saveSettings() {
|
||||
DependencyManager::get<Audio>()->saveSettings();
|
||||
DependencyManager::get<LODManager>()->saveSettings();
|
||||
DependencyManager::get<AudioClient>()->saveSettings();
|
||||
|
||||
Menu::getInstance()->saveSettings();
|
||||
_myAvatar->saveData();
|
||||
}
|
||||
|
@ -1629,7 +1671,7 @@ void Application::init() {
|
|||
DependencyManager::get<AmbientOcclusionEffect>()->init(this);
|
||||
|
||||
// TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager
|
||||
_avatarManager.init();
|
||||
DependencyManager::get<AvatarManager>()->init();
|
||||
_myCamera.setMode(CAMERA_MODE_FIRST_PERSON);
|
||||
|
||||
_mirrorCamera.setMode(CAMERA_MODE_MIRROR);
|
||||
|
@ -1970,35 +2012,22 @@ void Application::updateCursor(float deltaTime) {
|
|||
|
||||
static QPoint lastMousePos = QPoint();
|
||||
_lastMouseMove = (lastMousePos == QCursor::pos()) ? _lastMouseMove : usecTimestampNow();
|
||||
bool hideMouse = false;
|
||||
bool underMouse = QGuiApplication::topLevelAt(QCursor::pos()) ==
|
||||
Application::getInstance()->getWindow()->windowHandle();
|
||||
|
||||
static const int HIDE_CURSOR_TIMEOUT = 3 * USECS_PER_SECOND; // 3 second
|
||||
int elapsed = usecTimestampNow() - _lastMouseMove;
|
||||
if ((elapsed > HIDE_CURSOR_TIMEOUT) ||
|
||||
(OculusManager::isConnected() && Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode))) {
|
||||
hideMouse = underMouse;
|
||||
}
|
||||
|
||||
setCursorVisible(!hideMouse);
|
||||
lastMousePos = QCursor::pos();
|
||||
}
|
||||
|
||||
void Application::setCursorVisible(bool visible) {
|
||||
if (visible) {
|
||||
if (overrideCursor() != NULL) {
|
||||
restoreOverrideCursor();
|
||||
}
|
||||
void Application::updateCursorVisibility() {
|
||||
if (!_cursorVisible || Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode)) {
|
||||
DependencyManager::get<GLCanvas>()->setCursor(Qt::BlankCursor);
|
||||
} else {
|
||||
if (overrideCursor() != NULL) {
|
||||
changeOverrideCursor(Qt::BlankCursor);
|
||||
} else {
|
||||
setOverrideCursor(Qt::BlankCursor);
|
||||
}
|
||||
DependencyManager::get<GLCanvas>()->unsetCursor();
|
||||
}
|
||||
}
|
||||
|
||||
void Application::setCursorVisible(bool visible) {
|
||||
_cursorVisible = visible;
|
||||
updateCursorVisibility();
|
||||
}
|
||||
|
||||
void Application::update(float deltaTime) {
|
||||
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
||||
PerformanceWarning warn(showWarnings, "Application::update()");
|
||||
|
@ -2021,7 +2050,7 @@ void Application::update(float deltaTime) {
|
|||
|
||||
updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process...
|
||||
|
||||
_avatarManager.updateOtherAvatars(deltaTime); //loop through all the other avatars and simulate them...
|
||||
DependencyManager::get<AvatarManager>()->updateOtherAvatars(deltaTime); //loop through all the other avatars and simulate them...
|
||||
|
||||
updateMetavoxels(deltaTime); // update metavoxels
|
||||
updateCamera(deltaTime); // handle various camera tweaks like off axis projection
|
||||
|
@ -2048,7 +2077,7 @@ void Application::update(float deltaTime) {
|
|||
{
|
||||
PerformanceTimer perfTimer("myAvatar");
|
||||
updateMyAvatarLookAtPosition();
|
||||
updateMyAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes
|
||||
DependencyManager::get<AvatarManager>()->updateMyAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -2105,31 +2134,11 @@ void Application::update(float deltaTime) {
|
|||
if (sinceLastNack > TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS) {
|
||||
_lastSendDownstreamAudioStats = now;
|
||||
|
||||
QMetaObject::invokeMethod(DependencyManager::get<Audio>().data(), "sendDownstreamAudioStatsPacket", Qt::QueuedConnection);
|
||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "sendDownstreamAudioStatsPacket", Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Application::updateMyAvatar(float deltaTime) {
|
||||
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
||||
PerformanceWarning warn(showWarnings, "Application::updateMyAvatar()");
|
||||
|
||||
_myAvatar->update(deltaTime);
|
||||
|
||||
quint64 now = usecTimestampNow();
|
||||
quint64 dt = now - _lastSendAvatarDataTime;
|
||||
|
||||
if (dt > MIN_TIME_BETWEEN_MY_AVATAR_DATA_SENDS) {
|
||||
// send head/hand data to the avatar mixer and voxel server
|
||||
PerformanceTimer perfTimer("send");
|
||||
QByteArray packet = byteArrayWithPopulatedHeader(PacketTypeAvatarData);
|
||||
packet.append(_myAvatar->toByteArray());
|
||||
controlledBroadcastToNodes(packet, NodeSet() << NodeType::AvatarMixer);
|
||||
|
||||
_lastSendAvatarDataTime = now;
|
||||
}
|
||||
}
|
||||
|
||||
int Application::sendNackPackets() {
|
||||
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::DisableNackPackets)) {
|
||||
|
@ -2383,10 +2392,6 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node
|
|||
|
||||
// make sure we still have an active socket
|
||||
nodeList->writeUnverifiedDatagram(reinterpret_cast<const char*>(queryPacket), packetLength, node);
|
||||
|
||||
// Feed number of bytes to corresponding channel of the bandwidth meter
|
||||
_bandwidthRecorder.octreeChannel->output.updateValue(packetLength);
|
||||
_bandwidthRecorder.totalChannel->output.updateValue(packetLength);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -2573,7 +2578,7 @@ void Application::updateShadowMap() {
|
|||
|
||||
{
|
||||
PerformanceTimer perfTimer("avatarManager");
|
||||
_avatarManager.renderAvatars(Avatar::SHADOW_RENDER_MODE);
|
||||
DependencyManager::get<AvatarManager>()->renderAvatars(Avatar::SHADOW_RENDER_MODE);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -2612,6 +2617,9 @@ const GLfloat WORLD_AMBIENT_COLOR[] = { 0.525f, 0.525f, 0.6f };
|
|||
const GLfloat WORLD_DIFFUSE_COLOR[] = { 0.6f, 0.525f, 0.525f };
|
||||
const GLfloat WORLD_SPECULAR_COLOR[] = { 0.94f, 0.94f, 0.737f, 1.0f };
|
||||
|
||||
const glm::vec3 GLOBAL_LIGHT_COLOR = { 0.6f, 0.525f, 0.525f };
|
||||
const float GLOBAL_LIGHT_INTENSITY = 1.0f;
|
||||
|
||||
void Application::setupWorldLight() {
|
||||
|
||||
// Setup 3D lights (after the camera transform, so that they are positioned in world space)
|
||||
|
@ -2626,6 +2634,7 @@ void Application::setupWorldLight() {
|
|||
glLightfv(GL_LIGHT0, GL_SPECULAR, WORLD_SPECULAR_COLOR);
|
||||
glMaterialfv(GL_FRONT, GL_SPECULAR, WORLD_SPECULAR_COLOR);
|
||||
glMateriali(GL_FRONT, GL_SHININESS, 96);
|
||||
|
||||
}
|
||||
|
||||
bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) {
|
||||
|
@ -2825,14 +2834,14 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs
|
|||
bool mirrorMode = (theCamera.getMode() == CAMERA_MODE_MIRROR);
|
||||
{
|
||||
PerformanceTimer perfTimer("avatars");
|
||||
_avatarManager.renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE,
|
||||
DependencyManager::get<AvatarManager>()->renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE,
|
||||
false, selfAvatarOnly);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
DependencyManager::get<DeferredLightingEffect>()->setAmbientLightMode(getRenderAmbientLight());
|
||||
|
||||
DependencyManager::get<DeferredLightingEffect>()->setGlobalLight(-getSunDirection(), GLOBAL_LIGHT_COLOR, GLOBAL_LIGHT_INTENSITY);
|
||||
PROFILE_RANGE("DeferredLighting");
|
||||
PerformanceTimer perfTimer("lighting");
|
||||
DependencyManager::get<DeferredLightingEffect>()->render();
|
||||
|
@ -2840,7 +2849,7 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs
|
|||
|
||||
{
|
||||
PerformanceTimer perfTimer("avatarsPostLighting");
|
||||
_avatarManager.renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE,
|
||||
DependencyManager::get<AvatarManager>()->renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE,
|
||||
true, selfAvatarOnly);
|
||||
}
|
||||
|
||||
|
@ -2980,7 +2989,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) {
|
|||
_mirrorCamera.setPosition(_myAvatar->getPosition() +
|
||||
_myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale());
|
||||
|
||||
} else if (SettingHandles::rearViewZoomLevel.get() == BODY) {
|
||||
} else if (RearMirrorTools::rearViewZoomLevel.get() == BODY) {
|
||||
_mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees
|
||||
_mirrorCamera.setPosition(_myAvatar->getChestPosition() +
|
||||
_myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale());
|
||||
|
@ -3104,7 +3113,7 @@ void Application::resetSensors() {
|
|||
|
||||
_myAvatar->reset();
|
||||
|
||||
QMetaObject::invokeMethod(DependencyManager::get<Audio>().data(), "reset", Qt::QueuedConnection);
|
||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "reset", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
static void setShortcutsEnabled(QWidget* widget, bool enabled) {
|
||||
|
@ -3218,11 +3227,11 @@ void Application::connectedToDomain(const QString& hostname) {
|
|||
|
||||
if (accountManager.isLoggedIn() && !domainID.isNull()) {
|
||||
// update our data-server with the domain-server we're logged in with
|
||||
|
||||
QString domainPutJsonString = "{\"location\":{\"domain_id\":\"" + uuidStringWithoutCurlyBraces(domainID) + "\"}}";
|
||||
|
||||
accountManager.authenticatedRequest("/api/v1/user/location", QNetworkAccessManager::PutOperation,
|
||||
JSONCallbackParameters(), domainPutJsonString.toUtf8());
|
||||
|
||||
_notifiedPacketVersionMismatchThisDomain = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3244,7 +3253,7 @@ void Application::nodeKilled(SharedNodePointer node) {
|
|||
_entityEditSender.nodeKilled(node);
|
||||
|
||||
if (node->getType() == NodeType::AudioMixer) {
|
||||
QMetaObject::invokeMethod(DependencyManager::get<Audio>().data(), "audioMixerKilled");
|
||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "audioMixerKilled");
|
||||
}
|
||||
|
||||
if (node->getType() == NodeType::EntityServer) {
|
||||
|
@ -3287,7 +3296,7 @@ void Application::nodeKilled(SharedNodePointer node) {
|
|||
|
||||
} else if (node->getType() == NodeType::AvatarMixer) {
|
||||
// our avatar mixer has gone away - clear the hash of avatars
|
||||
_avatarManager.clearOtherAvatars();
|
||||
DependencyManager::get<AvatarManager>()->clearOtherAvatars();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3374,8 +3383,6 @@ int Application::parseOctreeStats(const QByteArray& packet, const SharedNodePoin
|
|||
}
|
||||
|
||||
void Application::packetSent(quint64 length) {
|
||||
_bandwidthRecorder.octreeChannel->output.updateValue(length);
|
||||
_bandwidthRecorder.totalChannel->output.updateValue(length);
|
||||
}
|
||||
|
||||
const QString SETTINGS_KEY = "Settings";
|
||||
|
@ -3438,7 +3445,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
|||
|
||||
// hook our avatar and avatar hash map object into this script engine
|
||||
scriptEngine->setAvatarData(_myAvatar, "MyAvatar"); // leave it as a MyAvatar class to expose thrust features
|
||||
scriptEngine->setAvatarHashMap(&_avatarManager, "AvatarList");
|
||||
scriptEngine->setAvatarHashMap(DependencyManager::get<AvatarManager>().data(), "AvatarList");
|
||||
|
||||
scriptEngine->registerGlobalObject("Camera", &_myCamera);
|
||||
|
||||
|
@ -3472,25 +3479,30 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
|||
scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
|
||||
scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
|
||||
scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>().data());
|
||||
scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance());
|
||||
scriptEngine->registerGlobalObject("SoundCache", DependencyManager::get<SoundCache>().data());
|
||||
scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance());
|
||||
scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels);
|
||||
|
||||
scriptEngine->registerGlobalObject("GlobalServices", GlobalServicesScriptingInterface::getInstance());
|
||||
qScriptRegisterMetaType(scriptEngine, DownloadInfoResultToScriptValue, DownloadInfoResultFromScriptValue);
|
||||
|
||||
scriptEngine->registerGlobalObject("AvatarManager", &_avatarManager);
|
||||
scriptEngine->registerGlobalObject("AvatarManager", DependencyManager::get<AvatarManager>().data());
|
||||
|
||||
scriptEngine->registerGlobalObject("Joysticks", &JoystickScriptingInterface::getInstance());
|
||||
qScriptRegisterMetaType(scriptEngine, joystickToScriptValue, joystickFromScriptValue);
|
||||
|
||||
scriptEngine->registerGlobalObject("UndoStack", &_undoStackScriptingInterface);
|
||||
|
||||
QScriptValue hmdInterface = scriptEngine->registerGlobalObject("HMD", &HMDScriptingInterface::getInstance());
|
||||
scriptEngine->registerFunction(hmdInterface, "getHUDLookAtPosition2D", HMDScriptingInterface::getHUDLookAtPosition2D, 0);
|
||||
scriptEngine->registerFunction(hmdInterface, "getHUDLookAtPosition3D", HMDScriptingInterface::getHUDLookAtPosition3D, 0);
|
||||
|
||||
#ifdef HAVE_RTMIDI
|
||||
scriptEngine->registerGlobalObject("MIDI", &MIDIManager::getInstance());
|
||||
#endif
|
||||
|
||||
QThread* workerThread = new QThread(this);
|
||||
workerThread->setObjectName("Script Engine Thread");
|
||||
|
||||
// when the worker thread is started, call our engine's run..
|
||||
connect(workerThread, &QThread::started, scriptEngine, &ScriptEngine::run);
|
||||
|
@ -3709,21 +3721,20 @@ void Application::domainSettingsReceived(const QJsonObject& domainSettingsObject
|
|||
|
||||
QString Application::getPreviousScriptLocation() {
|
||||
QString suggestedName;
|
||||
if (_previousScriptLocation.isEmpty()) {
|
||||
if (_previousScriptLocation.get().isEmpty()) {
|
||||
QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
|
||||
// Temporary fix to Qt bug: http://stackoverflow.com/questions/16194475
|
||||
#ifdef __APPLE__
|
||||
suggestedName = desktopLocation.append("/script.js");
|
||||
#endif
|
||||
} else {
|
||||
suggestedName = _previousScriptLocation;
|
||||
suggestedName = _previousScriptLocation.get();
|
||||
}
|
||||
return suggestedName;
|
||||
}
|
||||
|
||||
void Application::setPreviousScriptLocation(const QString& previousScriptLocation) {
|
||||
_previousScriptLocation = previousScriptLocation;
|
||||
SettingHandles::lastScriptLocation.set(_previousScriptLocation);
|
||||
_previousScriptLocation.set(previousScriptLocation);
|
||||
}
|
||||
|
||||
void Application::loadDialog() {
|
||||
|
@ -3758,12 +3769,12 @@ void Application::loadScriptURLDialog() {
|
|||
}
|
||||
}
|
||||
|
||||
QString Application::getScriptsLocation() const {
|
||||
return SettingHandles::scriptsLocation.get();
|
||||
QString Application::getScriptsLocation() {
|
||||
return _scriptsLocationHandle.get();
|
||||
}
|
||||
|
||||
void Application::setScriptsLocation(const QString& scriptsLocation) {
|
||||
SettingHandles::scriptsLocation.set(scriptsLocation);
|
||||
_scriptsLocationHandle.set(scriptsLocation);
|
||||
emit scriptLocationChanged(scriptsLocation);
|
||||
}
|
||||
|
||||
|
@ -3779,10 +3790,6 @@ void Application::toggleLogDialog() {
|
|||
}
|
||||
}
|
||||
|
||||
void Application::initAvatarAndViewFrustum() {
|
||||
updateMyAvatar(0.0f);
|
||||
}
|
||||
|
||||
void Application::checkVersion() {
|
||||
QNetworkRequest latestVersionRequest((QUrl(CHECK_VERSION_URL)));
|
||||
latestVersionRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
|
@ -3990,3 +3997,18 @@ int Application::getRenderAmbientLight() const {
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void Application::notifyPacketVersionMismatch() {
|
||||
if (!_notifiedPacketVersionMismatchThisDomain) {
|
||||
_notifiedPacketVersionMismatchThisDomain = true;
|
||||
|
||||
QString message = "The location you are visiting is running an incompatible server version.\n";
|
||||
message += "Content may not display properly.";
|
||||
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(message);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setIcon(QMessageBox::Warning);
|
||||
msgBox.exec();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <TextureCache.h>
|
||||
#include <ViewFrustum.h>
|
||||
|
||||
#include "AudioClient.h"
|
||||
#include "Bookmarks.h"
|
||||
#include "Camera.h"
|
||||
#include "DatagramProcessor.h"
|
||||
|
@ -49,7 +50,6 @@
|
|||
#include "Physics.h"
|
||||
#include "Stars.h"
|
||||
#include "avatar/Avatar.h"
|
||||
#include "avatar/AvatarManager.h"
|
||||
#include "avatar/MyAvatar.h"
|
||||
#include "devices/PrioVR.h"
|
||||
#include "devices/SixenseManager.h"
|
||||
|
@ -109,15 +109,18 @@ static const float MIRROR_REARVIEW_DISTANCE = 0.722f;
|
|||
static const float MIRROR_REARVIEW_BODY_DISTANCE = 2.56f;
|
||||
static const float MIRROR_FIELD_OF_VIEW = 30.0f;
|
||||
|
||||
// 70 times per second - target is 60hz, but this helps account for any small deviations
|
||||
// in the update loop
|
||||
static const quint64 MIN_TIME_BETWEEN_MY_AVATAR_DATA_SENDS = (1000 * 1000) / 70;
|
||||
|
||||
static const quint64 TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS = 1 * USECS_PER_SECOND;
|
||||
|
||||
static const QString INFO_HELP_PATH = "html/interface-welcome-allsvg.html";
|
||||
static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-entities-commands.html";
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
static const UINT UWM_IDENTIFY_INSTANCES =
|
||||
RegisterWindowMessage("UWM_IDENTIFY_INSTANCES_{8AB82783-B74A-4258-955B-8188C22AA0D6}");
|
||||
static const UINT UWM_SHOW_APPLICATION =
|
||||
RegisterWindowMessage("UWM_SHOW_APPLICATION_{71123FD6-3DA8-4DC1-9C27-8A12A6250CBA}");
|
||||
#endif
|
||||
|
||||
class Application;
|
||||
#if defined(qApp)
|
||||
#undef qApp
|
||||
|
@ -134,6 +137,8 @@ public:
|
|||
static Application* getInstance() { return qApp; } // TODO: replace fully by qApp
|
||||
static const glm::vec3& getPositionForPath() { return getInstance()->_myAvatar->getPosition(); }
|
||||
static glm::quat getOrientationForPath() { return getInstance()->_myAvatar->getOrientation(); }
|
||||
static glm::vec3 getPositionForAudio() { return getInstance()->_myAvatar->getHead()->getPosition(); }
|
||||
static glm::quat getOrientationForAudio() { return getInstance()->_myAvatar->getHead()->getFinalOrientationInWorldFrame(); }
|
||||
|
||||
Application(int& argc, char** argv, QElapsedTimer &startup_time);
|
||||
~Application();
|
||||
|
@ -168,8 +173,6 @@ public:
|
|||
|
||||
bool isThrottleRendering() const { return DependencyManager::get<GLCanvas>()->isThrottleRendering(); }
|
||||
|
||||
MyAvatar* getAvatar() { return _myAvatar; }
|
||||
const MyAvatar* getAvatar() const { return _myAvatar; }
|
||||
Camera* getCamera() { return &_myCamera; }
|
||||
ViewFrustum* getViewFrustum() { return &_viewFrustum; }
|
||||
ViewFrustum* getDisplayViewFrustum() { return &_displayViewFrustum; }
|
||||
|
@ -186,8 +189,7 @@ public:
|
|||
EntityTreeRenderer* getEntityClipboardRenderer() { return &_entityClipboardRenderer; }
|
||||
|
||||
bool isMousePressed() const { return _mousePressed; }
|
||||
bool isMouseHidden() const { return DependencyManager::get<GLCanvas>()->cursor().shape() == Qt::BlankCursor; }
|
||||
void setCursorVisible(bool visible);
|
||||
bool isMouseHidden() const { return !_cursorVisible; }
|
||||
const glm::vec3& getMouseRayOrigin() const { return _mouseRayOrigin; }
|
||||
const glm::vec3& getMouseRayDirection() const { return _mouseRayDirection; }
|
||||
bool mouseOnScreen() const;
|
||||
|
@ -202,21 +204,19 @@ public:
|
|||
bool getLastMouseMoveWasSimulated() const { return _lastMouseMoveWasSimulated; }
|
||||
|
||||
FaceTracker* getActiveFaceTracker();
|
||||
BandwidthRecorder* getBandwidthRecorder() { return &_bandwidthRecorder; }
|
||||
QSystemTrayIcon* getTrayIcon() { return _trayIcon; }
|
||||
ApplicationOverlay& getApplicationOverlay() { return _applicationOverlay; }
|
||||
Overlays& getOverlays() { return _overlays; }
|
||||
|
||||
float getFps() const { return _fps; }
|
||||
float getInPacketsPerSecond() const { return _inPacketsPerSecond; }
|
||||
float getOutPacketsPerSecond() const { return _outPacketsPerSecond; }
|
||||
float getInBytesPerSecond() const { return _inBytesPerSecond; }
|
||||
float getOutBytesPerSecond() const { return _outBytesPerSecond; }
|
||||
const glm::vec3& getViewMatrixTranslation() const { return _viewMatrixTranslation; }
|
||||
void setViewMatrixTranslation(const glm::vec3& translation) { _viewMatrixTranslation = translation; }
|
||||
|
||||
virtual const Transform& getViewTransform() const { return _viewTransform; }
|
||||
void setViewTransform(const Transform& view);
|
||||
|
||||
float getFieldOfView() { return _fieldOfView.get(); }
|
||||
void setFieldOfView(float fov) { _fieldOfView.set(fov); }
|
||||
|
||||
NodeToOctreeSceneStats* getOcteeSceneStats() { return &_octreeServerSceneStats; }
|
||||
void lockOctreeSceneStats() { _octreeSceneStatsLock.lockForRead(); }
|
||||
|
@ -227,8 +227,6 @@ public:
|
|||
virtual AbstractControllerScriptingInterface* getControllerScriptingInterface() { return &_controllerScriptingInterface; }
|
||||
virtual void registerScriptEngineWithApplicationServices(ScriptEngine* scriptEngine);
|
||||
|
||||
|
||||
AvatarManager& getAvatarManager() { return _avatarManager; }
|
||||
void resetProfile(const QString& username);
|
||||
|
||||
void controlledBroadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes);
|
||||
|
@ -266,7 +264,7 @@ public:
|
|||
virtual float getSizeScale() const;
|
||||
virtual int getBoundaryLevelAdjust() const;
|
||||
virtual PickRay computePickRay(float x, float y);
|
||||
virtual const glm::vec3& getAvatarPosition() const { return getAvatar()->getPosition(); }
|
||||
virtual const glm::vec3& getAvatarPosition() const { return _myAvatar->getPosition(); }
|
||||
|
||||
NodeBounds& getNodeBoundsDisplay() { return _nodeBoundsDisplay; }
|
||||
|
||||
|
@ -301,7 +299,7 @@ public:
|
|||
|
||||
Bookmarks* getBookmarks() const { return _bookmarks; }
|
||||
|
||||
QString getScriptsLocation() const;
|
||||
QString getScriptsLocation();
|
||||
void setScriptsLocation(const QString& scriptsLocation);
|
||||
|
||||
signals:
|
||||
|
@ -336,7 +334,6 @@ public slots:
|
|||
void loadDialog();
|
||||
void loadScriptURLDialog();
|
||||
void toggleLogDialog();
|
||||
void initAvatarAndViewFrustum();
|
||||
ScriptEngine* loadScript(const QString& scriptFilename = QString(), bool isUserLoaded = true,
|
||||
bool loadScriptFromEditor = false, bool activateMainWindow = false);
|
||||
void scriptFinished(const QString& scriptName);
|
||||
|
@ -367,6 +364,8 @@ public slots:
|
|||
void loadSettings();
|
||||
void saveSettings();
|
||||
|
||||
void notifyPacketVersionMismatch();
|
||||
|
||||
private slots:
|
||||
void clearDomainOctreeDetails();
|
||||
void timer();
|
||||
|
@ -398,15 +397,21 @@ private slots:
|
|||
|
||||
void audioMuteToggled();
|
||||
|
||||
void setCursorVisible(bool visible);
|
||||
|
||||
private:
|
||||
void resetCamerasOnResizeGL(Camera& camera, int width, int height);
|
||||
void updateProjectionMatrix();
|
||||
void updateProjectionMatrix(Camera& camera, bool updateViewFrustum = true);
|
||||
|
||||
void updateCursorVisibility();
|
||||
|
||||
void sendPingPackets();
|
||||
|
||||
void initDisplay();
|
||||
void init();
|
||||
|
||||
void cleanupBeforeQuit();
|
||||
|
||||
void update(float deltaTime);
|
||||
|
||||
|
@ -427,7 +432,6 @@ private:
|
|||
|
||||
void renderLookatIndicator(glm::vec3 pointOfInterest);
|
||||
|
||||
void updateMyAvatar(float deltaTime);
|
||||
void queryOctree(NodeType_t serverType, PacketType packetType, NodeToJurisdictionMap& jurisdictions);
|
||||
void loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum);
|
||||
|
||||
|
@ -484,10 +488,6 @@ private:
|
|||
|
||||
OctreeQuery _octreeQuery; // NodeData derived class for querying octee cells from octree servers
|
||||
|
||||
BandwidthRecorder _bandwidthRecorder;
|
||||
|
||||
|
||||
AvatarManager _avatarManager;
|
||||
MyAvatar* _myAvatar; // TODO: move this and relevant code to AvatarManager (or MyAvatar as the case may be)
|
||||
|
||||
PrioVR _prioVR;
|
||||
|
@ -496,6 +496,11 @@ private:
|
|||
Camera _mirrorCamera; // Cammera for mirror view
|
||||
QRect _mirrorViewRect;
|
||||
RearMirrorTools* _rearMirrorTools;
|
||||
|
||||
Setting::Handle<bool> _firstRun;
|
||||
Setting::Handle<QString> _previousScriptLocation;
|
||||
Setting::Handle<QString> _scriptsLocationHandle;
|
||||
Setting::Handle<float> _fieldOfView;
|
||||
|
||||
Transform _viewTransform;
|
||||
glm::mat4 _untranslatedViewMatrix;
|
||||
|
@ -512,6 +517,7 @@ private:
|
|||
|
||||
Environment _environment;
|
||||
|
||||
bool _cursorVisible;
|
||||
int _mouseDragStartedX;
|
||||
int _mouseDragStartedY;
|
||||
quint64 _lastMouseMove;
|
||||
|
@ -535,11 +541,6 @@ private:
|
|||
OctreePacketProcessor _octreeProcessor;
|
||||
EntityEditPacketSender _entityEditSender;
|
||||
|
||||
int _inPacketsPerSecond;
|
||||
int _outPacketsPerSecond;
|
||||
int _inBytesPerSecond;
|
||||
int _outBytesPerSecond;
|
||||
|
||||
StDev _idleLoopStdev;
|
||||
float _idleLoopMeasuredJitter;
|
||||
|
||||
|
@ -558,8 +559,6 @@ private:
|
|||
QPointer<LogDialog> _logDialog;
|
||||
QPointer<SnapshotShareDialog> _snapshotShareDialog;
|
||||
|
||||
QString _previousScriptLocation;
|
||||
|
||||
FileLogger* _logger;
|
||||
|
||||
void checkVersion();
|
||||
|
@ -582,13 +581,13 @@ private:
|
|||
quint64 _lastNackTime;
|
||||
quint64 _lastSendDownstreamAudioStats;
|
||||
|
||||
quint64 _lastSendAvatarDataTime;
|
||||
|
||||
bool _isVSyncOn;
|
||||
|
||||
bool _aboutToQuit;
|
||||
|
||||
Bookmarks* _bookmarks;
|
||||
|
||||
bool _notifiedPacketVersionMismatchThisDomain;
|
||||
|
||||
QThread _settingsThread;
|
||||
QTimer _settingsTimer;
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
//
|
||||
// BandwidthMeter.cpp
|
||||
// interface/src/ui
|
||||
//
|
||||
// Created by Seth Alves on 2015-1-30
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Based on code by Tobias Schwinger
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <GeometryCache.h>
|
||||
#include "BandwidthRecorder.h"
|
||||
|
||||
|
||||
BandwidthRecorder::Channel::Channel(char const* const caption,
|
||||
char const* unitCaption,
|
||||
double unitScale,
|
||||
unsigned colorRGBA) :
|
||||
caption(caption),
|
||||
unitCaption(unitCaption),
|
||||
unitScale(unitScale),
|
||||
colorRGBA(colorRGBA)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
BandwidthRecorder::BandwidthRecorder() {
|
||||
}
|
||||
|
||||
|
||||
BandwidthRecorder::~BandwidthRecorder() {
|
||||
delete audioChannel;
|
||||
delete avatarsChannel;
|
||||
delete octreeChannel;
|
||||
delete metavoxelsChannel;
|
||||
delete totalChannel;
|
||||
}
|
||||
|
||||
|
||||
BandwidthRecorder::Stream::Stream(float msToAverage) : _value(0.0f), _msToAverage(msToAverage) {
|
||||
_prevTime.start();
|
||||
}
|
||||
|
||||
|
||||
void BandwidthRecorder::Stream::updateValue(double amount) {
|
||||
|
||||
// Determine elapsed time
|
||||
double dt = (double)_prevTime.nsecsElapsed() / 1000000.0; // ns to ms
|
||||
|
||||
// Ignore this value when timer imprecision yields dt = 0
|
||||
if (dt == 0.0) {
|
||||
return;
|
||||
}
|
||||
|
||||
_prevTime.start();
|
||||
|
||||
// Compute approximate average
|
||||
_value = glm::mix(_value, amount / dt,
|
||||
glm::clamp(dt / _msToAverage, 0.0, 1.0));
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
//
|
||||
// BandwidthRecorder.h
|
||||
//
|
||||
// Created by Seth Alves on 2015-1-30
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Based on code by Tobias Schwinger
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
|
||||
#ifndef hifi_BandwidthRecorder_h
|
||||
#define hifi_BandwidthRecorder_h
|
||||
|
||||
#include <QElapsedTimer>
|
||||
|
||||
class BandwidthRecorder {
|
||||
public:
|
||||
BandwidthRecorder();
|
||||
~BandwidthRecorder();
|
||||
|
||||
// keep track of data rate in one direction
|
||||
class Stream {
|
||||
public:
|
||||
Stream(float msToAverage = 3000.0f);
|
||||
void updateValue(double amount);
|
||||
double getValue() const { return _value; }
|
||||
private:
|
||||
double _value; // Current value.
|
||||
double _msToAverage; // Milliseconds to average.
|
||||
QElapsedTimer _prevTime; // Time of last feed.
|
||||
};
|
||||
|
||||
// keep track of data rate in two directions as well as units and style to use during display
|
||||
class Channel {
|
||||
public:
|
||||
Channel(char const* const caption, char const* unitCaption, double unitScale, unsigned colorRGBA);
|
||||
Stream input;
|
||||
Stream output;
|
||||
char const* const caption;
|
||||
char const* unitCaption;
|
||||
double unitScale;
|
||||
unsigned colorRGBA;
|
||||
};
|
||||
|
||||
// create the channels we keep track of
|
||||
Channel* audioChannel = new Channel("Audio", "Kbps", 8000.0 / 1024.0, 0x33cc99ff);
|
||||
Channel* avatarsChannel = new Channel("Avatars", "Kbps", 8000.0 / 1024.0, 0xffef40c0);
|
||||
Channel* octreeChannel = new Channel("Octree", "Kbps", 8000.0 / 1024.0, 0xd0d0d0a0);
|
||||
Channel* metavoxelsChannel = new Channel("Metavoxels", "Kbps", 8000.0 / 1024.0, 0xd0d0d0a0);
|
||||
Channel* totalChannel = new Channel("Total", "Kbps", 8000.0 / 1024.0, 0xd0d0d0a0);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -15,7 +15,8 @@
|
|||
#include <PerfStat.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "Audio.h"
|
||||
#include "avatar/AvatarManager.h"
|
||||
#include "AudioClient.h"
|
||||
#include "Menu.h"
|
||||
|
||||
#include "DatagramProcessor.h"
|
||||
|
@ -39,8 +40,7 @@ void DatagramProcessor::processDatagrams() {
|
|||
|
||||
while (DependencyManager::get<NodeList>()->getNodeSocket().hasPendingDatagrams()) {
|
||||
incomingPacket.resize(nodeList->getNodeSocket().pendingDatagramSize());
|
||||
nodeList->getNodeSocket().readDatagram(incomingPacket.data(), incomingPacket.size(),
|
||||
senderSockAddr.getAddressPointer(), senderSockAddr.getPortPointer());
|
||||
nodeList->readDatagram(incomingPacket, senderSockAddr.getAddressPointer(), senderSockAddr.getPortPointer());
|
||||
|
||||
_inPacketCount++;
|
||||
_inByteCount += incomingPacket.size();
|
||||
|
@ -55,15 +55,15 @@ void DatagramProcessor::processDatagrams() {
|
|||
case PacketTypeMixedAudio:
|
||||
case PacketTypeSilentAudioFrame: {
|
||||
if (incomingType == PacketTypeAudioStreamStats) {
|
||||
QMetaObject::invokeMethod(DependencyManager::get<Audio>().data(), "parseAudioStreamStatsPacket",
|
||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "parseAudioStreamStatsPacket",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(QByteArray, incomingPacket));
|
||||
} else if (incomingType == PacketTypeAudioEnvironment) {
|
||||
QMetaObject::invokeMethod(DependencyManager::get<Audio>().data(), "parseAudioEnvironmentData",
|
||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "parseAudioEnvironmentData",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(QByteArray, incomingPacket));
|
||||
} else {
|
||||
QMetaObject::invokeMethod(DependencyManager::get<Audio>().data(), "addReceivedAudioToStream",
|
||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "addReceivedAudioToStream",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(QByteArray, incomingPacket));
|
||||
}
|
||||
|
@ -73,7 +73,6 @@ void DatagramProcessor::processDatagrams() {
|
|||
|
||||
if (audioMixer) {
|
||||
audioMixer->setLastHeardMicrostamp(usecTimestampNow());
|
||||
audioMixer->recordBytesReceived(incomingPacket.size());
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -82,8 +81,6 @@ void DatagramProcessor::processDatagrams() {
|
|||
// this will keep creatorTokenIDs to IDs mapped correctly
|
||||
EntityItemID::handleAddEntityResponse(incomingPacket);
|
||||
application->getEntities()->getTree()->handleAddEntityResponse(incomingPacket);
|
||||
application->_bandwidthRecorder.octreeChannel->input.updateValue(incomingPacket.size());
|
||||
application->_bandwidthRecorder.totalChannel->input.updateValue(incomingPacket.size());
|
||||
break;
|
||||
case PacketTypeEntityData:
|
||||
case PacketTypeEntityErase:
|
||||
|
@ -97,8 +94,6 @@ void DatagramProcessor::processDatagrams() {
|
|||
// add this packet to our list of octree packets and process them on the octree data processing
|
||||
application->_octreeProcessor.queueReceivedPacket(matchedNode, incomingPacket);
|
||||
}
|
||||
application->_bandwidthRecorder.octreeChannel->input.updateValue(incomingPacket.size());
|
||||
application->_bandwidthRecorder.totalChannel->input.updateValue(incomingPacket.size());
|
||||
break;
|
||||
}
|
||||
case PacketTypeMetavoxelData:
|
||||
|
@ -113,15 +108,11 @@ void DatagramProcessor::processDatagrams() {
|
|||
|
||||
if (avatarMixer) {
|
||||
avatarMixer->setLastHeardMicrostamp(usecTimestampNow());
|
||||
avatarMixer->recordBytesReceived(incomingPacket.size());
|
||||
|
||||
QMetaObject::invokeMethod(&application->getAvatarManager(), "processAvatarMixerDatagram",
|
||||
QMetaObject::invokeMethod(DependencyManager::get<AvatarManager>().data(), "processAvatarMixerDatagram",
|
||||
Q_ARG(const QByteArray&, incomingPacket),
|
||||
Q_ARG(const QWeakPointer<Node>&, avatarMixer));
|
||||
}
|
||||
|
||||
application->_bandwidthRecorder.avatarsChannel->input.updateValue(incomingPacket.size());
|
||||
application->_bandwidthRecorder.totalChannel->input.updateValue(incomingPacket.size());
|
||||
break;
|
||||
}
|
||||
case PacketTypeDomainConnectionDenied: {
|
||||
|
@ -134,22 +125,23 @@ void DatagramProcessor::processDatagrams() {
|
|||
}
|
||||
case PacketTypeNoisyMute:
|
||||
case PacketTypeMuteEnvironment: {
|
||||
bool mute = !DependencyManager::get<Audio>()->isMuted();
|
||||
bool mute = !DependencyManager::get<AudioClient>()->isMuted();
|
||||
|
||||
if (incomingType == PacketTypeMuteEnvironment) {
|
||||
glm::vec3 position;
|
||||
float radius, distance;
|
||||
float radius;
|
||||
|
||||
int headerSize = numBytesForPacketHeaderGivenPacketType(PacketTypeMuteEnvironment);
|
||||
memcpy(&position, incomingPacket.constData() + headerSize, sizeof(glm::vec3));
|
||||
memcpy(&radius, incomingPacket.constData() + headerSize + sizeof(glm::vec3), sizeof(float));
|
||||
distance = glm::distance(Application::getInstance()->getAvatar()->getPosition(), position);
|
||||
float distance = glm::distance(DependencyManager::get<AvatarManager>()->getMyAvatar()->getPosition(),
|
||||
position);
|
||||
|
||||
mute = mute && (distance < radius);
|
||||
}
|
||||
|
||||
if (mute) {
|
||||
DependencyManager::get<Audio>()->toggleMute();
|
||||
DependencyManager::get<AudioClient>()->toggleMute();
|
||||
if (incomingType == PacketTypeMuteEnvironment) {
|
||||
AudioScriptingInterface::getInstance().environmentMuted();
|
||||
} else {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// FileUtils.cpp
|
||||
// libraries/shared/src
|
||||
// interface/src
|
||||
//
|
||||
// Created by Stojce Slavkovski on 12/23/13.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
|
@ -9,9 +9,14 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <qdir.h>
|
||||
#include <qfileinfo.h>
|
||||
#include <qdesktopservices.h>
|
||||
#include <qprocess.h>
|
||||
#include <qurl.h>
|
||||
|
||||
#include "FileUtils.h"
|
||||
#include <QtCore>
|
||||
#include <QDesktopServices>
|
||||
|
||||
|
||||
void FileUtils::locateFile(QString filePath) {
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// FileUtils.h
|
||||
// libraries/shared/src
|
||||
// interface/src
|
||||
//
|
||||
// Created by Stojce Slavkovski on 12/23/13.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
|
@ -9,6 +9,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <SettingHandle.h>
|
||||
#include <Util.h>
|
||||
|
||||
#include "Application.h"
|
||||
|
@ -16,15 +17,14 @@
|
|||
|
||||
#include "LODManager.h"
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<bool> automaticAvatarLOD("automaticAvatarLOD", true);
|
||||
const SettingHandle<float> avatarLODDecreaseFPS("avatarLODDecreaseFPS", DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS);
|
||||
const SettingHandle<float> avatarLODIncreaseFPS("avatarLODIncreaseFPS", ADJUST_LOD_UP_FPS);
|
||||
const SettingHandle<float> avatarLODDistanceMultiplier("avatarLODDistanceMultiplier",
|
||||
Setting::Handle<bool> automaticAvatarLOD("automaticAvatarLOD", true);
|
||||
Setting::Handle<float> avatarLODDecreaseFPS("avatarLODDecreaseFPS", DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS);
|
||||
Setting::Handle<float> avatarLODIncreaseFPS("avatarLODIncreaseFPS", ADJUST_LOD_UP_FPS);
|
||||
Setting::Handle<float> avatarLODDistanceMultiplier("avatarLODDistanceMultiplier",
|
||||
DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER);
|
||||
const SettingHandle<int> boundaryLevelAdjust("boundaryLevelAdjust", 0);
|
||||
const SettingHandle<float> octreeSizeScale("octreeSizeScale", DEFAULT_OCTREE_SIZE_SCALE);
|
||||
}
|
||||
Setting::Handle<int> boundaryLevelAdjust("boundaryLevelAdjust", 0);
|
||||
Setting::Handle<float> octreeSizeScale("octreeSizeScale", DEFAULT_OCTREE_SIZE_SCALE);
|
||||
|
||||
|
||||
void LODManager::autoAdjustLOD(float currentFPS) {
|
||||
// NOTE: our first ~100 samples at app startup are completely all over the place, and we don't
|
||||
|
@ -190,21 +190,21 @@ void LODManager::setBoundaryLevelAdjust(int boundaryLevelAdjust) {
|
|||
|
||||
|
||||
void LODManager::loadSettings() {
|
||||
setAutomaticAvatarLOD(SettingHandles::automaticAvatarLOD.get());
|
||||
setAvatarLODDecreaseFPS(SettingHandles::avatarLODDecreaseFPS.get());
|
||||
setAvatarLODIncreaseFPS(SettingHandles::avatarLODIncreaseFPS.get());
|
||||
setAvatarLODDistanceMultiplier(SettingHandles::avatarLODDistanceMultiplier.get());
|
||||
setBoundaryLevelAdjust(SettingHandles::boundaryLevelAdjust.get());
|
||||
setOctreeSizeScale(SettingHandles::octreeSizeScale.get());
|
||||
setAutomaticAvatarLOD(automaticAvatarLOD.get());
|
||||
setAvatarLODDecreaseFPS(avatarLODDecreaseFPS.get());
|
||||
setAvatarLODIncreaseFPS(avatarLODIncreaseFPS.get());
|
||||
setAvatarLODDistanceMultiplier(avatarLODDistanceMultiplier.get());
|
||||
setBoundaryLevelAdjust(boundaryLevelAdjust.get());
|
||||
setOctreeSizeScale(octreeSizeScale.get());
|
||||
}
|
||||
|
||||
void LODManager::saveSettings() {
|
||||
SettingHandles::automaticAvatarLOD.set(getAutomaticAvatarLOD());
|
||||
SettingHandles::avatarLODDecreaseFPS.set(getAvatarLODDecreaseFPS());
|
||||
SettingHandles::avatarLODIncreaseFPS.set(getAvatarLODIncreaseFPS());
|
||||
SettingHandles::avatarLODDistanceMultiplier.set(getAvatarLODDistanceMultiplier());
|
||||
SettingHandles::boundaryLevelAdjust.set(getBoundaryLevelAdjust());
|
||||
SettingHandles::octreeSizeScale.set(getOctreeSizeScale());
|
||||
automaticAvatarLOD.set(getAutomaticAvatarLOD());
|
||||
avatarLODDecreaseFPS.set(getAvatarLODDecreaseFPS());
|
||||
avatarLODIncreaseFPS.set(getAvatarLODIncreaseFPS());
|
||||
avatarLODDistanceMultiplier.set(getAvatarLODDistanceMultiplier());
|
||||
boundaryLevelAdjust.set(getBoundaryLevelAdjust());
|
||||
octreeSizeScale.set(getOctreeSizeScale());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
#include <DependencyManager.h>
|
||||
#include <OctreeConstants.h>
|
||||
#include <Settings.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <SimpleMovingAverage.h>
|
||||
|
||||
|
|
|
@ -18,33 +18,41 @@
|
|||
#include <QHideEvent>
|
||||
#include <QWindowStateChangeEvent>
|
||||
|
||||
#include <Settings.h>
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "Menu.h"
|
||||
#include "Util.h"
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<QRect> windowGeometry("WindowGeometry");
|
||||
}
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) {
|
||||
MainWindow::MainWindow(QWidget* parent) :
|
||||
QMainWindow(parent),
|
||||
_windowGeometry("WindowGeometry"),
|
||||
_windowState("WindowState", 0)
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindow::restoreGeometry() {
|
||||
// Did not use setGeometry() on purpose,
|
||||
// see http://doc.qt.io/qt-5/qsettings.html#restoring-the-state-of-a-gui-application
|
||||
QRect geometry = SettingHandles::windowGeometry.get(qApp->desktop()->availableGeometry());
|
||||
QRect geometry = _windowGeometry.get(qApp->desktop()->availableGeometry());
|
||||
move(geometry.topLeft());
|
||||
resize(geometry.size());
|
||||
|
||||
// Restore to maximized or full screen after restoring to windowed so that going windowed goes to good position and sizes.
|
||||
Qt::WindowStates state = (Qt::WindowStates)_windowState.get(Qt::WindowNoState);
|
||||
if (state != Qt::WindowNoState) {
|
||||
setWindowState(state);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::saveGeometry() {
|
||||
// Did not use geometry() on purpose,
|
||||
// see http://doc.qt.io/qt-5/qsettings.html#restoring-the-state-of-a-gui-application
|
||||
QRect geometry(pos(), size());
|
||||
SettingHandles::windowGeometry.set(geometry);
|
||||
_windowState.set((int)windowState());
|
||||
|
||||
// Save position and size only if windowed so that have good values for windowed after starting maximized or full screen.
|
||||
if (windowState() == Qt::WindowNoState) {
|
||||
QRect geometry(pos(), size());
|
||||
_windowGeometry.set(geometry);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::moveEvent(QMoveEvent* event) {
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include <QMainWindow>
|
||||
|
||||
#include <SettingHandle.h>
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -33,6 +35,10 @@ protected:
|
|||
virtual void showEvent(QShowEvent* event);
|
||||
virtual void hideEvent(QHideEvent* event);
|
||||
virtual void changeEvent(QEvent* event);
|
||||
|
||||
private:
|
||||
Setting::Handle<QRect> _windowGeometry;
|
||||
Setting::Handle<int> _windowState;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__MainWindow__) */
|
||||
|
|
|
@ -14,18 +14,19 @@
|
|||
#include <QShortcut>
|
||||
|
||||
#include <AddressManager.h>
|
||||
#include <AudioClient.h>
|
||||
#include <DependencyManager.h>
|
||||
#include <GlowEffect.h>
|
||||
#include <PathUtils.h>
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
#include <UserActivityLogger.h>
|
||||
#include <XmppClient.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "AccountManager.h"
|
||||
#include "Audio.h"
|
||||
#include "audio/AudioIOStatsRenderer.h"
|
||||
#include "audio/AudioScope.h"
|
||||
#include "avatar/AvatarManager.h"
|
||||
#include "devices/Faceshift.h"
|
||||
#include "devices/RealSense.h"
|
||||
#include "devices/SixenseManager.h"
|
||||
|
@ -186,26 +187,26 @@ Menu::Menu() {
|
|||
SLOT(resetSensors()));
|
||||
|
||||
QMenu* avatarMenu = addMenu("Avatar");
|
||||
QObject* avatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
||||
|
||||
QMenu* avatarSizeMenu = avatarMenu->addMenu("Size");
|
||||
addActionToQMenuAndActionHash(avatarSizeMenu,
|
||||
MenuOption::IncreaseAvatarSize,
|
||||
Qt::Key_Plus,
|
||||
qApp->getAvatar(),
|
||||
avatar,
|
||||
SLOT(increaseSize()));
|
||||
addActionToQMenuAndActionHash(avatarSizeMenu,
|
||||
MenuOption::DecreaseAvatarSize,
|
||||
Qt::Key_Minus,
|
||||
qApp->getAvatar(),
|
||||
avatar,
|
||||
SLOT(decreaseSize()));
|
||||
addActionToQMenuAndActionHash(avatarSizeMenu,
|
||||
MenuOption::ResetAvatarSize,
|
||||
Qt::Key_Equal,
|
||||
qApp->getAvatar(),
|
||||
avatar,
|
||||
SLOT(resetSize()));
|
||||
|
||||
QObject* avatar = qApp->getAvatar();
|
||||
addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::KeyboardMotorControl,
|
||||
addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::KeyboardMotorControl,
|
||||
Qt::CTRL | Qt::SHIFT | Qt::Key_K, true, avatar, SLOT(updateMotionBehavior()));
|
||||
addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::ScriptedMotorControl, 0, true,
|
||||
avatar, SLOT(updateMotionBehavior()));
|
||||
|
@ -333,7 +334,7 @@ Menu::Menu() {
|
|||
#if defined(Q_OS_MAC)
|
||||
#else
|
||||
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::RenderTargetFramerateVSyncOn, 0, true,
|
||||
qApp, SLOT(changeVSync()));
|
||||
qApp, SLOT(setVSyncEnabled()));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -447,7 +448,7 @@ Menu::Menu() {
|
|||
addCheckableActionToQMenuAndActionHash(timingMenu, MenuOption::PipelineWarnings);
|
||||
addCheckableActionToQMenuAndActionHash(timingMenu, MenuOption::SuppressShortTimings);
|
||||
|
||||
auto audioIO = DependencyManager::get<Audio>();
|
||||
auto audioIO = DependencyManager::get<AudioClient>();
|
||||
QMenu* audioDebugMenu = developerMenu->addMenu("Audio");
|
||||
addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::AudioNoiseReduction,
|
||||
0,
|
||||
|
|
|
@ -239,8 +239,6 @@ namespace MenuOption {
|
|||
const QString RunTimingTests = "Run Timing Tests";
|
||||
const QString ScriptEditor = "Script Editor...";
|
||||
const QString ScriptedMotorControl = "Enable Scripted Motor Control";
|
||||
const QString SettingsExport = "Export Settings";
|
||||
const QString SettingsImport = "Import Settings";
|
||||
const QString ShowBordersEntityNodes = "Show Entity Nodes";
|
||||
const QString ShowBordersVoxelNodes = "Show Voxel Nodes";
|
||||
const QString ShowIKConstraints = "Show IK Constraints";
|
||||
|
|
|
@ -899,8 +899,6 @@ int MetavoxelSystemClient::parseData(const QByteArray& packet) {
|
|||
} else {
|
||||
QMetaObject::invokeMethod(&_sequencer, "receivedDatagram", Q_ARG(const QByteArray&, packet));
|
||||
}
|
||||
Application::getInstance()->getBandwidthRecorder()->metavoxelsChannel->input.updateValue(packet.size());
|
||||
Application::getInstance()->getBandwidthRecorder()->totalChannel->input.updateValue(packet.size());
|
||||
}
|
||||
return packet.size();
|
||||
}
|
||||
|
@ -1016,8 +1014,6 @@ void MetavoxelSystemClient::sendDatagram(const QByteArray& data) {
|
|||
} else {
|
||||
DependencyManager::get<NodeList>()->writeDatagram(data, _node);
|
||||
}
|
||||
Application::getInstance()->getBandwidthRecorder()->metavoxelsChannel->output.updateValue(data.size());
|
||||
Application::getInstance()->getBandwidthRecorder()->totalChannel->output.updateValue(data.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue