mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-16 17:08:45 +02:00
Merge branch 'master' into 20639
Conflicts: interface/CMakeLists.txt
This commit is contained in:
commit
02ae008c9c
19 changed files with 1611 additions and 1 deletions
38
cmake/modules/FindconnexionClient.cmake
Normal file
38
cmake/modules/FindconnexionClient.cmake
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#
|
||||||
|
# FindconnexionClient.cmake
|
||||||
|
#
|
||||||
|
# Once done this will define
|
||||||
|
#
|
||||||
|
# 3DCONNEXIONCLIENT_INCLUDE_DIRS
|
||||||
|
#
|
||||||
|
# Created on 10/06/2015 by Marcel Verhagen
|
||||||
|
# Copyright 2015 High Fidelity, Inc.
|
||||||
|
#
|
||||||
|
# Distributed under the Apache License, Version 2.0.
|
||||||
|
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
#
|
||||||
|
|
||||||
|
# setup hints for 3DCONNEXIONCLIENT search
|
||||||
|
include("${MACRO_DIR}/HifiLibrarySearchHints.cmake")
|
||||||
|
hifi_library_search_hints("connexionclient")
|
||||||
|
|
||||||
|
if (APPLE)
|
||||||
|
find_library(3DconnexionClient 3DconnexionClient)
|
||||||
|
if(EXISTS ${3DconnexionClient})
|
||||||
|
set(CONNEXIONCLIENT_FOUND true)
|
||||||
|
set(CONNEXIONCLIENT_INCLUDE_DIR ${3DconnexionClient})
|
||||||
|
set(CONNEXIONCLIENT_LIBRARY ${3DconnexionClient})
|
||||||
|
set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS "-weak_framework 3DconnexionClient")
|
||||||
|
message(STATUS "Found 3Dconnexion")
|
||||||
|
mark_as_advanced(CONNEXIONCLIENT_INCLUDE_DIR CONNEXIONCLIENT_LIBRARY)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
find_path(CONNEXIONCLIENT_INCLUDE_DIRS I3dMouseParams.h PATH_SUFFIXES Inc HINTS ${CONNEXIONCLIENT_SEARCH_DIRS})
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(connexionClient DEFAULT_MSG CONNEXIONCLIENT_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
mark_as_advanced(CONNEXIONCLIENT_INCLUDE_DIRS CONNEXIONCLIENT_SEARCH_DIRS)
|
||||||
|
endif()
|
28
examples/example/games/hitEffect.js
Normal file
28
examples/example/games/hitEffect.js
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
//
|
||||||
|
// hitEffect.js
|
||||||
|
// examples
|
||||||
|
//
|
||||||
|
// Created by Eric Levin on July 20, 2015
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// An example of how to toggle a screen-space hit effect using the Scene global 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 hitEffectEnabled = false;
|
||||||
|
|
||||||
|
toggleHitEffect();
|
||||||
|
|
||||||
|
function toggleHitEffect() {
|
||||||
|
Script.setTimeout(function() {
|
||||||
|
hitEffectEnabled = !hitEffectEnabled;
|
||||||
|
Scene.setEngineDisplayHitEffect(hitEffectEnabled);
|
||||||
|
toggleHitEffect();
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ set(TARGET_NAME interface)
|
||||||
project(${TARGET_NAME})
|
project(${TARGET_NAME})
|
||||||
|
|
||||||
# set a default root dir for each of our optional externals if it was not passed
|
# set a default root dir for each of our optional externals if it was not passed
|
||||||
set(OPTIONAL_EXTERNALS "Faceshift" "Sixense" "LeapMotion" "RtMidi" "SDL2" "RSSDK" "iViewHMD")
|
set(OPTIONAL_EXTERNALS "Faceshift" "Sixense" "LeapMotion" "RtMidi" "SDL2" "RSSDK" "iViewHMD" "connexionClient")
|
||||||
foreach(EXTERNAL ${OPTIONAL_EXTERNALS})
|
foreach(EXTERNAL ${OPTIONAL_EXTERNALS})
|
||||||
string(TOUPPER ${EXTERNAL} ${EXTERNAL}_UPPERCASE)
|
string(TOUPPER ${EXTERNAL} ${EXTERNAL}_UPPERCASE)
|
||||||
if (NOT ${${EXTERNAL}_UPPERCASE}_ROOT_DIR)
|
if (NOT ${${EXTERNAL}_UPPERCASE}_ROOT_DIR)
|
||||||
|
|
79
interface/external/connexionclient/Inc/I3dMouseParams.h
vendored
Normal file
79
interface/external/connexionclient/Inc/I3dMouseParams.h
vendored
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
//
|
||||||
|
// 3DConnexion.cpp
|
||||||
|
// hifi
|
||||||
|
//
|
||||||
|
// Created by MarcelEdward Verhagen on 09-06-15.
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef I3D_MOUSE_PARAMS_H
|
||||||
|
#define I3D_MOUSE_PARAMS_H
|
||||||
|
|
||||||
|
// Parameters for the 3D mouse based on the SDK from 3Dconnexion
|
||||||
|
|
||||||
|
class I3dMouseSensor {
|
||||||
|
public:
|
||||||
|
enum Speed {
|
||||||
|
SPEED_LOW = 0,
|
||||||
|
SPEED_MID,
|
||||||
|
SPEED_HIGH
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual bool IsPanZoom() const = 0;
|
||||||
|
virtual bool IsRotate() const = 0;
|
||||||
|
virtual Speed GetSpeed() const = 0;
|
||||||
|
|
||||||
|
virtual void SetPanZoom(bool isPanZoom) = 0;
|
||||||
|
virtual void SetRotate(bool isRotate) = 0;
|
||||||
|
virtual void SetSpeed(Speed speed) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~I3dMouseSensor() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class I3dMouseNavigation {
|
||||||
|
public:
|
||||||
|
enum Pivot {
|
||||||
|
PIVOT_MANUAL = 0,
|
||||||
|
PIVOT_AUTO,
|
||||||
|
PIVOT_AUTO_OVERRIDE
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Navigation {
|
||||||
|
NAVIGATION_OBJECT_MODE = 0,
|
||||||
|
NAVIGATION_CAMERA_MODE,
|
||||||
|
NAVIGATION_FLY_MODE,
|
||||||
|
NAVIGATION_WALK_MODE,
|
||||||
|
NAVIGATION_HELICOPTER_MODE
|
||||||
|
};
|
||||||
|
|
||||||
|
enum PivotVisibility {
|
||||||
|
PIVOT_HIDE = 0,
|
||||||
|
PIVOT_SHOW,
|
||||||
|
PIVOT_SHOW_MOVING
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual Navigation GetNavigationMode() const = 0;
|
||||||
|
virtual Pivot GetPivotMode() const = 0;
|
||||||
|
virtual PivotVisibility GetPivotVisibility() const = 0;
|
||||||
|
virtual bool IsLockHorizon() const = 0;
|
||||||
|
|
||||||
|
virtual void SetLockHorizon(bool bOn) = 0;
|
||||||
|
virtual void SetNavigationMode(Navigation navigation) = 0;
|
||||||
|
virtual void SetPivotMode(Pivot pivot) = 0;
|
||||||
|
virtual void SetPivotVisibility(PivotVisibility visibility) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~I3dMouseNavigation(){}
|
||||||
|
};
|
||||||
|
|
||||||
|
class I3dMouseParam : public I3dMouseSensor, public I3dMouseNavigation {
|
||||||
|
public:
|
||||||
|
virtual ~I3dMouseParam() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
4
interface/external/connexionclient/readme.txt
vendored
Normal file
4
interface/external/connexionclient/readme.txt
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
The mac version does not require any files here. 3D connexion should be installed from
|
||||||
|
http://www.3dconnexion.eu/service/drivers.html
|
||||||
|
|
||||||
|
For windows a header file is required Inc/I3dMouseParams.h
|
|
@ -116,6 +116,7 @@
|
||||||
#include "devices/RealSense.h"
|
#include "devices/RealSense.h"
|
||||||
#include "devices/SDL2Manager.h"
|
#include "devices/SDL2Manager.h"
|
||||||
#include "devices/TV3DManager.h"
|
#include "devices/TV3DManager.h"
|
||||||
|
#include "devices/3Dconnexion.h"
|
||||||
|
|
||||||
#include "scripting/AccountScriptingInterface.h"
|
#include "scripting/AccountScriptingInterface.h"
|
||||||
#include "scripting/AudioDeviceScriptingInterface.h"
|
#include "scripting/AudioDeviceScriptingInterface.h"
|
||||||
|
@ -646,6 +647,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
connect(applicationUpdater.data(), &AutoUpdater::newVersionIsAvailable, dialogsManager.data(), &DialogsManager::showUpdateDialog);
|
connect(applicationUpdater.data(), &AutoUpdater::newVersionIsAvailable, dialogsManager.data(), &DialogsManager::showUpdateDialog);
|
||||||
applicationUpdater->checkForUpdate();
|
applicationUpdater->checkForUpdate();
|
||||||
|
|
||||||
|
// the 3Dconnexion device wants to be initiliazed after a window is displayed.
|
||||||
|
ConnexionClient::init();
|
||||||
|
|
||||||
auto& packetReceiver = nodeList->getPacketReceiver();
|
auto& packetReceiver = nodeList->getPacketReceiver();
|
||||||
packetReceiver.registerListener(PacketType::DomainConnectionDenied, this, "handleDomainConnectionDeniedPacket");
|
packetReceiver.registerListener(PacketType::DomainConnectionDenied, this, "handleDomainConnectionDeniedPacket");
|
||||||
}
|
}
|
||||||
|
@ -760,6 +764,7 @@ Application::~Application() {
|
||||||
|
|
||||||
Leapmotion::destroy();
|
Leapmotion::destroy();
|
||||||
RealSense::destroy();
|
RealSense::destroy();
|
||||||
|
ConnexionClient::destroy();
|
||||||
|
|
||||||
qInstallMessageHandler(NULL); // NOTE: Do this as late as possible so we continue to get our log messages
|
qInstallMessageHandler(NULL); // NOTE: Do this as late as possible so we continue to get our log messages
|
||||||
}
|
}
|
||||||
|
@ -1490,6 +1495,7 @@ void Application::focusOutEvent(QFocusEvent* event) {
|
||||||
_keyboardMouseDevice.focusOutEvent(event);
|
_keyboardMouseDevice.focusOutEvent(event);
|
||||||
SixenseManager::getInstance().focusOutEvent();
|
SixenseManager::getInstance().focusOutEvent();
|
||||||
SDL2Manager::getInstance()->focusOutEvent();
|
SDL2Manager::getInstance()->focusOutEvent();
|
||||||
|
ConnexionData::getInstance().focusOutEvent();
|
||||||
|
|
||||||
// synthesize events for keys currently pressed, since we may not get their release events
|
// synthesize events for keys currently pressed, since we may not get their release events
|
||||||
foreach (int key, _keysPressed) {
|
foreach (int key, _keysPressed) {
|
||||||
|
@ -3290,6 +3296,7 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
|
||||||
renderContext._maxDrawnOverlay3DItems = sceneInterface->getEngineMaxDrawnOverlay3DItems();
|
renderContext._maxDrawnOverlay3DItems = sceneInterface->getEngineMaxDrawnOverlay3DItems();
|
||||||
|
|
||||||
renderContext._drawItemStatus = sceneInterface->doEngineDisplayItemStatus();
|
renderContext._drawItemStatus = sceneInterface->doEngineDisplayItemStatus();
|
||||||
|
renderContext._drawHitEffect = sceneInterface->doEngineDisplayHitEffect();
|
||||||
|
|
||||||
renderContext._occlusionStatus = Menu::getInstance()->isOptionChecked(MenuOption::DebugAmbientOcclusion);
|
renderContext._occlusionStatus = Menu::getInstance()->isOptionChecked(MenuOption::DebugAmbientOcclusion);
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "devices/Faceshift.h"
|
#include "devices/Faceshift.h"
|
||||||
#include "devices/RealSense.h"
|
#include "devices/RealSense.h"
|
||||||
#include "devices/SixenseManager.h"
|
#include "devices/SixenseManager.h"
|
||||||
|
#include "devices/3Dconnexion.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "scripting/MenuScriptingInterface.h"
|
#include "scripting/MenuScriptingInterface.h"
|
||||||
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
||||||
|
@ -455,6 +456,11 @@ Menu::Menu() {
|
||||||
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderLookAtVectors, 0, false);
|
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderLookAtVectors, 0, false);
|
||||||
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderFocusIndicator, 0, false);
|
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderFocusIndicator, 0, false);
|
||||||
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ShowWhosLookingAtMe, 0, false);
|
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ShowWhosLookingAtMe, 0, false);
|
||||||
|
addCheckableActionToQMenuAndActionHash(avatarDebugMenu,
|
||||||
|
MenuOption::Connexion,
|
||||||
|
0, false,
|
||||||
|
&ConnexionClient::getInstance(),
|
||||||
|
SLOT(toggleConnexion(bool)));
|
||||||
|
|
||||||
MenuWrapper* handOptionsMenu = developerMenu->addMenu("Hands");
|
MenuWrapper* handOptionsMenu = developerMenu->addMenu("Hands");
|
||||||
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::AlignForearmsWithWrists, 0, false);
|
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::AlignForearmsWithWrists, 0, false);
|
||||||
|
|
|
@ -160,6 +160,7 @@ namespace MenuOption {
|
||||||
const QString CenterPlayerInView = "Center Player In View";
|
const QString CenterPlayerInView = "Center Player In View";
|
||||||
const QString Chat = "Chat...";
|
const QString Chat = "Chat...";
|
||||||
const QString Collisions = "Collisions";
|
const QString Collisions = "Collisions";
|
||||||
|
const QString Connexion = "Activate 3D Connexion Devices";
|
||||||
const QString Console = "Console...";
|
const QString Console = "Console...";
|
||||||
const QString ControlWithSpeech = "Control With Speech";
|
const QString ControlWithSpeech = "Control With Speech";
|
||||||
const QString CopyAddress = "Copy Address to Clipboard";
|
const QString CopyAddress = "Copy Address to Clipboard";
|
||||||
|
|
1013
interface/src/devices/3Dconnexion.cpp
Executable file
1013
interface/src/devices/3Dconnexion.cpp
Executable file
File diff suppressed because it is too large
Load diff
244
interface/src/devices/3Dconnexion.h
Executable file
244
interface/src/devices/3Dconnexion.h
Executable file
|
@ -0,0 +1,244 @@
|
||||||
|
// 3DConnexion.h
|
||||||
|
// hifi
|
||||||
|
//
|
||||||
|
// Created by Marcel Verhagen on 09-06-15.
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_ConnexionClient_h
|
||||||
|
#define hifi_ConnexionClient_h
|
||||||
|
|
||||||
|
#include <qobject.h>
|
||||||
|
#include <qlibrary.h>
|
||||||
|
#include "InterfaceLogging.h"
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
|
#include "ui/UserInputMapper.h"
|
||||||
|
|
||||||
|
#ifndef HAVE_CONNEXIONCLIENT
|
||||||
|
class ConnexionClient : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
static ConnexionClient& getInstance();
|
||||||
|
static void init() {};
|
||||||
|
static void destroy() {};
|
||||||
|
static bool Is3dmouseAttached() { return false; };
|
||||||
|
public slots:
|
||||||
|
void toggleConnexion(bool shouldEnable) {};
|
||||||
|
};
|
||||||
|
#endif // NOT_HAVE_CONNEXIONCLIENT
|
||||||
|
|
||||||
|
#ifdef HAVE_CONNEXIONCLIENT
|
||||||
|
// the windows connexion rawinput
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
#include "I3dMouseParams.h"
|
||||||
|
#include <QAbstractNativeEventFilter>
|
||||||
|
#include <QAbstractEventDispatcher>
|
||||||
|
#include <Winsock2.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
// windows rawinput parameters
|
||||||
|
class MouseParameters : public I3dMouseParam {
|
||||||
|
public:
|
||||||
|
MouseParameters();
|
||||||
|
~MouseParameters();
|
||||||
|
|
||||||
|
// I3dmouseSensor interface
|
||||||
|
bool IsPanZoom() const;
|
||||||
|
bool IsRotate() const;
|
||||||
|
Speed GetSpeed() const;
|
||||||
|
|
||||||
|
void SetPanZoom(bool isPanZoom);
|
||||||
|
void SetRotate(bool isRotate);
|
||||||
|
void SetSpeed(Speed speed);
|
||||||
|
|
||||||
|
// I3dmouseNavigation interface
|
||||||
|
Navigation GetNavigationMode() const;
|
||||||
|
Pivot GetPivotMode() const;
|
||||||
|
PivotVisibility GetPivotVisibility() const;
|
||||||
|
bool IsLockHorizon() const;
|
||||||
|
|
||||||
|
void SetLockHorizon(bool bOn);
|
||||||
|
void SetNavigationMode(Navigation navigation);
|
||||||
|
void SetPivotMode(Pivot pivot);
|
||||||
|
void SetPivotVisibility(PivotVisibility visibility);
|
||||||
|
|
||||||
|
static bool Is3dmouseAttached();
|
||||||
|
|
||||||
|
private:
|
||||||
|
MouseParameters(const MouseParameters&);
|
||||||
|
const MouseParameters& operator = (const MouseParameters&);
|
||||||
|
|
||||||
|
Navigation fNavigation;
|
||||||
|
Pivot fPivot;
|
||||||
|
PivotVisibility fPivotVisibility;
|
||||||
|
bool fIsLockHorizon;
|
||||||
|
|
||||||
|
bool fIsPanZoom;
|
||||||
|
bool fIsRotate;
|
||||||
|
Speed fSpeed;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ConnexionClient : public QObject, public QAbstractNativeEventFilter {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ConnexionClient();
|
||||||
|
~ConnexionClient();
|
||||||
|
|
||||||
|
static ConnexionClient& getInstance();
|
||||||
|
|
||||||
|
ConnexionClient* client;
|
||||||
|
static void init();
|
||||||
|
static void destroy();
|
||||||
|
|
||||||
|
static bool Is3dmouseAttached();
|
||||||
|
|
||||||
|
I3dMouseParam& MouseParams();
|
||||||
|
const I3dMouseParam& MouseParams() const;
|
||||||
|
|
||||||
|
virtual void Move3d(HANDLE device, std::vector<float>& motionData);
|
||||||
|
virtual void On3dmouseKeyDown(HANDLE device, int virtualKeyCode);
|
||||||
|
virtual void On3dmouseKeyUp(HANDLE device, int virtualKeyCode);
|
||||||
|
|
||||||
|
virtual bool nativeEventFilter(const QByteArray& eventType, void* message, long* result) Q_DECL_OVERRIDE
|
||||||
|
{
|
||||||
|
MSG* msg = static_cast< MSG * >(message);
|
||||||
|
return ConnexionClient::RawInputEventFilter(message, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void toggleConnexion(bool shouldEnable);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void Move3d(std::vector<float>& motionData);
|
||||||
|
void On3dmouseKeyDown(int virtualKeyCode);
|
||||||
|
void On3dmouseKeyUp(int virtualKeyCode);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool InitializeRawInput(HWND hwndTarget);
|
||||||
|
|
||||||
|
static bool RawInputEventFilter(void* msg, long* result);
|
||||||
|
|
||||||
|
void OnRawInput(UINT nInputCode, HRAWINPUT hRawInput);
|
||||||
|
UINT GetRawInputBuffer(PRAWINPUT pData, PUINT pcbSize, UINT cbSizeHeader);
|
||||||
|
bool TranslateRawInputData(UINT nInputCode, PRAWINPUT pRawInput);
|
||||||
|
void On3dmouseInput();
|
||||||
|
|
||||||
|
class TInputData {
|
||||||
|
public:
|
||||||
|
TInputData() : fAxes(6) {}
|
||||||
|
|
||||||
|
bool IsZero() {
|
||||||
|
return (0.0f == fAxes[0] && 0.0f == fAxes[1] && 0.0f == fAxes[2] &&
|
||||||
|
0.0f == fAxes[3] && 0.0f == fAxes[4] && 0.0f == fAxes[5]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int fTimeToLive; // For telling if the device was unplugged while sending data
|
||||||
|
bool fIsDirty;
|
||||||
|
std::vector<float> fAxes;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
HWND fWindow;
|
||||||
|
|
||||||
|
// Data cache to handle multiple rawinput devices
|
||||||
|
std::map< HANDLE, TInputData> fDevice2Data;
|
||||||
|
std::map< HANDLE, unsigned long> fDevice2Keystate;
|
||||||
|
|
||||||
|
// 3dmouse parameters
|
||||||
|
MouseParameters f3dMouseParams; // Rotate, Pan Zoom etc.
|
||||||
|
|
||||||
|
// use to calculate distance traveled since last event
|
||||||
|
DWORD fLast3dmouseInputTime;
|
||||||
|
};
|
||||||
|
|
||||||
|
// the osx connexion api
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <glm/glm.hpp>
|
||||||
|
#include "3DconnexionClient/ConnexionClientAPI.h"
|
||||||
|
|
||||||
|
class ConnexionClient : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
static ConnexionClient& getInstance();
|
||||||
|
static bool Is3dmouseAttached();
|
||||||
|
static void init();
|
||||||
|
static void destroy();
|
||||||
|
public slots:
|
||||||
|
void toggleConnexion(bool shouldEnable);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __APPLE__
|
||||||
|
|
||||||
|
#endif // HAVE_CONNEXIONCLIENT
|
||||||
|
|
||||||
|
|
||||||
|
// connnects to the userinputmapper
|
||||||
|
class ConnexionData : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
static ConnexionData& getInstance();
|
||||||
|
ConnexionData();
|
||||||
|
|
||||||
|
enum PositionChannel {
|
||||||
|
POSITION_AXIS_X_POS = 1,
|
||||||
|
POSITION_AXIS_X_NEG = 2,
|
||||||
|
POSITION_AXIS_Y_POS = 3,
|
||||||
|
POSITION_AXIS_Y_NEG = 4,
|
||||||
|
POSITION_AXIS_Z_POS = 5,
|
||||||
|
POSITION_AXIS_Z_NEG = 6,
|
||||||
|
ROTATION_AXIS_X_POS = 7,
|
||||||
|
ROTATION_AXIS_X_NEG = 8,
|
||||||
|
ROTATION_AXIS_Y_POS = 9,
|
||||||
|
ROTATION_AXIS_Y_NEG = 10,
|
||||||
|
ROTATION_AXIS_Z_POS = 11,
|
||||||
|
ROTATION_AXIS_Z_NEG = 12
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ButtonChannel {
|
||||||
|
BUTTON_1 = 1,
|
||||||
|
BUTTON_2 = 2,
|
||||||
|
BUTTON_3 = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::unordered_set<int> ButtonPressedMap;
|
||||||
|
typedef std::map<int, float> AxisStateMap;
|
||||||
|
|
||||||
|
float getButton(int channel) const;
|
||||||
|
float getAxis(int channel) const;
|
||||||
|
|
||||||
|
UserInputMapper::Input makeInput(ConnexionData::PositionChannel axis);
|
||||||
|
UserInputMapper::Input makeInput(ConnexionData::ButtonChannel button);
|
||||||
|
|
||||||
|
void registerToUserInputMapper(UserInputMapper& mapper);
|
||||||
|
void assignDefaultInputMapping(UserInputMapper& mapper);
|
||||||
|
|
||||||
|
void update();
|
||||||
|
void focusOutEvent();
|
||||||
|
|
||||||
|
int getDeviceID() { return _deviceID; }
|
||||||
|
void setDeviceID(int deviceID) { _deviceID = deviceID; }
|
||||||
|
|
||||||
|
QString _name;
|
||||||
|
|
||||||
|
glm::vec3 cc_position;
|
||||||
|
glm::vec3 cc_rotation;
|
||||||
|
int clientId;
|
||||||
|
|
||||||
|
void setButton(int lastButtonState);
|
||||||
|
void handleAxisEvent();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int _deviceID = 0;
|
||||||
|
|
||||||
|
ButtonPressedMap _buttonPressedMap;
|
||||||
|
AxisStateMap _axisStateMap;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // defined(hifi_ConnexionClient_h)
|
86
libraries/render-utils/src/HitEffect.cpp
Normal file
86
libraries/render-utils/src/HitEffect.cpp
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
//
|
||||||
|
// HitEffect.cpp
|
||||||
|
// interface/src/renderer
|
||||||
|
//
|
||||||
|
// Created by Andrzej Kapolka on 7/14/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 this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL
|
||||||
|
|
||||||
|
|
||||||
|
#include <glm/gtc/random.hpp>
|
||||||
|
|
||||||
|
#include <PathUtils.h>
|
||||||
|
#include <SharedUtil.h>
|
||||||
|
|
||||||
|
#include "AbstractViewStateInterface.h"
|
||||||
|
#include "HitEffect.h"
|
||||||
|
#include "TextureCache.h"
|
||||||
|
#include "DependencyManager.h"
|
||||||
|
#include "ViewFrustum.h"
|
||||||
|
#include "GeometryCache.h"
|
||||||
|
|
||||||
|
#include <gpu/Context.h>
|
||||||
|
|
||||||
|
#include "hit_effect_vert.h"
|
||||||
|
#include "hit_effect_frag.h"
|
||||||
|
|
||||||
|
|
||||||
|
HitEffect::HitEffect() {
|
||||||
|
}
|
||||||
|
|
||||||
|
const gpu::PipelinePointer& HitEffect::getHitEffectPipeline() {
|
||||||
|
if (!_hitEffectPipeline) {
|
||||||
|
auto vs = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(hit_effect_vert)));
|
||||||
|
auto ps = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(hit_effect_frag)));
|
||||||
|
gpu::ShaderPointer program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps));
|
||||||
|
|
||||||
|
|
||||||
|
gpu::Shader::BindingSet slotBindings;
|
||||||
|
gpu::Shader::makeProgram(*program, slotBindings);
|
||||||
|
|
||||||
|
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||||
|
|
||||||
|
state->setDepthTest(false, false, gpu::LESS_EQUAL);
|
||||||
|
|
||||||
|
// Blend on transparent
|
||||||
|
state->setBlendFunction(true,
|
||||||
|
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA);
|
||||||
|
|
||||||
|
// Good to go add the brand new pipeline
|
||||||
|
_hitEffectPipeline.reset(gpu::Pipeline::create(program, state));
|
||||||
|
}
|
||||||
|
return _hitEffectPipeline;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HitEffect::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext) {
|
||||||
|
assert(renderContext->args);
|
||||||
|
assert(renderContext->args->_viewFrustum);
|
||||||
|
RenderArgs* args = renderContext->args;
|
||||||
|
gpu::Batch batch;
|
||||||
|
|
||||||
|
glm::mat4 projMat;
|
||||||
|
Transform viewMat;
|
||||||
|
args->_viewFrustum->evalProjectionMatrix(projMat);
|
||||||
|
args->_viewFrustum->evalViewTransform(viewMat);
|
||||||
|
batch.setProjectionTransform(projMat);
|
||||||
|
batch.setViewTransform(viewMat);
|
||||||
|
batch.setModelTransform(Transform());
|
||||||
|
|
||||||
|
batch.setPipeline(getHitEffectPipeline());
|
||||||
|
|
||||||
|
glm::vec4 color(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
glm::vec2 bottomLeft(-1.0f, -1.0f);
|
||||||
|
glm::vec2 topRight(1.0f, 1.0f);
|
||||||
|
DependencyManager::get<GeometryCache>()->renderQuad(batch, bottomLeft, topRight, color);
|
||||||
|
|
||||||
|
|
||||||
|
// Ready to render
|
||||||
|
args->_context->render((batch));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
33
libraries/render-utils/src/HitEffect.h
Normal file
33
libraries/render-utils/src/HitEffect.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
//
|
||||||
|
// hitEffect.h
|
||||||
|
// hifi
|
||||||
|
//
|
||||||
|
// Created by eric levin on 7/17/15.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_hitEffect_h
|
||||||
|
#define hifi_hitEffect_h
|
||||||
|
|
||||||
|
#include <DependencyManager.h>
|
||||||
|
#include "render/DrawTask.h"
|
||||||
|
|
||||||
|
class AbstractViewStateInterface;
|
||||||
|
class ProgramObject;
|
||||||
|
|
||||||
|
class HitEffect {
|
||||||
|
public:
|
||||||
|
|
||||||
|
HitEffect();
|
||||||
|
|
||||||
|
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
|
||||||
|
typedef render::Job::Model<HitEffect> JobModel;
|
||||||
|
|
||||||
|
const gpu::PipelinePointer& getHitEffectPipeline();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
gpu::PipelinePointer _hitEffectPipeline;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
//
|
//
|
||||||
// RenderDeferredTask.cpp
|
// RenderDeferredTask.cpp
|
||||||
// render-utils/src/
|
// render-utils/src/
|
||||||
|
@ -20,6 +21,7 @@
|
||||||
#include "FramebufferCache.h"
|
#include "FramebufferCache.h"
|
||||||
#include "DeferredLightingEffect.h"
|
#include "DeferredLightingEffect.h"
|
||||||
#include "TextureCache.h"
|
#include "TextureCache.h"
|
||||||
|
#include "HitEffect.h"
|
||||||
|
|
||||||
#include "render/DrawStatus.h"
|
#include "render/DrawStatus.h"
|
||||||
#include "AmbientOcclusionEffect.h"
|
#include "AmbientOcclusionEffect.h"
|
||||||
|
@ -78,6 +80,7 @@ RenderDeferredTask::RenderDeferredTask() : Task() {
|
||||||
_jobs.push_back(Job(new DepthSortItems::JobModel("DepthSortOpaque", _jobs.back().getOutput())));
|
_jobs.push_back(Job(new DepthSortItems::JobModel("DepthSortOpaque", _jobs.back().getOutput())));
|
||||||
auto& renderedOpaques = _jobs.back().getOutput();
|
auto& renderedOpaques = _jobs.back().getOutput();
|
||||||
_jobs.push_back(Job(new DrawOpaqueDeferred::JobModel("DrawOpaqueDeferred", _jobs.back().getOutput())));
|
_jobs.push_back(Job(new DrawOpaqueDeferred::JobModel("DrawOpaqueDeferred", _jobs.back().getOutput())));
|
||||||
|
|
||||||
_jobs.push_back(Job(new DrawLight::JobModel("DrawLight")));
|
_jobs.push_back(Job(new DrawLight::JobModel("DrawLight")));
|
||||||
_jobs.push_back(Job(new RenderDeferred::JobModel("RenderDeferred")));
|
_jobs.push_back(Job(new RenderDeferred::JobModel("RenderDeferred")));
|
||||||
_jobs.push_back(Job(new ResolveDeferred::JobModel("ResolveDeferred")));
|
_jobs.push_back(Job(new ResolveDeferred::JobModel("ResolveDeferred")));
|
||||||
|
@ -105,9 +108,14 @@ RenderDeferredTask::RenderDeferredTask() : Task() {
|
||||||
_drawStatusJobIndex = _jobs.size() - 1;
|
_drawStatusJobIndex = _jobs.size() - 1;
|
||||||
|
|
||||||
_jobs.push_back(Job(new DrawOverlay3D::JobModel("DrawOverlay3D")));
|
_jobs.push_back(Job(new DrawOverlay3D::JobModel("DrawOverlay3D")));
|
||||||
|
_jobs.push_back(Job(new HitEffect::JobModel("HitEffect")));
|
||||||
|
_jobs.back().setEnabled(false);
|
||||||
|
_drawHitEffectJobIndex = _jobs.size() -1;
|
||||||
|
|
||||||
|
|
||||||
_jobs.push_back(Job(new ResetGLState::JobModel()));
|
_jobs.push_back(Job(new ResetGLState::JobModel()));
|
||||||
|
|
||||||
|
|
||||||
// Give ourselves 3 frmaes of timer queries
|
// Give ourselves 3 frmaes of timer queries
|
||||||
_timerQueries.push_back(std::make_shared<gpu::Query>());
|
_timerQueries.push_back(std::make_shared<gpu::Query>());
|
||||||
_timerQueries.push_back(std::make_shared<gpu::Query>());
|
_timerQueries.push_back(std::make_shared<gpu::Query>());
|
||||||
|
@ -134,6 +142,10 @@ void RenderDeferredTask::run(const SceneContextPointer& sceneContext, const Rend
|
||||||
// Make sure we turn the displayItemStatus on/off
|
// Make sure we turn the displayItemStatus on/off
|
||||||
setDrawItemStatus(renderContext->_drawItemStatus);
|
setDrawItemStatus(renderContext->_drawItemStatus);
|
||||||
|
|
||||||
|
//Make sure we display hit effect on screen, as desired from a script
|
||||||
|
setDrawHitEffect(renderContext->_drawHitEffect);
|
||||||
|
|
||||||
|
|
||||||
// TODO: turn on/off AO through menu item
|
// TODO: turn on/off AO through menu item
|
||||||
setOcclusionStatus(renderContext->_occlusionStatus);
|
setOcclusionStatus(renderContext->_occlusionStatus);
|
||||||
|
|
||||||
|
|
|
@ -78,10 +78,14 @@ public:
|
||||||
render::Jobs _jobs;
|
render::Jobs _jobs;
|
||||||
|
|
||||||
int _drawStatusJobIndex = -1;
|
int _drawStatusJobIndex = -1;
|
||||||
|
int _drawHitEffectJobIndex = -1;
|
||||||
|
|
||||||
void setDrawItemStatus(bool draw) { if (_drawStatusJobIndex >= 0) { _jobs[_drawStatusJobIndex].setEnabled(draw); } }
|
void setDrawItemStatus(bool draw) { if (_drawStatusJobIndex >= 0) { _jobs[_drawStatusJobIndex].setEnabled(draw); } }
|
||||||
bool doDrawItemStatus() const { if (_drawStatusJobIndex >= 0) { return _jobs[_drawStatusJobIndex].isEnabled(); } else { return false; } }
|
bool doDrawItemStatus() const { if (_drawStatusJobIndex >= 0) { return _jobs[_drawStatusJobIndex].isEnabled(); } else { return false; } }
|
||||||
|
|
||||||
|
void setDrawHitEffect(bool draw) { if (_drawHitEffectJobIndex >= 0) { _jobs[_drawHitEffectJobIndex].setEnabled(draw); } }
|
||||||
|
bool doDrawHitEffect() const { if (_drawHitEffectJobIndex >=0) { return _jobs[_drawHitEffectJobIndex].isEnabled(); } else { return false; } }
|
||||||
|
|
||||||
int _occlusionJobIndex = -1;
|
int _occlusionJobIndex = -1;
|
||||||
|
|
||||||
void setOcclusionStatus(bool draw) { if (_occlusionJobIndex >= 0) { _jobs[_occlusionJobIndex].setEnabled(draw); } }
|
void setOcclusionStatus(bool draw) { if (_occlusionJobIndex >= 0) { _jobs[_occlusionJobIndex].setEnabled(draw); } }
|
||||||
|
|
24
libraries/render-utils/src/hit_effect.slf
Normal file
24
libraries/render-utils/src/hit_effect.slf
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<@include gpu/Config.slh@>
|
||||||
|
<$VERSION_HEADER$>
|
||||||
|
// Generated on <$_SCRIBE_DATE$>
|
||||||
|
//
|
||||||
|
// hit_effect.frag
|
||||||
|
// fragment shader
|
||||||
|
//
|
||||||
|
// Created by Eric Levin on 7/20
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
<@include DeferredBufferWrite.slh@>
|
||||||
|
|
||||||
|
varying vec2 varQuadPosition;
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
vec2 center = vec2(0.0, 0.0);
|
||||||
|
float distFromCenter = distance( vec2(0.0, 0.0), varQuadPosition);
|
||||||
|
float alpha = mix(0.0, 0.5, pow(distFromCenter,5.));
|
||||||
|
gl_FragColor = vec4(1.0, 0.0, 0.0, alpha);
|
||||||
|
}
|
24
libraries/render-utils/src/hit_effect.slv
Normal file
24
libraries/render-utils/src/hit_effect.slv
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<@include gpu/Config.slh@>
|
||||||
|
<$VERSION_HEADER$>
|
||||||
|
// Generated on <$_SCRIBE_DATE$>
|
||||||
|
//
|
||||||
|
// hit_effect.vert
|
||||||
|
// vertex shader
|
||||||
|
//
|
||||||
|
// Created by Eric Levin on 7/20/15.
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
<@include gpu/Transform.slh@>
|
||||||
|
|
||||||
|
<$declareStandardTransform()$>
|
||||||
|
|
||||||
|
varying vec2 varQuadPosition;
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
varQuadPosition = gl_Vertex.xy;
|
||||||
|
gl_Position = gl_Vertex;
|
||||||
|
}
|
|
@ -50,6 +50,7 @@ public:
|
||||||
int _maxDrawnOverlay3DItems = -1;
|
int _maxDrawnOverlay3DItems = -1;
|
||||||
|
|
||||||
bool _drawItemStatus = false;
|
bool _drawItemStatus = false;
|
||||||
|
bool _drawHitEffect = false;
|
||||||
|
|
||||||
bool _occlusionStatus = false;
|
bool _occlusionStatus = false;
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,9 @@ public:
|
||||||
Q_INVOKABLE void setEngineDisplayItemStatus(bool display) { _drawItemStatus = display; }
|
Q_INVOKABLE void setEngineDisplayItemStatus(bool display) { _drawItemStatus = display; }
|
||||||
Q_INVOKABLE bool doEngineDisplayItemStatus() { return _drawItemStatus; }
|
Q_INVOKABLE bool doEngineDisplayItemStatus() { return _drawItemStatus; }
|
||||||
|
|
||||||
|
Q_INVOKABLE void setEngineDisplayHitEffect(bool display) { _drawHitEffect = display; }
|
||||||
|
Q_INVOKABLE bool doEngineDisplayHitEffect() { return _drawHitEffect; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void shouldRenderAvatarsChanged(bool shouldRenderAvatars);
|
void shouldRenderAvatarsChanged(bool shouldRenderAvatars);
|
||||||
void shouldRenderEntitiesChanged(bool shouldRenderEntities);
|
void shouldRenderEntitiesChanged(bool shouldRenderEntities);
|
||||||
|
@ -142,6 +145,8 @@ protected:
|
||||||
|
|
||||||
bool _drawItemStatus = false;
|
bool _drawItemStatus = false;
|
||||||
|
|
||||||
|
bool _drawHitEffect = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_SceneScriptingInterface_h
|
#endif // hifi_SceneScriptingInterface_h
|
||||||
|
|
|
@ -106,6 +106,7 @@ public:
|
||||||
CachesSize,
|
CachesSize,
|
||||||
Chat,
|
Chat,
|
||||||
Collisions,
|
Collisions,
|
||||||
|
Connexion,
|
||||||
Console,
|
Console,
|
||||||
ControlWithSpeech,
|
ControlWithSpeech,
|
||||||
CopyAddress,
|
CopyAddress,
|
||||||
|
|
Loading…
Reference in a new issue