mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-09 10:47:53 +02:00
Merge branch 'master' of https://github.com/worklist/hifi into shared_and_weak_pointers
Conflicts: assignment-client/src/AssignmentClient.cpp assignment-client/src/AssignmentClient.h libraries/shared/src/NodeList.cpp
This commit is contained in:
commit
2c02178802
634 changed files with 21222 additions and 7430 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -42,5 +42,9 @@ interface/external/visage/*
|
|||
interface/resources/visage/*
|
||||
!interface/resources/visage/tracker.cfg
|
||||
|
||||
# Ignore Faceplus
|
||||
interface/external/faceplus/*
|
||||
!interface/external/faceplus/readme.txt
|
||||
|
||||
# Ignore interfaceCache for Linux users
|
||||
interface/interfaceCache/
|
||||
|
|
44
BUILD.md
44
BUILD.md
|
@ -1,10 +1,12 @@
|
|||
Dependencies
|
||||
===
|
||||
* [cmake](http://www.cmake.org/cmake/resources/software.html) ~> 2.8.11
|
||||
* [cmake](http://www.cmake.org/cmake/resources/software.html) ~> 2.8.12.2
|
||||
* [Qt](http://qt-project.org/downloads) ~> 5.2.0
|
||||
* [zLib](http://www.zlib.net/) ~> 1.2.8
|
||||
* [glm](http://glm.g-truc.net/0.9.5/index.html) ~> 0.9.5.2
|
||||
* [qxmpp](https://code.google.com/p/qxmpp/) ~> 0.7.6
|
||||
* [GnuTLS](http://gnutls.org/download.html) ~> 3.2.12
|
||||
* IMPORTANT: GnuTLS 3.2.12 is critical to avoid a security vulnerability.
|
||||
|
||||
#####Linux only
|
||||
* [freeglut](http://freeglut.sourceforge.net/) ~> 2.8.0
|
||||
|
@ -50,12 +52,18 @@ Should you choose not to install Qt5 via a package manager that handles dependen
|
|||
|
||||
libasound2 libxmu-dev libxi-dev freeglut3-dev libasound2-dev libjack-dev
|
||||
|
||||
#####GnuTLS
|
||||
|
||||
If `libgnutls28-dev` 3.2.12 or higher is available via your package manager, it would be easiest to grab it from there. At the time of this writing that is not the case for any version of Ubuntu, so it will need to be built from source.
|
||||
|
||||
`gmplib` is a dependency for GnuTLS. On Ubuntu, we were unable to build `hogweed` (part of `libnettle`) with `gmpib` 6.x.x. If nettle is not built with `hogweed`, GnuTLS will fail to build. If you run into this problem, try version 4.2.1 of `gmplib`.
|
||||
|
||||
####OS X
|
||||
#####Package Managers
|
||||
[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 zlib
|
||||
brew install cmake glm zlib gnutls
|
||||
brew install highfidelity/formulas/qt5
|
||||
brew link qt5 --force
|
||||
brew install highfidelity/formulas/qxmpp
|
||||
|
@ -71,7 +79,7 @@ If Xcode is your editor of choice, you can ask CMake to generate Xcode project f
|
|||
|
||||
After running cmake, you will have the make files or Xcode project file necessary to build all of the components. Open the hifi.xcodeproj file, choose ALL_BUILD from the Product > Scheme menu (or target drop down), and click Run.
|
||||
|
||||
If the build completes successfully, you will have built targets for all components located in the `build/${target_name}/Debug directories`.
|
||||
If the build completes successfully, you will have built targets for all components located in the `build/${target_name}/Debug` directories.
|
||||
|
||||
Windows
|
||||
===
|
||||
|
@ -100,11 +108,12 @@ Once Qt is installed, you need to manually configure the following:
|
|||
NOTE: zLib should configure itself correctly on install. However, sometimes zLib doesn't properly detect system components and fails to configure itself correctly. When it fails, it will not correctly set the #if HAVE_UNISTD_H at line 287 of zconf.h to #if 0... if it fails, you're build will have errors in the voxels target. You can correct this by setting the #if to 0 instead of 1, since Windows does not have unistd.h.
|
||||
|
||||
####External Libraries
|
||||
We don't currently have a Windows installer, so before running Interface, you will need to ensure that all required resources are loadable.
|
||||
|
||||
CMake will need to know where the headers and libraries for required external dependencies are. If you installed ZLIB using the installer, the FindZLIB cmake module will be able to find it. This isn't the case for the others.
|
||||
CMake will need to know where the headers and libraries for required external dependencies are.
|
||||
|
||||
The recommended route for CMake to find external dependencies is to place all of the dependencies in one folder and set one ENV variable - HIFI_LIB_DIR. That ENV variable should point to a directory with the following structure:
|
||||
If you installed zLib using the installer, the Cmake find module for zLib should locate it on your system.
|
||||
|
||||
The recommended route for CMake to find the other external dependencies is to place all of the dependencies in one folder and set one ENV variable - HIFI_LIB_DIR. That ENV variable should point to a directory with the following structure:
|
||||
|
||||
root_lib_dir
|
||||
-> glm
|
||||
|
@ -121,15 +130,30 @@ The recommended route for CMake to find external dependencies is to place all of
|
|||
-> qxmpp
|
||||
-> include
|
||||
-> lib
|
||||
|
||||
*NOTE: 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.*
|
||||
-> gnutls
|
||||
-> bin
|
||||
-> include
|
||||
-> lib
|
||||
|
||||
For many of the external libraries where precompiled binaries are readily available you should be able to simply copy the extracted folder that you get from the download links provided at the top of the guide. Otherwise you may need to build from source and install the built product to this directory. The `root_lib_dir` in the above example can be wherever you choose on your system - as long as the environment variable HIFI_LIB_DIR is set to it.
|
||||
|
||||
*NOTE: 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.*
|
||||
|
||||
*NOTE: Qt does not support 64-bit builds on Windows 7, so you must use the 32-bit version of libraries for interface.exe to run. The 32-bit version of the static library is the one linked by our CMake find modules*
|
||||
|
||||
#### DLLs
|
||||
As with the Qt libraries, you will need to make sure the directory containing dynamically-linked libraries is in your path. For example, for a dynamically linked build of freeglut, the directory to add to your path in which the DLL is found is `FREEGLUT_DIR/bin`. Where possible, you can use static builds of the external dependencies to avoid this requirement.
|
||||
##### DLLs
|
||||
As with the Qt libraries, you will need to make sure the directories containing dynamically-linked libraries is in your path.
|
||||
|
||||
For example, for a dynamically linked build of freeglut, the directory to add to your path in which the DLL is found is `FREEGLUT_DIR/bin`. Where possible, you can use static builds of the external dependencies to avoid this requirement.
|
||||
|
||||
#####GnuTLS
|
||||
You can get a precompiled version of GnuTLS for Windows [here](http://gnutls.org/download.html).
|
||||
|
||||
To use GnuTLS with Visual Studio, you will need to create `libgnutls-28.lib`, the import library for Visual Studio projects. this is done using the `lib` command in the `bin` folder of your GnuTLS download. Run the following in a Visual Studio Command Prompt (found in the tools menu of Visual Studio).
|
||||
|
||||
$GNUTLS_DIR\bin> lib /def:libgnutls-28.def
|
||||
|
||||
This will create `libgnutls-28.lib` in the `bin` folder. Copy that file to the `lib` sub-folder of your GnuTLS folder, and the Cmake FindGnuTLS module in this repo will find it during the Cmake run.
|
||||
|
||||
####Building in Visual Studio
|
||||
Follow the same build steps from the CMake section, but pass a different generator to CMake.
|
||||
|
|
14
LICENSE
14
LICENSE
|
@ -1 +1,13 @@
|
|||
All rights reserved. © High Fidelity, Inc. 2013
|
||||
Copyright 2014 High Fidelity, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
|
@ -29,4 +29,18 @@ link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}")
|
|||
# link in the hifi voxels library
|
||||
link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
# link the hifi networking library
|
||||
link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
find_package(GnuTLS REQUIRED)
|
||||
|
||||
# include the GnuTLS dir
|
||||
include_directories(SYSTEM "${GNUTLS_INCLUDE_DIR}")
|
||||
|
||||
# add a definition for ssize_t so that windows doesn't bail on gnutls.h
|
||||
if (WIN32)
|
||||
add_definitions(-Dssize_t=long)
|
||||
endif ()
|
||||
|
||||
# link GnuTLS
|
||||
target_link_libraries(${TARGET_NAME} "${GNUTLS_LIBRARY}")
|
|
@ -1,9 +1,12 @@
|
|||
//
|
||||
// AnimationServer.cpp
|
||||
// hifi
|
||||
// animation-server/src
|
||||
//
|
||||
// Created by Stephen Birarda on 12/5/2013.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// 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 <algorithm>
|
||||
|
@ -723,12 +726,12 @@ AnimationServer::AnimationServer(int &argc, char **argv) :
|
|||
::wantLocalDomain = cmdOptionExists(argc, (const char**) argv,local);
|
||||
if (::wantLocalDomain) {
|
||||
printf("Local Domain MODE!\n");
|
||||
nodeList->getDomainInfo().setIPToLocalhost();
|
||||
nodeList->getDomainHandler().setIPToLocalhost();
|
||||
}
|
||||
|
||||
const char* domainHostname = getCmdOption(argc, (const char**) argv, "--domain");
|
||||
if (domainHostname) {
|
||||
NodeList::getInstance()->getDomainInfo().setHostname(domainHostname);
|
||||
NodeList::getInstance()->getDomainHandler().setHostname(domainHostname);
|
||||
}
|
||||
|
||||
const char* packetsPerSecondCommand = getCmdOption(argc, (const char**) argv, "--pps");
|
||||
|
@ -797,11 +800,11 @@ AnimationServer::AnimationServer(int &argc, char **argv) :
|
|||
|
||||
QTimer* domainServerTimer = new QTimer(this);
|
||||
connect(domainServerTimer, SIGNAL(timeout()), nodeList, SLOT(sendDomainServerCheckIn()));
|
||||
domainServerTimer->start(DOMAIN_SERVER_CHECK_IN_USECS / 1000);
|
||||
domainServerTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS);
|
||||
|
||||
QTimer* silentNodeTimer = new QTimer(this);
|
||||
connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes()));
|
||||
silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000);
|
||||
silentNodeTimer->start(NODE_SILENCE_THRESHOLD_MSECS);
|
||||
|
||||
connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), SLOT(readPendingDatagrams()));
|
||||
}
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
//
|
||||
// AnimationServer.h
|
||||
// hifi
|
||||
// animation-server/src
|
||||
//
|
||||
// Created by Stephen Birarda on 12/5/2013.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// 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__AnimationServer__
|
||||
#define __hifi__AnimationServer__
|
||||
#ifndef hifi_AnimationServer_h
|
||||
#define hifi_AnimationServer_h
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
|
||||
|
@ -21,4 +24,4 @@ private slots:
|
|||
};
|
||||
|
||||
|
||||
#endif /* defined(__hifi__AnimationServer__) */
|
||||
#endif // hifi_AnimationServer_h
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
//
|
||||
// main.cpp
|
||||
// Animation Server
|
||||
// animation-server/src
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 05/16/2013
|
||||
// Copyright (c) 2012 High Fidelity, Inc. All rights reserved.
|
||||
// Created by Brad Hefta-Gaub on 05/16/2013.
|
||||
// Copyright 2012 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 "AnimationServer.h"
|
||||
|
|
|
@ -28,11 +28,22 @@ link_hifi_library(audio ${TARGET_NAME} "${ROOT_DIR}")
|
|||
link_hifi_library(avatars ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(particles ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(script-engine ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(embedded-webserver ${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
find_package(GnuTLS REQUIRED)
|
||||
|
||||
# add a definition for ssize_t so that windows doesn't bail on gnutls.h
|
||||
if (WIN32)
|
||||
add_definitions(-Dssize_t=long)
|
||||
endif ()
|
||||
|
||||
include_directories(SYSTEM "${GNUTLS_INCLUDE_DIR}")
|
||||
|
||||
if (UNIX)
|
||||
target_link_libraries(${TARGET_NAME} ${CMAKE_DL_LIBS})
|
||||
endif (UNIX)
|
||||
|
@ -41,4 +52,4 @@ IF (WIN32)
|
|||
target_link_libraries(${TARGET_NAME} Winmm Ws2_32)
|
||||
ENDIF(WIN32)
|
||||
|
||||
target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets Qt5::Script)
|
||||
target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets Qt5::Script "${GNUTLS_LIBRARY}")
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
//
|
||||
// Agent.cpp
|
||||
// hifi
|
||||
// assignment-client/src
|
||||
//
|
||||
// Created by Stephen Birarda on 7/1/13.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// 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/QCoreApplication>
|
||||
#include <QtCore/QEventLoop>
|
||||
#include <QtCore/QStandardPaths>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtNetwork/QNetworkAccessManager>
|
||||
#include <QtNetwork/QNetworkDiskCache>
|
||||
#include <QtNetwork/QNetworkRequest>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
|
||||
|
@ -17,6 +22,7 @@
|
|||
#include <AvatarData.h>
|
||||
#include <NodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <ResourceCache.h>
|
||||
#include <UUID.h>
|
||||
#include <VoxelConstants.h>
|
||||
#include <ParticlesScriptingInterface.h>
|
||||
|
@ -27,7 +33,8 @@ Agent::Agent(const QByteArray& packet) :
|
|||
ThreadedAssignment(packet),
|
||||
_voxelEditSender(),
|
||||
_particleEditSender(),
|
||||
_receivedAudioBuffer(NETWORK_BUFFER_LENGTH_SAMPLES_STEREO)
|
||||
_receivedAudioBuffer(NETWORK_BUFFER_LENGTH_SAMPLES_STEREO),
|
||||
_avatarHashMap()
|
||||
{
|
||||
// be the parent of the script engine so it gets moved when we do
|
||||
_scriptEngine.setParent(this);
|
||||
|
@ -125,6 +132,16 @@ void Agent::readPendingDatagrams() {
|
|||
// let this continue through to the NodeList so it updates last heard timestamp
|
||||
// for the sending audio mixer
|
||||
NodeList::getInstance()->processNodeData(senderSockAddr, receivedPacket);
|
||||
} else if (datagramPacketType == PacketTypeBulkAvatarData
|
||||
|| datagramPacketType == PacketTypeAvatarIdentity
|
||||
|| datagramPacketType == PacketTypeAvatarBillboard
|
||||
|| datagramPacketType == PacketTypeKillAvatar) {
|
||||
// let the avatar hash map process it
|
||||
_avatarHashMap.processAvatarMixerDatagram(receivedPacket, nodeList->sendingNodeForPacket(receivedPacket));
|
||||
|
||||
// let this continue through to the NodeList so it updates last heard timestamp
|
||||
// for the sending avatar-mixer
|
||||
NodeList::getInstance()->processNodeData(senderSockAddr, receivedPacket);
|
||||
} else {
|
||||
NodeList::getInstance()->processNodeData(senderSockAddr, receivedPacket);
|
||||
}
|
||||
|
@ -145,22 +162,32 @@ void Agent::run() {
|
|||
<< NodeType::ParticleServer);
|
||||
|
||||
// figure out the URL for the script for this agent assignment
|
||||
QString scriptURLString("http://%1:8080/assignment/%2");
|
||||
scriptURLString = scriptURLString.arg(NodeList::getInstance()->getDomainInfo().getIP().toString(),
|
||||
uuidStringWithoutCurlyBraces(_uuid));
|
||||
|
||||
QUrl scriptURL;
|
||||
if (_payload.isEmpty()) {
|
||||
scriptURL = QUrl(QString("http://%1:8080/assignment/%2")
|
||||
.arg(NodeList::getInstance()->getDomainHandler().getIP().toString(),
|
||||
uuidStringWithoutCurlyBraces(_uuid)));
|
||||
} else {
|
||||
scriptURL = QUrl(_payload);
|
||||
}
|
||||
|
||||
QNetworkAccessManager *networkManager = new QNetworkAccessManager(this);
|
||||
QNetworkReply *reply = networkManager->get(QNetworkRequest(QUrl(scriptURLString)));
|
||||
QNetworkReply *reply = networkManager->get(QNetworkRequest(scriptURL));
|
||||
QNetworkDiskCache* cache = new QNetworkDiskCache(networkManager);
|
||||
QString cachePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
|
||||
cache->setCacheDirectory(!cachePath.isEmpty() ? cachePath : "agentCache");
|
||||
networkManager->setCache(cache);
|
||||
|
||||
qDebug() << "Downloading script at" << scriptURLString;
|
||||
qDebug() << "Downloading script at" << scriptURL.toString();
|
||||
|
||||
QEventLoop loop;
|
||||
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
|
||||
|
||||
loop.exec();
|
||||
|
||||
// let the AvatarData class use our QNetworkAcessManager
|
||||
// let the AvatarData and ResourceCache classes use our QNetworkAccessManager
|
||||
AvatarData::setNetworkAccessManager(networkManager);
|
||||
ResourceCache::setNetworkAccessManager(networkManager);
|
||||
|
||||
QString scriptContents(reply->readAll());
|
||||
|
||||
|
@ -175,6 +202,7 @@ void Agent::run() {
|
|||
|
||||
// give this AvatarData object to the script engine
|
||||
_scriptEngine.setAvatarData(&scriptedAvatar, "Avatar");
|
||||
_scriptEngine.setAvatarHashMap(&_avatarHashMap, "AvatarList");
|
||||
|
||||
// register ourselves to the script engine
|
||||
_scriptEngine.registerGlobalObject("Agent", this);
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
//
|
||||
// Agent.h
|
||||
// hifi
|
||||
// assignment-client/src
|
||||
//
|
||||
// Created by Stephen Birarda on 7/1/13.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// 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__Agent__
|
||||
#define __hifi__Agent__
|
||||
#ifndef hifi_Agent_h
|
||||
#define hifi_Agent_h
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
@ -15,6 +18,7 @@
|
|||
#include <QtCore/QObject>
|
||||
#include <QtCore/QUrl>
|
||||
|
||||
#include <AvatarHashMap.h>
|
||||
#include <MixedAudioRingBuffer.h>
|
||||
#include <ParticleEditPacketSender.h>
|
||||
#include <ParticleTree.h>
|
||||
|
@ -62,6 +66,7 @@ private:
|
|||
VoxelTreeHeadlessViewer _voxelViewer;
|
||||
|
||||
MixedAudioRingBuffer _receivedAudioBuffer;
|
||||
AvatarHashMap _avatarHashMap;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__Agent__) */
|
||||
#endif // hifi_Agent_h
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
//
|
||||
// AssignmentClient.cpp
|
||||
// hifi
|
||||
// assignment-client/src
|
||||
//
|
||||
// Created by Stephen Birarda on 11/25/2013.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// 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/QProcess>
|
||||
#include <QtCore/QThread>
|
||||
#include <QtCore/QTimer>
|
||||
|
||||
#include <gnutls/gnutls.h>
|
||||
|
||||
#include <AccountManager.h>
|
||||
#include <Assignment.h>
|
||||
#include <Logging.h>
|
||||
|
@ -30,64 +35,58 @@ SharedAssignmentPointer AssignmentClient::_currentAssignment;
|
|||
int hifiSockAddrMeta = qRegisterMetaType<HifiSockAddr>("HifiSockAddr");
|
||||
|
||||
AssignmentClient::AssignmentClient(int &argc, char **argv) :
|
||||
QCoreApplication(argc, argv)
|
||||
QCoreApplication(argc, argv),
|
||||
_assignmentServerHostname(DEFAULT_ASSIGNMENT_SERVER_HOSTNAME)
|
||||
{
|
||||
DTLSClientSession::globalInit();
|
||||
|
||||
setOrganizationName("High Fidelity");
|
||||
setOrganizationDomain("highfidelity.io");
|
||||
setApplicationName("assignment-client");
|
||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||
|
||||
QStringList argumentList = arguments();
|
||||
|
||||
// register meta type is required for queued invoke method on Assignment subclasses
|
||||
|
||||
// set the logging target to the the CHILD_TARGET_NAME
|
||||
Logging::setTargetName(ASSIGNMENT_CLIENT_TARGET_NAME);
|
||||
|
||||
const char ASSIGNMENT_TYPE_OVVERIDE_OPTION[] = "-t";
|
||||
const char* assignmentTypeString = getCmdOption(argc, (const char**)argv, ASSIGNMENT_TYPE_OVVERIDE_OPTION);
|
||||
const QString ASSIGNMENT_TYPE_OVVERIDE_OPTION = "-t";
|
||||
int argumentIndex = argumentList.indexOf(ASSIGNMENT_TYPE_OVVERIDE_OPTION);
|
||||
|
||||
Assignment::Type requestAssignmentType = Assignment::AllTypes;
|
||||
|
||||
if (assignmentTypeString) {
|
||||
// the user is asking to only be assigned to a particular type of assignment
|
||||
// so set that as the ::overridenAssignmentType to be used in requests
|
||||
requestAssignmentType = (Assignment::Type) atoi(assignmentTypeString);
|
||||
if (argumentIndex != -1) {
|
||||
requestAssignmentType = (Assignment::Type) argumentList[argumentIndex + 1].toInt();
|
||||
}
|
||||
|
||||
const char ASSIGNMENT_POOL_OPTION[] = "--pool";
|
||||
const char* requestAssignmentPool = getCmdOption(argc, (const char**) argv, ASSIGNMENT_POOL_OPTION);
|
||||
const QString ASSIGNMENT_POOL_OPTION = "--pool";
|
||||
|
||||
argumentIndex = argumentList.indexOf(ASSIGNMENT_POOL_OPTION);
|
||||
|
||||
QString assignmentPool;
|
||||
|
||||
if (argumentIndex != -1) {
|
||||
assignmentPool = argumentList[argumentIndex + 1];
|
||||
}
|
||||
// setup our _requestAssignment member variable from the passed arguments
|
||||
_requestAssignment = Assignment(Assignment::RequestCommand, requestAssignmentType, requestAssignmentPool);
|
||||
_requestAssignment = Assignment(Assignment::RequestCommand, requestAssignmentType, assignmentPool);
|
||||
|
||||
// create a NodeList as an unassigned client
|
||||
NodeList* nodeList = NodeList::createInstance(NodeType::Unassigned);
|
||||
|
||||
const char CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION[] = "-a";
|
||||
const char CUSTOM_ASSIGNMENT_SERVER_PORT_OPTION[] = "-p";
|
||||
// check for an overriden assignment server hostname
|
||||
const QString CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION = "-a";
|
||||
|
||||
// grab the overriden assignment-server hostname from argv, if it exists
|
||||
const char* customAssignmentServerHostname = getCmdOption(argc, (const char**)argv, CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION);
|
||||
const char* customAssignmentServerPortString = getCmdOption(argc,(const char**)argv, CUSTOM_ASSIGNMENT_SERVER_PORT_OPTION);
|
||||
argumentIndex = argumentList.indexOf(CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION);
|
||||
|
||||
HifiSockAddr customAssignmentSocket;
|
||||
|
||||
if (customAssignmentServerHostname || customAssignmentServerPortString) {
|
||||
if (argumentIndex != -1) {
|
||||
_assignmentServerHostname = argumentList[argumentIndex + 1];
|
||||
|
||||
// set the custom port or default if it wasn't passed
|
||||
unsigned short assignmentServerPort = customAssignmentServerPortString
|
||||
? atoi(customAssignmentServerPortString) : DEFAULT_DOMAIN_SERVER_PORT;
|
||||
// set the custom assignment socket on our NodeList
|
||||
HifiSockAddr customAssignmentSocket = HifiSockAddr(_assignmentServerHostname, DEFAULT_DOMAIN_SERVER_PORT);
|
||||
|
||||
// set the custom hostname or default if it wasn't passed
|
||||
if (!customAssignmentServerHostname) {
|
||||
customAssignmentServerHostname = DEFAULT_ASSIGNMENT_SERVER_HOSTNAME;
|
||||
}
|
||||
|
||||
customAssignmentSocket = HifiSockAddr(customAssignmentServerHostname, assignmentServerPort);
|
||||
}
|
||||
|
||||
// set the custom assignment socket if we have it
|
||||
if (!customAssignmentSocket.isNull()) {
|
||||
nodeList->setAssignmentServerSocket(customAssignmentSocket);
|
||||
}
|
||||
|
||||
|
@ -106,6 +105,10 @@ AssignmentClient::AssignmentClient(int &argc, char **argv) :
|
|||
this, &AssignmentClient::handleAuthenticationRequest);
|
||||
}
|
||||
|
||||
AssignmentClient::~AssignmentClient() {
|
||||
DTLSClientSession::globalDeinit();
|
||||
}
|
||||
|
||||
void AssignmentClient::sendAssignmentRequest() {
|
||||
if (!_currentAssignment) {
|
||||
NodeList::getInstance()->sendAssignment(_requestAssignment);
|
||||
|
@ -131,12 +134,12 @@ void AssignmentClient::readPendingDatagrams() {
|
|||
if (_currentAssignment) {
|
||||
qDebug() << "Received an assignment -" << *_currentAssignment;
|
||||
|
||||
// switch our nodelist domain IP and port to whoever sent us the assignment
|
||||
// switch our DomainHandler hostname and port to whoever sent us the assignment
|
||||
|
||||
nodeList->getDomainInfo().setSockAddr(senderSockAddr);
|
||||
nodeList->getDomainInfo().setAssignmentUUID(_currentAssignment->getUUID());
|
||||
nodeList->getDomainHandler().setSockAddr(senderSockAddr, _assignmentServerHostname);
|
||||
nodeList->getDomainHandler().setAssignmentUUID(_currentAssignment->getUUID());
|
||||
|
||||
qDebug() << "Destination IP for assignment is" << nodeList->getDomainInfo().getIP().toString();
|
||||
qDebug() << "Destination IP for assignment is" << nodeList->getDomainHandler().getIP().toString();
|
||||
|
||||
// start the deployed assignment
|
||||
AssignmentThread* workerThread = new AssignmentThread(_currentAssignment, this);
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
//
|
||||
// AssignmentClient.h
|
||||
// hifi
|
||||
// assignment-client/src
|
||||
//
|
||||
// Created by Stephen Birarda on 11/25/2013.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// 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__AssignmentClient__
|
||||
#define __hifi__AssignmentClient__
|
||||
#ifndef hifi_AssignmentClient_h
|
||||
#define hifi_AssignmentClient_h
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
|
||||
|
@ -17,9 +20,8 @@ class AssignmentClient : public QCoreApplication {
|
|||
Q_OBJECT
|
||||
public:
|
||||
AssignmentClient(int &argc, char **argv);
|
||||
|
||||
static const SharedAssignmentPointer& getCurrentAssignment() { return _currentAssignment; }
|
||||
|
||||
~AssignmentClient();
|
||||
private slots:
|
||||
void sendAssignmentRequest();
|
||||
void readPendingDatagrams();
|
||||
|
@ -29,6 +31,7 @@ private slots:
|
|||
private:
|
||||
Assignment _requestAssignment;
|
||||
static SharedAssignmentPointer _currentAssignment;
|
||||
QString _assignmentServerHostname;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__AssignmentClient__) */
|
||||
#endif // hifi_AssignmentClient_h
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
//
|
||||
// AssignmentClientMonitor.cpp
|
||||
// hifi
|
||||
// assignment-client/src
|
||||
//
|
||||
// Created by Stephen Birarda on 1/10/2014.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
// 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 <Logging.h>
|
||||
|
@ -53,4 +56,4 @@ void AssignmentClientMonitor::spawnChildClient() {
|
|||
void AssignmentClientMonitor::childProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) {
|
||||
qDebug("Replacing dead child assignment client with a new one");
|
||||
spawnChildClient();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
//
|
||||
// AssignmentClientMonitor.h
|
||||
// hifi
|
||||
// assignment-client/src
|
||||
//
|
||||
// Created by Stephen Birarda on 1/10/2014.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef __hifi__AssignmentClientMonitor__
|
||||
#define __hifi__AssignmentClientMonitor__
|
||||
#ifndef hifi_AssignmentClientMonitor_h
|
||||
#define hifi_AssignmentClientMonitor_h
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QProcess>
|
||||
|
@ -28,4 +31,4 @@ private:
|
|||
QStringList _childArguments;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__AssignmentClientMonitor__) */
|
||||
#endif // hifi_AssignmentClientMonitor_h
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
//
|
||||
// AssignmentFactory.cpp
|
||||
// hifi
|
||||
// assignment-client/src
|
||||
//
|
||||
// Created by Stephen Birarda on 9/17/13.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// 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 <PacketHeaders.h>
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
//
|
||||
// AssignmentFactory.h
|
||||
// hifi
|
||||
// assignment-client/src
|
||||
//
|
||||
// Created by Stephen Birarda on 9/17/13.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// 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__AssignmentFactory__
|
||||
#define __hifi__AssignmentFactory__
|
||||
#ifndef hifi_AssignmentFactory_h
|
||||
#define hifi_AssignmentFactory_h
|
||||
|
||||
#include <ThreadedAssignment.h>
|
||||
|
||||
|
@ -16,4 +19,4 @@ public:
|
|||
static ThreadedAssignment* unpackAssignment(const QByteArray& packet);
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__AssignmentFactory__) */
|
||||
#endif // hifi_AssignmentFactory_h
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
//
|
||||
// AssignmentThread.cpp
|
||||
// hifi
|
||||
// assignment-client/src
|
||||
//
|
||||
// Created by Stephen Birarda on 2014-03-28.
|
||||
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||
// Created by Stephen Birarda on 2014.
|
||||
// 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 "AssignmentThread.h"
|
||||
|
@ -13,4 +16,4 @@ AssignmentThread::AssignmentThread(const SharedAssignmentPointer& assignment, QO
|
|||
_assignment(assignment)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
//
|
||||
// AssignmentThread.h
|
||||
// hifi
|
||||
// assignment-client/src
|
||||
//
|
||||
// Created by Stephen Birarda on 2014-03-28.
|
||||
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||
// Created by Stephen Birarda on 2014.
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef __hifi__AssignmentThread__
|
||||
#define __hifi__AssignmentThread__
|
||||
#ifndef hifi_AssignmentThread_h
|
||||
#define hifi_AssignmentThread_h
|
||||
|
||||
#include <QtCore/QThread>
|
||||
|
||||
|
@ -20,4 +23,4 @@ private:
|
|||
SharedAssignmentPointer _assignment;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__AssignmentThread__) */
|
||||
#endif // hifi_AssignmentThread_h
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
//
|
||||
// AudioMixer.cpp
|
||||
// hifi
|
||||
// assignment-client/src/audio
|
||||
//
|
||||
// Created by Stephen Birarda on 8/22/13.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// 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 <mmintrin.h>
|
||||
|
@ -18,7 +21,6 @@
|
|||
#include <string.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "Syssocket.h"
|
||||
#include "Systime.h"
|
||||
#include <math.h>
|
||||
#else
|
||||
|
@ -369,7 +371,7 @@ void AudioMixer::sendStatsPacket() {
|
|||
statsObject["average_mixes_per_listener"] = 0.0;
|
||||
}
|
||||
|
||||
ThreadedAssignment::addPacketStatsAndSendStatsPacket(statsObject);
|
||||
// ThreadedAssignment::addPacketStatsAndSendStatsPacket(statsObject);
|
||||
|
||||
_sumListeners = 0;
|
||||
_sumMixes = 0;
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
//
|
||||
// AudioMixer.h
|
||||
// hifi
|
||||
// assignment-client/src/audio
|
||||
//
|
||||
// Created by Stephen Birarda on 8/22/13.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// 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__AudioMixer__
|
||||
#define __hifi__AudioMixer__
|
||||
#ifndef hifi_AudioMixer_h
|
||||
#define hifi_AudioMixer_h
|
||||
|
||||
#include <AudioRingBuffer.h>
|
||||
|
||||
|
@ -50,4 +53,4 @@ private:
|
|||
int _sumMixes;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__AudioMixer__) */
|
||||
#endif // hifi_AudioMixer_h
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
//
|
||||
// AudioMixerClientData.cpp
|
||||
// hifi
|
||||
// assignment-client/src/audio
|
||||
//
|
||||
// Created by Stephen Birarda on 10/18/13.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// 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 <QDebug>
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
//
|
||||
// AudioMixerClientData.h
|
||||
// hifi
|
||||
// assignment-client/src/audio
|
||||
//
|
||||
// Created by Stephen Birarda on 10/18/13.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// 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__AudioMixerClientData__
|
||||
#define __hifi__AudioMixerClientData__
|
||||
#ifndef hifi_AudioMixerClientData_h
|
||||
#define hifi_AudioMixerClientData_h
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
@ -31,4 +34,4 @@ private:
|
|||
std::vector<PositionalAudioRingBuffer*> _ringBuffers;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__AudioMixerClientData__) */
|
||||
#endif // hifi_AudioMixerClientData_h
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
//
|
||||
// AvatarAudioRingBuffer.cpp
|
||||
// hifi
|
||||
// assignment-client/src/audio
|
||||
//
|
||||
// Created by Stephen Birarda on 6/5/13.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// 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 <PacketHeaders.h>
|
||||
|
@ -18,4 +21,4 @@ AvatarAudioRingBuffer::AvatarAudioRingBuffer() :
|
|||
int AvatarAudioRingBuffer::parseData(const QByteArray& packet) {
|
||||
_shouldLoopbackForNode = (packetTypeForPacket(packet) == PacketTypeMicrophoneAudioWithEcho);
|
||||
return PositionalAudioRingBuffer::parseData(packet);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
//
|
||||
// AvatarAudioRingBuffer.h
|
||||
// hifi
|
||||
// assignment-client/src/audio
|
||||
//
|
||||
// Created by Stephen Birarda on 6/5/13.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// 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__AvatarAudioRingBuffer__
|
||||
#define __hifi__AvatarAudioRingBuffer__
|
||||
#ifndef hifi_AvatarAudioRingBuffer_h
|
||||
#define hifi_AvatarAudioRingBuffer_h
|
||||
|
||||
#include <QtCore/QUuid>
|
||||
|
||||
|
@ -24,4 +27,4 @@ private:
|
|||
AvatarAudioRingBuffer& operator= (const AvatarAudioRingBuffer&);
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__AvatarAudioRingBuffer__) */
|
||||
#endif // hifi_AvatarAudioRingBuffer_h
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
//
|
||||
// AvatarMixer.cpp
|
||||
// hifi
|
||||
// assignment-client/src/avatars
|
||||
//
|
||||
// Created by Stephen Birarda on 9/5/13.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// Original avatar-mixer main created by Leonardo Murillo on 03/25/13.
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
// The avatar mixer receives head, hand and positional data from all connected
|
||||
// nodes, and broadcasts that data back to them, every BROADCAST_INTERVAL ms.
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QDateTime>
|
||||
|
|
|
@ -1,13 +1,19 @@
|
|||
//
|
||||
// AvatarMixer.h
|
||||
// hifi
|
||||
// assignment-client/src/avatars
|
||||
//
|
||||
// Created by Stephen Birarda on 9/5/13.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// The avatar mixer receives head, hand and positional data from all connected
|
||||
// nodes, and broadcasts that data back to them, every BROADCAST_INTERVAL ms.
|
||||
//
|
||||
// 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__AvatarMixer__
|
||||
#define __hifi__AvatarMixer__
|
||||
#ifndef hifi_AvatarMixer_h
|
||||
#define hifi_AvatarMixer_h
|
||||
|
||||
#include <ThreadedAssignment.h>
|
||||
|
||||
|
@ -43,4 +49,4 @@ private:
|
|||
int _sumIdentityPackets;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__AvatarMixer__) */
|
||||
#endif // hifi_AvatarMixer_h
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
//
|
||||
// AvatarMixerClientData.cpp
|
||||
// hifi
|
||||
// assignment-client/src/avatars
|
||||
//
|
||||
// Created by Stephen Birarda on 2/4/2014.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
// 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 <PacketHeaders.h>
|
||||
|
||||
#include "AvatarMixerClientData.h"
|
||||
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
//
|
||||
// AvatarMixerClientData.h
|
||||
// hifi
|
||||
// assignment-client/src/avatars
|
||||
//
|
||||
// Created by Stephen Birarda on 2/4/2014.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef __hifi__AvatarMixerClientData__
|
||||
#define __hifi__AvatarMixerClientData__
|
||||
#ifndef hifi_AvatarMixerClientData_h
|
||||
#define hifi_AvatarMixerClientData_h
|
||||
|
||||
#include <QtCore/QUrl>
|
||||
|
||||
|
@ -37,4 +40,4 @@ private:
|
|||
quint64 _identityChangeTimestamp;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__AvatarMixerClientData__) */
|
||||
#endif // hifi_AvatarMixerClientData_h
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
//
|
||||
// main.cpp
|
||||
// assignment-client
|
||||
// assignment-client/src
|
||||
//
|
||||
// Created by Stephen Birarda on 8/22/13.
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
// 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 <Logging.h>
|
||||
|
@ -37,4 +40,4 @@ int main(int argc, char* argv[]) {
|
|||
AssignmentClient client(argc, argv);
|
||||
return client.exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
//
|
||||
// MetavoxelServer.cpp
|
||||
// hifi
|
||||
// assignment-client/src/metavoxels
|
||||
//
|
||||
// Created by Andrzej Kapolka on 12/18/13.
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
// 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 <QDateTime>
|
||||
|
@ -95,6 +98,8 @@ MetavoxelSession::MetavoxelSession(MetavoxelServer* server, const SharedNodePoin
|
|||
connect(&_sequencer, SIGNAL(readyToRead(Bitstream&)), SLOT(readPacket(Bitstream&)));
|
||||
connect(&_sequencer, SIGNAL(sendAcknowledged(int)), SLOT(clearSendRecordsBefore(int)));
|
||||
connect(&_sequencer, SIGNAL(receivedHighPriorityMessage(const QVariant&)), SLOT(handleMessage(const QVariant&)));
|
||||
connect(_sequencer.getReliableInputChannel(), SIGNAL(receivedMessage(const QVariant&)),
|
||||
SLOT(handleMessage(const QVariant&)));
|
||||
|
||||
// insert the baseline send record
|
||||
SendRecord record = { 0 };
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
//
|
||||
// MetavoxelServer.h
|
||||
// hifi
|
||||
// assignment-client/src/metavoxels
|
||||
//
|
||||
// Created by Andrzej Kapolka on 12/18/13.
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
// 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__MetavoxelServer__
|
||||
#define __hifi__MetavoxelServer__
|
||||
#ifndef hifi_MetavoxelServer_h
|
||||
#define hifi_MetavoxelServer_h
|
||||
|
||||
#include <QList>
|
||||
#include <QTimer>
|
||||
|
@ -92,4 +95,4 @@ private:
|
|||
QList<SendRecord> _sendRecords;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__MetavoxelServer__) */
|
||||
#endif // hifi_MetavoxelServer_h
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
//
|
||||
// OctreeInboundPacketProcessor.cpp
|
||||
// voxel-server
|
||||
// assignment-client/src/octree
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 8/21/13
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
// Created by Brad Hefta-Gaub on 8/21/13.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// Threaded or non-threaded network packet processor for the voxel-server
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <PacketHeaders.h>
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
//
|
||||
// OctreeInboundPacketProcessor.h
|
||||
// voxel-server
|
||||
// assignment-client/src/octree
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 8/21/13
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
// Created by Brad Hefta-Gaub on 8/21/13.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// Threaded or non-threaded network packet processor for the voxel-server
|
||||
// Threaded or non-threaded network packet processor for the voxel-server
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef __octree_server__OctreeInboundPacketProcessor__
|
||||
#define __octree_server__OctreeInboundPacketProcessor__
|
||||
#ifndef hifi_OctreeInboundPacketProcessor_h
|
||||
#define hifi_OctreeInboundPacketProcessor_h
|
||||
|
||||
#include <map>
|
||||
|
||||
|
@ -80,4 +83,4 @@ private:
|
|||
|
||||
NodeToSenderStatsMap _singleSenderStats;
|
||||
};
|
||||
#endif // __octree_server__OctreeInboundPacketProcessor__
|
||||
#endif // hifi_OctreeInboundPacketProcessor_h
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
//
|
||||
// OctreeQueryNode.cpp
|
||||
// hifi
|
||||
// assignment-client/src/octree
|
||||
//
|
||||
// Created by Stephen Birarda on 3/21/13.
|
||||
// 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 "PacketHeaders.h"
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
//
|
||||
// OctreeQueryNode.h
|
||||
// hifi
|
||||
// assignment-client/src/octree
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 12/4/13.
|
||||
// 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__OctreeQueryNode__
|
||||
#define __hifi__OctreeQueryNode__
|
||||
#ifndef hifi_OctreeQueryNode_h
|
||||
#define hifi_OctreeQueryNode_h
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
@ -140,4 +143,4 @@ private:
|
|||
bool _isShuttingDown;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__OctreeQueryNode__) */
|
||||
#endif // hifi_OctreeQueryNode_h
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
//
|
||||
// OctreeSendThread.cpp
|
||||
// assignment-client/src/octree
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 8/21/13
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
// Created by Brad Hefta-Gaub on 8/21/13.
|
||||
// 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 <QMutexLocker>
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
//
|
||||
// OctreeSendThread.h
|
||||
// assignment-client/src/octree
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 8/21/13
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
// Created by Brad Hefta-Gaub on 8/21/13.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// Threaded or non-threaded object for sending voxels to a client
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef __octree_server__OctreeSendThread__
|
||||
#define __octree_server__OctreeSendThread__
|
||||
#ifndef hifi_OctreeSendThread_h
|
||||
#define hifi_OctreeSendThread_h
|
||||
|
||||
#include <GenericThread.h>
|
||||
#include <NetworkPacket.h>
|
||||
|
@ -54,4 +58,4 @@ private:
|
|||
bool _isShuttingDown;
|
||||
};
|
||||
|
||||
#endif // __octree_server__OctreeSendThread__
|
||||
#endif // hifi_OctreeSendThread_h
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
//
|
||||
// OctreeServer.cpp
|
||||
// hifi
|
||||
// assignment-client/src/octree
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 9/16/13.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// 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 <QJsonObject>
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
//
|
||||
// OctreeServer.h
|
||||
// voxel-server
|
||||
// assignment-client/src/octree
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 8/21/13
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
// Created by Brad Hefta-Gaub on 8/21/13.
|
||||
// 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 __octree_server__OctreeServer__
|
||||
#define __octree_server__OctreeServer__
|
||||
#ifndef hifi_OctreeServer_h
|
||||
#define hifi_OctreeServer_h
|
||||
|
||||
#include <QStringList>
|
||||
#include <QDateTime>
|
||||
|
@ -218,4 +220,4 @@ protected:
|
|||
static QMutex _threadsDidCallWriteDatagramMutex;
|
||||
};
|
||||
|
||||
#endif // __octree_server__OctreeServer__
|
||||
#endif // hifi_OctreeServer_h
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
//
|
||||
// OctreeServerConsts.h
|
||||
// octree-server
|
||||
// assignment-client/src/octree
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 12/4/13
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
// Created by Brad Hefta-Gaub on 12/4/13.
|
||||
// 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 __octree_server__OctreeServerConsts__
|
||||
#define __octree_server__OctreeServerConsts__
|
||||
#ifndef hifi_OctreeServerConsts_h
|
||||
#define hifi_OctreeServerConsts_h
|
||||
|
||||
#include <SharedUtil.h>
|
||||
#include <NodeList.h> // for MAX_PACKET_SIZE
|
||||
|
@ -18,4 +21,4 @@ const int INTERVALS_PER_SECOND = 60;
|
|||
const int OCTREE_SEND_INTERVAL_USECS = (1000 * 1000)/INTERVALS_PER_SECOND;
|
||||
const int SENDING_TIME_TO_SPARE = 5 * 1000; // usec of sending interval to spare for calculating voxels
|
||||
|
||||
#endif // __octree_server__OctreeServerConsts__
|
||||
#endif // hifi_OctreeServerConsts_h
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
//
|
||||
// ParticleNodeData.h
|
||||
// hifi
|
||||
// assignment-client/src/particles
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 12/4/13
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
// Created by Brad Hefta-Gaub on 12/4/13.
|
||||
// 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__ParticleNodeData__
|
||||
#define __hifi__ParticleNodeData__
|
||||
#ifndef hifi_ParticleNodeData_h
|
||||
#define hifi_ParticleNodeData_h
|
||||
|
||||
#include <PacketHeaders.h>
|
||||
|
||||
|
@ -29,4 +31,4 @@ private:
|
|||
quint64 _lastDeletedParticlesSentAt;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__ParticleNodeData__) */
|
||||
#endif // hifi_ParticleNodeData_h
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
//
|
||||
// ParticleServer.cpp
|
||||
// hifi
|
||||
// assignment-client/src/particles
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 12/4/13
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// Created by Brad Hefta-Gaub on 12/4/13.
|
||||
// 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 <QTimer>
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
//
|
||||
// ParticleServer.h
|
||||
// particle-server
|
||||
// assignment-client/src/particles
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 12/2/13
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
// Created by Brad Hefta-Gaub on 12/2/13.
|
||||
// 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 __particle_server__ParticleServer__
|
||||
#define __particle_server__ParticleServer__
|
||||
#ifndef hifi_ParticleServer_h
|
||||
#define hifi_ParticleServer_h
|
||||
|
||||
#include "../octree/OctreeServer.h"
|
||||
|
||||
|
@ -45,4 +47,4 @@ public slots:
|
|||
private:
|
||||
};
|
||||
|
||||
#endif // __particle_server__ParticleServer__
|
||||
#endif // hifi_ParticleServer_h
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
//
|
||||
// ParticleServerConsts.h
|
||||
// particle-server
|
||||
// assignment-client/src/particles
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 8/21/13
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
// Created by Brad Hefta-Gaub on 8/21/13.
|
||||
// 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 __particle_server__ParticleServerConsts__
|
||||
#define __particle_server__ParticleServerConsts__
|
||||
#ifndef hifi_ParticleServerConsts_h
|
||||
#define hifi_ParticleServerConsts_h
|
||||
|
||||
extern const char* PARTICLE_SERVER_NAME;
|
||||
extern const char* PARTICLE_SERVER_LOGGING_TARGET_NAME;
|
||||
extern const char* LOCAL_PARTICLES_PERSIST_FILE;
|
||||
|
||||
#endif // __particle_server__ParticleServerConsts__
|
||||
#endif // hifi_ParticleServerConsts_h
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
//
|
||||
// VoxelNodeData.h
|
||||
// hifi
|
||||
// assignment-client/src/voxels
|
||||
//
|
||||
// Created by Stephen Birarda on 3/21/13.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef __hifi__VoxelNodeData__
|
||||
#define __hifi__VoxelNodeData__
|
||||
#ifndef hifi_VoxelNodeData_h
|
||||
#define hifi_VoxelNodeData_h
|
||||
|
||||
#include <PacketHeaders.h>
|
||||
|
||||
|
@ -19,4 +22,4 @@ public:
|
|||
virtual PacketType getMyPacketType() const { return PacketTypeVoxelData; }
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__VoxelNodeData__) */
|
||||
#endif // hifi_VoxelNodeData_h
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
//
|
||||
// VoxelServer.cpp
|
||||
// hifi
|
||||
// assignment-client/src/voxels
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 9/16/13.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// 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 <VoxelTree.h>
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
//
|
||||
// VoxelServer.h
|
||||
// voxel-server
|
||||
// assignment-client/src/voxels
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 8/21/13
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
// Created by Brad Hefta-Gaub on 8/21/13.
|
||||
// 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 __voxel_server__VoxelServer__
|
||||
#define __voxel_server__VoxelServer__
|
||||
#ifndef hifi_VoxelServer_h
|
||||
#define hifi_VoxelServer_h
|
||||
|
||||
#include <QStringList>
|
||||
#include <QDateTime>
|
||||
|
@ -53,4 +55,4 @@ private:
|
|||
unsigned char _tempOutputBuffer[MAX_PACKET_SIZE];
|
||||
};
|
||||
|
||||
#endif // __voxel_server__VoxelServer__
|
||||
#endif // hifi_VoxelServer_h
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
//
|
||||
// VoxelServerConsts.h
|
||||
// voxel-server
|
||||
// assignment-client/src/voxels
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 8/21/13
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
// Created by Brad Hefta-Gaub on 8/21/13.
|
||||
// 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 __voxel_server__VoxelServerConsts__
|
||||
#define __voxel_server__VoxelServerConsts__
|
||||
#ifndef hifi_VoxelServerConsts_h
|
||||
#define hifi_VoxelServerConsts_h
|
||||
|
||||
extern const char* VOXEL_SERVER_NAME;
|
||||
extern const char* VOXEL_SERVER_LOGGING_TARGET_NAME;
|
||||
|
@ -15,4 +18,4 @@ extern const char* LOCAL_VOXELS_PERSIST_FILE;
|
|||
|
||||
const int ENVIRONMENT_SEND_INTERVAL_USECS = 1000000;
|
||||
|
||||
#endif // __voxel_server__VoxelServerConsts__
|
||||
#endif // hifi_VoxelServerConsts_h
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
#
|
||||
# AutoMTC.cmake
|
||||
#
|
||||
# Created by Andrzej Kapolka on 12/31/13.
|
||||
# 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(AUTO_MTC TARGET ROOT_DIR)
|
||||
if (NOT TARGET mtc)
|
||||
add_subdirectory("${ROOT_DIR}/tools/mtc" "${ROOT_DIR}/tools/mtc")
|
||||
|
@ -8,6 +18,4 @@ macro(AUTO_MTC TARGET ROOT_DIR)
|
|||
file(GLOB INCLUDE_FILES src/*.h)
|
||||
|
||||
add_custom_command(OUTPUT ${AUTOMTC_SRC} COMMAND mtc -o ${AUTOMTC_SRC} ${INCLUDE_FILES} DEPENDS mtc ${INCLUDE_FILES})
|
||||
endmacro()
|
||||
|
||||
|
||||
endmacro()
|
|
@ -1,3 +1,12 @@
|
|||
#
|
||||
# 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 TARGET ROOT_DIR)
|
||||
|
||||
find_package(GLM REQUIRED)
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
#
|
||||
# LinkHifiLibrary.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(LINK_HIFI_LIBRARY LIBRARY TARGET ROOT_DIR)
|
||||
|
||||
if (NOT TARGET ${LIBRARY})
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
#
|
||||
# SetupHifiLibrary.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(SETUP_HIFI_LIBRARY TARGET)
|
||||
|
||||
project(${TARGET})
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
#
|
||||
# SetupHifiProject.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(SETUP_HIFI_PROJECT TARGET INCLUDE_QT)
|
||||
project(${TARGET})
|
||||
|
||||
|
|
42
cmake/modules/FindFaceplus.cmake
Normal file
42
cmake/modules/FindFaceplus.cmake
Normal file
|
@ -0,0 +1,42 @@
|
|||
# Try to find the Faceplus library
|
||||
#
|
||||
# You must provide a FACEPLUS_ROOT_DIR which contains lib and include directories
|
||||
#
|
||||
# Once done this will define
|
||||
#
|
||||
# FACEPLUS_FOUND - system found Faceplus
|
||||
# FACEPLUS_INCLUDE_DIRS - the Faceplus include directory
|
||||
# FACEPLUS_LIBRARIES - Link this to use Faceplus
|
||||
#
|
||||
# Created on 4/8/2014 by Andrzej Kapolka
|
||||
# Copyright (c) 2014 High Fidelity
|
||||
#
|
||||
|
||||
if (FACEPLUS_LIBRARIES AND FACEPLUS_INCLUDE_DIRS)
|
||||
# in cache already
|
||||
set(FACEPLUS_FOUND TRUE)
|
||||
else (FACEPLUS_LIBRARIES AND FACEPLUS_INCLUDE_DIRS)
|
||||
find_path(FACEPLUS_INCLUDE_DIRS faceplus.h ${FACEPLUS_ROOT_DIR}/include)
|
||||
|
||||
if (WIN32)
|
||||
find_library(FACEPLUS_LIBRARIES faceplus.lib ${FACEPLUS_ROOT_DIR}/win32/)
|
||||
endif (WIN32)
|
||||
|
||||
if (FACEPLUS_INCLUDE_DIRS AND FACEPLUS_LIBRARIES)
|
||||
set(FACEPLUS_FOUND TRUE)
|
||||
endif (FACEPLUS_INCLUDE_DIRS AND FACEPLUS_LIBRARIES)
|
||||
|
||||
if (FACEPLUS_FOUND)
|
||||
if (NOT FACEPLUS_FIND_QUIETLY)
|
||||
message(STATUS "Found Faceplus... ${FACEPLUS_LIBRARIES}")
|
||||
endif (NOT FACEPLUS_FIND_QUIETLY)
|
||||
else ()
|
||||
if (FACEPLUS_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Could not find Faceplus")
|
||||
endif (FACEPLUS_FIND_REQUIRED)
|
||||
endif ()
|
||||
|
||||
# show the FACEPLUS_INCLUDE_DIRS and FACEPLUS_LIBRARIES variables only in the advanced view
|
||||
mark_as_advanced(FACEPLUS_INCLUDE_DIRS FACEPLUS_LIBRARIES)
|
||||
|
||||
endif (FACEPLUS_LIBRARIES AND FACEPLUS_INCLUDE_DIRS)
|
|
@ -1,3 +1,6 @@
|
|||
#
|
||||
# FindFaceshift.cmake
|
||||
#
|
||||
# Try to find the Faceshift networking library
|
||||
#
|
||||
# You must provide a FACESHIFT_ROOT_DIR which contains lib and include directories
|
||||
|
@ -9,8 +12,11 @@
|
|||
# FACESHIFT_LIBRARIES - Link this to use Faceshift
|
||||
#
|
||||
# Created on 8/30/2013 by Andrzej Kapolka
|
||||
# Copyright (c) 2013 High Fidelity
|
||||
# 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
|
||||
#
|
||||
|
||||
if (FACESHIFT_LIBRARIES AND FACESHIFT_INCLUDE_DIRS)
|
||||
# in cache already
|
||||
|
|
|
@ -1,16 +1,22 @@
|
|||
#
|
||||
# Try to find GLEW library and include path.
|
||||
# Once done this will define
|
||||
#
|
||||
# GLEW_FOUND
|
||||
# GLEW_INCLUDE_DIRS
|
||||
# GLEW_LIBRARY
|
||||
# FindGLEW.cmake
|
||||
#
|
||||
|
||||
# Created on 2/6/2014 by Stephen Birarda
|
||||
# Try to find GLEW library and include path.
|
||||
# Once done this will define
|
||||
#
|
||||
# Adapted from FindGLEW.cmake available in the nvidia-texture-tools repository
|
||||
# (https://code.google.com/p/nvidia-texture-tools/source/browse/trunk/cmake/FindGLEW.cmake?r=96)
|
||||
# GLEW_FOUND
|
||||
# GLEW_INCLUDE_DIRS
|
||||
# GLEW_LIBRARY
|
||||
#
|
||||
# Created on 2/6/2014 by Stephen Birarda
|
||||
# Copyright 2014 High Fidelity, Inc.
|
||||
#
|
||||
# Adapted from FindGLEW.cmake available in the nvidia-texture-tools repository
|
||||
# (https://code.google.com/p/nvidia-texture-tools/source/browse/trunk/cmake/FindGLEW.cmake?r=96)
|
||||
#
|
||||
# Distributed under the Apache License, Version 2.0.
|
||||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
|
||||
if (GLEW_INCLUDE_DIRS AND GLEW_LIBRARY)
|
||||
set(GLEW_FOUND TRUE)
|
||||
|
@ -20,7 +26,7 @@ else ()
|
|||
|
||||
find_path(GLEW_INCLUDE_DIRS GL/glew.h PATH_SUFFIXES include HINTS ${WIN_GLEW_SEARCH_DIRS})
|
||||
|
||||
find_library(GLEW_LIBRARY glew32s PATH_SUFFIXES "lib/Release/Win32" HINTS ${WIN_GLEW_SEARCH_DIRS})
|
||||
find_library(GLEW_LIBRARY glew32s PATH_SUFFIXES "lib/Release/Win32" "lib" HINTS ${WIN_GLEW_SEARCH_DIRS})
|
||||
endif ()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
|
|
@ -1,15 +1,23 @@
|
|||
# Try to find GLUT library and include path.
|
||||
# Once done this will define
|
||||
#
|
||||
# FindGLUT.cmake
|
||||
#
|
||||
# Try to find GLUT library and include path.
|
||||
# Once done this will define
|
||||
#
|
||||
# GLUT_FOUND
|
||||
# GLUT_INCLUDE_DIR
|
||||
# GLUT_LIBRARIES
|
||||
# GLUT_DLL_PATH - Optionally defined for Win32, if not in path
|
||||
# GLUT_FOUND
|
||||
# GLUT_INCLUDE_DIR
|
||||
# GLUT_LIBRARIES
|
||||
# GLUT_DLL_PATH - Optionally defined for Win32, if not in path
|
||||
#
|
||||
# Created on 2/6/2014 by Stephen Birarda
|
||||
# Copyright 2014 High Fidelity, Inc.
|
||||
#
|
||||
# Adapted from FindGLUT.cmake available in tlorach's OpenGLText Repository
|
||||
# https://raw.github.com/tlorach/OpenGLText/master/cmake/FindGLUT.cmake
|
||||
#
|
||||
# Distributed under the Apache License, Version 2.0.
|
||||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
# Adapted from FindGLUT.cmake available in tlorach's OpenGLText Repository
|
||||
# https://raw.github.com/tlorach/OpenGLText/master/cmake/FindGLUT.cmake
|
||||
|
||||
if (GLUT_INCLUDE_DIR AND GLUT_LIBRARIES)
|
||||
set(GLUT_FOUND TRUE)
|
||||
|
|
41
cmake/modules/FindGnuTLS.cmake
Normal file
41
cmake/modules/FindGnuTLS.cmake
Normal file
|
@ -0,0 +1,41 @@
|
|||
#
|
||||
# FindGnuTLS.cmake
|
||||
#
|
||||
# Try to find the GnuTLS library
|
||||
#
|
||||
# You can provide a GNUTLS_ROOT_DIR which contains lib and include directories
|
||||
#
|
||||
# Once done this will define
|
||||
#
|
||||
# GNUTLS_FOUND - system found GnuTLS
|
||||
# GNUTLS_INCLUDE_DIR - the GnuTLS include directory
|
||||
# GNUTLS_LIBRARY - Link this to use GnuTLS
|
||||
#
|
||||
# Created on 3/31/2014 by Stephen Birarda
|
||||
# Copyright (c) 2014 High Fidelity
|
||||
#
|
||||
# Distributed under the Apache License, Version 2.0.
|
||||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
|
||||
if (GNUTLS_LIBRARY AND GNUTLS_INCLUDE_DIRS)
|
||||
# in cache already
|
||||
set(GNUTLS_FOUND TRUE)
|
||||
else ()
|
||||
set(GNUTLS_SEARCH_DIRS "${GNUTLS_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/gnutls")
|
||||
|
||||
find_path(GNUTLS_INCLUDE_DIR gnutls/gnutls.h PATH_SUFFIXES include HINTS ${GNUTLS_SEARCH_DIRS})
|
||||
|
||||
find_library(GNUTLS_LIBRARY NAMES gnutls libgnutls libgnutls-28 PATH_SUFFIXES lib HINTS ${GNUTLS_SEARCH_DIRS})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(GNUTLS DEFAULT_MSG GNUTLS_INCLUDE_DIR GNUTLS_LIBRARY)
|
||||
|
||||
if (WIN32 AND NOT GNUTLS_FOUND)
|
||||
message(STATUS "If you're generating a MSVC environment, you'll need to run the command")
|
||||
message(STATUS "$GnuTLS-DIR\\bin>lib /def:libgnutls-28.def")
|
||||
message(STATUS "From the MSVC command prompt to generate the .lib file and copy it into")
|
||||
message(STATUS "the GnuTLS lib folder. Replace $GnuTLS-DIR in the command with the directory")
|
||||
message(STATUS "containing GnuTLS.")
|
||||
endif ()
|
||||
endif ()
|
|
@ -1,4 +1,7 @@
|
|||
# - Try to find the LibOVR library to use the Oculus
|
||||
#
|
||||
# FindLibOVR.cmake
|
||||
#
|
||||
# Try to find the LibOVR library to use the Oculus
|
||||
#
|
||||
# You must provide a LIBOVR_ROOT_DIR which contains Lib and Include directories
|
||||
#
|
||||
|
@ -9,8 +12,11 @@
|
|||
# LIBOVR_LIBRARIES - Link this to use LibOVR
|
||||
#
|
||||
# Created on 5/9/2013 by Stephen Birarda
|
||||
# Copyright (c) 2013 High Fidelity
|
||||
# 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
|
||||
#
|
||||
|
||||
if (LIBOVR_LIBRARIES AND LIBOVR_INCLUDE_DIRS)
|
||||
# in cache already
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#=============================================================================
|
||||
|
||||
|
||||
|
||||
function(QT5_CREATE_TRANSLATION_CUSTOM _qm_files)
|
||||
set(options)
|
||||
set(oneValueArgs)
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#
|
||||
# FindQxmpp.cmake
|
||||
#
|
||||
# Try to find the qxmpp library
|
||||
#
|
||||
# You can provide a QXMPP_ROOT_DIR which contains lib and include directories
|
||||
|
@ -6,11 +9,14 @@
|
|||
#
|
||||
# QXMPP_FOUND - system found qxmpp
|
||||
# QXMPP_INCLUDE_DIRS - the qxmpp include directory
|
||||
# QXMPP_LIBRARIES - Link this to use qxmpp
|
||||
# QXMPP_LIBRARY - Link this to use qxmpp
|
||||
#
|
||||
# Created on 3/10/2014 by Stephen Birarda
|
||||
# Copyright (c) 2014 High Fidelity
|
||||
# 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
|
||||
#
|
||||
|
||||
if (QXMPP_LIBRARIES AND QXMPP_INCLUDE_DIRS)
|
||||
# in cache already
|
||||
|
@ -25,14 +31,4 @@ else ()
|
|||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(QXMPP DEFAULT_MSG QXMPP_INCLUDE_DIR QXMPP_LIBRARY)
|
||||
|
||||
if (QXMPP_FOUND)
|
||||
if (NOT QXMPP_FIND_QUIETLY)
|
||||
message(STATUS "Found qxmpp: ${QXMPP_LIBRARY}")
|
||||
endif ()
|
||||
else ()
|
||||
if (QXMPP_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Could not find qxmpp")
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
|
@ -1,3 +1,6 @@
|
|||
#
|
||||
# FindSixense.cmake
|
||||
#
|
||||
# Try to find the Sixense controller library
|
||||
#
|
||||
# You must provide a SIXENSE_ROOT_DIR which contains lib and include directories
|
||||
|
@ -9,8 +12,11 @@
|
|||
# SIXENSE_LIBRARIES - Link this to use Sixense
|
||||
#
|
||||
# Created on 11/15/2013 by Andrzej Kapolka
|
||||
# Copyright (c) 2013 High Fidelity
|
||||
# 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
|
||||
#
|
||||
|
||||
if (SIXENSE_LIBRARIES AND SIXENSE_INCLUDE_DIRS)
|
||||
# in cache already
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#
|
||||
# FindVisage.cmake
|
||||
#
|
||||
# Try to find the Visage controller library
|
||||
#
|
||||
# You must provide a VISAGE_ROOT_DIR which contains lib and include directories
|
||||
|
@ -9,8 +12,11 @@
|
|||
# VISAGE_LIBRARIES - Link this to use Visage
|
||||
#
|
||||
# Created on 2/11/2014 by Andrzej Kapolka
|
||||
# Copyright (c) 2014 High Fidelity
|
||||
# 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
|
||||
#
|
||||
|
||||
if (VISAGE_LIBRARIES AND VISAGE_INCLUDE_DIRS)
|
||||
# in cache already
|
||||
|
|
|
@ -17,6 +17,7 @@ include(${MACRO_DIR}/IncludeGLM.cmake)
|
|||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
find_package(Qt5Network REQUIRED)
|
||||
find_package(GnuTLS REQUIRED)
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiProject.cmake)
|
||||
|
||||
|
@ -33,11 +34,21 @@ add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
|
|||
|
||||
# link the shared hifi library
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(embedded-webserver ${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
# include the GnuTLS dir
|
||||
include_directories(SYSTEM "${GNUTLS_INCLUDE_DIR}")
|
||||
|
||||
# add a definition for ssize_t so that windows doesn't bail on gnutls.h
|
||||
if (WIN32)
|
||||
add_definitions(-Dssize_t=long)
|
||||
endif ()
|
||||
|
||||
IF (WIN32)
|
||||
target_link_libraries(${TARGET_NAME} Winmm Ws2_32)
|
||||
ENDIF(WIN32)
|
||||
|
||||
target_link_libraries(${TARGET_NAME} Qt5::Network)
|
||||
# link QtNetwork and GnuTLS
|
||||
target_link_libraries(${TARGET_NAME} Qt5::Network "${GNUTLS_LIBRARY}")
|
|
@ -42,13 +42,13 @@ body {
|
|||
background-color: #28FF57;
|
||||
}
|
||||
|
||||
#instance-field {
|
||||
#extra-fields {
|
||||
position: absolute;
|
||||
right: 20px;
|
||||
top: 40px;
|
||||
top: 30px;
|
||||
}
|
||||
|
||||
#instance-field input {
|
||||
#extra-fields input {
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,13 @@
|
|||
Run
|
||||
</a>
|
||||
</div>
|
||||
<div class='big-field' id='instance-field'>
|
||||
<input type='text' name='instances' placeholder='# of instances'>
|
||||
<div id="extra-fields">
|
||||
<div class='big-field' id='instance-field'>
|
||||
<input type='text' name='instances' placeholder='# of instances'>
|
||||
</div>
|
||||
<div class='big-field' id='pool-field'>
|
||||
<input type='text' name='pool' placeholder='pool'>
|
||||
</div>
|
||||
</div>
|
||||
<!-- %div#stop-button.big-button -->
|
||||
</body>
|
||||
|
|
|
@ -22,9 +22,14 @@ $(document).ready(function(){
|
|||
+ '--' + boundary + '--\r\n';
|
||||
|
||||
var headers = {};
|
||||
|
||||
if ($('#instance-field input').val()) {
|
||||
headers['ASSIGNMENT-INSTANCES'] = $('#instance-field input').val();
|
||||
}
|
||||
|
||||
if ($('#pool-field input').val()) {
|
||||
headers['ASSIGNMENT-POOL'] = $('#pool-field input').val();
|
||||
}
|
||||
|
||||
// post form to assignment in order to create an assignment
|
||||
$.ajax({
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<th>Pool</th>
|
||||
<th>Public</th>
|
||||
<th>Local</th>
|
||||
<th>Uptime (s)</th>
|
||||
<th>Kill?</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
|
@ -2,16 +2,47 @@ $(document).ready(function(){
|
|||
// setup a function to grab the assignments
|
||||
function getNodesAndAssignments() {
|
||||
$.getJSON("nodes.json", function(json){
|
||||
|
||||
json.nodes.sort(function(a, b){
|
||||
if (a.type === b.type) {
|
||||
if (a.wake_timestamp < b.wake_timestamp) {
|
||||
return 1;
|
||||
} else if (a.wake_timestamp > b.wake_timestamp) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (a.type === "agent" && b.type !== "agent") {
|
||||
return 1;
|
||||
} else if (b.type === "agent" && a.type !== "agent") {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (a.type > b.type) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (a.type < b.type) {
|
||||
return -1;
|
||||
}
|
||||
});
|
||||
|
||||
nodesTableBody = "";
|
||||
|
||||
$.each(json.nodes, function (uuid, data) {
|
||||
$.each(json.nodes, function(index, data) {
|
||||
nodesTableBody += "<tr>";
|
||||
nodesTableBody += "<td>" + data.type + "</td>";
|
||||
nodesTableBody += "<td><a href='stats/?uuid=" + uuid + "'>" + uuid + "</a></td>";
|
||||
nodesTableBody += "<td><a href='stats/?uuid=" + data.uuid + "'>" + data.uuid + "</a></td>";
|
||||
nodesTableBody += "<td>" + (data.pool ? data.pool : "") + "</td>";
|
||||
nodesTableBody += "<td>" + data.public.ip + "<span class='port'>:" + data.public.port + "</span></td>";
|
||||
nodesTableBody += "<td>" + data.local.ip + "<span class='port'>:" + data.local.port + "</span></td>";
|
||||
nodesTableBody += "<td><span class='glyphicon glyphicon-remove' data-uuid=" + uuid + "></span></td>";
|
||||
|
||||
var uptimeSeconds = (Date.now() - data.wake_timestamp) / 1000;
|
||||
nodesTableBody += "<td>" + uptimeSeconds.toLocaleString() + "</td>";
|
||||
|
||||
nodesTableBody += "<td><span class='glyphicon glyphicon-remove' data-uuid=" + data.uuid + "></span></td>";
|
||||
nodesTableBody += "</tr>";
|
||||
});
|
||||
|
||||
|
|
18
domain-server/src/DTLSServerSession.cpp
Normal file
18
domain-server/src/DTLSServerSession.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
//
|
||||
// DTLSServerSession.cpp
|
||||
// domain-server/src
|
||||
//
|
||||
// Created by Stephen Birarda on 2014-04-01.
|
||||
// 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 "DTLSServerSession.h"
|
||||
|
||||
DTLSServerSession::DTLSServerSession(QUdpSocket& dtlsSocket, HifiSockAddr& destinationSocket) :
|
||||
DTLSSession(GNUTLS_SERVER, dtlsSocket, destinationSocket)
|
||||
{
|
||||
|
||||
}
|
24
domain-server/src/DTLSServerSession.h
Normal file
24
domain-server/src/DTLSServerSession.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
//
|
||||
// DTLSServerSession.h
|
||||
// domain-server/src
|
||||
//
|
||||
// Created by Stephen Birarda on 2014-04-01.
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef hifi_DTLSServerSession_h
|
||||
#define hifi_DTLSServerSession_h
|
||||
|
||||
#include <gnutls/dtls.h>
|
||||
|
||||
#include <DTLSSession.h>
|
||||
|
||||
class DTLSServerSession : public DTLSSession {
|
||||
public:
|
||||
DTLSServerSession(QUdpSocket& dtlsSocket, HifiSockAddr& destinationSocket);
|
||||
};
|
||||
|
||||
#endif // hifi_DTLSServerSession_h
|
File diff suppressed because it is too large
Load diff
|
@ -1,13 +1,16 @@
|
|||
//
|
||||
// DomainServer.h
|
||||
// hifi
|
||||
// domain-server/src
|
||||
//
|
||||
// Created by Stephen Birarda on 9/26/13.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// 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__DomainServer__
|
||||
#define __hifi__DomainServer__
|
||||
#ifndef hifi_DomainServer_h
|
||||
#define hifi_DomainServer_h
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QHash>
|
||||
|
@ -17,9 +20,13 @@
|
|||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QUrl>
|
||||
|
||||
#include <gnutls/gnutls.h>
|
||||
|
||||
#include <Assignment.h>
|
||||
#include <HTTPManager.h>
|
||||
#include <NodeList.h>
|
||||
#include <LimitedNodeList.h>
|
||||
|
||||
#include "DTLSServerSession.h"
|
||||
|
||||
typedef QSharedPointer<Assignment> SharedAssignmentPointer;
|
||||
|
||||
|
@ -27,8 +34,7 @@ class DomainServer : public QCoreApplication, public HTTPRequestHandler {
|
|||
Q_OBJECT
|
||||
public:
|
||||
DomainServer(int argc, char* argv[]);
|
||||
|
||||
bool requiresAuthentication() const { return !_nodeAuthenticationURL.isEmpty(); }
|
||||
~DomainServer();
|
||||
|
||||
bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url);
|
||||
|
||||
|
@ -40,23 +46,28 @@ public slots:
|
|||
/// Called by NodeList to inform us a node has been killed
|
||||
void nodeKilled(SharedNodePointer node);
|
||||
|
||||
private slots:
|
||||
|
||||
void readAvailableDatagrams();
|
||||
void readAvailableDTLSDatagrams();
|
||||
private:
|
||||
void setupNodeListAndAssignments(const QUuid& sessionUUID = QUuid::createUuid());
|
||||
bool optionallySetupDTLS();
|
||||
bool readX509KeyAndCertificate();
|
||||
|
||||
void requestAuthenticationFromPotentialNode(const HifiSockAddr& senderSockAddr);
|
||||
void addNodeToNodeListAndConfirmConnection(const QByteArray& packet, const HifiSockAddr& senderSockAddr,
|
||||
const QJsonObject& authJsonObject = QJsonObject());
|
||||
void processDatagram(const QByteArray& receivedPacket, const HifiSockAddr& senderSockAddr);
|
||||
|
||||
void addNodeToNodeListAndConfirmConnection(const QByteArray& packet, const HifiSockAddr& senderSockAddr);
|
||||
int parseNodeDataFromByteArray(NodeType_t& nodeType, HifiSockAddr& publicSockAddr,
|
||||
HifiSockAddr& localSockAddr, const QByteArray& packet, const HifiSockAddr& senderSockAddr);
|
||||
NodeSet nodeInterestListFromPacket(const QByteArray& packet, int numPreceedingBytes);
|
||||
void sendDomainListToNode(const SharedNodePointer& node, const HifiSockAddr& senderSockAddr,
|
||||
const NodeSet& nodeInterestList);
|
||||
|
||||
void parseCommandLineTypeConfigs(const QStringList& argumentList, QSet<Assignment::Type>& excludedTypes);
|
||||
void readConfigFile(const QString& path, QSet<Assignment::Type>& excludedTypes);
|
||||
QString readServerAssignmentConfig(const QJsonObject& jsonObject, const QString& nodeName);
|
||||
void parseAssignmentConfigs(QSet<Assignment::Type>& excludedTypes);
|
||||
void addStaticAssignmentToAssignmentHash(Assignment* newAssignment);
|
||||
void createStaticAssignmentsForTypeGivenConfigString(Assignment::Type type, const QString& configString);
|
||||
void createScriptedAssignmentsFromArray(const QJsonArray& configArray);
|
||||
void createStaticAssignmentsForType(Assignment::Type type, const QJsonArray& configArray);
|
||||
void populateDefaultStaticAssignmentsExcludingTypes(const QSet<Assignment::Type>& excludedTypes);
|
||||
|
||||
SharedAssignmentPointer matchingStaticAssignmentForCheckIn(const QUuid& checkInUUID, NodeType_t nodeType);
|
||||
|
@ -73,17 +84,15 @@ private:
|
|||
QHash<QUuid, SharedAssignmentPointer> _staticAssignmentHash;
|
||||
QQueue<SharedAssignmentPointer> _assignmentQueue;
|
||||
|
||||
QUrl _nodeAuthenticationURL;
|
||||
QVariantMap _argumentVariantMap;
|
||||
|
||||
QStringList _argumentList;
|
||||
bool _isUsingDTLS;
|
||||
gnutls_certificate_credentials_t* _x509Credentials;
|
||||
gnutls_dh_params_t* _dhParams;
|
||||
gnutls_datum_t* _cookieKey;
|
||||
gnutls_priority_t* _priorityCache;
|
||||
|
||||
QHash<QString, QJsonObject> _redeemedTokenResponses;
|
||||
private slots:
|
||||
void requestCreationFromDataServer();
|
||||
void processCreateResponseFromDataServer(const QJsonObject& jsonObject);
|
||||
void processTokenRedeemResponse(const QJsonObject& jsonObject);
|
||||
|
||||
void readAvailableDatagrams();
|
||||
QHash<HifiSockAddr, DTLSServerSession*> _dtlsSessions;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__DomainServer__) */
|
||||
#endif // hifi_DomainServer_h
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
//
|
||||
// DomainServerNodeData.cpp
|
||||
// hifi
|
||||
// domain-server/src
|
||||
//
|
||||
// Created by Stephen Birarda on 2/6/2014.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
// 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 <QtCore/QDataStream>
|
||||
|
@ -17,7 +20,8 @@
|
|||
DomainServerNodeData::DomainServerNodeData() :
|
||||
_sessionSecretHash(),
|
||||
_staticAssignmentUUID(),
|
||||
_statsJSONObject()
|
||||
_statsJSONObject(),
|
||||
_sendingSockAddr()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -45,4 +49,4 @@ QJsonObject DomainServerNodeData::mergeJSONStatsFromNewObject(const QJsonObject&
|
|||
}
|
||||
|
||||
return destinationObject;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,21 @@
|
|||
//
|
||||
// DomainServerNodeData.h
|
||||
// hifi
|
||||
// domain-server/src
|
||||
//
|
||||
// Created by Stephen Birarda on 2/6/2014.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef __hifi__DomainServerNodeData__
|
||||
#define __hifi__DomainServerNodeData__
|
||||
#ifndef hifi_DomainServerNodeData_h
|
||||
#define hifi_DomainServerNodeData_h
|
||||
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QUuid>
|
||||
|
||||
#include <HifiSockAddr.h>
|
||||
#include <NodeData.h>
|
||||
|
||||
class DomainServerNodeData : public NodeData {
|
||||
|
@ -26,6 +30,9 @@ public:
|
|||
void setStaticAssignmentUUID(const QUuid& staticAssignmentUUID) { _staticAssignmentUUID = staticAssignmentUUID; }
|
||||
const QUuid& getStaticAssignmentUUID() const { return _staticAssignmentUUID; }
|
||||
|
||||
void setSendingSockAddr(const HifiSockAddr& sendingSockAddr) { _sendingSockAddr = sendingSockAddr; }
|
||||
const HifiSockAddr& getSendingSockAddr() { return _sendingSockAddr; }
|
||||
|
||||
QHash<QUuid, QUuid>& getSessionSecretHash() { return _sessionSecretHash; }
|
||||
private:
|
||||
QJsonObject mergeJSONStatsFromNewObject(const QJsonObject& newObject, QJsonObject destinationObject);
|
||||
|
@ -33,6 +40,7 @@ private:
|
|||
QHash<QUuid, QUuid> _sessionSecretHash;
|
||||
QUuid _staticAssignmentUUID;
|
||||
QJsonObject _statsJSONObject;
|
||||
HifiSockAddr _sendingSockAddr;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__DomainServerNodeData__) */
|
||||
#endif // hifi_DomainServerNodeData_h
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
//
|
||||
// main.cpp
|
||||
// Domain Server
|
||||
// domain-server/src
|
||||
//
|
||||
// Created by Philip Rosedale on 11/20/12.
|
||||
// Copyright (c) 2012 High Fidelity, Inc. All rights reserved.
|
||||
// Copyright 2012 High Fidelity, Inc.
|
||||
//
|
||||
// The Domain Server keeps a list of nodes that have connected to it, and echoes that list of
|
||||
// nodes out to nodes when they check in.
|
||||
|
@ -11,6 +11,9 @@
|
|||
// The connection is stateless... the domain server will set you inactive if it does not hear from
|
||||
// you in LOGOFF_CHECK_INTERVAL milliseconds, meaning your info will not be sent to other users.
|
||||
//
|
||||
// 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/QCoreApplication>
|
||||
|
||||
|
@ -23,7 +26,7 @@ int main(int argc, char* argv[]) {
|
|||
#ifndef WIN32
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
#endif
|
||||
|
||||
|
||||
qInstallMessageHandler(Logging::verboseMessageHandler);
|
||||
DomainServer domainServer(argc, argv);
|
||||
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
//
|
||||
// addVoxelOnMouseClickExample.js
|
||||
// hifi
|
||||
// examples
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 2/6/14.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// This is an example script that demonstrates use of the Camera and Voxels class to implement
|
||||
// clicking on a voxel and adding a new voxel on the clicked on face
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
function mousePressEvent(event) {
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
//
|
||||
// audioBall.js
|
||||
// hifi
|
||||
// examples
|
||||
//
|
||||
// Created by Athanasios Gaitatzes on 2/10/14.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// This script creates a particle in front of the user that stays in front of
|
||||
// the user's avatar as they move, and animates it's radius and color
|
||||
// in response to the audio intensity.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var sound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/mexicanWhipoorwill.raw");
|
||||
var CHANCE_OF_PLAYING_SOUND = 0.01;
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
//
|
||||
// audioDeviceExample.js
|
||||
// hifi
|
||||
// examples
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 3/22/14
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// This is an example script that demonstrates use of the Menu object
|
||||
//
|
||||
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var outputDevices = AudioDevice.getOutputDevices();
|
||||
var defaultOutputDevice = AudioDevice.getDefaultOutputDevice();
|
||||
|
|
841
examples/audioReflectorTools.js
Normal file
841
examples/audioReflectorTools.js
Normal file
|
@ -0,0 +1,841 @@
|
|||
//
|
||||
// audioReflectorTools.js
|
||||
// hifi
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 2/14/14.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
//
|
||||
// Tools for manipulating the attributes of the AudioReflector behavior
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
var delayScale = 100.0;
|
||||
var fanoutScale = 10.0;
|
||||
var speedScale = 20;
|
||||
var factorScale = 5.0;
|
||||
var localFactorScale = 1.0;
|
||||
var reflectiveScale = 100.0;
|
||||
var diffusionScale = 100.0;
|
||||
var absorptionScale = 100.0;
|
||||
var combFilterScale = 50.0;
|
||||
var originalScale = 2.0;
|
||||
var echoesScale = 2.0;
|
||||
|
||||
// these three properties are bound together, if you change one, the others will also change
|
||||
var reflectiveRatio = AudioReflector.getReflectiveRatio();
|
||||
var diffusionRatio = AudioReflector.getDiffusionRatio();
|
||||
var absorptionRatio = AudioReflector.getAbsorptionRatio();
|
||||
|
||||
var reflectiveThumbX;
|
||||
var diffusionThumbX;
|
||||
var absorptionThumbX;
|
||||
|
||||
function setReflectiveRatio(reflective) {
|
||||
var total = diffusionRatio + absorptionRatio + (reflective / reflectiveScale);
|
||||
diffusionRatio = diffusionRatio / total;
|
||||
absorptionRatio = absorptionRatio / total;
|
||||
reflectiveRatio = (reflective / reflectiveScale) / total;
|
||||
updateRatioValues();
|
||||
}
|
||||
|
||||
function setDiffusionRatio(diffusion) {
|
||||
var total = (diffusion / diffusionScale) + absorptionRatio + reflectiveRatio;
|
||||
diffusionRatio = (diffusion / diffusionScale) / total;
|
||||
absorptionRatio = absorptionRatio / total;
|
||||
reflectiveRatio = reflectiveRatio / total;
|
||||
updateRatioValues();
|
||||
}
|
||||
|
||||
function setAbsorptionRatio(absorption) {
|
||||
var total = diffusionRatio + (absorption / absorptionScale) + reflectiveRatio;
|
||||
diffusionRatio = diffusionRatio / total;
|
||||
absorptionRatio = (absorption / absorptionScale) / total;
|
||||
reflectiveRatio = reflectiveRatio / total;
|
||||
updateRatioValues();
|
||||
}
|
||||
|
||||
function updateRatioSliders() {
|
||||
reflectiveThumbX = reflectiveMinThumbX + ((reflectiveMaxThumbX - reflectiveMinThumbX) * reflectiveRatio);
|
||||
diffusionThumbX = diffusionMinThumbX + ((diffusionMaxThumbX - diffusionMinThumbX) * diffusionRatio);
|
||||
absorptionThumbX = absorptionMinThumbX + ((absorptionMaxThumbX - absorptionMinThumbX) * absorptionRatio);
|
||||
|
||||
Overlays.editOverlay(reflectiveThumb, { x: reflectiveThumbX } );
|
||||
Overlays.editOverlay(diffusionThumb, { x: diffusionThumbX } );
|
||||
Overlays.editOverlay(absorptionThumb, { x: absorptionThumbX } );
|
||||
}
|
||||
|
||||
function updateRatioValues() {
|
||||
AudioReflector.setReflectiveRatio(reflectiveRatio);
|
||||
AudioReflector.setDiffusionRatio(diffusionRatio);
|
||||
AudioReflector.setAbsorptionRatio(absorptionRatio);
|
||||
}
|
||||
|
||||
var topY = 250;
|
||||
var sliderHeight = 35;
|
||||
|
||||
var delayY = topY;
|
||||
topY += sliderHeight;
|
||||
var delayLabel = Overlays.addOverlay("text", {
|
||||
x: 40,
|
||||
y: delayY,
|
||||
width: 60,
|
||||
height: sliderHeight,
|
||||
color: { red: 0, green: 0, blue: 0},
|
||||
textColor: { red: 255, green: 255, blue: 255},
|
||||
topMargin: 12,
|
||||
leftMargin: 5,
|
||||
text: "Delay:"
|
||||
});
|
||||
|
||||
var delaySlider = Overlays.addOverlay("image", {
|
||||
// alternate form of expressing bounds
|
||||
bounds: { x: 100, y: delayY, width: 150, height: sliderHeight},
|
||||
subImage: { x: 46, y: 0, width: 200, height: 71 },
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/slider.png",
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
|
||||
var delayMinThumbX = 110;
|
||||
var delayMaxThumbX = delayMinThumbX + 110;
|
||||
var delayThumbX = delayMinThumbX + ((delayMaxThumbX - delayMinThumbX) * (AudioReflector.getPreDelay() / delayScale));
|
||||
var delayThumb = Overlays.addOverlay("image", {
|
||||
x: delayThumbX,
|
||||
y: delayY + 9,
|
||||
width: 18,
|
||||
height: 17,
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/thumb.png",
|
||||
color: { red: 255, green: 0, blue: 0},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
var fanoutY = topY;
|
||||
topY += sliderHeight;
|
||||
|
||||
var fanoutLabel = Overlays.addOverlay("text", {
|
||||
x: 40,
|
||||
y: fanoutY,
|
||||
width: 60,
|
||||
height: sliderHeight,
|
||||
color: { red: 0, green: 0, blue: 0},
|
||||
textColor: { red: 255, green: 255, blue: 255},
|
||||
topMargin: 12,
|
||||
leftMargin: 5,
|
||||
text: "Fanout:"
|
||||
});
|
||||
|
||||
var fanoutSlider = Overlays.addOverlay("image", {
|
||||
// alternate form of expressing bounds
|
||||
bounds: { x: 100, y: fanoutY, width: 150, height: sliderHeight},
|
||||
subImage: { x: 46, y: 0, width: 200, height: 71 },
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/slider.png",
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
|
||||
var fanoutMinThumbX = 110;
|
||||
var fanoutMaxThumbX = fanoutMinThumbX + 110;
|
||||
var fanoutThumbX = fanoutMinThumbX + ((fanoutMaxThumbX - fanoutMinThumbX) * (AudioReflector.getDiffusionFanout() / fanoutScale));
|
||||
var fanoutThumb = Overlays.addOverlay("image", {
|
||||
x: fanoutThumbX,
|
||||
y: fanoutY + 9,
|
||||
width: 18,
|
||||
height: 17,
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/thumb.png",
|
||||
color: { red: 255, green: 255, blue: 0},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
|
||||
var speedY = topY;
|
||||
topY += sliderHeight;
|
||||
|
||||
var speedLabel = Overlays.addOverlay("text", {
|
||||
x: 40,
|
||||
y: speedY,
|
||||
width: 60,
|
||||
height: sliderHeight,
|
||||
color: { red: 0, green: 0, blue: 0},
|
||||
textColor: { red: 255, green: 255, blue: 255},
|
||||
topMargin: 6,
|
||||
leftMargin: 5,
|
||||
text: "Speed\nin ms/m:"
|
||||
});
|
||||
|
||||
var speedSlider = Overlays.addOverlay("image", {
|
||||
// alternate form of expressing bounds
|
||||
bounds: { x: 100, y: speedY, width: 150, height: sliderHeight},
|
||||
subImage: { x: 46, y: 0, width: 200, height: 71 },
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/slider.png",
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
|
||||
var speedMinThumbX = 110;
|
||||
var speedMaxThumbX = speedMinThumbX + 110;
|
||||
var speedThumbX = speedMinThumbX + ((speedMaxThumbX - speedMinThumbX) * (AudioReflector.getSoundMsPerMeter() / speedScale));
|
||||
var speedThumb = Overlays.addOverlay("image", {
|
||||
x: speedThumbX,
|
||||
y: speedY+9,
|
||||
width: 18,
|
||||
height: 17,
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/thumb.png",
|
||||
color: { red: 0, green: 255, blue: 0},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
var factorY = topY;
|
||||
topY += sliderHeight;
|
||||
|
||||
var factorLabel = Overlays.addOverlay("text", {
|
||||
x: 40,
|
||||
y: factorY,
|
||||
width: 60,
|
||||
height: sliderHeight,
|
||||
color: { red: 0, green: 0, blue: 0},
|
||||
textColor: { red: 255, green: 255, blue: 255},
|
||||
topMargin: 6,
|
||||
leftMargin: 5,
|
||||
text: "Attenuation\nFactor:"
|
||||
});
|
||||
|
||||
|
||||
var factorSlider = Overlays.addOverlay("image", {
|
||||
// alternate form of expressing bounds
|
||||
bounds: { x: 100, y: factorY, width: 150, height: sliderHeight},
|
||||
subImage: { x: 46, y: 0, width: 200, height: 71 },
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/slider.png",
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
|
||||
var factorMinThumbX = 110;
|
||||
var factorMaxThumbX = factorMinThumbX + 110;
|
||||
var factorThumbX = factorMinThumbX + ((factorMaxThumbX - factorMinThumbX) * (AudioReflector.getDistanceAttenuationScalingFactor() / factorScale));
|
||||
var factorThumb = Overlays.addOverlay("image", {
|
||||
x: factorThumbX,
|
||||
y: factorY+9,
|
||||
width: 18,
|
||||
height: 17,
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/thumb.png",
|
||||
color: { red: 0, green: 0, blue: 255},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
var localFactorY = topY;
|
||||
topY += sliderHeight;
|
||||
|
||||
var localFactorLabel = Overlays.addOverlay("text", {
|
||||
x: 40,
|
||||
y: localFactorY,
|
||||
width: 60,
|
||||
height: sliderHeight,
|
||||
color: { red: 0, green: 0, blue: 0},
|
||||
textColor: { red: 255, green: 255, blue: 255},
|
||||
topMargin: 6,
|
||||
leftMargin: 5,
|
||||
text: "Local\nFactor:"
|
||||
});
|
||||
|
||||
|
||||
var localFactorSlider = Overlays.addOverlay("image", {
|
||||
// alternate form of expressing bounds
|
||||
bounds: { x: 100, y: localFactorY, width: 150, height: sliderHeight},
|
||||
subImage: { x: 46, y: 0, width: 200, height: 71 },
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/slider.png",
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
|
||||
var localFactorMinThumbX = 110;
|
||||
var localFactorMaxThumbX = localFactorMinThumbX + 110;
|
||||
var localFactorThumbX = localFactorMinThumbX + ((localFactorMaxThumbX - localFactorMinThumbX) * (AudioReflector.getLocalAudioAttenuationFactor() / localFactorScale));
|
||||
var localFactorThumb = Overlays.addOverlay("image", {
|
||||
x: localFactorThumbX,
|
||||
y: localFactorY+9,
|
||||
width: 18,
|
||||
height: 17,
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/thumb.png",
|
||||
color: { red: 0, green: 128, blue: 128},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
var combFilterY = topY;
|
||||
topY += sliderHeight;
|
||||
|
||||
var combFilterLabel = Overlays.addOverlay("text", {
|
||||
x: 40,
|
||||
y: combFilterY,
|
||||
width: 60,
|
||||
height: sliderHeight,
|
||||
color: { red: 0, green: 0, blue: 0},
|
||||
textColor: { red: 255, green: 255, blue: 255},
|
||||
topMargin: 6,
|
||||
leftMargin: 5,
|
||||
text: "Comb Filter\nWindow:"
|
||||
});
|
||||
|
||||
|
||||
var combFilterSlider = Overlays.addOverlay("image", {
|
||||
// alternate form of expressing bounds
|
||||
bounds: { x: 100, y: combFilterY, width: 150, height: sliderHeight},
|
||||
subImage: { x: 46, y: 0, width: 200, height: 71 },
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/slider.png",
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
|
||||
var combFilterMinThumbX = 110;
|
||||
var combFilterMaxThumbX = combFilterMinThumbX + 110;
|
||||
var combFilterThumbX = combFilterMinThumbX + ((combFilterMaxThumbX - combFilterMinThumbX) * (AudioReflector.getCombFilterWindow() / combFilterScale));
|
||||
var combFilterThumb = Overlays.addOverlay("image", {
|
||||
x: combFilterThumbX,
|
||||
y: combFilterY+9,
|
||||
width: 18,
|
||||
height: 17,
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/thumb.png",
|
||||
color: { red: 128, green: 128, blue: 0},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
|
||||
var reflectiveY = topY;
|
||||
topY += sliderHeight;
|
||||
|
||||
var reflectiveLabel = Overlays.addOverlay("text", {
|
||||
x: 40,
|
||||
y: reflectiveY,
|
||||
width: 60,
|
||||
height: sliderHeight,
|
||||
color: { red: 0, green: 0, blue: 0},
|
||||
textColor: { red: 255, green: 255, blue: 255},
|
||||
topMargin: 6,
|
||||
leftMargin: 5,
|
||||
text: "Reflective\nRatio:"
|
||||
});
|
||||
|
||||
|
||||
var reflectiveSlider = Overlays.addOverlay("image", {
|
||||
// alternate form of expressing bounds
|
||||
bounds: { x: 100, y: reflectiveY, width: 150, height: sliderHeight},
|
||||
subImage: { x: 46, y: 0, width: 200, height: 71 },
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/slider.png",
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
|
||||
var reflectiveMinThumbX = 110;
|
||||
var reflectiveMaxThumbX = reflectiveMinThumbX + 110;
|
||||
reflectiveThumbX = reflectiveMinThumbX + ((reflectiveMaxThumbX - reflectiveMinThumbX) * AudioReflector.getReflectiveRatio());
|
||||
var reflectiveThumb = Overlays.addOverlay("image", {
|
||||
x: reflectiveThumbX,
|
||||
y: reflectiveY+9,
|
||||
width: 18,
|
||||
height: 17,
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/thumb.png",
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
var diffusionY = topY;
|
||||
topY += sliderHeight;
|
||||
|
||||
var diffusionLabel = Overlays.addOverlay("text", {
|
||||
x: 40,
|
||||
y: diffusionY,
|
||||
width: 60,
|
||||
height: sliderHeight,
|
||||
color: { red: 0, green: 0, blue: 0},
|
||||
textColor: { red: 255, green: 255, blue: 255},
|
||||
topMargin: 6,
|
||||
leftMargin: 5,
|
||||
text: "Diffusion\nRatio:"
|
||||
});
|
||||
|
||||
|
||||
var diffusionSlider = Overlays.addOverlay("image", {
|
||||
// alternate form of expressing bounds
|
||||
bounds: { x: 100, y: diffusionY, width: 150, height: sliderHeight},
|
||||
subImage: { x: 46, y: 0, width: 200, height: 71 },
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/slider.png",
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
|
||||
var diffusionMinThumbX = 110;
|
||||
var diffusionMaxThumbX = diffusionMinThumbX + 110;
|
||||
diffusionThumbX = diffusionMinThumbX + ((diffusionMaxThumbX - diffusionMinThumbX) * AudioReflector.getDiffusionRatio());
|
||||
var diffusionThumb = Overlays.addOverlay("image", {
|
||||
x: diffusionThumbX,
|
||||
y: diffusionY+9,
|
||||
width: 18,
|
||||
height: 17,
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/thumb.png",
|
||||
color: { red: 0, green: 255, blue: 255},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
var absorptionY = topY;
|
||||
topY += sliderHeight;
|
||||
|
||||
var absorptionLabel = Overlays.addOverlay("text", {
|
||||
x: 40,
|
||||
y: absorptionY,
|
||||
width: 60,
|
||||
height: sliderHeight,
|
||||
color: { red: 0, green: 0, blue: 0},
|
||||
textColor: { red: 255, green: 255, blue: 255},
|
||||
topMargin: 6,
|
||||
leftMargin: 5,
|
||||
text: "Absorption\nRatio:"
|
||||
});
|
||||
|
||||
|
||||
var absorptionSlider = Overlays.addOverlay("image", {
|
||||
// alternate form of expressing bounds
|
||||
bounds: { x: 100, y: absorptionY, width: 150, height: sliderHeight},
|
||||
subImage: { x: 46, y: 0, width: 200, height: 71 },
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/slider.png",
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
|
||||
var absorptionMinThumbX = 110;
|
||||
var absorptionMaxThumbX = absorptionMinThumbX + 110;
|
||||
absorptionThumbX = absorptionMinThumbX + ((absorptionMaxThumbX - absorptionMinThumbX) * AudioReflector.getAbsorptionRatio());
|
||||
var absorptionThumb = Overlays.addOverlay("image", {
|
||||
x: absorptionThumbX,
|
||||
y: absorptionY+9,
|
||||
width: 18,
|
||||
height: 17,
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/thumb.png",
|
||||
color: { red: 255, green: 0, blue: 255},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
var originalY = topY;
|
||||
topY += sliderHeight;
|
||||
|
||||
var originalLabel = Overlays.addOverlay("text", {
|
||||
x: 40,
|
||||
y: originalY,
|
||||
width: 60,
|
||||
height: sliderHeight,
|
||||
color: { red: 0, green: 0, blue: 0},
|
||||
textColor: { red: 255, green: 255, blue: 255},
|
||||
topMargin: 6,
|
||||
leftMargin: 5,
|
||||
text: "Original\nMix:"
|
||||
});
|
||||
|
||||
|
||||
var originalSlider = Overlays.addOverlay("image", {
|
||||
// alternate form of expressing bounds
|
||||
bounds: { x: 100, y: originalY, width: 150, height: sliderHeight},
|
||||
subImage: { x: 46, y: 0, width: 200, height: 71 },
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/slider.png",
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
|
||||
var originalMinThumbX = 110;
|
||||
var originalMaxThumbX = originalMinThumbX + 110;
|
||||
var originalThumbX = originalMinThumbX + ((originalMaxThumbX - originalMinThumbX) * (AudioReflector.getOriginalSourceAttenuation() / originalScale));
|
||||
var originalThumb = Overlays.addOverlay("image", {
|
||||
x: originalThumbX,
|
||||
y: originalY+9,
|
||||
width: 18,
|
||||
height: 17,
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/thumb.png",
|
||||
color: { red: 128, green: 128, blue: 0},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
var echoesY = topY;
|
||||
topY += sliderHeight;
|
||||
|
||||
var echoesLabel = Overlays.addOverlay("text", {
|
||||
x: 40,
|
||||
y: echoesY,
|
||||
width: 60,
|
||||
height: sliderHeight,
|
||||
color: { red: 0, green: 0, blue: 0},
|
||||
textColor: { red: 255, green: 255, blue: 255},
|
||||
topMargin: 6,
|
||||
leftMargin: 5,
|
||||
text: "Echoes\nMix:"
|
||||
});
|
||||
|
||||
|
||||
var echoesSlider = Overlays.addOverlay("image", {
|
||||
// alternate form of expressing bounds
|
||||
bounds: { x: 100, y: echoesY, width: 150, height: sliderHeight},
|
||||
subImage: { x: 46, y: 0, width: 200, height: 71 },
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/slider.png",
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
|
||||
var echoesMinThumbX = 110;
|
||||
var echoesMaxThumbX = echoesMinThumbX + 110;
|
||||
var echoesThumbX = echoesMinThumbX + ((echoesMaxThumbX - echoesMinThumbX) * (AudioReflector.getEchoesAttenuation() / echoesScale));
|
||||
var echoesThumb = Overlays.addOverlay("image", {
|
||||
x: echoesThumbX,
|
||||
y: echoesY+9,
|
||||
width: 18,
|
||||
height: 17,
|
||||
imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/thumb.png",
|
||||
color: { red: 128, green: 128, blue: 0},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
|
||||
// When our script shuts down, we should clean up all of our overlays
|
||||
function scriptEnding() {
|
||||
Overlays.deleteOverlay(factorLabel);
|
||||
Overlays.deleteOverlay(factorThumb);
|
||||
Overlays.deleteOverlay(factorSlider);
|
||||
|
||||
Overlays.deleteOverlay(combFilterLabel);
|
||||
Overlays.deleteOverlay(combFilterThumb);
|
||||
Overlays.deleteOverlay(combFilterSlider);
|
||||
|
||||
Overlays.deleteOverlay(localFactorLabel);
|
||||
Overlays.deleteOverlay(localFactorThumb);
|
||||
Overlays.deleteOverlay(localFactorSlider);
|
||||
|
||||
Overlays.deleteOverlay(speedLabel);
|
||||
Overlays.deleteOverlay(speedThumb);
|
||||
Overlays.deleteOverlay(speedSlider);
|
||||
|
||||
Overlays.deleteOverlay(delayLabel);
|
||||
Overlays.deleteOverlay(delayThumb);
|
||||
Overlays.deleteOverlay(delaySlider);
|
||||
|
||||
Overlays.deleteOverlay(fanoutLabel);
|
||||
Overlays.deleteOverlay(fanoutThumb);
|
||||
Overlays.deleteOverlay(fanoutSlider);
|
||||
|
||||
Overlays.deleteOverlay(reflectiveLabel);
|
||||
Overlays.deleteOverlay(reflectiveThumb);
|
||||
Overlays.deleteOverlay(reflectiveSlider);
|
||||
|
||||
Overlays.deleteOverlay(diffusionLabel);
|
||||
Overlays.deleteOverlay(diffusionThumb);
|
||||
Overlays.deleteOverlay(diffusionSlider);
|
||||
|
||||
Overlays.deleteOverlay(absorptionLabel);
|
||||
Overlays.deleteOverlay(absorptionThumb);
|
||||
Overlays.deleteOverlay(absorptionSlider);
|
||||
|
||||
Overlays.deleteOverlay(echoesLabel);
|
||||
Overlays.deleteOverlay(echoesThumb);
|
||||
Overlays.deleteOverlay(echoesSlider);
|
||||
|
||||
Overlays.deleteOverlay(originalLabel);
|
||||
Overlays.deleteOverlay(originalThumb);
|
||||
Overlays.deleteOverlay(originalSlider);
|
||||
|
||||
}
|
||||
Script.scriptEnding.connect(scriptEnding);
|
||||
|
||||
|
||||
var count = 0;
|
||||
|
||||
// Our update() function is called at approximately 60fps, and we will use it to animate our various overlays
|
||||
function update(deltaTime) {
|
||||
count++;
|
||||
}
|
||||
Script.update.connect(update);
|
||||
|
||||
|
||||
// The slider is handled in the mouse event callbacks.
|
||||
var movingSliderDelay = false;
|
||||
var movingSliderFanout = false;
|
||||
var movingSliderSpeed = false;
|
||||
var movingSliderFactor = false;
|
||||
var movingSliderCombFilter = false;
|
||||
var movingSliderLocalFactor = false;
|
||||
var movingSliderReflective = false;
|
||||
var movingSliderDiffusion = false;
|
||||
var movingSliderAbsorption = false;
|
||||
var movingSliderOriginal = false;
|
||||
var movingSliderEchoes = false;
|
||||
|
||||
var thumbClickOffsetX = 0;
|
||||
function mouseMoveEvent(event) {
|
||||
if (movingSliderDelay) {
|
||||
newThumbX = event.x - thumbClickOffsetX;
|
||||
if (newThumbX < delayMinThumbX) {
|
||||
newThumbX = delayMinThumbX;
|
||||
}
|
||||
if (newThumbX > delayMaxThumbX) {
|
||||
newThumbX = delayMaxThumbX;
|
||||
}
|
||||
Overlays.editOverlay(delayThumb, { x: newThumbX } );
|
||||
var delay = ((newThumbX - delayMinThumbX) / (delayMaxThumbX - delayMinThumbX)) * delayScale;
|
||||
AudioReflector.setPreDelay(delay);
|
||||
}
|
||||
if (movingSliderFanout) {
|
||||
newThumbX = event.x - thumbClickOffsetX;
|
||||
if (newThumbX < fanoutMinThumbX) {
|
||||
newThumbX = fanoutMinThumbX;
|
||||
}
|
||||
if (newThumbX > fanoutMaxThumbX) {
|
||||
newThumbX = fanoutMaxThumbX;
|
||||
}
|
||||
Overlays.editOverlay(fanoutThumb, { x: newThumbX } );
|
||||
var fanout = Math.round(((newThumbX - fanoutMinThumbX) / (fanoutMaxThumbX - fanoutMinThumbX)) * fanoutScale);
|
||||
AudioReflector.setDiffusionFanout(fanout);
|
||||
}
|
||||
if (movingSliderSpeed) {
|
||||
newThumbX = event.x - thumbClickOffsetX;
|
||||
if (newThumbX < speedMinThumbX) {
|
||||
newThumbX = speedMminThumbX;
|
||||
}
|
||||
if (newThumbX > speedMaxThumbX) {
|
||||
newThumbX = speedMaxThumbX;
|
||||
}
|
||||
Overlays.editOverlay(speedThumb, { x: newThumbX } );
|
||||
var speed = ((newThumbX - speedMinThumbX) / (speedMaxThumbX - speedMinThumbX)) * speedScale;
|
||||
AudioReflector.setSoundMsPerMeter(speed);
|
||||
}
|
||||
if (movingSliderFactor) {
|
||||
newThumbX = event.x - thumbClickOffsetX;
|
||||
if (newThumbX < factorMinThumbX) {
|
||||
newThumbX = factorMminThumbX;
|
||||
}
|
||||
if (newThumbX > factorMaxThumbX) {
|
||||
newThumbX = factorMaxThumbX;
|
||||
}
|
||||
Overlays.editOverlay(factorThumb, { x: newThumbX } );
|
||||
var factor = ((newThumbX - factorMinThumbX) / (factorMaxThumbX - factorMinThumbX)) * factorScale;
|
||||
AudioReflector.setDistanceAttenuationScalingFactor(factor);
|
||||
}
|
||||
if (movingSliderCombFilter) {
|
||||
newThumbX = event.x - thumbClickOffsetX;
|
||||
if (newThumbX < combFilterMinThumbX) {
|
||||
newThumbX = combFilterMminThumbX;
|
||||
}
|
||||
if (newThumbX > combFilterMaxThumbX) {
|
||||
newThumbX = combFilterMaxThumbX;
|
||||
}
|
||||
Overlays.editOverlay(combFilterThumb, { x: newThumbX } );
|
||||
var combFilter = ((newThumbX - combFilterMinThumbX) / (combFilterMaxThumbX - combFilterMinThumbX)) * combFilterScale;
|
||||
AudioReflector.setCombFilterWindow(combFilter);
|
||||
}
|
||||
if (movingSliderLocalFactor) {
|
||||
newThumbX = event.x - thumbClickOffsetX;
|
||||
if (newThumbX < localFactorMinThumbX) {
|
||||
newThumbX = localFactorMminThumbX;
|
||||
}
|
||||
if (newThumbX > localFactorMaxThumbX) {
|
||||
newThumbX = localFactorMaxThumbX;
|
||||
}
|
||||
Overlays.editOverlay(localFactorThumb, { x: newThumbX } );
|
||||
var localFactor = ((newThumbX - localFactorMinThumbX) / (localFactorMaxThumbX - localFactorMinThumbX)) * localFactorScale;
|
||||
AudioReflector.setLocalAudioAttenuationFactor(localFactor);
|
||||
}
|
||||
|
||||
if (movingSliderAbsorption) {
|
||||
newThumbX = event.x - thumbClickOffsetX;
|
||||
if (newThumbX < absorptionMinThumbX) {
|
||||
newThumbX = absorptionMminThumbX;
|
||||
}
|
||||
if (newThumbX > absorptionMaxThumbX) {
|
||||
newThumbX = absorptionMaxThumbX;
|
||||
}
|
||||
Overlays.editOverlay(absorptionThumb, { x: newThumbX } );
|
||||
var absorption = ((newThumbX - absorptionMinThumbX) / (absorptionMaxThumbX - absorptionMinThumbX)) * absorptionScale;
|
||||
setAbsorptionRatio(absorption);
|
||||
}
|
||||
|
||||
if (movingSliderReflective) {
|
||||
newThumbX = event.x - thumbClickOffsetX;
|
||||
if (newThumbX < reflectiveMinThumbX) {
|
||||
newThumbX = reflectiveMminThumbX;
|
||||
}
|
||||
if (newThumbX > reflectiveMaxThumbX) {
|
||||
newThumbX = reflectiveMaxThumbX;
|
||||
}
|
||||
Overlays.editOverlay(reflectiveThumb, { x: newThumbX } );
|
||||
var reflective = ((newThumbX - reflectiveMinThumbX) / (reflectiveMaxThumbX - reflectiveMinThumbX)) * reflectiveScale;
|
||||
setReflectiveRatio(reflective);
|
||||
}
|
||||
|
||||
if (movingSliderDiffusion) {
|
||||
newThumbX = event.x - thumbClickOffsetX;
|
||||
if (newThumbX < diffusionMinThumbX) {
|
||||
newThumbX = diffusionMminThumbX;
|
||||
}
|
||||
if (newThumbX > diffusionMaxThumbX) {
|
||||
newThumbX = diffusionMaxThumbX;
|
||||
}
|
||||
Overlays.editOverlay(diffusionThumb, { x: newThumbX } );
|
||||
var diffusion = ((newThumbX - diffusionMinThumbX) / (diffusionMaxThumbX - diffusionMinThumbX)) * diffusionScale;
|
||||
setDiffusionRatio(diffusion);
|
||||
}
|
||||
if (movingSliderEchoes) {
|
||||
newThumbX = event.x - thumbClickOffsetX;
|
||||
if (newThumbX < echoesMinThumbX) {
|
||||
newThumbX = echoesMminThumbX;
|
||||
}
|
||||
if (newThumbX > echoesMaxThumbX) {
|
||||
newThumbX = echoesMaxThumbX;
|
||||
}
|
||||
Overlays.editOverlay(echoesThumb, { x: newThumbX } );
|
||||
var echoes = ((newThumbX - echoesMinThumbX) / (echoesMaxThumbX - echoesMinThumbX)) * echoesScale;
|
||||
AudioReflector.setEchoesAttenuation(echoes);
|
||||
}
|
||||
if (movingSliderOriginal) {
|
||||
newThumbX = event.x - thumbClickOffsetX;
|
||||
if (newThumbX < originalMinThumbX) {
|
||||
newThumbX = originalMminThumbX;
|
||||
}
|
||||
if (newThumbX > originalMaxThumbX) {
|
||||
newThumbX = originalMaxThumbX;
|
||||
}
|
||||
Overlays.editOverlay(originalThumb, { x: newThumbX } );
|
||||
var original = ((newThumbX - originalMinThumbX) / (originalMaxThumbX - originalMinThumbX)) * originalScale;
|
||||
AudioReflector.setOriginalSourceAttenuation(original);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// we also handle click detection in our mousePressEvent()
|
||||
function mousePressEvent(event) {
|
||||
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y});
|
||||
if (clickedOverlay == delayThumb) {
|
||||
movingSliderDelay = true;
|
||||
thumbClickOffsetX = event.x - delayThumbX;
|
||||
}
|
||||
if (clickedOverlay == fanoutThumb) {
|
||||
movingSliderFanout = true;
|
||||
thumbClickOffsetX = event.x - fanoutThumbX;
|
||||
}
|
||||
if (clickedOverlay == speedThumb) {
|
||||
movingSliderSpeed = true;
|
||||
thumbClickOffsetX = event.x - speedThumbX;
|
||||
}
|
||||
if (clickedOverlay == factorThumb) {
|
||||
movingSliderFactor = true;
|
||||
thumbClickOffsetX = event.x - factorThumbX;
|
||||
}
|
||||
if (clickedOverlay == localFactorThumb) {
|
||||
movingSliderLocalFactor = true;
|
||||
thumbClickOffsetX = event.x - localFactorThumbX;
|
||||
}
|
||||
if (clickedOverlay == combFilterThumb) {
|
||||
movingSliderCombFilter = true;
|
||||
thumbClickOffsetX = event.x - combFilterThumbX;
|
||||
}
|
||||
if (clickedOverlay == diffusionThumb) {
|
||||
movingSliderDiffusion = true;
|
||||
thumbClickOffsetX = event.x - diffusionThumbX;
|
||||
}
|
||||
if (clickedOverlay == absorptionThumb) {
|
||||
movingSliderAbsorption = true;
|
||||
thumbClickOffsetX = event.x - absorptionThumbX;
|
||||
}
|
||||
if (clickedOverlay == reflectiveThumb) {
|
||||
movingSliderReflective = true;
|
||||
thumbClickOffsetX = event.x - reflectiveThumbX;
|
||||
}
|
||||
if (clickedOverlay == originalThumb) {
|
||||
movingSliderOriginal = true;
|
||||
thumbClickOffsetX = event.x - originalThumbX;
|
||||
}
|
||||
if (clickedOverlay == echoesThumb) {
|
||||
movingSliderEchoes = true;
|
||||
thumbClickOffsetX = event.x - echoesThumbX;
|
||||
}
|
||||
}
|
||||
|
||||
function mouseReleaseEvent(event) {
|
||||
if (movingSliderDelay) {
|
||||
movingSliderDelay = false;
|
||||
var delay = ((newThumbX - delayMinThumbX) / (delayMaxThumbX - delayMinThumbX)) * delayScale;
|
||||
AudioReflector.setPreDelay(delay);
|
||||
delayThumbX = newThumbX;
|
||||
}
|
||||
if (movingSliderFanout) {
|
||||
movingSliderFanout = false;
|
||||
var fanout = Math.round(((newThumbX - fanoutMinThumbX) / (fanoutMaxThumbX - fanoutMinThumbX)) * fanoutScale);
|
||||
AudioReflector.setDiffusionFanout(fanout);
|
||||
fanoutThumbX = newThumbX;
|
||||
}
|
||||
if (movingSliderSpeed) {
|
||||
movingSliderSpeed = false;
|
||||
var speed = ((newThumbX - speedMinThumbX) / (speedMaxThumbX - speedMinThumbX)) * speedScale;
|
||||
AudioReflector.setSoundMsPerMeter(speed);
|
||||
speedThumbX = newThumbX;
|
||||
}
|
||||
if (movingSliderFactor) {
|
||||
movingSliderFactor = false;
|
||||
var factor = ((newThumbX - factorMinThumbX) / (factorMaxThumbX - factorMinThumbX)) * factorScale;
|
||||
AudioReflector.setDistanceAttenuationScalingFactor(factor);
|
||||
factorThumbX = newThumbX;
|
||||
}
|
||||
if (movingSliderCombFilter) {
|
||||
movingSliderCombFilter = false;
|
||||
var combFilter = ((newThumbX - combFilterMinThumbX) / (combFilterMaxThumbX - combFilterMinThumbX)) * combFilterScale;
|
||||
AudioReflector.setCombFilterWindow(combFilter);
|
||||
combFilterThumbX = newThumbX;
|
||||
}
|
||||
if (movingSliderLocalFactor) {
|
||||
movingSliderLocalFactor = false;
|
||||
var localFactor = ((newThumbX - localFactorMinThumbX) / (localFactorMaxThumbX - localFactorMinThumbX)) * localFactorScale;
|
||||
AudioReflector.setLocalAudioAttenuationFactor(localFactor);
|
||||
localFactorThumbX = newThumbX;
|
||||
}
|
||||
if (movingSliderReflective) {
|
||||
movingSliderReflective = false;
|
||||
var reflective = ((newThumbX - reflectiveMinThumbX) / (reflectiveMaxThumbX - reflectiveMinThumbX)) * reflectiveScale;
|
||||
setReflectiveRatio(reflective);
|
||||
reflectiveThumbX = newThumbX;
|
||||
updateRatioSliders();
|
||||
}
|
||||
if (movingSliderDiffusion) {
|
||||
movingSliderDiffusion = false;
|
||||
var diffusion = ((newThumbX - diffusionMinThumbX) / (diffusionMaxThumbX - diffusionMinThumbX)) * diffusionScale;
|
||||
setDiffusionRatio(diffusion);
|
||||
diffusionThumbX = newThumbX;
|
||||
updateRatioSliders();
|
||||
}
|
||||
if (movingSliderAbsorption) {
|
||||
movingSliderAbsorption = false;
|
||||
var absorption = ((newThumbX - absorptionMinThumbX) / (absorptionMaxThumbX - absorptionMinThumbX)) * absorptionScale;
|
||||
setAbsorptionRatio(absorption);
|
||||
absorptionThumbX = newThumbX;
|
||||
updateRatioSliders();
|
||||
}
|
||||
if (movingSliderEchoes) {
|
||||
movingSliderEchoes = false;
|
||||
var echoes = ((newThumbX - echoesMinThumbX) / (echoesMaxThumbX - echoesMinThumbX)) * echoesScale;
|
||||
AudioReflector.setEchoesAttenuation(echoes);
|
||||
echoesThumbX = newThumbX;
|
||||
}
|
||||
if (movingSliderOriginal) {
|
||||
movingSliderOriginal = false;
|
||||
var original = ((newThumbX - originalMinThumbX) / (originalMaxThumbX - originalMinThumbX)) * originalScale;
|
||||
AudioReflector.setOriginalSourceAttenuation(original);
|
||||
originalThumbX = newThumbX;
|
||||
}
|
||||
}
|
||||
|
||||
Controller.mouseMoveEvent.connect(mouseMoveEvent);
|
||||
Controller.mousePressEvent.connect(mousePressEvent);
|
||||
Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
|
||||
|
68
examples/avatarCollision.js
Normal file
68
examples/avatarCollision.js
Normal file
|
@ -0,0 +1,68 @@
|
|||
//
|
||||
// avatarCollision.js
|
||||
// examples
|
||||
//
|
||||
// Created by Andrew Meadows on 2014-04-09
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Play a sound on collisions with your avatar
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var SOUND_TRIGGER_CLEAR = 1000; // milliseconds
|
||||
var SOUND_TRIGGER_DELAY = 200; // milliseconds
|
||||
var soundExpiry = 0;
|
||||
var DateObj = new Date();
|
||||
var audioOptions = new AudioInjectionOptions();
|
||||
audioOptions.volume = 0.5;
|
||||
audioOptions.position = { x: 0, y: 0, z: 0 };
|
||||
|
||||
var hitSounds = new Array();
|
||||
hitSounds[0] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit1.raw");
|
||||
hitSounds[1] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit2.raw");
|
||||
hitSounds[2] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit3.raw");
|
||||
hitSounds[3] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit4.raw");
|
||||
hitSounds[4] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit5.raw");
|
||||
hitSounds[5] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit6.raw");
|
||||
hitSounds[6] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit7.raw");
|
||||
hitSounds[7] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit8.raw");
|
||||
hitSounds[8] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit9.raw");
|
||||
hitSounds[9] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit10.raw");
|
||||
hitSounds[10] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit11.raw");
|
||||
hitSounds[11] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit12.raw");
|
||||
hitSounds[12] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit13.raw");
|
||||
hitSounds[13] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit14.raw");
|
||||
hitSounds[14] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit15.raw");
|
||||
hitSounds[15] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit16.raw");
|
||||
hitSounds[16] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit17.raw");
|
||||
hitSounds[17] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit18.raw");
|
||||
hitSounds[18] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit19.raw");
|
||||
hitSounds[19] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit20.raw");
|
||||
hitSounds[20] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit21.raw");
|
||||
hitSounds[21] = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Collisions-hitsandslaps/Hit22.raw");
|
||||
|
||||
function playHitSound(mySessionID, theirSessionID, collision) {
|
||||
var now = new Date();
|
||||
var msec = now.getTime();
|
||||
if (msec > soundExpiry) {
|
||||
// this is a new contact --> play a new sound
|
||||
var soundIndex = Math.floor((Math.random() * hitSounds.length) % hitSounds.length);
|
||||
audioOptions.position = collision.contactPoint;
|
||||
Audio.playSound(hitSounds[soundIndex], audioOptions);
|
||||
|
||||
// bump the expiry
|
||||
soundExpiry = msec + SOUND_TRIGGER_CLEAR;
|
||||
|
||||
// log the collision info
|
||||
Uuid.print("my sessionID = ", mySessionID);
|
||||
Uuid.print(" their sessionID = ", theirSessionID);
|
||||
Vec3.print(" penetration = ", collision.penetration);
|
||||
Vec3.print(" contactPoint = ", collision.contactPoint);
|
||||
} else {
|
||||
// this is a recurring contact --> continue to delay sound trigger
|
||||
soundExpiry = msec + SOUND_TRIGGER_DELAY;
|
||||
}
|
||||
}
|
||||
MyAvatar.collisionWithAvatar.connect(playHitSound);
|
|
@ -1,13 +1,15 @@
|
|||
//
|
||||
// bot.js
|
||||
// hifi
|
||||
// examples
|
||||
//
|
||||
// Created by Stephen Birarda on 2/20/14.
|
||||
// Modified by Philip on 3/3/14
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// This is an example script that demonstrates an NPC avatar.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
function getRandomFloat(min, max) {
|
||||
|
@ -23,10 +25,10 @@ function printVector(string, vector) {
|
|||
}
|
||||
|
||||
var CHANCE_OF_MOVING = 0.005;
|
||||
var CHANCE_OF_SOUND = 0.005;
|
||||
var CHANCE_OF_SOUND = 0.000;
|
||||
var CHANCE_OF_HEAD_TURNING = 0.05;
|
||||
var CHANCE_OF_BIG_MOVE = 0.1;
|
||||
var CHANCE_OF_WAVING = 0.005; // Currently this isn't working
|
||||
var CHANCE_OF_WAVING = 0.009;
|
||||
|
||||
var shouldReceiveVoxels = true;
|
||||
var VOXEL_FPS = 60.0;
|
||||
|
@ -39,12 +41,16 @@ var isWaving = false;
|
|||
var waveFrequency = 0.0;
|
||||
var waveAmplitude = 0.0;
|
||||
|
||||
var X_MIN = 0.0;
|
||||
var X_MAX = 5.0;
|
||||
var Z_MIN = 0.0;
|
||||
var Z_MAX = 5.0;
|
||||
var X_MIN = 20.0;
|
||||
var X_MAX = 25.0;
|
||||
var Z_MIN = 20.0;
|
||||
var Z_MAX = 25.0;
|
||||
var Y_PELVIS = 2.5;
|
||||
var SHOULDER_JOINT_NUMBER = 15;
|
||||
var SPINE_JOINT_NUMBER = 13;
|
||||
var SHOULDER_JOINT_NUMBER = 17;
|
||||
var ELBOW_JOINT_NUMBER = 18;
|
||||
var JOINT_R_HIP = 1;
|
||||
var JOINT_R_KNEE = 2;
|
||||
|
||||
var MOVE_RANGE_SMALL = 0.5;
|
||||
var MOVE_RANGE_BIG = Math.max(X_MAX - X_MIN, Z_MAX - Z_MIN) / 2.0;
|
||||
|
@ -61,6 +67,9 @@ var targetDirection = { x: 0, y: 0, z: 0, w: 0 };
|
|||
var currentDirection = { x: 0, y: 0, z: 0, w: 0 };
|
||||
var targetHeadPitch = 0.0;
|
||||
|
||||
var walkFrequency = 5.0;
|
||||
var walkAmplitude = 45.0;
|
||||
|
||||
var cumulativeTime = 0.0;
|
||||
|
||||
var sounds = [];
|
||||
|
@ -115,12 +124,30 @@ printVector("New bot, position = ", Avatar.position);
|
|||
function stopWaving() {
|
||||
isWaving = false;
|
||||
Avatar.clearJointData(SHOULDER_JOINT_NUMBER);
|
||||
Avatar.clearJointData(ELBOW_JOINT_NUMBER);
|
||||
Avatar.clearJointData(SPINE_JOINT_NUMBER);
|
||||
}
|
||||
|
||||
function keepWalking() {
|
||||
Avatar.setJointData(JOINT_R_HIP, Quat.fromPitchYawRollDegrees(walkAmplitude * Math.sin(cumulativeTime * walkFrequency), 0.0, 0.0));
|
||||
Avatar.setJointData(JOINT_R_KNEE, Quat.fromPitchYawRollDegrees(walkAmplitude * Math.sin(cumulativeTime * walkFrequency), 0.0, 0.0));
|
||||
}
|
||||
|
||||
function stopWalking() {
|
||||
Avatar.clearJointData(JOINT_R_HIP);
|
||||
Avatar.clearJointData(JOINT_R_KNEE);
|
||||
}
|
||||
|
||||
function updateBehavior(deltaTime) {
|
||||
|
||||
cumulativeTime += deltaTime;
|
||||
|
||||
// Hack - right now you need to set the avatar position a bit after the avatar is made to make sure it's there.
|
||||
|
||||
if (CHANCE_OF_MOVING == 0.000) {
|
||||
Avatar.position = firstPosition;
|
||||
}
|
||||
|
||||
if (shouldReceiveVoxels && ((cumulativeTime - lastVoxelQueryTime) > (1.0 / VOXEL_FPS))) {
|
||||
VoxelViewer.setPosition(Avatar.position);
|
||||
VoxelViewer.setOrientation(Avatar.orientation);
|
||||
|
@ -134,13 +161,18 @@ function updateBehavior(deltaTime) {
|
|||
|
||||
if (!isWaving && (Math.random() < CHANCE_OF_WAVING)) {
|
||||
isWaving = true;
|
||||
waveFrequency = 1.0 + Math.random() * 5.0;
|
||||
waveFrequency = 3.0 + Math.random() * 5.0;
|
||||
waveAmplitude = 5.0 + Math.random() * 60.0;
|
||||
Script.setTimeout(stopWaving, 1000 + Math.random() * 2000);
|
||||
Avatar.setJointData(ELBOW_JOINT_NUMBER, Quat.fromPitchYawRollDegrees(0.0, 45, 0.0)); // Initially turn the palm outward
|
||||
} else if (isWaving) {
|
||||
Avatar.setJointData(SHOULDER_JOINT_NUMBER, Quat.fromPitchYawRollDegrees(0.0, 0.0, waveAmplitude * Math.sin(cumulativeTime * waveFrequency)));
|
||||
Avatar.setJointData(SHOULDER_JOINT_NUMBER, Quat.fromPitchYawRollDegrees(0.0, 0.0, 60 + waveAmplitude * Math.sin((cumulativeTime - 0.25) * waveFrequency)));
|
||||
Avatar.setJointData(ELBOW_JOINT_NUMBER, Quat.fromPitchYawRollDegrees(0.0, 0.0, 25 + waveAmplitude/2.0 * Math.sin(cumulativeTime * 1.2 * waveFrequency)));
|
||||
Avatar.setJointData(SPINE_JOINT_NUMBER, Quat.fromPitchYawRollDegrees(0.0, 0.0, 60 + waveAmplitude/4.0 * Math.sin(cumulativeTime * waveFrequency)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (Math.random() < CHANCE_OF_SOUND) {
|
||||
playRandomSound();
|
||||
}
|
||||
|
@ -168,11 +200,13 @@ function updateBehavior(deltaTime) {
|
|||
targetPosition.y = Y_PELVIS;
|
||||
|
||||
isMoving = true;
|
||||
} else {
|
||||
} else if (isMoving) {
|
||||
keepWalking();
|
||||
Avatar.position = Vec3.sum(Avatar.position, Vec3.multiply(Vec3.subtract(targetPosition, Avatar.position), MOVE_RATE));
|
||||
Avatar.orientation = Quat.mix(Avatar.orientation, targetDirection, TURN_RATE);
|
||||
if (Vec3.length(Vec3.subtract(Avatar.position, targetPosition)) < STOP_TOLERANCE) {
|
||||
isMoving = false;
|
||||
isMoving = false;
|
||||
stopWalking();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
//
|
||||
// cameraExample.js
|
||||
// hifi
|
||||
// examples
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 2/6/14.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// This is an example script that demonstrates use of the Camera class
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var damping = 0.9;
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
//
|
||||
// cameraExample.js
|
||||
// examples
|
||||
//
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// This sample script watches your hydra hands and makes clapping sound when they come close together fast
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
function length(v) {
|
||||
return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
//
|
||||
// clipboardExample.js
|
||||
// hifi
|
||||
// examples
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 1/28/14.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// This is an example script that demonstrates use of the Clipboard class
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var selectedVoxel = { x: 0, y: 0, z: 0, s: 0 };
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
//
|
||||
// collidingParticles.js
|
||||
// hifi
|
||||
// examples
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 12/31/13.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// This is an example script that creates a couple particles, and sends them on a collision course.
|
||||
// One of the particles has a script that when it collides with another particle, it swaps colors with that particle.
|
||||
// The other particle has a script that when it collides with another particle it set's it's script to a suicide script.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var currentIteration = 0;
|
||||
|
@ -30,9 +32,10 @@ var gravity = {
|
|||
var damping = 0.1;
|
||||
|
||||
var scriptA = " " +
|
||||
" function collisionWithParticle(other, penetration) { " +
|
||||
" function collisionWithParticle(other, collision) { " +
|
||||
" print('collisionWithParticle(other.getID()=' + other.getID() + ')...'); " +
|
||||
" Vec3.print('penetration=', penetration); " +
|
||||
" Vec3.print('penetration=', collision.penetration); " +
|
||||
" Vec3.print('contactPoint=', collision.contactPoint); " +
|
||||
" print('myID=' + Particle.getID() + '\\n'); " +
|
||||
" var colorBlack = { red: 0, green: 0, blue: 0 };" +
|
||||
" var otherColor = other.getColor();" +
|
||||
|
@ -46,9 +49,10 @@ var scriptA = " " +
|
|||
" ";
|
||||
|
||||
var scriptB = " " +
|
||||
" function collisionWithParticle(other, penetration) { " +
|
||||
" function collisionWithParticle(other, collision) { " +
|
||||
" print('collisionWithParticle(other.getID()=' + other.getID() + ')...'); " +
|
||||
" Vec3.print('penetration=', penetration); " +
|
||||
" Vec3.print('penetration=', collision.penetration); " +
|
||||
" Vec3.print('contactPoint=', collision.contactPoint); " +
|
||||
" print('myID=' + Particle.getID() + '\\n'); " +
|
||||
" Particle.setScript('Particle.setShouldDie(true);'); " +
|
||||
" } " +
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
//
|
||||
// controllerExample.js
|
||||
// hifi
|
||||
// examples
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 1/28/14.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// This is an example script that demonstrates use of the Controller class
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
// initialize our triggers
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
//
|
||||
// count.js
|
||||
// hifi
|
||||
// examples
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 12/31/13.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// This is an example script that runs in a loop and displays a counter to the log
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
//
|
||||
|
||||
var count = 0;
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
//
|
||||
// crazylegs.js
|
||||
// hifi
|
||||
// examples
|
||||
//
|
||||
// Created by Andrzej Kapolka on 3/6/14.
|
||||
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var FREQUENCY = 5.0;
|
||||
|
@ -12,9 +15,12 @@ var AMPLITUDE = 45.0;
|
|||
|
||||
var cumulativeTime = 0.0;
|
||||
|
||||
print("Joint List:");
|
||||
var jointList = MyAvatar.getJointNames();
|
||||
print(jointList);
|
||||
var jointMappings = "\n# Joint list start";
|
||||
for (var i = 0; i < jointList.length; i++) {
|
||||
jointMappings = jointMappings + "\njointIndex = " + jointList[i] + " = " + i;
|
||||
}
|
||||
print(jointMappings + "\n# Joint list end");
|
||||
|
||||
Script.update.connect(function(deltaTime) {
|
||||
cumulativeTime += deltaTime;
|
||||
|
|
49
examples/dancing_bot.js
Normal file
49
examples/dancing_bot.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
//
|
||||
// dancing_bot.js
|
||||
// examples
|
||||
//
|
||||
// Created by Andrzej Kapolka on 4/16/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// This is an example script that demonstrates an NPC avatar running an FBX animation loop.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var animation = AnimationCache.getAnimation("http://www.fungibleinsight.com/faces/gangnam_style_2.fbx");
|
||||
|
||||
Avatar.skeletonModelURL = "http://www.fungibleinsight.com/faces/beta.fst";
|
||||
|
||||
Agent.isAvatar = true;
|
||||
|
||||
var jointMapping;
|
||||
|
||||
var frameIndex = 0.0;
|
||||
|
||||
var FRAME_RATE = 30.0; // frames per second
|
||||
|
||||
Script.update.connect(function(deltaTime) {
|
||||
if (!jointMapping) {
|
||||
var avatarJointNames = Avatar.jointNames;
|
||||
var animationJointNames = animation.jointNames;
|
||||
if (avatarJointNames.length === 0 || animationJointNames.length === 0) {
|
||||
return;
|
||||
}
|
||||
jointMapping = new Array(avatarJointNames.length);
|
||||
for (var i = 0; i < avatarJointNames.length; i++) {
|
||||
jointMapping[i] = animationJointNames.indexOf(avatarJointNames[i]);
|
||||
}
|
||||
}
|
||||
frameIndex += deltaTime * FRAME_RATE;
|
||||
var frames = animation.frames;
|
||||
var rotations = frames[Math.floor(frameIndex) % frames.length].rotations;
|
||||
for (var j = 0; j < jointMapping.length; j++) {
|
||||
var rotationIndex = jointMapping[j];
|
||||
if (rotationIndex != -1) {
|
||||
Avatar.setJointData(j, rotations[rotationIndex]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -1,5 +1,13 @@
|
|||
//
|
||||
// defaultScripts.js
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// examples
|
||||
//
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("lookWithTouch.js");
|
||||
Script.include("editVoxels.js");
|
||||
Script.include("selectAudioDevice.js");
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
//
|
||||
// drumStick.js
|
||||
// examples
|
||||
//
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// This example musical instrument script plays 'air drums' when you move your hands downward
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
function length(v) {
|
||||
return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
//
|
||||
// editParticleExample.js
|
||||
// hifi
|
||||
// examples
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 12/31/13.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// This is an example script that demonstrates creating and editing a particle
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var count = 0;
|
||||
var moveUntil = 2000;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
//
|
||||
// editVoxels.js
|
||||
// hifi
|
||||
// examples
|
||||
//
|
||||
// Created by Philip Rosedale on February 8, 2014
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Captures mouse clicks and edits voxels accordingly.
|
||||
//
|
||||
|
@ -15,6 +15,9 @@
|
|||
//
|
||||
// Click and drag to create more new voxels in the same direction
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var windowDimensions = Controller.getViewportDimensions();
|
||||
|
||||
|
@ -32,6 +35,7 @@ var MIN_PASTE_VOXEL_SCALE = .256;
|
|||
var zFightingSizeAdjust = 0.002; // used to adjust preview voxels to prevent z fighting
|
||||
var previewLineWidth = 1.5;
|
||||
|
||||
var inspectJsIsRunning = false;
|
||||
var isAdding = false;
|
||||
var isExtruding = false;
|
||||
var extrudeDirection = { x: 0, y: 0, z: 0 };
|
||||
|
@ -60,19 +64,92 @@ colors[8] = { red: 31, green: 64, blue: 64 };
|
|||
var numColors = 9;
|
||||
var whichColor = -1; // Starting color is 'Copy' mode
|
||||
|
||||
// Create sounds for adding, deleting, recoloring voxels
|
||||
var addSound1 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Voxels/voxel+create+2.raw");
|
||||
var addSound2 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Voxels/voxel+create+3.raw");
|
||||
var addSound3 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Voxels/voxel+create+4.raw");
|
||||
|
||||
var deleteSound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Voxels/voxel+delete+2.raw");
|
||||
var changeColorSound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Voxels/voxel+edit+2.raw");
|
||||
var clickSound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Switches+and+sliders/toggle+switch+-+medium.raw");
|
||||
// Create sounds for for every script actions that require one
|
||||
var audioOptions = new AudioInjectionOptions();
|
||||
|
||||
audioOptions.volume = 0.5;
|
||||
audioOptions.volume = 1.0;
|
||||
audioOptions.position = Vec3.sum(MyAvatar.position, { x: 0, y: 1, z: 0 } ); // start with audio slightly above the avatar
|
||||
|
||||
function SoundArray() {
|
||||
this.audioOptions = audioOptions
|
||||
this.sounds = new Array();
|
||||
this.addSound = function (soundURL) {
|
||||
this.sounds[this.sounds.length] = new Sound(soundURL);
|
||||
}
|
||||
this.play = function (index) {
|
||||
if (0 <= index && index < this.sounds.length) {
|
||||
Audio.playSound(this.sounds[index], this.audioOptions);
|
||||
} else {
|
||||
print("[ERROR] editVoxels.js:randSound.play() : Index " + index + " out of range.");
|
||||
}
|
||||
}
|
||||
this.playRandom = function () {
|
||||
if (this.sounds.length > 0) {
|
||||
rand = Math.floor(Math.random() * this.sounds.length);
|
||||
Audio.playSound(this.sounds[rand], this.audioOptions);
|
||||
} else {
|
||||
print("[ERROR] editVoxels.js:randSound.playRandom() : Array is empty.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var addVoxelSound = new SoundArray();
|
||||
addVoxelSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Voxel+Add/VA+1.raw");
|
||||
addVoxelSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Voxel+Add/VA+2.raw");
|
||||
addVoxelSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Voxel+Add/VA+3.raw");
|
||||
addVoxelSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Voxel+Add/VA+4.raw");
|
||||
addVoxelSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Voxel+Add/VA+5.raw");
|
||||
addVoxelSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Voxel+Add/VA+6.raw");
|
||||
|
||||
var delVoxelSound = new SoundArray();
|
||||
delVoxelSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Voxel+Del/VD+A1.raw");
|
||||
delVoxelSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Voxel+Del/VD+A2.raw");
|
||||
delVoxelSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Voxel+Del/VD+A3.raw");
|
||||
delVoxelSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Voxel+Del/VD+B1.raw");
|
||||
delVoxelSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Voxel+Del/VD+B2.raw");
|
||||
delVoxelSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Voxel+Del/VD+B3.raw");
|
||||
|
||||
var resizeVoxelSound = new SoundArray();
|
||||
resizeVoxelSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Voxel+Size/V+Size+Minus.raw");
|
||||
resizeVoxelSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Voxel+Size/V+Size+Plus.raw");
|
||||
var voxelSizeMinus = 0;
|
||||
var voxelSizePlus = 1;
|
||||
|
||||
var swatchesSound = new SoundArray();
|
||||
swatchesSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Swatches/Swatch+1.raw");
|
||||
swatchesSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Swatches/Swatch+2.raw");
|
||||
swatchesSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Swatches/Swatch+3.raw");
|
||||
swatchesSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Swatches/Swatch+4.raw");
|
||||
swatchesSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Swatches/Swatch+5.raw");
|
||||
swatchesSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Swatches/Swatch+6.raw");
|
||||
swatchesSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Swatches/Swatch+7.raw");
|
||||
swatchesSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Swatches/Swatch+8.raw");
|
||||
swatchesSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Swatches/Swatch+9.raw");
|
||||
|
||||
var undoSound = new SoundArray();
|
||||
undoSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Undo/Undo+1.raw");
|
||||
undoSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Undo/Undo+2.raw");
|
||||
undoSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Undo/Undo+3.raw");
|
||||
|
||||
var scriptInitSound = new SoundArray();
|
||||
scriptInitSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Script+Init/Script+Init+A.raw");
|
||||
scriptInitSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Script+Init/Script+Init+B.raw");
|
||||
scriptInitSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Script+Init/Script+Init+C.raw");
|
||||
scriptInitSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Script+Init/Script+Init+D.raw");
|
||||
|
||||
var modeSwitchSound = new SoundArray();
|
||||
modeSwitchSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Mode+Switch/Mode+1.raw");
|
||||
modeSwitchSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Mode+Switch/Mode+2.raw");
|
||||
modeSwitchSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Mode+Switch/Mode+3.raw");
|
||||
|
||||
var initialVoxelSound = new SoundArray();
|
||||
initialVoxelSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Initial+Voxel/Initial+V.raw");
|
||||
|
||||
var colorInheritSound = new SoundArray();
|
||||
colorInheritSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Color+Inherit/Inherit+A.raw");
|
||||
colorInheritSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Color+Inherit/Inherit+B.raw");
|
||||
colorInheritSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Color+Inherit/Inherit+C.raw");
|
||||
|
||||
|
||||
var editToolsOn = true; // starts out off
|
||||
|
||||
// previewAsVoxel - by default, we will preview adds/deletes/recolors as just 4 lines on the intersecting face. But if you
|
||||
|
@ -375,8 +452,17 @@ function calcThumbFromScale(scale) {
|
|||
if (thumbStep > pointerVoxelScaleSteps) {
|
||||
thumbStep = pointerVoxelScaleSteps;
|
||||
}
|
||||
var oldThumbX = thumbX;
|
||||
thumbX = (thumbDeltaPerStep * (thumbStep - 1)) + minThumbX;
|
||||
Overlays.editOverlay(thumb, { x: thumbX + sliderX } );
|
||||
|
||||
if (thumbX > oldThumbX) {
|
||||
resizeVoxelSound.play(voxelSizePlus);
|
||||
print("Plus");
|
||||
} else if (thumbX < oldThumbX) {
|
||||
resizeVoxelSound.play(voxelSizeMinus);
|
||||
print("Minus");
|
||||
}
|
||||
}
|
||||
|
||||
function calcScaleFromThumb(newThumbX) {
|
||||
|
@ -439,15 +525,6 @@ var recolorToolSelected = false;
|
|||
var eyedropperToolSelected = false;
|
||||
var pasteMode = false;
|
||||
|
||||
function playRandomAddSound(audioOptions) {
|
||||
if (Math.random() < 0.33) {
|
||||
Audio.playSound(addSound1, audioOptions);
|
||||
} else if (Math.random() < 0.5) {
|
||||
Audio.playSound(addSound2, audioOptions);
|
||||
} else {
|
||||
Audio.playSound(addSound3, audioOptions);
|
||||
}
|
||||
}
|
||||
|
||||
function calculateVoxelFromIntersection(intersection, operation) {
|
||||
//print("calculateVoxelFromIntersection() operation="+operation);
|
||||
|
@ -727,6 +804,9 @@ function trackKeyPressEvent(event) {
|
|||
trackAsEyedropper = true;
|
||||
moveTools();
|
||||
}
|
||||
if (event.text == "ALT") {
|
||||
inspectJsIsRunning = true;
|
||||
}
|
||||
showPreviewGuides();
|
||||
}
|
||||
|
||||
|
@ -737,7 +817,11 @@ function trackKeyReleaseEvent(event) {
|
|||
moveTools();
|
||||
setAudioPosition(); // make sure we set the audio position before playing sounds
|
||||
showPreviewGuides();
|
||||
Audio.playSound(clickSound, audioOptions);
|
||||
scriptInitSound.playRandom();
|
||||
}
|
||||
|
||||
if (event.text == "ALT") {
|
||||
inspectJsIsRunning = false;
|
||||
}
|
||||
|
||||
if (editToolsOn) {
|
||||
|
@ -777,11 +861,13 @@ function trackKeyReleaseEvent(event) {
|
|||
}
|
||||
|
||||
function mousePressEvent(event) {
|
||||
|
||||
// if our tools are off, then don't do anything
|
||||
if (!editToolsOn) {
|
||||
return;
|
||||
}
|
||||
if (inspectJsIsRunning) {
|
||||
return;
|
||||
}
|
||||
|
||||
var clickedOnSomething = false;
|
||||
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y});
|
||||
|
@ -795,18 +881,21 @@ function mousePressEvent(event) {
|
|||
Overlays.editOverlay(thumb, { imageURL: toolIconUrl + "voxel-size-slider-handle.svg", });
|
||||
|
||||
} else if (clickedOverlay == voxelTool) {
|
||||
modeSwitchSound.play(0);
|
||||
voxelToolSelected = true;
|
||||
recolorToolSelected = false;
|
||||
eyedropperToolSelected = false;
|
||||
moveTools();
|
||||
clickedOnSomething = true;
|
||||
} else if (clickedOverlay == recolorTool) {
|
||||
modeSwitchSound.play(1);
|
||||
voxelToolSelected = false;
|
||||
recolorToolSelected = true;
|
||||
eyedropperToolSelected = false;
|
||||
moveTools();
|
||||
clickedOnSomething = true;
|
||||
} else if (clickedOverlay == eyedropperTool) {
|
||||
modeSwitchSound.play(2);
|
||||
voxelToolSelected = false;
|
||||
recolorToolSelected = false;
|
||||
eyedropperToolSelected = true;
|
||||
|
@ -833,6 +922,7 @@ function mousePressEvent(event) {
|
|||
whichColor = s;
|
||||
moveTools();
|
||||
clickedOnSomething = true;
|
||||
swatchesSound.play(whichColor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -875,7 +965,7 @@ function mousePressEvent(event) {
|
|||
// Delete voxel
|
||||
voxelDetails = calculateVoxelFromIntersection(intersection,"delete");
|
||||
Voxels.eraseVoxel(voxelDetails.x, voxelDetails.y, voxelDetails.z, voxelDetails.s);
|
||||
Audio.playSound(deleteSound, audioOptions);
|
||||
delVoxelSound.playRandom();
|
||||
Overlays.editOverlay(voxelPreview, { visible: false });
|
||||
} else if (eyedropperToolSelected || trackAsEyedropper) {
|
||||
if (whichColor != -1) {
|
||||
|
@ -883,6 +973,7 @@ function mousePressEvent(event) {
|
|||
colors[whichColor].green = intersection.voxel.green;
|
||||
colors[whichColor].blue = intersection.voxel.blue;
|
||||
moveTools();
|
||||
swatchesSound.play(whichColor);
|
||||
}
|
||||
|
||||
} else if (recolorToolSelected || trackAsRecolor) {
|
||||
|
@ -890,10 +981,9 @@ function mousePressEvent(event) {
|
|||
voxelDetails = calculateVoxelFromIntersection(intersection,"recolor");
|
||||
|
||||
// doing this erase then set will make sure we only recolor just the target voxel
|
||||
Voxels.eraseVoxel(voxelDetails.x, voxelDetails.y, voxelDetails.z, voxelDetails.s);
|
||||
Voxels.setVoxel(voxelDetails.x, voxelDetails.y, voxelDetails.z, voxelDetails.s,
|
||||
colors[whichColor].red, colors[whichColor].green, colors[whichColor].blue);
|
||||
Audio.playSound(changeColorSound, audioOptions);
|
||||
swatchesSound.play(whichColor);
|
||||
Overlays.editOverlay(voxelPreview, { visible: false });
|
||||
} else if (voxelToolSelected) {
|
||||
// Add voxel on face
|
||||
|
@ -911,14 +1001,13 @@ function mousePressEvent(event) {
|
|||
}
|
||||
|
||||
voxelDetails = calculateVoxelFromIntersection(intersection,"add");
|
||||
Voxels.eraseVoxel(voxelDetails.x, voxelDetails.y, voxelDetails.z, voxelDetails.s);
|
||||
Voxels.setVoxel(voxelDetails.x, voxelDetails.y, voxelDetails.z, voxelDetails.s,
|
||||
newColor.red, newColor.green, newColor.blue);
|
||||
lastVoxelPosition = { x: voxelDetails.x, y: voxelDetails.y, z: voxelDetails.z };
|
||||
lastVoxelColor = { red: newColor.red, green: newColor.green, blue: newColor.blue };
|
||||
lastVoxelScale = voxelDetails.s;
|
||||
|
||||
playRandomAddSound(audioOptions);
|
||||
addVoxelSound.playRandom();
|
||||
|
||||
Overlays.editOverlay(voxelPreview, { visible: false });
|
||||
dragStart = { x: event.x, y: event.y };
|
||||
|
@ -934,12 +1023,12 @@ function keyPressEvent(event) {
|
|||
if (event.text == "`") {
|
||||
print("Color = Copy");
|
||||
whichColor = -1;
|
||||
Audio.playSound(clickSound, audioOptions);
|
||||
colorInheritSound.playRandom();
|
||||
moveTools();
|
||||
} else if ((nVal > 0) && (nVal <= numColors)) {
|
||||
whichColor = nVal - 1;
|
||||
print("Color = " + (whichColor + 1));
|
||||
Audio.playSound(clickSound, audioOptions);
|
||||
swatchesSound.play(whichColor);
|
||||
moveTools();
|
||||
} else if (event.text == "0") {
|
||||
// Create a brand new 1 meter voxel in front of your avatar
|
||||
|
@ -957,8 +1046,12 @@ function keyPressEvent(event) {
|
|||
Voxels.eraseVoxel(newVoxel.x, newVoxel.y, newVoxel.z, newVoxel.s);
|
||||
Voxels.setVoxel(newVoxel.x, newVoxel.y, newVoxel.z, newVoxel.s, newVoxel.red, newVoxel.green, newVoxel.blue);
|
||||
setAudioPosition();
|
||||
playRandomAddSound(audioOptions);
|
||||
initialVoxelSound.playRandom();
|
||||
} else if (event.text == "z") {
|
||||
undoSound.playRandom();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
trackKeyPressEvent(event); // used by preview support
|
||||
|
@ -1061,7 +1154,9 @@ function mouseMoveEvent(event) {
|
|||
if (!editToolsOn) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (inspectJsIsRunning) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isMovingSlider) {
|
||||
thumbX = (event.x - thumbClickOffsetX) - sliderX;
|
||||
|
@ -1121,7 +1216,10 @@ function mouseReleaseEvent(event) {
|
|||
if (!editToolsOn) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (inspectJsIsRunning) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isMovingSlider) {
|
||||
isMovingSlider = false;
|
||||
}
|
||||
|
@ -1214,24 +1312,6 @@ function moveTools() {
|
|||
|
||||
}
|
||||
|
||||
function touchBeginEvent(event) {
|
||||
if (!editToolsOn) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function touchUpdateEvent(event) {
|
||||
if (!editToolsOn) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function touchEndEvent(event) {
|
||||
if (!editToolsOn) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var lastFingerAddVoxel = { x: -1, y: -1, z: -1}; // off of the build-able area
|
||||
var lastFingerDeleteVoxel = { x: -1, y: -1, z: -1}; // off of the build-able area
|
||||
|
||||
|
@ -1326,15 +1406,12 @@ function wheelEvent(event) {
|
|||
}
|
||||
}
|
||||
|
||||
Controller.wheelEvent.connect(wheelEvent);
|
||||
// Controller.wheelEvent.connect(wheelEvent);
|
||||
Controller.mousePressEvent.connect(mousePressEvent);
|
||||
Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
|
||||
Controller.mouseMoveEvent.connect(mouseMoveEvent);
|
||||
Controller.keyPressEvent.connect(keyPressEvent);
|
||||
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
||||
Controller.touchBeginEvent.connect(touchBeginEvent);
|
||||
Controller.touchUpdateEvent.connect(touchUpdateEvent);
|
||||
Controller.touchEndEvent.connect(touchEndEvent);
|
||||
Controller.captureKeyEvents({ text: "+" });
|
||||
Controller.captureKeyEvents({ text: "-" });
|
||||
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
//
|
||||
// findParticleExample.js
|
||||
// hifi
|
||||
// examples
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 1/24/14.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// This is an example script that demonstrates "finding" particles
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var iteration = 0;
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
//
|
||||
// flockingBirds.js
|
||||
// hifi
|
||||
// examples
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 3/4/14.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// This is an example script that generates particles that act like flocking birds
|
||||
//
|
||||
|
@ -13,12 +13,16 @@
|
|||
// go back to gliding
|
||||
// birds don't like to be below a certain altitude
|
||||
// if they are below that altitude they will keep thrusting up, until they get ove
|
||||
|
||||
//
|
||||
// flocking
|
||||
// try to align your velocity with velocity of other birds
|
||||
// try to fly toward center of flock
|
||||
// but dont get too close
|
||||
//
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var birdsInFlock = 40;
|
||||
|
||||
|
|
|
@ -1,4 +1,12 @@
|
|||
|
||||
//
|
||||
// fountain.js
|
||||
// examples
|
||||
//
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
function vLength(v) {
|
||||
return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
// Add your JavaScript for assignment below this line
|
||||
|
||||
// The following is an example of Conway's Game of Life (http://en.wikipedia.org/wiki/Conway's_Game_of_Life)
|
||||
//
|
||||
// gameoflife.js
|
||||
// examples
|
||||
//
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// The following is an example of Conway's Game of Life (http://en.wikipedia.org/wiki/Conway's_Game_of_Life)
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var NUMBER_OF_CELLS_EACH_DIMENSION = 64;
|
||||
var NUMBER_OF_CELLS = NUMBER_OF_CELLS_EACH_DIMENSION * NUMBER_OF_CELLS_EACH_DIMENSION;
|
||||
|
|
|
@ -1,29 +1,33 @@
|
|||
//
|
||||
// globalCollisionsExample.js
|
||||
// hifi
|
||||
// examples
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 1/29/14.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// This is an example script that demonstrates use of the Controller class
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
|
||||
print("hello...");
|
||||
|
||||
function particleCollisionWithVoxel(particle, voxel, penetration) {
|
||||
function particleCollisionWithVoxel(particle, voxel, collision) {
|
||||
print("particleCollisionWithVoxel()..");
|
||||
print(" particle.getID()=" + particle.id);
|
||||
print(" voxel color...=" + voxel.red + ", " + voxel.green + ", " + voxel.blue);
|
||||
Vec3.print('penetration=', penetration);
|
||||
Vec3.print('penetration=', collision.penetration);
|
||||
Vec3.print('contactPoint=', collision.contactPoint);
|
||||
}
|
||||
|
||||
function particleCollisionWithParticle(particleA, particleB, penetration) {
|
||||
function particleCollisionWithParticle(particleA, particleB, collision) {
|
||||
print("particleCollisionWithParticle()..");
|
||||
print(" particleA.getID()=" + particleA.id);
|
||||
print(" particleB.getID()=" + particleB.id);
|
||||
Vec3.print('penetration=', penetration);
|
||||
Vec3.print('penetration=', collision.penetration);
|
||||
Vec3.print('contactPoint=', collision.contactPoint);
|
||||
}
|
||||
|
||||
Particles.particleCollisionWithVoxel.connect(particleCollisionWithVoxel);
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
//
|
||||
// gun.js
|
||||
// hifi
|
||||
// examples
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 12/31/13.
|
||||
// Modified by Philip on 3/3/14
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// This is an example script that turns the hydra controllers and mouse into a particle gun.
|
||||
// It reads the controller, watches for trigger pulls, and launches particles.
|
||||
// When particles collide with voxels they blow little holes out of the voxels.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
|
||||
function getRandomFloat(min, max) {
|
||||
return Math.random() * (max - min) + min;
|
||||
}
|
||||
|
@ -27,6 +28,9 @@ var BULLET_VELOCITY = 5.0;
|
|||
var MIN_THROWER_DELAY = 1000;
|
||||
var MAX_THROWER_DELAY = 1000;
|
||||
var LEFT_BUTTON_3 = 3;
|
||||
var RELOAD_INTERVAL = 9;
|
||||
|
||||
var showScore = false;
|
||||
|
||||
// Load some sound to use for loading and firing
|
||||
var fireSound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guns/GUN-SHOT2.raw");
|
||||
|
@ -38,6 +42,8 @@ var targetLaunchSound = new Sound("http://highfidelity-public.s3-us-west-1.amazo
|
|||
var audioOptions = new AudioInjectionOptions();
|
||||
audioOptions.volume = 0.9;
|
||||
|
||||
var shotsFired = 0;
|
||||
|
||||
var shotTime = new Date();
|
||||
|
||||
// initialize our triggers
|
||||
|
@ -63,7 +69,8 @@ var reticle = Overlays.addOverlay("image", {
|
|||
alpha: 1
|
||||
});
|
||||
|
||||
var text = Overlays.addOverlay("text", {
|
||||
if (showScore) {
|
||||
var text = Overlays.addOverlay("text", {
|
||||
x: screenSize.x / 2 - 100,
|
||||
y: screenSize.y / 2 - 50,
|
||||
width: 150,
|
||||
|
@ -74,6 +81,8 @@ var text = Overlays.addOverlay("text", {
|
|||
leftMargin: 4,
|
||||
text: "Score: " + score
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function printVector(string, vector) {
|
||||
|
@ -94,6 +103,10 @@ function shootBullet(position, velocity) {
|
|||
// Play firing sounds
|
||||
audioOptions.position = position;
|
||||
Audio.playSound(fireSound, audioOptions);
|
||||
shotsFired++;
|
||||
if ((shotsFired % RELOAD_INTERVAL) == 0) {
|
||||
Audio.playSound(loadSound, audioOptions);
|
||||
}
|
||||
}
|
||||
|
||||
function shootTarget() {
|
||||
|
@ -133,35 +146,36 @@ function shootTarget() {
|
|||
|
||||
|
||||
|
||||
function particleCollisionWithVoxel(particle, voxel, penetration) {
|
||||
function particleCollisionWithVoxel(particle, voxel, collision) {
|
||||
var HOLE_SIZE = 0.125;
|
||||
var particleProperties = Particles.getParticleProperties(particle);
|
||||
var position = particleProperties.position;
|
||||
Particles.deleteParticle(particle);
|
||||
// Make a hole in this voxel
|
||||
Vec3.print("penetration", penetration);
|
||||
Vec3.print("position", position);
|
||||
var pointOfEntry = Vec3.subtract(position, penetration);
|
||||
Vec3.print("pointOfEntry", pointOfEntry);
|
||||
Voxels.eraseVoxel(pointOfEntry.x, pointOfEntry.y, pointOfEntry.z, HOLE_SIZE);
|
||||
Voxels.eraseVoxel(position.x, position.y, position.z, HOLE_SIZE);
|
||||
//audioOptions.position = position;
|
||||
audioOptions.position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation()));
|
||||
Audio.playSound(targetHitSound, audioOptions);
|
||||
//Vec3.print("voxel penetration", collision.penetration);
|
||||
//Vec3.print("voxel contactPoint", collision.contactPoint);
|
||||
Voxels.eraseVoxel(collision.contactPoint.x, collision.contactPoint.y, collision.contactPoint.z, HOLE_SIZE);
|
||||
audioOptions.position = collision.contactPoint;
|
||||
Audio.playSound(impactSound, audioOptions);
|
||||
}
|
||||
|
||||
function particleCollisionWithParticle(particle1, particle2) {
|
||||
function particleCollisionWithParticle(particle1, particle2, collision) {
|
||||
score++;
|
||||
Overlays.editOverlay(text, { text: "Score: " + score } );
|
||||
if (showScore) {
|
||||
Overlays.editOverlay(text, { text: "Score: " + score } );
|
||||
}
|
||||
|
||||
// Sort out which particle is which
|
||||
|
||||
// Record shot time
|
||||
var endTime = new Date();
|
||||
var msecs = endTime.valueOf() - shotTime.valueOf();
|
||||
print("hit, msecs = " + msecs);
|
||||
//print("hit, msecs = " + msecs);
|
||||
//Vec3.print("penetration = ", collision.penetration);
|
||||
//Vec3.print("contactPoint = ", collision.contactPoint);
|
||||
Particles.deleteParticle(particle1);
|
||||
Particles.deleteParticle(particle2);
|
||||
audioOptions.position = newPosition;
|
||||
// play the sound near the camera so the shooter can hear it
|
||||
audioOptions.position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation()));
|
||||
Audio.playSound(targetHitSound, audioOptions);
|
||||
}
|
||||
|
@ -171,12 +185,12 @@ function keyPressEvent(event) {
|
|||
if (event.text == "t") {
|
||||
var time = MIN_THROWER_DELAY + Math.random() * MAX_THROWER_DELAY;
|
||||
Script.setTimeout(shootTarget, time);
|
||||
} if (event.text == ".") {
|
||||
shootFromMouse();
|
||||
}
|
||||
}
|
||||
|
||||
function update(deltaTime) {
|
||||
|
||||
|
||||
// Check for mouseLook movement, update rotation
|
||||
// rotate body yaw for yaw received from mouse
|
||||
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromVec3Radians( { x: 0, y: yawFromMouse, z: 0 } ));
|
||||
|
@ -257,18 +271,21 @@ function mousePressEvent(event) {
|
|||
isMouseDown = true;
|
||||
lastX = event.x;
|
||||
lastY = event.y;
|
||||
audioOptions.position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation()));
|
||||
Audio.playSound(loadSound, audioOptions);
|
||||
//audioOptions.position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation()));
|
||||
//Audio.playSound(loadSound, audioOptions);
|
||||
}
|
||||
|
||||
function mouseReleaseEvent(event) {
|
||||
// position
|
||||
function shootFromMouse() {
|
||||
var DISTANCE_FROM_CAMERA = 2.0;
|
||||
var camera = Camera.getPosition();
|
||||
var forwardVector = Quat.getFront(Camera.getOrientation());
|
||||
var newPosition = Vec3.sum(camera, Vec3.multiply(forwardVector, DISTANCE_FROM_CAMERA));
|
||||
var velocity = Vec3.multiply(forwardVector, BULLET_VELOCITY);
|
||||
shootBullet(newPosition, velocity);
|
||||
}
|
||||
|
||||
function mouseReleaseEvent(event) {
|
||||
// position
|
||||
isMouseDown = false;
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue