Add HMD roll control JavaScript API

This commit is contained in:
David Rowe 2017-06-14 11:55:04 +12:00
parent 88929c7bd7
commit 05f19d54f4
3 changed files with 55 additions and 0 deletions

View file

@ -132,6 +132,10 @@ class MyAvatar : public Avatar {
Q_PROPERTY(bool characterControllerEnabled READ getCharacterControllerEnabled WRITE setCharacterControllerEnabled)
Q_PROPERTY(bool useAdvancedMovementControls READ useAdvancedMovementControls WRITE setUseAdvancedMovementControls)
Q_PROPERTY(bool hmdRollControlEnabled READ getHMDRollControlEnabled WRITE setHMDRollControlEnabled)
Q_PROPERTY(float hmdRollControlDeadZone READ getHMDRollControlDeadZone WRITE setHMDRollControlDeadZone)
Q_PROPERTY(float hmdRollControlSpeed READ getHMDRollControlSpeed WRITE setHMDRollControlSpeed)
public:
enum DriveKeys {
TRANSLATE_X = 0,
@ -337,6 +341,13 @@ public:
void setUseAdvancedMovementControls(bool useAdvancedMovementControls)
{ _useAdvancedMovementControls.set(useAdvancedMovementControls); }
void setHMDRollControlEnabled(bool value) { _hmdRollControlEnabled = value; }
bool getHMDRollControlEnabled() const { return _hmdRollControlEnabled; }
void setHMDRollControlDeadZone(float value) { _hmdRollControlDeadZone = value; }
float getHMDRollControlDeadZone() const { return _hmdRollControlDeadZone; }
void setHMDRollControlSpeed(float value) { _hmdRollControlSpeed = value; }
float getHMDRollControlSpeed() const { return _hmdRollControlSpeed; }
// get/set avatar data
void saveData();
void loadData();
@ -687,6 +698,12 @@ private:
bool _useSnapTurn { true };
bool _clearOverlayWhenMoving { true };
const float ROLL_CONTROL_DEAD_ZONE_DEFAULT = 8.0f; // deg
const float ROLL_CONTROL_SPEED_DEFAULT = 2.5f; // deg/sec/deg
bool _hmdRollControlEnabled { true };
float _hmdRollControlDeadZone { ROLL_CONTROL_DEAD_ZONE_DEFAULT };
float _hmdRollControlSpeed { ROLL_CONTROL_SPEED_DEFAULT };
// working copies -- see AvatarData for thread-safe _sensorToWorldMatrixCache, used for outward facing access
glm::mat4 _sensorToWorldMatrix { glm::mat4() };

View file

@ -0,0 +1,17 @@
//
// hmdRollControlDisable.js
//
// Created by David Rowe on 4 Jun 2017.
// Copyright 2017 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 hmdRollControlEnabled = false;
print("HMD roll control: " + hmdRollControlEnabled);
MyAvatar.hmdRollControlEnabled = hmdRollControlEnabled;
Script.stop();

View file

@ -0,0 +1,21 @@
//
// hmdRollControlEnable.js
//
// Created by David Rowe on 4 Jun 2017.
// Copyright 2017 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 hmdRollControlEnabled = true;
var hmdRollControlDeadZone = 8.0; // deg
var hmdRollControlSpeed = 1.0; // deg/sec/deg
print("HMD roll control: " + hmdRollControlEnabled + ", " + hmdRollControlDeadZone + ", " + hmdRollControlSpeed);
MyAvatar.hmdRollControlEnabled = hmdRollControlEnabled;
MyAvatar.hmdRollControlDeadZone = hmdRollControlDeadZone;
MyAvatar.hmdRollControlSpeed = hmdRollControlSpeed;
Script.stop();