mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 06:03:26 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into branchJS
This commit is contained in:
commit
f9ebbea585
28 changed files with 688 additions and 330 deletions
2
BUILD.md
2
BUILD.md
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
* [cmake](http://www.cmake.org/cmake/resources/software.html) ~> 2.8.12.2
|
* [cmake](http://www.cmake.org/cmake/resources/software.html) ~> 2.8.12.2
|
||||||
* [Qt](http://www.qt.io/download-open-source) ~> 5.4.1
|
* [Qt](http://www.qt.io/download-open-source) ~> 5.4.1
|
||||||
* [OpenSSL](https://www.openssl.org/related/binaries.html) ~> 1.0.1m
|
* [OpenSSL](https://www.openssl.org/community/binaries.html) ~> 1.0.1m
|
||||||
* IMPORTANT: Using the recommended version of OpenSSL is critical to avoid security vulnerabilities.
|
* IMPORTANT: Using the recommended version of OpenSSL is critical to avoid security vulnerabilities.
|
||||||
* [VHACD](https://github.com/virneo/v-hacd)(clone this repository)(Optional)
|
* [VHACD](https://github.com/virneo/v-hacd)(clone this repository)(Optional)
|
||||||
|
|
||||||
|
|
|
@ -267,7 +267,10 @@ void Agent::processAgentAvatarAndAudio(float deltaTime) {
|
||||||
|
|
||||||
QByteArray avatarByteArray = _avatarData->toByteArray(true, randFloat() < AVATAR_SEND_FULL_UPDATE_RATIO);
|
QByteArray avatarByteArray = _avatarData->toByteArray(true, randFloat() < AVATAR_SEND_FULL_UPDATE_RATIO);
|
||||||
_avatarData->doneEncoding(true);
|
_avatarData->doneEncoding(true);
|
||||||
auto avatarPacket = NLPacket::create(PacketType::AvatarData, avatarByteArray.size());
|
|
||||||
|
static AvatarDataSequenceNumber sequenceNumber = 0;
|
||||||
|
auto avatarPacket = NLPacket::create(PacketType::AvatarData, avatarByteArray.size() + sizeof(sequenceNumber));
|
||||||
|
avatarPacket->writePrimitive(sequenceNumber++);
|
||||||
|
|
||||||
avatarPacket->write(avatarByteArray);
|
avatarPacket->write(avatarByteArray);
|
||||||
|
|
||||||
|
|
129
examples/away.js
Normal file
129
examples/away.js
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
"use strict";
|
||||||
|
/*jslint vars: true, plusplus: true*/
|
||||||
|
/*global HMD, AudioDevice, MyAvatar, Controller, Script, Overlays, print*/
|
||||||
|
//
|
||||||
|
// away.js
|
||||||
|
// examples
|
||||||
|
//
|
||||||
|
// Created by Howard Stearns 11/3/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
|
||||||
|
//
|
||||||
|
// Goes into "paused" when the '.' key (and automatically when started in HMD), and normal when pressing any key.
|
||||||
|
// See MAIN CONTROL, below, for what "paused" actually does.
|
||||||
|
|
||||||
|
var IK_WINDOW_AFTER_GOING_ACTIVE = 3000; // milliseconds
|
||||||
|
var OVERLAY_DATA = {
|
||||||
|
text: "Paused:\npress any key to continue",
|
||||||
|
font: {size: 75},
|
||||||
|
color: {red: 200, green: 255, blue: 255},
|
||||||
|
alpha: 0.9
|
||||||
|
};
|
||||||
|
|
||||||
|
// ANIMATION
|
||||||
|
// We currently don't have play/stopAnimation integrated with the animation graph, but we can get the same effect
|
||||||
|
// using an animation graph with a state that we turn on and off through the animation var defined with that state.
|
||||||
|
var awayAnimationHandlerId, activeAnimationHandlerId, stopper;
|
||||||
|
function playAwayAnimation() {
|
||||||
|
function animateAway() {
|
||||||
|
return {isAway: true, isNotAway: false, isNotMoving: false, ikOverlayAlpha: 0.0};
|
||||||
|
}
|
||||||
|
if (stopper) {
|
||||||
|
Script.clearTimeout(stopper);
|
||||||
|
stopper = false;
|
||||||
|
MyAvatar.removeAnimationStateHandler(activeAnimationHandlerId); // do it now, before making new assignment
|
||||||
|
}
|
||||||
|
awayAnimationHandlerId = MyAvatar.addAnimationStateHandler(animateAway, null);
|
||||||
|
}
|
||||||
|
function stopAwayAnimation() {
|
||||||
|
MyAvatar.removeAnimationStateHandler(awayAnimationHandlerId);
|
||||||
|
if (stopper) {
|
||||||
|
print('WARNING: unexpected double stop');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// How do we know when to turn ikOverlayAlpha back on?
|
||||||
|
// It cannot be as soon as we want to stop the away animation, because then things will look goofy as we come out of that animation.
|
||||||
|
// (Imagine an away animation that sits or kneels, and then stands back up when coming out of it. If head is at the HMD, then it won't
|
||||||
|
// want to track the standing up animation.)
|
||||||
|
// Our standard anim graph flips 'awayOutroOnDone' for one frame, but it's a trigger (not an animVar) and other folks might use different graphs.
|
||||||
|
// So... Just give us a fixed amount of time to be done with animation, before we turn ik back on.
|
||||||
|
var backToNormal = false;
|
||||||
|
stopper = Script.setTimeout(function () {
|
||||||
|
backToNormal = true;
|
||||||
|
stopper = false;
|
||||||
|
}, IK_WINDOW_AFTER_GOING_ACTIVE);
|
||||||
|
function animateActive(state) {
|
||||||
|
if (state.ikOverlayAlpha) {
|
||||||
|
// Once the right state gets reflected back to us, we don't need the hander any more.
|
||||||
|
// But we are locked against handler changes during the execution of a handler, so remove asynchronously.
|
||||||
|
Script.setTimeout(function () { MyAvatar.removeAnimationStateHandler(activeAnimationHandlerId); }, 0);
|
||||||
|
}
|
||||||
|
// It might be cool to "come back to life" by fading the ik overlay back in over a short time. But let's see how this goes.
|
||||||
|
return {isAway: false, isNotAway: true, ikOverlayAlpha: backToNormal ? 1.0 : 0.0}; // IWBNI we had a way of deleting an anim var.
|
||||||
|
}
|
||||||
|
activeAnimationHandlerId = MyAvatar.addAnimationStateHandler(animateActive, ['isAway', 'isNotAway', 'isNotMoving', 'ikOverlayAlpha']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// OVERLAY
|
||||||
|
var overlay = Overlays.addOverlay("text", OVERLAY_DATA);
|
||||||
|
function showOverlay() {
|
||||||
|
var screen = Controller.getViewportDimensions();
|
||||||
|
Overlays.editOverlay(overlay, {visible: true, x: screen.x / 4, y: screen.y / 4});
|
||||||
|
}
|
||||||
|
function hideOverlay() {
|
||||||
|
Overlays.editOverlay(overlay, {visible: false});
|
||||||
|
}
|
||||||
|
hideOverlay();
|
||||||
|
|
||||||
|
|
||||||
|
// MAIN CONTROL
|
||||||
|
var wasMuted, isAway;
|
||||||
|
function goAway() {
|
||||||
|
if (isAway) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isAway = true;
|
||||||
|
print('going "away"');
|
||||||
|
wasMuted = AudioDevice.getMuted();
|
||||||
|
if (!wasMuted) {
|
||||||
|
AudioDevice.toggleMute();
|
||||||
|
}
|
||||||
|
MyAvatar.setEnableMeshVisible(false); // just for our own display, without changing point of view
|
||||||
|
playAwayAnimation(); // animation is still seen by others
|
||||||
|
showOverlay();
|
||||||
|
}
|
||||||
|
function goActive() {
|
||||||
|
if (!isAway) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isAway = false;
|
||||||
|
print('going "active"');
|
||||||
|
if (!wasMuted) {
|
||||||
|
AudioDevice.toggleMute();
|
||||||
|
}
|
||||||
|
MyAvatar.setEnableMeshVisible(true); // IWBNI we respected Developer->Avatar->Draw Mesh setting.
|
||||||
|
stopAwayAnimation();
|
||||||
|
hideOverlay();
|
||||||
|
}
|
||||||
|
Script.scriptEnding.connect(goActive);
|
||||||
|
Controller.keyPressEvent.connect(function (event) {
|
||||||
|
if (event.isAutoRepeat) { // isAutoRepeat is true when held down (or when Windows feels like it)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!isAway && (event.text === '.')) {
|
||||||
|
goAway();
|
||||||
|
} else {
|
||||||
|
goActive();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var wasHmdActive = false;
|
||||||
|
Script.update.connect(function () {
|
||||||
|
if (HMD.active !== wasHmdActive) {
|
||||||
|
wasHmdActive = !wasHmdActive;
|
||||||
|
if (wasHmdActive) {
|
||||||
|
goAway();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
72
examples/controllers/Spacemouse/spacemouseExample.js
Normal file
72
examples/controllers/Spacemouse/spacemouseExample.js
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
//
|
||||||
|
// spaceMouseDebug.js
|
||||||
|
// examples
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var firstmove = 1;
|
||||||
|
var position = {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
};
|
||||||
|
var rotation = {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
};
|
||||||
|
|
||||||
|
function toggleFirstMove() {
|
||||||
|
if(firstmove){
|
||||||
|
print("____________________________________");
|
||||||
|
firstmove = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function spacemouseCheck() {
|
||||||
|
return Controller.Hardware.Spacemouse !== undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function update(deltaTime) {
|
||||||
|
if(spacemouseCheck){
|
||||||
|
if(Controller.getValue(Controller.Standard.LY) != 0){
|
||||||
|
toggleFirstMove();
|
||||||
|
print("- Controller TY: " + Controller.getValue(Controller.Standard.LY));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Controller.getValue(Controller.Standard.LX) != 0){
|
||||||
|
toggleFirstMove();
|
||||||
|
print("- Controller RZ: " + Controller.getValue(Controller.Standard.LX));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Controller.getValue(Controller.Standard.LB) != 0){
|
||||||
|
toggleFirstMove();
|
||||||
|
print("- Controller LEFTB: " + Controller.getValue(Controller.Standard.LB));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Controller.getValue(Controller.Standard.RY) != 0){
|
||||||
|
toggleFirstMove();
|
||||||
|
print("- Controller TZ: " + Controller.getValue(Controller.Standard.RY));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Controller.getValue(Controller.Standard.RX) != 0){
|
||||||
|
toggleFirstMove();
|
||||||
|
print("- Controller TX: " + Controller.getValue(Controller.Standard.RX));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Controller.getValue(Controller.Standard.RB) != 0){
|
||||||
|
toggleFirstMove();
|
||||||
|
print("- Controller RIGHTB: " + Controller.getValue(Controller.Standard.RB));
|
||||||
|
}
|
||||||
|
|
||||||
|
firstmove = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.update.connect(update);
|
|
@ -101,10 +101,10 @@ var STATE_DISTANCE_HOLDING = 2;
|
||||||
var STATE_CONTINUE_DISTANCE_HOLDING = 3;
|
var STATE_CONTINUE_DISTANCE_HOLDING = 3;
|
||||||
var STATE_NEAR_GRABBING = 4;
|
var STATE_NEAR_GRABBING = 4;
|
||||||
var STATE_CONTINUE_NEAR_GRABBING = 5;
|
var STATE_CONTINUE_NEAR_GRABBING = 5;
|
||||||
var STATE_NEAR_GRABBING_NON_COLLIDING = 6;
|
var STATE_NEAR_TRIGGER = 6;
|
||||||
var STATE_CONTINUE_NEAR_GRABBING_NON_COLLIDING = 7;
|
var STATE_CONTINUE_NEAR_TRIGGER = 7;
|
||||||
var STATE_FAR_GRABBING_NON_COLLIDING = 8;
|
var STATE_FAR_TRIGGER = 8;
|
||||||
var STATE_CONTINUE_FAR_GRABBING_NON_COLLIDING = 9;
|
var STATE_CONTINUE_FAR_TRIGGER = 9;
|
||||||
var STATE_RELEASE = 10;
|
var STATE_RELEASE = 10;
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,14 +122,14 @@ function stateToName(state) {
|
||||||
return "near_grabbing";
|
return "near_grabbing";
|
||||||
case STATE_CONTINUE_NEAR_GRABBING:
|
case STATE_CONTINUE_NEAR_GRABBING:
|
||||||
return "continue_near_grabbing";
|
return "continue_near_grabbing";
|
||||||
case STATE_NEAR_GRABBING_NON_COLLIDING:
|
case STATE_NEAR_TRIGGER:
|
||||||
return "near_grabbing_non_colliding";
|
return "near_trigger";
|
||||||
case STATE_CONTINUE_NEAR_GRABBING_NON_COLLIDING:
|
case STATE_CONTINUE_NEAR_TRIGGER:
|
||||||
return "continue_near_grabbing_non_colliding";
|
return "continue_near_trigger";
|
||||||
case STATE_FAR_GRABBING_NON_COLLIDING:
|
case STATE_FAR_TRIGGER:
|
||||||
return "far_grabbing_non_colliding";
|
return "far_trigger";
|
||||||
case STATE_CONTINUE_FAR_GRABBING_NON_COLLIDING:
|
case STATE_CONTINUE_FAR_TRIGGER:
|
||||||
return "continue_far_grabbing_non_colliding";
|
return "continue_far_trigger";
|
||||||
case STATE_RELEASE:
|
case STATE_RELEASE:
|
||||||
return "release";
|
return "release";
|
||||||
}
|
}
|
||||||
|
@ -212,17 +212,17 @@ function MyController(hand) {
|
||||||
case STATE_CONTINUE_NEAR_GRABBING:
|
case STATE_CONTINUE_NEAR_GRABBING:
|
||||||
this.continueNearGrabbing();
|
this.continueNearGrabbing();
|
||||||
break;
|
break;
|
||||||
case STATE_NEAR_GRABBING_NON_COLLIDING:
|
case STATE_NEAR_TRIGGER:
|
||||||
this.nearGrabbingNonColliding();
|
this.nearTrigger();
|
||||||
break;
|
break;
|
||||||
case STATE_CONTINUE_NEAR_GRABBING_NON_COLLIDING:
|
case STATE_CONTINUE_NEAR_TRIGGER:
|
||||||
this.continueNearGrabbingNonColliding();
|
this.continueNearTrigger();
|
||||||
break;
|
break;
|
||||||
case STATE_FAR_GRABBING_NON_COLLIDING:
|
case STATE_FAR_TRIGGER:
|
||||||
this.farGrabbingNonColliding();
|
this.farTrigger();
|
||||||
break;
|
break;
|
||||||
case STATE_CONTINUE_FAR_GRABBING_NON_COLLIDING:
|
case STATE_CONTINUE_FAR_TRIGGER:
|
||||||
this.continueFarGrabbingNonColliding();
|
this.continueFarTrigger();
|
||||||
break;
|
break;
|
||||||
case STATE_RELEASE:
|
case STATE_RELEASE:
|
||||||
this.release();
|
this.release();
|
||||||
|
@ -394,7 +394,7 @@ function MyController(hand) {
|
||||||
// the hand is very close to the intersected object. go into close-grabbing mode.
|
// the hand is very close to the intersected object. go into close-grabbing mode.
|
||||||
if (grabbableData.wantsTrigger) {
|
if (grabbableData.wantsTrigger) {
|
||||||
this.grabbedEntity = intersection.entityID;
|
this.grabbedEntity = intersection.entityID;
|
||||||
this.setState(STATE_NEAR_GRABBING_NON_COLLIDING);
|
this.setState(STATE_NEAR_TRIGGER);
|
||||||
return;
|
return;
|
||||||
} else if (!intersection.properties.locked) {
|
} else if (!intersection.properties.locked) {
|
||||||
this.grabbedEntity = intersection.entityID;
|
this.grabbedEntity = intersection.entityID;
|
||||||
|
@ -411,7 +411,7 @@ function MyController(hand) {
|
||||||
return;
|
return;
|
||||||
} else if (grabbableData.wantsTrigger) {
|
} else if (grabbableData.wantsTrigger) {
|
||||||
this.grabbedEntity = intersection.entityID;
|
this.grabbedEntity = intersection.entityID;
|
||||||
this.setState(STATE_FAR_GRABBING_NON_COLLIDING);
|
this.setState(STATE_FAR_TRIGGER);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -455,6 +455,10 @@ function MyController(hand) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (propsForCandidate.type == 'PolyLine') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (propsForCandidate.type == 'Zone') {
|
if (propsForCandidate.type == 'Zone') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -483,7 +487,7 @@ function MyController(hand) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (grabbableData.wantsTrigger) {
|
if (grabbableData.wantsTrigger) {
|
||||||
this.setState(STATE_NEAR_GRABBING_NON_COLLIDING);
|
this.setState(STATE_NEAR_TRIGGER);
|
||||||
return;
|
return;
|
||||||
} else if (!props.locked) {
|
} else if (!props.locked) {
|
||||||
this.setState(STATE_NEAR_GRABBING);
|
this.setState(STATE_NEAR_GRABBING);
|
||||||
|
@ -538,6 +542,7 @@ function MyController(hand) {
|
||||||
this.continueDistanceHolding = function() {
|
this.continueDistanceHolding = function() {
|
||||||
if (this.triggerSmoothedReleased()) {
|
if (this.triggerSmoothedReleased()) {
|
||||||
this.setState(STATE_RELEASE);
|
this.setState(STATE_RELEASE);
|
||||||
|
Entities.callEntityMethod(this.grabbedEntity, "releaseGrab");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -631,6 +636,7 @@ function MyController(hand) {
|
||||||
|
|
||||||
if (this.triggerSmoothedReleased()) {
|
if (this.triggerSmoothedReleased()) {
|
||||||
this.setState(STATE_RELEASE);
|
this.setState(STATE_RELEASE);
|
||||||
|
Entities.callEntityMethod(this.grabbedEntity, "releaseGrab");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -698,6 +704,7 @@ function MyController(hand) {
|
||||||
this.continueNearGrabbing = function() {
|
this.continueNearGrabbing = function() {
|
||||||
if (this.triggerSmoothedReleased()) {
|
if (this.triggerSmoothedReleased()) {
|
||||||
this.setState(STATE_RELEASE);
|
this.setState(STATE_RELEASE);
|
||||||
|
Entities.callEntityMethod(this.grabbedEntity, "releaseGrab");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -733,9 +740,10 @@ function MyController(hand) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.nearGrabbingNonColliding = function() {
|
this.nearTrigger = function() {
|
||||||
if (this.triggerSmoothedReleased()) {
|
if (this.triggerSmoothedReleased()) {
|
||||||
this.setState(STATE_RELEASE);
|
this.setState(STATE_RELEASE);
|
||||||
|
Entities.callEntityMethod(this.grabbedEntity, "stopNearTrigger");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.hand === RIGHT_HAND) {
|
if (this.hand === RIGHT_HAND) {
|
||||||
|
@ -743,13 +751,14 @@ function MyController(hand) {
|
||||||
} else {
|
} else {
|
||||||
Entities.callEntityMethod(this.grabbedEntity, "setLeftHand");
|
Entities.callEntityMethod(this.grabbedEntity, "setLeftHand");
|
||||||
}
|
}
|
||||||
Entities.callEntityMethod(this.grabbedEntity, "startNearGrabNonColliding");
|
Entities.callEntityMethod(this.grabbedEntity, "startNearTrigger");
|
||||||
this.setState(STATE_CONTINUE_NEAR_GRABBING_NON_COLLIDING);
|
this.setState(STATE_CONTINUE_NEAR_TRIGGER);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.farGrabbingNonColliding = function() {
|
this.farTrigger = function() {
|
||||||
if (this.triggerSmoothedReleased()) {
|
if (this.triggerSmoothedReleased()) {
|
||||||
this.setState(STATE_RELEASE);
|
this.setState(STATE_RELEASE);
|
||||||
|
Entities.callEntityMethod(this.grabbedEntity, "stopFarTrigger");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -758,22 +767,24 @@ function MyController(hand) {
|
||||||
} else {
|
} else {
|
||||||
Entities.callEntityMethod(this.grabbedEntity, "setLeftHand");
|
Entities.callEntityMethod(this.grabbedEntity, "setLeftHand");
|
||||||
}
|
}
|
||||||
Entities.callEntityMethod(this.grabbedEntity, "startFarGrabNonColliding");
|
Entities.callEntityMethod(this.grabbedEntity, "startFarTrigger");
|
||||||
this.setState(STATE_CONTINUE_FAR_GRABBING_NON_COLLIDING);
|
this.setState(STATE_CONTINUE_FAR_TRIGGER);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.continueNearGrabbingNonColliding = function() {
|
this.continueNearTrigger = function() {
|
||||||
if (this.triggerSmoothedReleased()) {
|
if (this.triggerSmoothedReleased()) {
|
||||||
this.setState(STATE_RELEASE);
|
this.setState(STATE_RELEASE);
|
||||||
|
Entities.callEntityMethod(this.grabbedEntity, "stopNearTrigger");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entities.callEntityMethod(this.grabbedEntity, "continueNearGrabbingNonColliding");
|
Entities.callEntityMethod(this.grabbedEntity, "continueNearTrigger");
|
||||||
};
|
};
|
||||||
|
|
||||||
this.continueFarGrabbingNonColliding = function() {
|
this.continueFarTrigger = function() {
|
||||||
if (this.triggerSmoothedReleased()) {
|
if (this.triggerSmoothedReleased()) {
|
||||||
this.setState(STATE_RELEASE);
|
this.setState(STATE_RELEASE);
|
||||||
|
Entities.callEntityMethod(this.grabbedEntity, "stopNearTrigger");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -789,12 +800,13 @@ function MyController(hand) {
|
||||||
this.lastPickTime = now;
|
this.lastPickTime = now;
|
||||||
if (intersection.entityID != this.grabbedEntity) {
|
if (intersection.entityID != this.grabbedEntity) {
|
||||||
this.setState(STATE_RELEASE);
|
this.setState(STATE_RELEASE);
|
||||||
|
Entities.callEntityMethod(this.grabbedEntity, "stopFarTrigger");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lineOn(pickRay.origin, Vec3.multiply(pickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR);
|
this.lineOn(pickRay.origin, Vec3.multiply(pickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR);
|
||||||
Entities.callEntityMethod(this.grabbedEntity, "continueFarGrabbingNonColliding");
|
Entities.callEntityMethod(this.grabbedEntity, "continueFarTrigger");
|
||||||
};
|
};
|
||||||
|
|
||||||
_this.allTouchedIDs = {};
|
_this.allTouchedIDs = {};
|
||||||
|
@ -876,7 +888,6 @@ function MyController(hand) {
|
||||||
if (this.actionID !== null) {
|
if (this.actionID !== null) {
|
||||||
Entities.deleteAction(this.grabbedEntity, this.actionID);
|
Entities.deleteAction(this.grabbedEntity, this.actionID);
|
||||||
}
|
}
|
||||||
Entities.callEntityMethod(this.grabbedEntity, "releaseGrab");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.deactivateEntity(this.grabbedEntity);
|
this.deactivateEntity(this.grabbedEntity);
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
Script.load("away.js");
|
||||||
Script.load("progress.js");
|
Script.load("progress.js");
|
||||||
Script.load("edit.js");
|
Script.load("edit.js");
|
||||||
Script.load("selectAudioDevice.js");
|
Script.load("selectAudioDevice.js");
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
ColorSelector.prototype = {
|
ColorSelector.prototype = {
|
||||||
|
|
||||||
startFarGrabNonColliding: function() {
|
startFarTrigger: function() {
|
||||||
this.selectColor();
|
this.selectColor();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
BoardEraser.prototype = {
|
BoardEraser.prototype = {
|
||||||
|
|
||||||
startFarGrabNonColliding: function() {
|
startFarTrigger: function() {
|
||||||
this.eraseBoard();
|
this.eraseBoard();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
this.hand = LEFT_HAND;
|
this.hand = LEFT_HAND;
|
||||||
},
|
},
|
||||||
|
|
||||||
startFarGrabNonColliding: function() {
|
startFarTrigger: function() {
|
||||||
if (this.painting) {
|
if (this.painting) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
continueFarGrabbingNonColliding: function() {
|
continueFarTrigger: function() {
|
||||||
var handPosition = this.getHandPosition();
|
var handPosition = this.getHandPosition();
|
||||||
var pickRay = {
|
var pickRay = {
|
||||||
origin: handPosition,
|
origin: handPosition,
|
||||||
|
@ -183,7 +183,7 @@
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
releaseGrab: function() {
|
stopFarTrigger: function() {
|
||||||
if(this.hand !== this.whichHand) {
|
if(this.hand !== this.whichHand) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,9 @@ var drawingSurface = Entities.addEntity({
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
color: {
|
color: {
|
||||||
currentColor: colors[0]
|
currentColor: colors[0]
|
||||||
|
},
|
||||||
|
grabbableKey: {
|
||||||
|
wantsTrigger: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -84,12 +87,24 @@ var light = Entities.addEntity({
|
||||||
type: 'Light',
|
type: 'Light',
|
||||||
name: 'whiteboard light',
|
name: 'whiteboard light',
|
||||||
position: lightPosition,
|
position: lightPosition,
|
||||||
dimensions: {x: 10, y: 10, z: 10},
|
dimensions: {
|
||||||
|
x: 10,
|
||||||
|
y: 10,
|
||||||
|
z: 10
|
||||||
|
},
|
||||||
intensity: 2,
|
intensity: 2,
|
||||||
color: {red: 255, green: 255, blue: 255}
|
color: {
|
||||||
|
red: 255,
|
||||||
|
green: 255,
|
||||||
|
blue: 255
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var eraserPosition = Vec3.sum(center, {x: 0, y: 2.05, z: 0 });
|
var eraserPosition = Vec3.sum(center, {
|
||||||
|
x: 0,
|
||||||
|
y: 2.05,
|
||||||
|
z: 0
|
||||||
|
});
|
||||||
eraserPosition = Vec3.sum(eraserPosition, Vec3.multiply(-0.1, rotation));
|
eraserPosition = Vec3.sum(eraserPosition, Vec3.multiply(-0.1, rotation));
|
||||||
scriptURL = Script.resolvePath("eraseBoardEntityScript.js");
|
scriptURL = Script.resolvePath("eraseBoardEntityScript.js");
|
||||||
var eraser = Entities.addEntity({
|
var eraser = Entities.addEntity({
|
||||||
|
@ -100,7 +115,10 @@ var eraser = Entities.addEntity({
|
||||||
script: scriptURL,
|
script: scriptURL,
|
||||||
rotation: rotation,
|
rotation: rotation,
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
whiteboard: drawingSurface
|
whiteboard: drawingSurface,
|
||||||
|
grabbableKey: {
|
||||||
|
wantsTrigger: true
|
||||||
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -112,20 +130,32 @@ Script.setTimeout(function() {
|
||||||
|
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
var blockerPosition = Vec3.sum(center, {x: 0, y: -1, z: 0 });
|
var blockerPosition = Vec3.sum(center, {
|
||||||
|
x: 0,
|
||||||
|
y: -1,
|
||||||
|
z: 0
|
||||||
|
});
|
||||||
blockerPosition = Vec3.sum(blockerPosition, Vec3.multiply(-1, Quat.getFront(rotation)));
|
blockerPosition = Vec3.sum(blockerPosition, Vec3.multiply(-1, Quat.getFront(rotation)));
|
||||||
blocker = Entities.addEntity({
|
blocker = Entities.addEntity({
|
||||||
type: "Box",
|
type: "Box",
|
||||||
rotation: rotation,
|
rotation: rotation,
|
||||||
position: blockerPosition,
|
position: blockerPosition,
|
||||||
dimensions: {x: whiteboardDimensions.x, y: 1, z: 0.1},
|
dimensions: {
|
||||||
|
x: whiteboardDimensions.x,
|
||||||
|
y: 1,
|
||||||
|
z: 0.1
|
||||||
|
},
|
||||||
shapeType: "box",
|
shapeType: "box",
|
||||||
visible: false
|
visible: false
|
||||||
});
|
});
|
||||||
|
|
||||||
var eraseModelDimensions = Entities.getEntityProperties(eraser, "naturalDimensions").naturalDimensions;
|
var eraseModelDimensions = Entities.getEntityProperties(eraser, "naturalDimensions").naturalDimensions;
|
||||||
Entities.editEntity(eraser, {dimensions: eraseModelDimensions});
|
Entities.editEntity(eraser, {
|
||||||
Entities.editEntity(colorIndicatorBorder, {dimensions: colorIndicatorBorderDimensions});
|
dimensions: eraseModelDimensions
|
||||||
|
});
|
||||||
|
Entities.editEntity(colorIndicatorBorder, {
|
||||||
|
dimensions: colorIndicatorBorderDimensions
|
||||||
|
});
|
||||||
|
|
||||||
scriptURL = Script.resolvePath("colorIndicatorEntityScript.js");
|
scriptURL = Script.resolvePath("colorIndicatorEntityScript.js");
|
||||||
var colorIndicatorPosition = Vec3.sum(center, {
|
var colorIndicatorPosition = Vec3.sum(center, {
|
||||||
|
@ -153,7 +183,10 @@ function setUp() {
|
||||||
color: {
|
color: {
|
||||||
currentColor: colors[0]
|
currentColor: colors[0]
|
||||||
},
|
},
|
||||||
colorIndicator: colorIndicatorBox
|
colorIndicator: colorIndicatorBox,
|
||||||
|
grabbableKey: {
|
||||||
|
wantsTrigger: true
|
||||||
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -186,7 +219,10 @@ function setUp() {
|
||||||
script: scriptURL,
|
script: scriptURL,
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
whiteboard: drawingSurface,
|
whiteboard: drawingSurface,
|
||||||
colorIndicator: colorIndicatorBox
|
colorIndicator: colorIndicatorBox,
|
||||||
|
grabbableKey: {
|
||||||
|
wantsTrigger: true
|
||||||
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
colorBoxes.push(colorBox);
|
colorBoxes.push(colorBox);
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
this.toggleLights();
|
this.toggleLights();
|
||||||
},
|
},
|
||||||
|
|
||||||
startNearGrabNonColliding: function () {
|
startNearTrigger: function() {
|
||||||
this.toggleLights();
|
this.toggleLights();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -63,6 +63,10 @@
|
||||||
type: lightType,
|
type: lightType,
|
||||||
resetMe: true
|
resetMe: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setEntityCustomData('grabbableKey', this.entityID, {
|
||||||
|
wantsTrigger: true
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
flipSwitch: function() {
|
flipSwitch: function() {
|
||||||
|
|
|
@ -12,28 +12,49 @@
|
||||||
{ "from": "Keyboard.W", "when": "Keyboard.Shift", "to": "Actions.PITCH_UP" },
|
{ "from": "Keyboard.W", "when": "Keyboard.Shift", "to": "Actions.PITCH_UP" },
|
||||||
|
|
||||||
|
|
||||||
{ "from": { "makeAxis" : ["Keyboard.MouseMoveLeft", "Keyboard.MouseMoveRight"] },
|
{ "comment" : "Mouse turn need to be small continuous increments",
|
||||||
|
"from": { "makeAxis" : [
|
||||||
|
[ "Keyboard.MouseMoveLeft" ],
|
||||||
|
[ "Keyboard.MouseMoveRight" ]
|
||||||
|
]
|
||||||
|
},
|
||||||
"when": [ "Application.InHMD", "Application.ComfortMode", "Keyboard.RightMouseButton" ],
|
"when": [ "Application.InHMD", "Application.ComfortMode", "Keyboard.RightMouseButton" ],
|
||||||
"to": "Actions.StepYaw",
|
"to": "Actions.StepYaw",
|
||||||
"filters":
|
"filters":
|
||||||
[
|
[
|
||||||
"constrainToInteger",
|
"constrainToInteger",
|
||||||
{ "type": "pulse", "interval": 0.5 },
|
{ "type": "pulse", "interval": 0.2 },
|
||||||
{ "type": "scale", "scale": 15 }
|
{ "type": "scale", "scale": 22.5 }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
{ "from": { "makeAxis" : [
|
{ "comment" : "Touchpad turn need to be small continuous increments, but without the RMB constraint",
|
||||||
["Keyboard.A", "Keyboard.Left", "Keyboard.TouchpadLeft"],
|
"from": { "makeAxis" : [
|
||||||
["Keyboard.D", "Keyboard.Right", "Keyboard.TouchpadRight"]
|
[ "Keyboard.TouchpadLeft" ],
|
||||||
|
[ "Keyboard.TouchpadRight" ]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"when": [ "Application.InHMD", "Application.ComfortMode" ],
|
"when": [ "Application.InHMD", "Application.ComfortMode" ],
|
||||||
"to": "Actions.StepYaw",
|
"to": "Actions.StepYaw",
|
||||||
"filters":
|
"filters":
|
||||||
[
|
[
|
||||||
{ "type": "pulse", "interval": 0.5 },
|
"constrainToInteger",
|
||||||
{ "type": "scale", "scale": 15 }
|
{ "type": "pulse", "interval": 0.2 },
|
||||||
|
{ "type": "scale", "scale": 22.5 }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
{ "from": { "makeAxis" : [
|
||||||
|
["Keyboard.A", "Keyboard.Left" ],
|
||||||
|
["Keyboard.D", "Keyboard.Right"]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"when": [ "Application.InHMD", "Application.ComfortMode" ],
|
||||||
|
"to": "Actions.StepYaw",
|
||||||
|
"filters":
|
||||||
|
[
|
||||||
|
{ "type": "pulse", "interval": 0.5, "resetOnZero": true },
|
||||||
|
{ "type": "scale", "scale": 22.5 }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
15
interface/resources/controllers/spacemouse.json
Normal file
15
interface/resources/controllers/spacemouse.json
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"name": "Spacemouse to Standard",
|
||||||
|
"channels": [
|
||||||
|
|
||||||
|
{ "from": "Spacemouse.TranslateX", "to": "Standard.RX" },
|
||||||
|
{ "from": "Spacemouse.TranslateY", "to": "Standard.LY" },
|
||||||
|
{ "from": "Spacemouse.TranslateZ", "to": "Standard.RY" },
|
||||||
|
|
||||||
|
{ "from": "Spacemouse.RotateZ", "to": "Standard.LX" },
|
||||||
|
|
||||||
|
{ "from": "Spacemouse.LeftButton", "to": "Standard.LB" },
|
||||||
|
{ "from": "Spacemouse.RightButton", "to": "Standard.RB" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
"type": "overlay",
|
"type": "overlay",
|
||||||
"data": {
|
"data": {
|
||||||
"alpha": 1.0,
|
"alpha": 1.0,
|
||||||
|
"alphaVar": "ikOverlayAlpha",
|
||||||
"boneSet": "fullBody"
|
"boneSet": "fullBody"
|
||||||
},
|
},
|
||||||
"children": [
|
"children": [
|
||||||
|
@ -178,7 +179,7 @@
|
||||||
"type": "clip",
|
"type": "clip",
|
||||||
"data": {
|
"data": {
|
||||||
"url": "http://hifi-public.s3.amazonaws.com/ozan/anim/hand_anims/point_right_hand.fbx",
|
"url": "http://hifi-public.s3.amazonaws.com/ozan/anim/hand_anims/point_right_hand.fbx",
|
||||||
"startFrame": 0.0,
|
"startFrame": 12.0,
|
||||||
"endFrame": 65.0,
|
"endFrame": 65.0,
|
||||||
"timeScale": 1.0,
|
"timeScale": 1.0,
|
||||||
"loopFlag": false
|
"loopFlag": false
|
||||||
|
@ -327,7 +328,7 @@
|
||||||
"type": "clip",
|
"type": "clip",
|
||||||
"data": {
|
"data": {
|
||||||
"url": "http://hifi-public.s3.amazonaws.com/ozan/anim/hand_anims/point_left_hand.fbx",
|
"url": "http://hifi-public.s3.amazonaws.com/ozan/anim/hand_anims/point_left_hand.fbx",
|
||||||
"startFrame": 0.0,
|
"startFrame": 12.0,
|
||||||
"endFrame": 65.0,
|
"endFrame": 65.0,
|
||||||
"timeScale": 1.0,
|
"timeScale": 1.0,
|
||||||
"loopFlag": false
|
"loopFlag": false
|
||||||
|
@ -378,15 +379,16 @@
|
||||||
"states": [
|
"states": [
|
||||||
{
|
{
|
||||||
"id": "idle",
|
"id": "idle",
|
||||||
"interpTarget": 6,
|
"interpTarget": 15,
|
||||||
"interpDuration": 6,
|
"interpDuration": 15,
|
||||||
"transitions": [
|
"transitions": [
|
||||||
{ "var": "isMovingForward", "state": "walkFwd" },
|
{ "var": "isMovingForward", "state": "walkFwd" },
|
||||||
{ "var": "isMovingBackward", "state": "walkBwd" },
|
{ "var": "isMovingBackward", "state": "walkBwd" },
|
||||||
{ "var": "isMovingRight", "state": "strafeRight" },
|
{ "var": "isMovingRight", "state": "strafeRight" },
|
||||||
{ "var": "isMovingLeft", "state": "strafeLeft" },
|
{ "var": "isMovingLeft", "state": "strafeLeft" },
|
||||||
{ "var": "isTurningRight", "state": "turnRight" },
|
{ "var": "isTurningRight", "state": "turnRight" },
|
||||||
{ "var": "isTurningLeft", "state": "turnLeft" }
|
{ "var": "isTurningLeft", "state": "turnLeft" },
|
||||||
|
{ "var": "isAway", "state": "awayIntro" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -399,7 +401,8 @@
|
||||||
{ "var": "isMovingRight", "state": "strafeRight" },
|
{ "var": "isMovingRight", "state": "strafeRight" },
|
||||||
{ "var": "isMovingLeft", "state": "strafeLeft" },
|
{ "var": "isMovingLeft", "state": "strafeLeft" },
|
||||||
{ "var": "isTurningRight", "state": "turnRight" },
|
{ "var": "isTurningRight", "state": "turnRight" },
|
||||||
{ "var": "isTurningLeft", "state": "turnLeft" }
|
{ "var": "isTurningLeft", "state": "turnLeft" },
|
||||||
|
{ "var": "isAway", "state": "awayIntro" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -412,7 +415,8 @@
|
||||||
{ "var": "isMovingRight", "state": "strafeRight" },
|
{ "var": "isMovingRight", "state": "strafeRight" },
|
||||||
{ "var": "isMovingLeft", "state": "strafeLeft" },
|
{ "var": "isMovingLeft", "state": "strafeLeft" },
|
||||||
{ "var": "isTurningRight", "state": "turnRight" },
|
{ "var": "isTurningRight", "state": "turnRight" },
|
||||||
{ "var": "isTurningLeft", "state": "turnLeft" }
|
{ "var": "isTurningLeft", "state": "turnLeft" },
|
||||||
|
{ "var": "isAway", "state": "awayIntro" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -425,7 +429,8 @@
|
||||||
{ "var": "isMovingBackward", "state": "walkBwd" },
|
{ "var": "isMovingBackward", "state": "walkBwd" },
|
||||||
{ "var": "isMovingLeft", "state": "strafeLeft" },
|
{ "var": "isMovingLeft", "state": "strafeLeft" },
|
||||||
{ "var": "isTurningRight", "state": "turnRight" },
|
{ "var": "isTurningRight", "state": "turnRight" },
|
||||||
{ "var": "isTurningLeft", "state": "turnLeft" }
|
{ "var": "isTurningLeft", "state": "turnLeft" },
|
||||||
|
{ "var": "isAway", "state": "awayIntro" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -438,7 +443,8 @@
|
||||||
{ "var": "isMovingBackward", "state": "walkBwd" },
|
{ "var": "isMovingBackward", "state": "walkBwd" },
|
||||||
{ "var": "isMovingRight", "state": "strafeRight" },
|
{ "var": "isMovingRight", "state": "strafeRight" },
|
||||||
{ "var": "isTurningRight", "state": "turnRight" },
|
{ "var": "isTurningRight", "state": "turnRight" },
|
||||||
{ "var": "isTurningLeft", "state": "turnLeft" }
|
{ "var": "isTurningLeft", "state": "turnLeft" },
|
||||||
|
{ "var": "isAway", "state": "awayIntro" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -451,7 +457,8 @@
|
||||||
{ "var": "isMovingBackward", "state": "walkBwd" },
|
{ "var": "isMovingBackward", "state": "walkBwd" },
|
||||||
{ "var": "isMovingRight", "state": "strafeRight" },
|
{ "var": "isMovingRight", "state": "strafeRight" },
|
||||||
{ "var": "isMovingLeft", "state": "strafeLeft" },
|
{ "var": "isMovingLeft", "state": "strafeLeft" },
|
||||||
{ "var": "isTurningLeft", "state": "turnLeft" }
|
{ "var": "isTurningLeft", "state": "turnLeft" },
|
||||||
|
{ "var": "isAway", "state": "awayIntro" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -464,7 +471,32 @@
|
||||||
{ "var": "isMovingBackward", "state": "walkBwd" },
|
{ "var": "isMovingBackward", "state": "walkBwd" },
|
||||||
{ "var": "isMovingRight", "state": "strafeRight" },
|
{ "var": "isMovingRight", "state": "strafeRight" },
|
||||||
{ "var": "isMovingLeft", "state": "strafeLeft" },
|
{ "var": "isMovingLeft", "state": "strafeLeft" },
|
||||||
{ "var": "isTurningRight", "state": "turnRight" }
|
{ "var": "isTurningRight", "state": "turnRight" },
|
||||||
|
{ "var": "isAway", "state": "awayIntro" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "awayIntro",
|
||||||
|
"interpTarget": 30,
|
||||||
|
"interpDuration": 30,
|
||||||
|
"transitions": [
|
||||||
|
{ "var": "awayIntroOnDone", "state": "away"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "away",
|
||||||
|
"interpTarget": 3,
|
||||||
|
"interpDuration": 3,
|
||||||
|
"transitions": [
|
||||||
|
{ "var": "isNotAway", "state": "awayOutro" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "awayOutro",
|
||||||
|
"interpTarget": 3,
|
||||||
|
"interpDuration": 3,
|
||||||
|
"transitions": [
|
||||||
|
{ "var": "awayOutroOnDone", "state": "idle" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -704,6 +736,42 @@
|
||||||
"children": []
|
"children": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "awayIntro",
|
||||||
|
"type": "clip",
|
||||||
|
"data": {
|
||||||
|
"url": "https://hifi-public.s3.amazonaws.com/ozan/anim/kneel/kneel.fbx",
|
||||||
|
"startFrame": 0.0,
|
||||||
|
"endFrame": 83.0,
|
||||||
|
"timeScale": 1.0,
|
||||||
|
"loopFlag": false
|
||||||
|
},
|
||||||
|
"children": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "away",
|
||||||
|
"type": "clip",
|
||||||
|
"data": {
|
||||||
|
"url": "https://hifi-public.s3.amazonaws.com/ozan/anim/kneel/kneel.fbx",
|
||||||
|
"startFrame": 83.0,
|
||||||
|
"endFrame": 84.0,
|
||||||
|
"timeScale": 1.0,
|
||||||
|
"loopFlag": true
|
||||||
|
},
|
||||||
|
"children": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "awayOutro",
|
||||||
|
"type": "clip",
|
||||||
|
"data": {
|
||||||
|
"url": "https://hifi-public.s3.amazonaws.com/ozan/anim/kneel/kneel.fbx",
|
||||||
|
"startFrame": 84.0,
|
||||||
|
"endFrame": 167.0,
|
||||||
|
"timeScale": 1.0,
|
||||||
|
"loopFlag": false
|
||||||
|
},
|
||||||
|
"children": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@
|
||||||
#include "audio/AudioScope.h"
|
#include "audio/AudioScope.h"
|
||||||
#include "avatar/AvatarManager.h"
|
#include "avatar/AvatarManager.h"
|
||||||
#include "CrashHandler.h"
|
#include "CrashHandler.h"
|
||||||
#include "devices/3DConnexionClient.h"
|
#include "input-plugins/SpacemouseManager.h"
|
||||||
#include "devices/DdeFaceTracker.h"
|
#include "devices/DdeFaceTracker.h"
|
||||||
#include "devices/EyeTracker.h"
|
#include "devices/EyeTracker.h"
|
||||||
#include "devices/Faceshift.h"
|
#include "devices/Faceshift.h"
|
||||||
|
@ -726,10 +726,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
|
||||||
// Now that menu is initalized we can sync myAvatar with it's state.
|
// Now that menu is initalized we can sync myAvatar with it's state.
|
||||||
getMyAvatar()->updateMotionBehaviorFromMenu();
|
getMyAvatar()->updateMotionBehaviorFromMenu();
|
||||||
|
|
||||||
#if 0
|
|
||||||
// the 3Dconnexion device wants to be initiliazed after a window is displayed.
|
// the 3Dconnexion device wants to be initiliazed after a window is displayed.
|
||||||
ConnexionClient::getInstance().init();
|
SpacemouseManager::getInstance().init();
|
||||||
#endif
|
|
||||||
|
|
||||||
auto& packetReceiver = nodeList->getPacketReceiver();
|
auto& packetReceiver = nodeList->getPacketReceiver();
|
||||||
packetReceiver.registerListener(PacketType::DomainConnectionDenied, this, "handleDomainConnectionDeniedPacket");
|
packetReceiver.registerListener(PacketType::DomainConnectionDenied, this, "handleDomainConnectionDeniedPacket");
|
||||||
|
@ -940,14 +938,12 @@ void Application::initializeGL() {
|
||||||
qCDebug(interfaceapp) << "Created Display Window.";
|
qCDebug(interfaceapp) << "Created Display Window.";
|
||||||
|
|
||||||
// initialize glut for shape drawing; Qt apparently initializes it on OS X
|
// initialize glut for shape drawing; Qt apparently initializes it on OS X
|
||||||
#ifndef __APPLE__
|
if (_isGLInitialized) {
|
||||||
static bool isInitialized = false;
|
|
||||||
if (isInitialized) {
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
isInitialized = true;
|
_isGLInitialized = true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
// Where the gpuContext is initialized and where the TRUE Backend is created and assigned
|
// Where the gpuContext is initialized and where the TRUE Backend is created and assigned
|
||||||
gpu::Context::init<gpu::GLBackend>();
|
gpu::Context::init<gpu::GLBackend>();
|
||||||
_gpuContext = std::make_shared<gpu::Context>();
|
_gpuContext = std::make_shared<gpu::Context>();
|
||||||
|
@ -1059,7 +1055,9 @@ void Application::paintGL() {
|
||||||
_lastFramesPerSecondUpdate = now;
|
_lastFramesPerSecondUpdate = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_isGLInitialized) {
|
||||||
idle(now);
|
idle(now);
|
||||||
|
}
|
||||||
|
|
||||||
PROFILE_RANGE(__FUNCTION__);
|
PROFILE_RANGE(__FUNCTION__);
|
||||||
PerformanceTimer perfTimer("paintGL");
|
PerformanceTimer perfTimer("paintGL");
|
||||||
|
@ -1851,9 +1849,10 @@ void Application::focusOutEvent(QFocusEvent* event) {
|
||||||
inputPlugin->pluginFocusOutEvent();
|
inputPlugin->pluginFocusOutEvent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
ConnexionData::getInstance().focusOutEvent();
|
//SpacemouseDevice::getInstance().focusOutEvent();
|
||||||
#endif
|
//SpacemouseManager::getInstance().getDevice()->focusOutEvent();
|
||||||
|
SpacemouseManager::getInstance().ManagerFocusOutEvent();
|
||||||
|
|
||||||
// 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) {
|
||||||
|
@ -2795,7 +2794,7 @@ void Application::update(float deltaTime) {
|
||||||
float timeFactor = EXPECTED_FRAME_RATE * deltaTime;
|
float timeFactor = EXPECTED_FRAME_RATE * deltaTime;
|
||||||
myAvatar->setDriveKeys(PITCH, -1.0f * userInputMapper->getActionState(controller::Action::PITCH) / timeFactor);
|
myAvatar->setDriveKeys(PITCH, -1.0f * userInputMapper->getActionState(controller::Action::PITCH) / timeFactor);
|
||||||
myAvatar->setDriveKeys(YAW, -1.0f * userInputMapper->getActionState(controller::Action::YAW) / timeFactor);
|
myAvatar->setDriveKeys(YAW, -1.0f * userInputMapper->getActionState(controller::Action::YAW) / timeFactor);
|
||||||
myAvatar->setDriveKeys(STEP_YAW, -1.0f * userInputMapper->getActionState(controller::Action::STEP_YAW) / timeFactor);
|
myAvatar->setDriveKeys(STEP_YAW, -1.0f * userInputMapper->getActionState(controller::Action::STEP_YAW));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
myAvatar->setDriveKeys(ZOOM, userInputMapper->getActionState(controller::Action::TRANSLATE_CAMERA_Z));
|
myAvatar->setDriveKeys(ZOOM, userInputMapper->getActionState(controller::Action::TRANSLATE_CAMERA_Z));
|
||||||
|
|
|
@ -414,7 +414,7 @@ private:
|
||||||
|
|
||||||
bool _dependencyManagerIsSetup;
|
bool _dependencyManagerIsSetup;
|
||||||
|
|
||||||
OffscreenGlCanvas* _offscreenContext;
|
OffscreenGlCanvas* _offscreenContext { nullptr };
|
||||||
DisplayPluginPointer _displayPlugin;
|
DisplayPluginPointer _displayPlugin;
|
||||||
InputPluginList _activeInputPlugins;
|
InputPluginList _activeInputPlugins;
|
||||||
|
|
||||||
|
@ -548,6 +548,7 @@ private:
|
||||||
quint64 _lastSimsPerSecondUpdate = 0;
|
quint64 _lastSimsPerSecondUpdate = 0;
|
||||||
bool _isForeground = true; // starts out assumed to be in foreground
|
bool _isForeground = true; // starts out assumed to be in foreground
|
||||||
bool _inPaint = false;
|
bool _inPaint = false;
|
||||||
|
bool _isGLInitialized { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Application_h
|
#endif // hifi_Application_h
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include "devices/DdeFaceTracker.h"
|
#include "devices/DdeFaceTracker.h"
|
||||||
#include "devices/Faceshift.h"
|
#include "devices/Faceshift.h"
|
||||||
#include "devices/RealSense.h"
|
#include "devices/RealSense.h"
|
||||||
#include "devices/3DConnexionClient.h"
|
#include "input-plugins/SpacemouseManager.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "scripting/MenuScriptingInterface.h"
|
#include "scripting/MenuScriptingInterface.h"
|
||||||
#include "ui/AssetUploadDialogFactory.h"
|
#include "ui/AssetUploadDialogFactory.h"
|
||||||
|
@ -464,13 +464,9 @@ Menu::Menu() {
|
||||||
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::MeshVisible, 0, true,
|
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::MeshVisible, 0, true,
|
||||||
avatar, SLOT(setEnableMeshVisible(bool)));
|
avatar, SLOT(setEnableMeshVisible(bool)));
|
||||||
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::DisableEyelidAdjustment, 0, false);
|
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::DisableEyelidAdjustment, 0, false);
|
||||||
#if 0
|
|
||||||
addCheckableActionToQMenuAndActionHash(avatarDebugMenu,
|
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::Connexion, 0, false, &SpacemouseManager::getInstance(), SLOT(toggleSpacemouse(bool)));
|
||||||
MenuOption::Connexion,
|
|
||||||
0, false,
|
|
||||||
&ConnexionClient::getInstance(),
|
|
||||||
SLOT(toggleConnexion(bool)));
|
|
||||||
#endif
|
|
||||||
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ComfortMode, 0, true);
|
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ComfortMode, 0, true);
|
||||||
|
|
||||||
MenuWrapper* handOptionsMenu = developerMenu->addMenu("Hands");
|
MenuWrapper* handOptionsMenu = developerMenu->addMenu("Hands");
|
||||||
|
|
|
@ -81,7 +81,7 @@ void AnimClip::setCurrentFrameInternal(float frame) {
|
||||||
// because dt is 0, we should not encounter any triggers
|
// because dt is 0, we should not encounter any triggers
|
||||||
const float dt = 0.0f;
|
const float dt = 0.0f;
|
||||||
Triggers triggers;
|
Triggers triggers;
|
||||||
_frame = ::accumulateTime(_startFrame, _endFrame, _timeScale, frame, dt, _loopFlag, _id, triggers);
|
_frame = ::accumulateTime(_startFrame, _endFrame, _timeScale, frame + _startFrame, dt, _loopFlag, _id, triggers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimClip::copyFromNetworkAnim() {
|
void AnimClip::copyFromNetworkAnim() {
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
/// Updates the state of the joint at the specified index.
|
/// Updates the state of the joint at the specified index.
|
||||||
void AvatarRig::updateJointState(int index, glm::mat4 rootTransform) {
|
void AvatarRig::updateJointState(int index, glm::mat4 rootTransform) {
|
||||||
if (index < 0 && index >= _jointStates.size()) {
|
if (index < 0 || index >= _jointStates.size()) {
|
||||||
return; // bail
|
return; // bail
|
||||||
}
|
}
|
||||||
JointState& state = _jointStates[index];
|
JointState& state = _jointStates[index];
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
using namespace controller;
|
using namespace controller;
|
||||||
|
|
||||||
|
const float PulseFilter::DEFAULT_LAST_EMIT_TIME = -::std::numeric_limits<float>::max();
|
||||||
|
|
||||||
float PulseFilter::apply(float value) const {
|
float PulseFilter::apply(float value) const {
|
||||||
float result = 0.0f;
|
float result = 0.0f;
|
||||||
|
@ -25,13 +25,22 @@ float PulseFilter::apply(float value) const {
|
||||||
_lastEmitTime = now;
|
_lastEmitTime = now;
|
||||||
result = value;
|
result = value;
|
||||||
}
|
}
|
||||||
|
} else if (_resetOnZero) {
|
||||||
|
_lastEmitTime = DEFAULT_LAST_EMIT_TIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PulseFilter::parseParameters(const QJsonValue& parameters) {
|
bool PulseFilter::parseParameters(const QJsonValue& parameters) {
|
||||||
static const QString JSON_MIN = QStringLiteral("interval");
|
static const QString JSON_INTERVAL = QStringLiteral("interval");
|
||||||
return parseSingleFloatParameter(parameters, JSON_MIN, _interval);
|
static const QString JSON_RESET = QStringLiteral("resetOnZero");
|
||||||
|
if (parameters.isObject()) {
|
||||||
|
auto obj = parameters.toObject();
|
||||||
|
if (obj.contains(JSON_RESET)) {
|
||||||
|
_resetOnZero = obj[JSON_RESET].toBool();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return parseSingleFloatParameter(parameters, JSON_INTERVAL, _interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,14 +21,15 @@ public:
|
||||||
PulseFilter() {}
|
PulseFilter() {}
|
||||||
PulseFilter(float interval) : _interval(interval) {}
|
PulseFilter(float interval) : _interval(interval) {}
|
||||||
|
|
||||||
|
|
||||||
virtual float apply(float value) const override;
|
virtual float apply(float value) const override;
|
||||||
|
|
||||||
virtual bool parseParameters(const QJsonValue& parameters);
|
virtual bool parseParameters(const QJsonValue& parameters);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable float _lastEmitTime { -::std::numeric_limits<float>::max() };
|
static const float DEFAULT_LAST_EMIT_TIME;
|
||||||
float _interval = 1.0f;
|
mutable float _lastEmitTime { DEFAULT_LAST_EMIT_TIME };
|
||||||
|
bool _resetOnZero { false };
|
||||||
|
float _interval { 1.0f };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
285
interface/src/devices/3DConnexionClient.cpp → libraries/input-plugins/src/input-plugins/SpacemouseManager.cpp
Executable file → Normal file
285
interface/src/devices/3DConnexionClient.cpp → libraries/input-plugins/src/input-plugins/SpacemouseManager.cpp
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// 3DConnexionClient.cpp
|
// SpacemouseManager.cpp
|
||||||
// interface/src/devices
|
// interface/src/devices
|
||||||
//
|
//
|
||||||
// Created by MarcelEdward Verhagen on 09-06-15.
|
// Created by MarcelEdward Verhagen on 09-06-15.
|
||||||
|
@ -9,107 +9,74 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include "SpacemouseManager.h"
|
||||||
|
|
||||||
#include "3DConnexionClient.h"
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
#include <UserActivityLogger.h>
|
#include <UserActivityLogger.h>
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
|
|
||||||
#include "Menu.h"
|
#include <plugins/PluginContainer.h>
|
||||||
|
#include <controllers/UserInputMapper.h>
|
||||||
|
|
||||||
|
#include "../../../interface/src/Menu.h"
|
||||||
|
|
||||||
const float MAX_AXIS = 75.0f; // max forward = 2x speed
|
const float MAX_AXIS = 75.0f; // max forward = 2x speed
|
||||||
|
|
||||||
void ConnexionData::focusOutEvent() {
|
static std::shared_ptr<SpacemouseDevice> instance;
|
||||||
|
SpacemouseDevice::SpacemouseDevice() :
|
||||||
|
InputDevice("Spacemouse")
|
||||||
|
{
|
||||||
|
instance = std::shared_ptr<SpacemouseDevice>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpacemouseDevice::focusOutEvent() {
|
||||||
_axisStateMap.clear();
|
_axisStateMap.clear();
|
||||||
_buttonPressedMap.clear();
|
_buttonPressedMap.clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
ConnexionData& ConnexionData::getInstance() {
|
|
||||||
static ConnexionData sharedInstance;
|
|
||||||
return sharedInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void SpacemouseDevice::handleAxisEvent() {
|
||||||
ConnexionData::ConnexionData() : InputDevice("ConnexionClient") {}
|
|
||||||
|
|
||||||
|
|
||||||
void ConnexionData::handleAxisEvent() {
|
|
||||||
auto rotation = cc_rotation / MAX_AXIS;
|
auto rotation = cc_rotation / MAX_AXIS;
|
||||||
_axisStateMap[ROTATE_X] = rotation.x;
|
_axisStateMap[ROTATE_X] = rotation.x;
|
||||||
_axisStateMap[ROTATE_Y] = rotation.y;
|
_axisStateMap[ROTATE_Y] = rotation.y;
|
||||||
_axisStateMap[ROTATE_Z] = rotation.z;
|
_axisStateMap[ROTATE_Z] = rotation.z;
|
||||||
auto position = cc_rotation / MAX_AXIS;
|
auto position = cc_position / MAX_AXIS;
|
||||||
_axisStateMap[TRANSLATE_X] = position.x;
|
_axisStateMap[TRANSLATE_X] = position.x;
|
||||||
_axisStateMap[TRANSLATE_Y] = position.y;
|
_axisStateMap[TRANSLATE_Y] = position.y;
|
||||||
_axisStateMap[TRANSLATE_Z] = position.z;
|
_axisStateMap[TRANSLATE_Z] = position.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnexionData::setButton(int lastButtonState) {
|
void SpacemouseDevice::setButton(int lastButtonState) {
|
||||||
_buttonPressedMap.clear();
|
_buttonPressedMap.clear();
|
||||||
_buttonPressedMap.insert(lastButtonState);
|
_buttonPressedMap.insert(lastButtonState);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnexionData::buildDeviceProxy(controller::DeviceProxy::Pointer proxy) {
|
|
||||||
proxy->_name = _name = "ConnexionClient";
|
controller::Input::NamedVector SpacemouseDevice::getAvailableInputs() const {
|
||||||
proxy->getButton = [this](const controller::Input& input, int timestamp) -> bool { return this->getButton(input.getChannel()); };
|
|
||||||
proxy->getAxis = [this](const controller::Input& input, int timestamp) -> float { return this->getAxis(input.getChannel()); };
|
|
||||||
proxy->getAvailabeInputs = [this]() -> QVector<controller::Input::NamedPair> {
|
|
||||||
using namespace controller;
|
using namespace controller;
|
||||||
static QVector<controller::Input::NamedPair> availableInputs {
|
|
||||||
Input::NamedPair(makeInput(BUTTON_1), "LeftButton"),
|
|
||||||
Input::NamedPair(makeInput(BUTTON_2), "RightButton"),
|
static const Input::NamedVector availableInputs{
|
||||||
Input::NamedPair(makeInput(BUTTON_3), "BothButtons"),
|
|
||||||
Input::NamedPair(makeInput(TRANSLATE_X), "TranslateX"),
|
makePair(BUTTON_1, "LeftButton"),
|
||||||
Input::NamedPair(makeInput(TRANSLATE_Y), "TranslateY"),
|
makePair(BUTTON_2, "RightButton"),
|
||||||
Input::NamedPair(makeInput(TRANSLATE_Z), "TranslateZ"),
|
//makePair(BUTTON_3, "BothButtons"),
|
||||||
Input::NamedPair(makeInput(ROTATE_X), "RotateX"),
|
makePair(TRANSLATE_X, "TranslateX"),
|
||||||
Input::NamedPair(makeInput(ROTATE_Y), "RotateY"),
|
makePair(TRANSLATE_Y, "TranslateY"),
|
||||||
Input::NamedPair(makeInput(ROTATE_Z), "RotateZ"),
|
makePair(TRANSLATE_Z, "TranslateZ"),
|
||||||
|
//makePair(ROTATE_X, "RotateX"),
|
||||||
|
//makePair(ROTATE_Y, "RotateY"),
|
||||||
|
makePair(ROTATE_Z, "RotateZ"),
|
||||||
|
|
||||||
};
|
};
|
||||||
return availableInputs;
|
return availableInputs;
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ConnexionData::getDefaultMappingConfig() {
|
QString SpacemouseDevice::getDefaultMappingConfig() const {
|
||||||
static const QString MAPPING_JSON = PathUtils::resourcesPath() + "/controllers/vive.json";
|
static const QString MAPPING_JSON = PathUtils::resourcesPath() + "/controllers/spacemouse.json";
|
||||||
return MAPPING_JSON;
|
return MAPPING_JSON;
|
||||||
}
|
}
|
||||||
|
|
||||||
//void ConnexionData::assignDefaultInputMapping(UserInputMapper& mapper) {
|
float SpacemouseDevice::getButton(int channel) const {
|
||||||
// const float JOYSTICK_MOVE_SPEED = 1.0f;
|
|
||||||
// //const float DPAD_MOVE_SPEED = 0.5f;
|
|
||||||
// const float JOYSTICK_YAW_SPEED = 0.5f;
|
|
||||||
// const float JOYSTICK_PITCH_SPEED = 0.25f;
|
|
||||||
// const float BOOM_SPEED = 0.1f;
|
|
||||||
//
|
|
||||||
// // Y axes are flipped (up is negative)
|
|
||||||
// // postion: Movement, strafing
|
|
||||||
// mapper.addInputChannel(UserInputMapper::LONGITUDINAL_FORWARD, makeInput(POSITION_AXIS_Y_NEG), JOYSTICK_MOVE_SPEED);
|
|
||||||
// mapper.addInputChannel(UserInputMapper::LONGITUDINAL_BACKWARD, makeInput(POSITION_AXIS_Y_POS), JOYSTICK_MOVE_SPEED);
|
|
||||||
// mapper.addInputChannel(UserInputMapper::LATERAL_RIGHT, makeInput(POSITION_AXIS_X_POS), JOYSTICK_MOVE_SPEED);
|
|
||||||
// mapper.addInputChannel(UserInputMapper::LATERAL_LEFT, makeInput(POSITION_AXIS_X_NEG), JOYSTICK_MOVE_SPEED);
|
|
||||||
// mapper.addInputChannel(UserInputMapper::VERTICAL_UP, makeInput(POSITION_AXIS_Z_NEG), JOYSTICK_MOVE_SPEED);
|
|
||||||
// mapper.addInputChannel(UserInputMapper::VERTICAL_DOWN, makeInput(POSITION_AXIS_Z_POS), JOYSTICK_MOVE_SPEED);
|
|
||||||
//
|
|
||||||
// // Rotation: Camera orientation with button 1
|
|
||||||
// mapper.addInputChannel(UserInputMapper::YAW_RIGHT, makeInput(ROTATION_AXIS_Z_POS), JOYSTICK_YAW_SPEED);
|
|
||||||
// mapper.addInputChannel(UserInputMapper::YAW_LEFT, makeInput(ROTATION_AXIS_Z_NEG), JOYSTICK_YAW_SPEED);
|
|
||||||
// mapper.addInputChannel(UserInputMapper::PITCH_DOWN, makeInput(ROTATION_AXIS_Y_NEG), JOYSTICK_PITCH_SPEED);
|
|
||||||
// mapper.addInputChannel(UserInputMapper::PITCH_UP, makeInput(ROTATION_AXIS_Y_POS), JOYSTICK_PITCH_SPEED);
|
|
||||||
//
|
|
||||||
// // Button controls
|
|
||||||
// // Zoom
|
|
||||||
// mapper.addInputChannel(UserInputMapper::BOOM_IN, makeInput(BUTTON_1), BOOM_SPEED);
|
|
||||||
// mapper.addInputChannel(UserInputMapper::BOOM_OUT, makeInput(BUTTON_2), BOOM_SPEED);
|
|
||||||
//
|
|
||||||
// // Zoom
|
|
||||||
// // mapper.addInputChannel(UserInputMapper::BOOM_IN, makeInput(ROTATION_AXIS_Z_NEG), BOOM_SPEED);
|
|
||||||
// // mapper.addInputChannel(UserInputMapper::BOOM_OUT, makeInput(ROTATION_AXIS_Z_POS), BOOM_SPEED);
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
|
|
||||||
float ConnexionData::getButton(int channel) const {
|
|
||||||
if (!_buttonPressedMap.empty()) {
|
if (!_buttonPressedMap.empty()) {
|
||||||
if (_buttonPressedMap.find(channel) != _buttonPressedMap.end()) {
|
if (_buttonPressedMap.find(channel) != _buttonPressedMap.end()) {
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
|
@ -120,7 +87,7 @@ float ConnexionData::getButton(int channel) const {
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ConnexionData::getAxis(int channel) const {
|
float SpacemouseDevice::getAxis(int channel) const {
|
||||||
auto axis = _axisStateMap.find(channel);
|
auto axis = _axisStateMap.find(channel);
|
||||||
if (axis != _axisStateMap.end()) {
|
if (axis != _axisStateMap.end()) {
|
||||||
return (*axis).second;
|
return (*axis).second;
|
||||||
|
@ -129,55 +96,78 @@ float ConnexionData::getAxis(int channel) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
controller::Input ConnexionData::makeInput(ConnexionData::ButtonChannel button) {
|
controller::Input SpacemouseDevice::makeInput(SpacemouseDevice::ButtonChannel button) const {
|
||||||
return controller::Input(_deviceID, button, controller::ChannelType::BUTTON);
|
return controller::Input(_deviceID, button, controller::ChannelType::BUTTON);
|
||||||
}
|
}
|
||||||
|
|
||||||
controller::Input ConnexionData::makeInput(ConnexionData::PositionChannel axis) {
|
controller::Input SpacemouseDevice::makeInput(SpacemouseDevice::PositionChannel axis) const {
|
||||||
return controller::Input(_deviceID, axis, controller::ChannelType::AXIS);
|
return controller::Input(_deviceID, axis, controller::ChannelType::AXIS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnexionData::update(float deltaTime, bool jointsCaptured) {
|
controller::Input::NamedPair SpacemouseDevice::makePair(SpacemouseDevice::ButtonChannel button, const QString& name) const {
|
||||||
// the update is done in the ConnexionClient class.
|
return controller::Input::NamedPair(makeInput(button), name);
|
||||||
|
}
|
||||||
|
|
||||||
|
controller::Input::NamedPair SpacemouseDevice::makePair(SpacemouseDevice::PositionChannel axis, const QString& name) const {
|
||||||
|
return controller::Input::NamedPair(makeInput(axis), name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpacemouseDevice::update(float deltaTime, bool jointsCaptured) {
|
||||||
|
// the update is done in the SpacemouseManager class.
|
||||||
// for windows in the nativeEventFilter the inputmapper is connected or registed or removed when an 3Dconnnexion device is attached or detached
|
// for windows in the nativeEventFilter the inputmapper is connected or registed or removed when an 3Dconnnexion device is attached or detached
|
||||||
// for osx the api will call DeviceAddedHandler or DeviceRemoveHandler when a 3Dconnexion device is attached or detached
|
// for osx the api will call DeviceAddedHandler or DeviceRemoveHandler when a 3Dconnexion device is attached or detached
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnexionClient& ConnexionClient::getInstance() {
|
SpacemouseManager& SpacemouseManager::getInstance() {
|
||||||
static ConnexionClient sharedInstance;
|
static SpacemouseManager sharedInstance;
|
||||||
|
if (instance == nullptr) {
|
||||||
|
new SpacemouseDevice();
|
||||||
|
}
|
||||||
return sharedInstance;
|
return sharedInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SpacemouseManager::ManagerFocusOutEvent() {
|
||||||
|
instance->focusOutEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpacemouseManager::init() {
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_3DCONNEXIONCLIENT
|
#ifdef HAVE_3DCONNEXIONCLIENT
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
|
||||||
#include <VersionHelpers.h>
|
#include <VersionHelpers.h>
|
||||||
|
|
||||||
void ConnexionClient::toggleConnexion(bool shouldEnable) {
|
void SpacemouseManager::toggleSpacemouse(bool shouldEnable) {
|
||||||
ConnexionData& connexiondata = ConnexionData::getInstance();
|
if (shouldEnable) {
|
||||||
if (shouldEnable && connexiondata.getDeviceID() == 0) {
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
if (!shouldEnable && connexiondata.getDeviceID() != 0) {
|
if (!shouldEnable && instance->getDeviceID() != controller::Input::INVALID_DEVICE) {
|
||||||
destroy();
|
destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnexionClient::init() {
|
void SpacemouseManager::init() {
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Connexion)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::Connexion)) {
|
||||||
fLast3dmouseInputTime = 0;
|
fLast3dmouseInputTime = 0;
|
||||||
|
|
||||||
InitializeRawInput(GetActiveWindow());
|
InitializeRawInput(GetActiveWindow());
|
||||||
|
|
||||||
QAbstractEventDispatcher::instance()->installNativeEventFilter(this);
|
QAbstractEventDispatcher::instance()->installNativeEventFilter(this);
|
||||||
|
|
||||||
|
if (instance->getDeviceID() != controller::Input::INVALID_DEVICE) {
|
||||||
|
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
||||||
|
userInputMapper->registerDevice(instance);
|
||||||
|
UserActivityLogger::getInstance().connectedDevice("controller", "Spacemouse");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnexionClient::destroy() {
|
void SpacemouseManager::destroy() {
|
||||||
QAbstractEventDispatcher::instance()->removeNativeEventFilter(this);
|
QAbstractEventDispatcher::instance()->removeNativeEventFilter(this);
|
||||||
ConnexionData& connexiondata = ConnexionData::getInstance();
|
int deviceid = instance->getDeviceID();
|
||||||
int deviceid = connexiondata.getDeviceID();
|
|
||||||
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
||||||
userInputMapper->removeDevice(deviceid);
|
userInputMapper->removeDevice(deviceid);
|
||||||
}
|
}
|
||||||
|
@ -281,14 +271,15 @@ unsigned short HidToVirtualKey(unsigned long pid, unsigned short hidKeyCode) {
|
||||||
return virtualkey;
|
return virtualkey;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConnexionClient::RawInputEventFilter(void* msg, long* result) {
|
bool SpacemouseManager::RawInputEventFilter(void* msg, long* result) {
|
||||||
ConnexionData& connexiondata = ConnexionData::getInstance();
|
|
||||||
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
||||||
if (Is3dmouseAttached() && connexiondata.getDeviceID() == 0) {
|
if (Is3dmouseAttached() && instance->getDeviceID() == controller::Input::INVALID_DEVICE) {
|
||||||
userInputMapper->registerDevice(&connexiondata);
|
userInputMapper->registerDevice(instance);
|
||||||
UserActivityLogger::getInstance().connectedDevice("controller", "3Dconnexion");
|
UserActivityLogger::getInstance().connectedDevice("controller", "Spacemouse");
|
||||||
} else if (!Is3dmouseAttached() && connexiondata.getDeviceID() != 0) {
|
}
|
||||||
userInputMapper->removeDevice(connexiondata.getDeviceID());
|
else if (!Is3dmouseAttached() && instance->getDeviceID() != controller::Input::INVALID_DEVICE) {
|
||||||
|
userInputMapper->removeDevice(instance->getDeviceID());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Is3dmouseAttached()) {
|
if (!Is3dmouseAttached()) {
|
||||||
|
@ -309,36 +300,34 @@ bool ConnexionClient::RawInputEventFilter(void* msg, long* result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Access the mouse parameters structure
|
// Access the mouse parameters structure
|
||||||
I3dMouseParam& ConnexionClient::MouseParams() {
|
I3dMouseParam& SpacemouseManager::MouseParams() {
|
||||||
return f3dMouseParams;
|
return f3dMouseParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Access the mouse parameters structure
|
// Access the mouse parameters structure
|
||||||
const I3dMouseParam& ConnexionClient::MouseParams() const {
|
const I3dMouseParam& SpacemouseManager::MouseParams() const {
|
||||||
return f3dMouseParams;
|
return f3dMouseParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Called with the processed motion data when a 3D mouse event is received
|
//Called with the processed motion data when a 3D mouse event is received
|
||||||
void ConnexionClient::Move3d(HANDLE device, std::vector<float>& motionData) {
|
void SpacemouseManager::Move3d(HANDLE device, std::vector<float>& motionData) {
|
||||||
Q_UNUSED(device);
|
Q_UNUSED(device);
|
||||||
ConnexionData& connexiondata = ConnexionData::getInstance();
|
|
||||||
connexiondata.cc_position = { motionData[0] * 1000, motionData[1] * 1000, motionData[2] * 1000 };
|
instance->cc_position = { motionData[0] * 1000, motionData[1] * 1000, motionData[2] * 1000 };
|
||||||
connexiondata.cc_rotation = { motionData[3] * 1500, motionData[4] * 1500, motionData[5] * 1500 };
|
instance->cc_rotation = { motionData[3] * 1500, motionData[4] * 1500, motionData[5] * 1500 };
|
||||||
connexiondata.handleAxisEvent();
|
instance->handleAxisEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Called when a 3D mouse key is pressed
|
//Called when a 3D mouse key is pressed
|
||||||
void ConnexionClient::On3dmouseKeyDown(HANDLE device, int virtualKeyCode) {
|
void SpacemouseManager::On3dmouseKeyDown(HANDLE device, int virtualKeyCode) {
|
||||||
Q_UNUSED(device);
|
Q_UNUSED(device);
|
||||||
ConnexionData& connexiondata = ConnexionData::getInstance();
|
instance->setButton(virtualKeyCode);
|
||||||
connexiondata.setButton(virtualKeyCode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Called when a 3D mouse key is released
|
//Called when a 3D mouse key is released
|
||||||
void ConnexionClient::On3dmouseKeyUp(HANDLE device, int virtualKeyCode) {
|
void SpacemouseManager::On3dmouseKeyUp(HANDLE device, int virtualKeyCode) {
|
||||||
Q_UNUSED(device);
|
Q_UNUSED(device);
|
||||||
ConnexionData& connexiondata = ConnexionData::getInstance();
|
instance->setButton(0);
|
||||||
connexiondata.setButton(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get an initialized array of PRAWINPUTDEVICE for the 3D devices
|
//Get an initialized array of PRAWINPUTDEVICE for the 3D devices
|
||||||
|
@ -357,7 +346,7 @@ static PRAWINPUTDEVICE GetDevicesToRegister(unsigned int* pNumDevices) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Detect the 3D mouse
|
//Detect the 3D mouse
|
||||||
bool ConnexionClient::Is3dmouseAttached() {
|
bool SpacemouseManager::Is3dmouseAttached() {
|
||||||
unsigned int numDevicesOfInterest = 0;
|
unsigned int numDevicesOfInterest = 0;
|
||||||
PRAWINPUTDEVICE devicesToRegister = GetDevicesToRegister(&numDevicesOfInterest);
|
PRAWINPUTDEVICE devicesToRegister = GetDevicesToRegister(&numDevicesOfInterest);
|
||||||
|
|
||||||
|
@ -400,7 +389,7 @@ bool ConnexionClient::Is3dmouseAttached() {
|
||||||
|
|
||||||
// Initialize the window to recieve raw-input messages
|
// Initialize the window to recieve raw-input messages
|
||||||
// This needs to be called initially so that Windows will send the messages from the 3D mouse to the window.
|
// This needs to be called initially so that Windows will send the messages from the 3D mouse to the window.
|
||||||
bool ConnexionClient::InitializeRawInput(HWND hwndTarget) {
|
bool SpacemouseManager::InitializeRawInput(HWND hwndTarget) {
|
||||||
fWindow = hwndTarget;
|
fWindow = hwndTarget;
|
||||||
|
|
||||||
// Simply fail if there is no window
|
// Simply fail if there is no window
|
||||||
|
@ -429,7 +418,7 @@ bool ConnexionClient::InitializeRawInput(HWND hwndTarget) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get the raw input data from Windows
|
//Get the raw input data from Windows
|
||||||
UINT ConnexionClient::GetRawInputBuffer(PRAWINPUT pData, PUINT pcbSize, UINT cbSizeHeader) {
|
UINT SpacemouseManager::GetRawInputBuffer(PRAWINPUT pData, PUINT pcbSize, UINT cbSizeHeader) {
|
||||||
//Includes workaround for incorrect alignment of the RAWINPUT structure on x64 os
|
//Includes workaround for incorrect alignment of the RAWINPUT structure on x64 os
|
||||||
//when running as Wow64 (copied directly from 3DConnexion code)
|
//when running as Wow64 (copied directly from 3DConnexion code)
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
|
@ -477,7 +466,7 @@ UINT ConnexionClient::GetRawInputBuffer(PRAWINPUT pData, PUINT pcbSize, UINT cbS
|
||||||
// Process the raw input device data
|
// Process the raw input device data
|
||||||
// On3dmouseInput() does all the preprocessing of the rawinput device data before
|
// On3dmouseInput() does all the preprocessing of the rawinput device data before
|
||||||
// finally calling the Move3d method.
|
// finally calling the Move3d method.
|
||||||
void ConnexionClient::On3dmouseInput() {
|
void SpacemouseManager::On3dmouseInput() {
|
||||||
// Don't do any data processing in background
|
// Don't do any data processing in background
|
||||||
bool bIsForeground = (::GetActiveWindow() != NULL);
|
bool bIsForeground = (::GetActiveWindow() != NULL);
|
||||||
if (!bIsForeground) {
|
if (!bIsForeground) {
|
||||||
|
@ -604,7 +593,7 @@ void ConnexionClient::On3dmouseInput() {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Called when new raw input data is available
|
//Called when new raw input data is available
|
||||||
void ConnexionClient::OnRawInput(UINT nInputCode, HRAWINPUT hRawInput) {
|
void SpacemouseManager::OnRawInput(UINT nInputCode, HRAWINPUT hRawInput) {
|
||||||
const size_t cbSizeOfBuffer = 1024;
|
const size_t cbSizeOfBuffer = 1024;
|
||||||
BYTE pBuffer[cbSizeOfBuffer];
|
BYTE pBuffer[cbSizeOfBuffer];
|
||||||
|
|
||||||
|
@ -645,7 +634,7 @@ void ConnexionClient::OnRawInput(UINT nInputCode, HRAWINPUT hRawInput) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConnexionClient::TranslateRawInputData(UINT nInputCode, PRAWINPUT pRawInput) {
|
bool SpacemouseManager::TranslateRawInputData(UINT nInputCode, PRAWINPUT pRawInput) {
|
||||||
bool bIsForeground = (nInputCode == RIM_INPUT);
|
bool bIsForeground = (nInputCode == RIM_INPUT);
|
||||||
|
|
||||||
// We are not interested in keyboard or mouse data received via raw input
|
// We are not interested in keyboard or mouse data received via raw input
|
||||||
|
@ -700,16 +689,16 @@ bool ConnexionClient::TranslateRawInputData(UINT nInputCode, PRAWINPUT pRawInput
|
||||||
|
|
||||||
//qDebug("Pan/Zoom RI Data =\t0x%x,\t0x%x,\t0x%x\n", pnRawData[0], pnRawData[1], pnRawData[2]);
|
//qDebug("Pan/Zoom RI Data =\t0x%x,\t0x%x,\t0x%x\n", pnRawData[0], pnRawData[1], pnRawData[2]);
|
||||||
|
|
||||||
if (pRawInput->data.hid.dwSizeHid >= 13) { // Highspeed package
|
//if (pRawInput->data.hid.dwSizeHid >= 13) { // Highspeed package
|
||||||
// Cache the rotation data
|
// // Cache the rotation data
|
||||||
deviceData.fAxes[3] = static_cast<float>(pnRawData[3]);
|
// deviceData.fAxes[3] = static_cast<float>(pnRawData[3]);
|
||||||
deviceData.fAxes[4] = static_cast<float>(pnRawData[4]);
|
// deviceData.fAxes[4] = static_cast<float>(pnRawData[4]);
|
||||||
deviceData.fAxes[5] = static_cast<float>(pnRawData[5]);
|
// deviceData.fAxes[5] = static_cast<float>(pnRawData[5]);
|
||||||
deviceData.fIsDirty = true;
|
// deviceData.fIsDirty = true;
|
||||||
|
|
||||||
// qDebug("Rotation RI Data =\t0x%x,\t0x%x,\t0x%x\n", pnRawData[3], pnRawData[4], pnRawData[5]);
|
// qDebug("Rotation RI Data =\t0x%x,\t0x%x,\t0x%x\n", pnRawData[3], pnRawData[4], pnRawData[5]);
|
||||||
return true;
|
// return true;
|
||||||
}
|
//}
|
||||||
} else { // Zero out the data if the app is not in forground
|
} else { // Zero out the data if the app is not in forground
|
||||||
deviceData.fAxes.assign(6, 0.f);
|
deviceData.fAxes.assign(6, 0.f);
|
||||||
}
|
}
|
||||||
|
@ -845,13 +834,13 @@ void MouseParameters::SetPivotVisibility(PivotVisibility visibility) {
|
||||||
|
|
||||||
int fConnexionClientID;
|
int fConnexionClientID;
|
||||||
|
|
||||||
static ConnexionDeviceState lastState;
|
static SpacemouseDeviceState lastState;
|
||||||
|
|
||||||
static void DeviceAddedHandler(unsigned int connection);
|
static void DeviceAddedHandler(unsigned int connection);
|
||||||
static void DeviceRemovedHandler(unsigned int connection);
|
static void DeviceRemovedHandler(unsigned int connection);
|
||||||
static void MessageHandler(unsigned int connection, unsigned int messageType, void *messageArgument);
|
static void MessageHandler(unsigned int connection, unsigned int messageType, void *messageArgument);
|
||||||
|
|
||||||
void ConnexionClient::toggleConnexion(bool shouldEnable) {
|
void SpacemouseManager::toggleSpacemouse(bool shouldEnable) {
|
||||||
if (shouldEnable && !Is3dmouseAttached()) {
|
if (shouldEnable && !Is3dmouseAttached()) {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
@ -860,7 +849,7 @@ void ConnexionClient::toggleConnexion(bool shouldEnable) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnexionClient::init() {
|
void SpacemouseManager::init() {
|
||||||
// Make sure the framework is installed
|
// Make sure the framework is installed
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Connexion)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::Connexion)) {
|
||||||
// Install message handler and register our client
|
// Install message handler and register our client
|
||||||
|
@ -870,8 +859,7 @@ void ConnexionClient::init() {
|
||||||
|
|
||||||
// ...or use this to take over system-wide
|
// ...or use this to take over system-wide
|
||||||
fConnexionClientID = RegisterConnexionClient(kConnexionClientWildcard, NULL, kConnexionClientModeTakeOver, kConnexionMaskAll);
|
fConnexionClientID = RegisterConnexionClient(kConnexionClientWildcard, NULL, kConnexionClientModeTakeOver, kConnexionMaskAll);
|
||||||
ConnexionData& connexiondata = ConnexionData::getInstance();
|
memcpy(&instance->clientId, &fConnexionClientID, (long)sizeof(int));
|
||||||
memcpy(&connexiondata.clientId, &fConnexionClientID, (long)sizeof(int));
|
|
||||||
|
|
||||||
// A separate API call is required to capture buttons beyond the first 8
|
// A separate API call is required to capture buttons beyond the first 8
|
||||||
SetConnexionClientButtonMask(fConnexionClientID, kConnexionMaskAllButtons);
|
SetConnexionClientButtonMask(fConnexionClientID, kConnexionMaskAllButtons);
|
||||||
|
@ -879,17 +867,17 @@ void ConnexionClient::init() {
|
||||||
// use default switches
|
// use default switches
|
||||||
ConnexionClientControl(fConnexionClientID, kConnexionCtlSetSwitches, kConnexionSwitchesDisabled, NULL);
|
ConnexionClientControl(fConnexionClientID, kConnexionCtlSetSwitches, kConnexionSwitchesDisabled, NULL);
|
||||||
|
|
||||||
if (Is3dmouseAttached() && connexiondata.getDeviceID() == 0) {
|
if (Is3dmouseAttached() && instance->getDeviceID() == controller::Input::INVALID_DEVICE) {
|
||||||
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
||||||
userInputMapper->registerDevice(&connexiondata);
|
userInputMapper->registerDevice(instance);
|
||||||
UserActivityLogger::getInstance().connectedDevice("controller", "3Dconnexion");
|
UserActivityLogger::getInstance().connectedDevice("controller", "Spacemouse");
|
||||||
}
|
}
|
||||||
//let one axis be dominant
|
//let one axis be dominant
|
||||||
//ConnexionClientControl(fConnexionClientID, kConnexionCtlSetSwitches, kConnexionSwitchDominant | kConnexionSwitchEnableAll, NULL);
|
//ConnexionClientControl(fConnexionClientID, kConnexionCtlSetSwitches, kConnexionSwitchDominant | kConnexionSwitchEnableAll, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnexionClient::destroy() {
|
void SpacemouseManager::destroy() {
|
||||||
// Make sure the framework is installed
|
// Make sure the framework is installed
|
||||||
if (&InstallConnexionHandlers != NULL) {
|
if (&InstallConnexionHandlers != NULL) {
|
||||||
// Unregister our client and clean up all handlers
|
// Unregister our client and clean up all handlers
|
||||||
|
@ -898,36 +886,33 @@ void ConnexionClient::destroy() {
|
||||||
}
|
}
|
||||||
CleanupConnexionHandlers();
|
CleanupConnexionHandlers();
|
||||||
fConnexionClientID = 0;
|
fConnexionClientID = 0;
|
||||||
ConnexionData& connexiondata = ConnexionData::getInstance();
|
if (instance->getDeviceID() != controller::Input::INVALID_DEVICE) {
|
||||||
if (connexiondata.getDeviceID()!=0) {
|
|
||||||
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
||||||
userInputMapper->removeDevice(connexiondata.getDeviceID());
|
userInputMapper->removeDevice(instance->getDeviceID());
|
||||||
connexiondata.setDeviceID(0);
|
instance->setDeviceID(controller::Input::INVALID_DEVICE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceAddedHandler(unsigned int connection) {
|
void DeviceAddedHandler(unsigned int connection) {
|
||||||
ConnexionData& connexiondata = ConnexionData::getInstance();
|
if (instance->getDeviceID() == controller::Input::INVALID_DEVICE) {
|
||||||
if (connexiondata.getDeviceID() == 0) {
|
qCWarning(interfaceapp) << "Spacemouse device added ";
|
||||||
qCWarning(interfaceapp) << "3Dconnexion device added ";
|
|
||||||
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
||||||
userInputMapper->registerDevice(&connexiondata);
|
userInputMapper->registerDevice(instance);
|
||||||
UserActivityLogger::getInstance().connectedDevice("controller", "3Dconnexion");
|
UserActivityLogger::getInstance().connectedDevice("controller", "Spacemouse");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceRemovedHandler(unsigned int connection) {
|
void DeviceRemovedHandler(unsigned int connection) {
|
||||||
ConnexionData& connexiondata = ConnexionData::getInstance();
|
if (instance->getDeviceID() != controller::Input::INVALID_DEVICE) {
|
||||||
if (connexiondata.getDeviceID() != 0) {
|
qCWarning(interfaceapp) << "Spacemouse device removed";
|
||||||
qCWarning(interfaceapp) << "3Dconnexion device removed";
|
|
||||||
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
||||||
userInputMapper->removeDevice(connexiondata.getDeviceID());
|
userInputMapper->removeDevice(instance->getDeviceID());
|
||||||
connexiondata.setDeviceID(0);
|
instance->setDeviceID(controller::Input::INVALID_DEVICE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConnexionClient::Is3dmouseAttached() {
|
bool SpacemouseManager::Is3dmouseAttached() {
|
||||||
int result;
|
int result;
|
||||||
if (fConnexionClientID) {
|
if (fConnexionClientID) {
|
||||||
if (ConnexionControl(kConnexionCtlGetDeviceID, 0, &result)) {
|
if (ConnexionControl(kConnexionCtlGetDeviceID, 0, &result)) {
|
||||||
|
@ -939,21 +924,20 @@ bool ConnexionClient::Is3dmouseAttached() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHandler(unsigned int connection, unsigned int messageType, void *messageArgument) {
|
void MessageHandler(unsigned int connection, unsigned int messageType, void *messageArgument) {
|
||||||
ConnexionDeviceState *state;
|
SpacemouseDeviceState *state;
|
||||||
|
|
||||||
switch (messageType) {
|
switch (messageType) {
|
||||||
case kConnexionMsgDeviceState:
|
case kConnexionMsgDeviceState:
|
||||||
state = (ConnexionDeviceState*)messageArgument;
|
state = (SpacemouseDeviceState*)messageArgument;
|
||||||
if (state->client == fConnexionClientID) {
|
if (state->client == fConnexionClientID) {
|
||||||
ConnexionData& connexiondata = ConnexionData::getInstance();
|
instance->cc_position = { state->axis[0], state->axis[1], state->axis[2] };
|
||||||
connexiondata.cc_position = { state->axis[0], state->axis[1], state->axis[2] };
|
instance->cc_rotation = { state->axis[3], state->axis[4], state->axis[5] };
|
||||||
connexiondata.cc_rotation = { state->axis[3], state->axis[4], state->axis[5] };
|
|
||||||
|
|
||||||
connexiondata.handleAxisEvent();
|
instance->handleAxisEvent();
|
||||||
if (state->buttons != lastState.buttons) {
|
if (state->buttons != lastState.buttons) {
|
||||||
connexiondata.setButton(state->buttons);
|
instance->setButton(state->buttons);
|
||||||
}
|
}
|
||||||
memmove(&lastState, state, (long)sizeof(ConnexionDeviceState));
|
memmove(&lastState, state, (long)sizeof(SpacemouseDeviceState));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kConnexionMsgPrefsChanged:
|
case kConnexionMsgPrefsChanged:
|
||||||
|
@ -968,5 +952,4 @@ void MessageHandler(unsigned int connection, unsigned int messageType, void *mes
|
||||||
|
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
|
|
||||||
#endif // HAVE_3DCONNEXIONCLIENT
|
|
||||||
#endif
|
#endif
|
70
interface/src/devices/3DConnexionClient.h → libraries/input-plugins/src/input-plugins/SpacemouseManager.h
Executable file → Normal file
70
interface/src/devices/3DConnexionClient.h → libraries/input-plugins/src/input-plugins/SpacemouseManager.h
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
||||||
// 3DConnexionClient.h
|
// SpacemouseManager.h
|
||||||
// interface/src/devices
|
// interface/src/devices
|
||||||
//
|
//
|
||||||
// Created by Marcel Verhagen on 09-06-15.
|
// Created by Marcel Verhagen on 09-06-15.
|
||||||
|
@ -8,34 +8,36 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef hifi_3DConnexionClient_h
|
#ifndef hifi_SpacemouseManager_h
|
||||||
#define hifi_3DConnexionClient_h
|
#define hifi_SpacemouseManager_h
|
||||||
|
|
||||||
#if 0
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QLibrary>
|
#include <QLibrary>
|
||||||
#include <controllers/UserInputMapper.h>
|
#include <controllers/UserInputMapper.h>
|
||||||
|
#include <controllers/InputDevice.h>
|
||||||
|
#include <controllers/StandardControls.h>
|
||||||
|
|
||||||
#include "InterfaceLogging.h"
|
#include "InputPlugin.h"
|
||||||
|
|
||||||
#ifndef HAVE_3DCONNEXIONCLIENT
|
#ifndef HAVE_3DCONNEXIONCLIENT
|
||||||
class ConnexionClient : public QObject {
|
class SpacemouseManager : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static ConnexionClient& getInstance();
|
static SpacemouseManager& getInstance();
|
||||||
void init() {};
|
void ManagerFocusOutEvent();
|
||||||
|
void init();
|
||||||
void destroy() {};
|
void destroy() {};
|
||||||
bool Is3dmouseAttached() { return false; };
|
bool Is3dmouseAttached() { return false; };
|
||||||
public slots:
|
public slots:
|
||||||
void toggleConnexion(bool shouldEnable) {};
|
void toggleSpacemouse(bool shouldEnable) {};
|
||||||
};
|
};
|
||||||
#endif // NOT_HAVE_3DCONNEXIONCLIENT
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_3DCONNEXIONCLIENT
|
#ifdef HAVE_3DCONNEXIONCLIENT
|
||||||
// the windows connexion rawinput
|
// the windows connexion rawinput
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
|
||||||
#include "I3dMouseParams.h"
|
#include "../../../interface/external/3dconnexionclient/include/I3dMouseParams.h"
|
||||||
#include <QAbstractNativeEventFilter>
|
#include <QAbstractNativeEventFilter>
|
||||||
#include <QAbstractEventDispatcher>
|
#include <QAbstractEventDispatcher>
|
||||||
#include <Winsock2.h>
|
#include <Winsock2.h>
|
||||||
|
@ -68,6 +70,8 @@ public:
|
||||||
|
|
||||||
static bool Is3dmouseAttached();
|
static bool Is3dmouseAttached();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MouseParameters(const MouseParameters&);
|
MouseParameters(const MouseParameters&);
|
||||||
const MouseParameters& operator = (const MouseParameters&);
|
const MouseParameters& operator = (const MouseParameters&);
|
||||||
|
@ -82,17 +86,20 @@ private:
|
||||||
Speed fSpeed;
|
Speed fSpeed;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConnexionClient : public QObject, public QAbstractNativeEventFilter {
|
class SpacemouseManager : public QObject, public QAbstractNativeEventFilter {
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ConnexionClient() {};
|
SpacemouseManager() {};
|
||||||
|
|
||||||
static ConnexionClient& getInstance();
|
static SpacemouseManager& getInstance();
|
||||||
void init();
|
void init();
|
||||||
void destroy();
|
void destroy();
|
||||||
bool Is3dmouseAttached();
|
bool Is3dmouseAttached();
|
||||||
|
|
||||||
ConnexionClient* client;
|
SpacemouseManager* client;
|
||||||
|
|
||||||
|
void ManagerFocusOutEvent();
|
||||||
|
|
||||||
I3dMouseParam& MouseParams();
|
I3dMouseParam& MouseParams();
|
||||||
const I3dMouseParam& MouseParams() const;
|
const I3dMouseParam& MouseParams() const;
|
||||||
|
@ -108,7 +115,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void toggleConnexion(bool shouldEnable);
|
void toggleSpacemouse(bool shouldEnable);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void Move3d(std::vector<float>& motionData);
|
void Move3d(std::vector<float>& motionData);
|
||||||
|
@ -157,31 +164,30 @@ private:
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include "ConnexionClientAPI.h"
|
#include "../../../interface/external/3dconnexionclient/include/ConnexionClientAPI.h"
|
||||||
|
|
||||||
class ConnexionClient : public QObject {
|
class SpacemouseManager : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static ConnexionClient& getInstance();
|
static SpacemouseManager& getInstance();
|
||||||
void init();
|
void init();
|
||||||
void destroy();
|
void destroy();
|
||||||
bool Is3dmouseAttached();
|
bool Is3dmouseAttached();
|
||||||
public slots:
|
public slots:
|
||||||
void toggleConnexion(bool shouldEnable);
|
void toggleSpacemouse(bool shouldEnable);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
|
|
||||||
#endif // HAVE_3DCONNEXIONCLIENT
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// connnects to the userinputmapper
|
// connnects to the userinputmapper
|
||||||
class ConnexionData : public QObject, public controller::InputDevice {
|
class SpacemouseDevice : public QObject, public controller::InputDevice {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ConnexionData& getInstance();
|
SpacemouseDevice();
|
||||||
ConnexionData();
|
|
||||||
enum PositionChannel {
|
enum PositionChannel {
|
||||||
TRANSLATE_X,
|
TRANSLATE_X,
|
||||||
TRANSLATE_Y,
|
TRANSLATE_Y,
|
||||||
|
@ -203,10 +209,14 @@ public:
|
||||||
float getButton(int channel) const;
|
float getButton(int channel) const;
|
||||||
float getAxis(int channel) const;
|
float getAxis(int channel) const;
|
||||||
|
|
||||||
controller::Input makeInput(ConnexionData::PositionChannel axis);
|
controller::Input makeInput(SpacemouseDevice::PositionChannel axis) const;
|
||||||
controller::Input makeInput(ConnexionData::ButtonChannel button);
|
controller::Input makeInput(SpacemouseDevice::ButtonChannel button) const;
|
||||||
virtual void buildDeviceProxy(controller::DeviceProxy::Pointer proxy) override;
|
|
||||||
virtual QString getDefaultMappingConfig() override;
|
controller::Input::NamedPair makePair(SpacemouseDevice::PositionChannel axis, const QString& name) const;
|
||||||
|
controller::Input::NamedPair makePair(SpacemouseDevice::ButtonChannel button, const QString& name) const;
|
||||||
|
|
||||||
|
virtual controller::Input::NamedVector getAvailableInputs() const override;
|
||||||
|
virtual QString getDefaultMappingConfig() const override;
|
||||||
virtual void update(float deltaTime, bool jointsCaptured) override;
|
virtual void update(float deltaTime, bool jointsCaptured) override;
|
||||||
virtual void focusOutEvent() override;
|
virtual void focusOutEvent() override;
|
||||||
|
|
||||||
|
@ -218,6 +228,4 @@ public:
|
||||||
void handleAxisEvent();
|
void handleAxisEvent();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // defined(hifi_SpacemouseManager_h)
|
||||||
|
|
||||||
#endif // defined(hifi_3DConnexionClient_h)
|
|
|
@ -25,7 +25,7 @@ bool OculusDebugDisplayPlugin::isSupported() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OculusDebugDisplayPlugin::customizeContext() {
|
void OculusDebugDisplayPlugin::customizeContext() {
|
||||||
WindowOpenGLDisplayPlugin::customizeContext();
|
OculusBaseDisplayPlugin::customizeContext();
|
||||||
enableVsync(false);
|
enableVsync(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ var HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||||
|
|
||||||
Resetter.prototype = {
|
Resetter.prototype = {
|
||||||
|
|
||||||
startNearGrabNonColliding: function() {
|
startNearTrigger: function() {
|
||||||
this.resetObjects();
|
this.resetObjects();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
startNearGrabNonColliding: function() {
|
startNearTrigger: function() {
|
||||||
this.triggerReset();
|
this.triggerReset();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -247,7 +247,8 @@ MasterReset = function() {
|
||||||
resetMe: true
|
resetMe: true
|
||||||
},
|
},
|
||||||
grabbableKey: {
|
grabbableKey: {
|
||||||
grabbable: false
|
grabbable: false,
|
||||||
|
wantsTrigger:true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
Resetter.prototype = {
|
Resetter.prototype = {
|
||||||
|
|
||||||
startNearGrabNonColliding: function() {
|
startNearTrigger: function() {
|
||||||
this.resetObjects();
|
this.resetObjects();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue