diff --git a/examples/cameraExample.js b/examples/cameraExample.js index ddfff15935..6e3c51a348 100644 --- a/examples/cameraExample.js +++ b/examples/cameraExample.js @@ -74,7 +74,7 @@ function checkCamera(deltaTime) { if (yaw < -360) { yaw += 360; } - var orientation = Quat.fromPitchYawRoll(pitch, yaw, roll); + var orientation = Quat.fromPitchYawRollDegrees(pitch, yaw, roll); Camera.setOrientation(orientation); } } diff --git a/examples/crazylegs.js b/examples/crazylegs.js index 0f26088ae0..0daf2275f3 100644 --- a/examples/crazylegs.js +++ b/examples/crazylegs.js @@ -14,10 +14,10 @@ var cumulativeTime = 0.0; Script.update.connect(function(deltaTime) { cumulativeTime += deltaTime; - MyAvatar.setJointData("joint_R_hip", Quat.fromPitchYawRoll(0.0, 0.0, AMPLITUDE * Math.sin(cumulativeTime * FREQUENCY))); - MyAvatar.setJointData("joint_L_hip", Quat.fromPitchYawRoll(0.0, 0.0, -AMPLITUDE * Math.sin(cumulativeTime * FREQUENCY))); - MyAvatar.setJointData("joint_R_knee", Quat.fromPitchYawRoll(0.0, 0.0, + MyAvatar.setJointData("joint_R_hip", Quat.fromPitchYawRollDegrees(0.0, 0.0, AMPLITUDE * Math.sin(cumulativeTime * FREQUENCY))); + MyAvatar.setJointData("joint_L_hip", Quat.fromPitchYawRollDegrees(0.0, 0.0, -AMPLITUDE * Math.sin(cumulativeTime * FREQUENCY))); + MyAvatar.setJointData("joint_R_knee", Quat.fromPitchYawRollDegrees(0.0, 0.0, AMPLITUDE * (1.0 + Math.sin(cumulativeTime * FREQUENCY)))); - MyAvatar.setJointData("joint_L_knee", Quat.fromPitchYawRoll(0.0, 0.0, + MyAvatar.setJointData("joint_L_knee", Quat.fromPitchYawRollDegrees(0.0, 0.0, AMPLITUDE * (1.0 - Math.sin(cumulativeTime * FREQUENCY)))); }); diff --git a/examples/gun.js b/examples/gun.js index 6f80b62ef5..29b60a94ad 100644 --- a/examples/gun.js +++ b/examples/gun.js @@ -152,7 +152,7 @@ function update(deltaTime) { // Check for mouseLook movement, update rotation // rotate body yaw for yaw received from mouse - var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromVec3( { x: 0, y: yawFromMouse, z: 0 } )); + var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromVec3Radians( { x: 0, y: yawFromMouse, z: 0 } )); MyAvatar.orientation = newOrientation; yawFromMouse = 0; diff --git a/examples/hydraMove.js b/examples/hydraMove.js index 1f9634a8e6..92c594df9e 100644 --- a/examples/hydraMove.js +++ b/examples/hydraMove.js @@ -184,7 +184,7 @@ function flyWithHydra(deltaTime) { // change the body yaw based on our x controller var orientation = MyAvatar.orientation; - var deltaOrientation = Quat.fromPitchYawRoll(0, (-1 * viewJoystickPosition.x * JOYSTICK_YAW_MAG * deltaTime), 0); + var deltaOrientation = Quat.fromPitchYawRollDegrees(0, (-1 * viewJoystickPosition.x * JOYSTICK_YAW_MAG * deltaTime), 0); MyAvatar.orientation = Quat.multiply(orientation, deltaOrientation); // change the headPitch based on our x controller diff --git a/examples/lookWithMouse.js b/examples/lookWithMouse.js index 878813a94a..ef8f11ec16 100644 --- a/examples/lookWithMouse.js +++ b/examples/lookWithMouse.js @@ -54,7 +54,7 @@ function update(deltaTime) { print("update()..."); } // rotate body yaw for yaw received from mouse - var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromVec3( { x: 0, y: yawFromMouse, z: 0 } )); + var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromVec3Radians( { x: 0, y: yawFromMouse, z: 0 } )); if (wantDebugging) { print("changing orientation" + " [old]MyAvatar.orientation="+MyAvatar.orientation.x + "," + MyAvatar.orientation.y + "," diff --git a/examples/lookWithTouch.js b/examples/lookWithTouch.js index ddc42c04c0..852573aea6 100644 --- a/examples/lookWithTouch.js +++ b/examples/lookWithTouch.js @@ -45,7 +45,7 @@ function touchUpdateEvent(event) { function update(deltaTime) { // rotate body yaw for yaw received from mouse - var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromVec3( { x: 0, y: yawFromMouse, z: 0 } )); + var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromPitchYawRollRadians(0, yawFromMouse, 0)); if (wantDebugging) { print("changing orientation" + " [old]MyAvatar.orientation="+MyAvatar.orientation.x + "," + MyAvatar.orientation.y + "," diff --git a/examples/multitouchExample.js b/examples/multitouchExample.js index 1041651c7b..51bbcc2c20 100644 --- a/examples/multitouchExample.js +++ b/examples/multitouchExample.js @@ -92,7 +92,7 @@ Controller.touchEndEvent.connect(touchEndEvent); function update(deltaTime) { // rotate body yaw for yaw received from multitouch rotate - var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromVec3( { x: 0, y: yawFromMultiTouch, z: 0 } )); + var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromVec3Radians( { x: 0, y: yawFromMultiTouch, z: 0 } )); if (wantDebugging) { print("changing orientation" + " [old]MyAvatar.orientation="+MyAvatar.orientation.x + "," + MyAvatar.orientation.y + "," diff --git a/examples/seeingVoxelsExample.js b/examples/seeingVoxelsExample.js index 62ebd599ee..257e869b5b 100644 --- a/examples/seeingVoxelsExample.js +++ b/examples/seeingVoxelsExample.js @@ -17,7 +17,7 @@ var yawMin = 20; var isLocal = false; // set up our VoxelViewer with a position and orientation -var orientation = Quat.fromPitchYawRoll(0, yaw, 0); +var orientation = Quat.fromPitchYawRollDegrees(0, yaw, 0); function init() { if (isLocal) { @@ -40,7 +40,7 @@ function keepLooking(deltaTime) { count++; if (count % 10 == 0) { yaw += yawDirection; - orientation = Quat.fromPitchYawRoll(0, yaw, 0); + orientation = Quat.fromPitchYawRollDegrees(0, yaw, 0); if (yaw > yawMax || yaw < yawMin) { yawDirection = yawDirection * -1; } diff --git a/interface/interface_en.ts b/interface/interface_en.ts index c52ec91671..f07f50f287 100644 --- a/interface/interface_en.ts +++ b/interface/interface_en.ts @@ -4,22 +4,22 @@ Application - + Export Voxels - + Sparse Voxel Octree Files (*.svo) - + Open Script - + JavaScript Files (*.js) @@ -45,7 +45,7 @@ - + day %n day @@ -53,7 +53,7 @@ - + hour %n hour @@ -61,7 +61,7 @@ - + minute %n minute @@ -76,7 +76,7 @@ - + %1 online now: diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index fedde89a38..37b2810c68 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -292,14 +291,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : ResourceCache::setNetworkAccessManager(_networkAccessManager); ResourceCache::setRequestLimit(3); - QWidget* centralWidget = new QWidget(); - QHBoxLayout* mainLayout = new QHBoxLayout(); - mainLayout->setSpacing(0); - mainLayout->setContentsMargins(0, 0, 0, 0); - centralWidget->setLayout(mainLayout); - _glWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - centralWidget->layout()->addWidget(_glWidget); - _window->setCentralWidget(centralWidget); + _window->setCentralWidget(_glWidget); restoreSizeAndPosition(); diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 15cfb78cca..c4b7fdcdd6 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -1044,13 +1044,11 @@ void Menu::showMetavoxelEditor() { void Menu::showChat() { if (!_chatWindow) { - _chatWindow = new ChatWindow(); - QMainWindow* mainWindow = Application::getInstance()->getWindow(); - QBoxLayout* boxLayout = static_cast(mainWindow->centralWidget()->layout()); - boxLayout->addWidget(_chatWindow, 0, Qt::AlignRight); + Application::getInstance()->getWindow()->addDockWidget(Qt::RightDockWidgetArea, _chatWindow = new ChatWindow()); + } else { - if (!_chatWindow->isVisible()) { - _chatWindow->show(); + if (!_chatWindow->toggleViewAction()->isChecked()) { + _chatWindow->toggleViewAction()->trigger(); } } } @@ -1058,8 +1056,8 @@ void Menu::showChat() { void Menu::toggleChat() { #ifdef HAVE_QXMPP _chatAction->setEnabled(XmppClient::getInstance().getXMPPClient().isConnected()); - if (!_chatAction->isEnabled() && _chatWindow) { - _chatWindow->hide(); + if (!_chatAction->isEnabled() && _chatWindow && _chatWindow->toggleViewAction()->isChecked()) { + _chatWindow->toggleViewAction()->trigger(); } #endif } diff --git a/interface/src/avatar/Head.cpp b/interface/src/avatar/Head.cpp index 6c2bad865f..a9b85ffce2 100644 --- a/interface/src/avatar/Head.cpp +++ b/interface/src/avatar/Head.cpp @@ -36,9 +36,9 @@ Head::Head(Avatar* owningAvatar) : _leftEyeBlinkVelocity(0.0f), _rightEyeBlinkVelocity(0.0f), _timeWithoutTalking(0.0f), - _tweakedPitch(0.f), - _tweakedYaw(0.f), - _tweakedRoll(0.f), + _pitchTweak(0.f), + _yawTweak(0.f), + _rollTweak(0.f), _isCameraMoving(false), _faceModel(this) { @@ -202,15 +202,15 @@ glm::vec3 Head::getScalePivot() const { } float Head::getTweakedYaw() const { - return glm::clamp(_yaw + _tweakedYaw, MIN_HEAD_YAW, MAX_HEAD_YAW); + return glm::clamp(_yaw + _yawTweak, MIN_HEAD_YAW, MAX_HEAD_YAW); } float Head::getTweakedPitch() const { - return glm::clamp(_pitch + _tweakedPitch, MIN_HEAD_PITCH, MAX_HEAD_PITCH); + return glm::clamp(_pitch + _pitchTweak, MIN_HEAD_PITCH, MAX_HEAD_PITCH); } float Head::getTweakedRoll() const { - return glm::clamp(_roll + _tweakedRoll, MIN_HEAD_ROLL, MAX_HEAD_ROLL); + return glm::clamp(_roll + _rollTweak, MIN_HEAD_ROLL, MAX_HEAD_ROLL); } void Head::applyCollision(CollisionInfo& collision) { diff --git a/interface/src/avatar/Head.h b/interface/src/avatar/Head.h index 7e7a96a3a7..a9ea9b4cc6 100644 --- a/interface/src/avatar/Head.h +++ b/interface/src/avatar/Head.h @@ -70,10 +70,15 @@ public: /// Returns the point about which scaling occurs. glm::vec3 getScalePivot() const; - void tweakPitch(float pitch) { _tweakedPitch = pitch; } - void tweakYaw(float yaw) { _tweakedYaw = yaw; } - void tweakRoll(float roll) { _tweakedRoll = roll; } + void setPitchTweak(float pitch) { _pitchTweak = pitch; } + float getPitchTweak() const { return _pitchTweak; } + void setYawTweak(float yaw) { _yawTweak = yaw; } + float getYawTweak() const { return _yawTweak; } + + void setRollTweak(float roll) { _rollTweak = roll; } + float getRollTweak() const { return _rollTweak; } + virtual float getTweakedPitch() const; virtual float getTweakedYaw() const; virtual float getTweakedRoll() const; @@ -104,9 +109,9 @@ private: float _timeWithoutTalking; // tweaked angles affect the rendered head, but not the camera - float _tweakedPitch; - float _tweakedYaw; - float _tweakedRoll; + float _pitchTweak; + float _yawTweak; + float _rollTweak; bool _isCameraMoving; FaceModel _faceModel; diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 0a2462e656..e4aaa07a4b 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -363,8 +363,9 @@ void MyAvatar::updateFromGyros(float deltaTime) { // restore rotation, lean to neutral positions const float RESTORE_PERIOD = 1.f; // seconds float restorePercentage = glm::clamp(deltaTime/RESTORE_PERIOD, 0.f, 1.f); - head->setYaw(glm::mix(head->getYaw(), 0.0f, restorePercentage)); - head->setRoll(glm::mix(head->getRoll(), 0.0f, restorePercentage)); + head->setPitchTweak(glm::mix(head->getPitchTweak(), 0.0f, restorePercentage)); + head->setYawTweak(glm::mix(head->getYawTweak(), 0.0f, restorePercentage)); + head->setRollTweak(glm::mix(head->getRollTweak(), 0.0f, restorePercentage)); head->setLeanSideways(glm::mix(head->getLeanSideways(), 0.0f, restorePercentage)); head->setLeanForward(glm::mix(head->getLeanForward(), 0.0f, restorePercentage)); return; @@ -375,9 +376,9 @@ void MyAvatar::updateFromGyros(float deltaTime) { const float AVATAR_HEAD_PITCH_MAGNIFY = 1.0f; const float AVATAR_HEAD_YAW_MAGNIFY = 1.0f; const float AVATAR_HEAD_ROLL_MAGNIFY = 1.0f; - head->tweakPitch(estimatedRotation.x * AVATAR_HEAD_PITCH_MAGNIFY); - head->tweakYaw(estimatedRotation.y * AVATAR_HEAD_YAW_MAGNIFY); - head->tweakRoll(estimatedRotation.z * AVATAR_HEAD_ROLL_MAGNIFY); + head->setPitchTweak(estimatedRotation.x * AVATAR_HEAD_PITCH_MAGNIFY); + head->setYawTweak(estimatedRotation.y * AVATAR_HEAD_YAW_MAGNIFY); + head->setRollTweak(estimatedRotation.z * AVATAR_HEAD_ROLL_MAGNIFY); // Update torso lean distance based on accelerometer data const float TORSO_LENGTH = 0.5f; diff --git a/interface/src/ui/ChatWindow.cpp b/interface/src/ui/ChatWindow.cpp index 103f045cfa..55f32c5c7c 100644 --- a/interface/src/ui/ChatWindow.cpp +++ b/interface/src/ui/ChatWindow.cpp @@ -28,17 +28,21 @@ const int NUM_MESSAGES_TO_TIME_STAMP = 20; const QRegularExpression regexLinks("((?:(?:ftp)|(?:https?))://\\S+)"); ChatWindow::ChatWindow() : - QWidget(), ui(new Ui::ChatWindow), numMessagesAfterLastTimeStamp(0) { - ui->setupUi(this); + QWidget* widget = new QWidget(); + setWidget(widget); + + ui->setupUi(widget); FlowLayout* flowLayout = new FlowLayout(0, 4, 4); ui->usersWidget->setLayout(flowLayout); ui->messagePlainTextEdit->installEventFilter(this); + ui->closeButton->hide(); + #ifdef HAVE_QXMPP const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient(); if (xmppClient.isConnected()) { diff --git a/interface/src/ui/ChatWindow.h b/interface/src/ui/ChatWindow.h index fbf9fc0859..da8d423b9d 100644 --- a/interface/src/ui/ChatWindow.h +++ b/interface/src/ui/ChatWindow.h @@ -10,8 +10,8 @@ #define __interface__ChatWindow__ #include +#include #include -#include #include @@ -26,7 +26,7 @@ namespace Ui { class ChatWindow; } -class ChatWindow : public QWidget { +class ChatWindow : public QDockWidget { Q_OBJECT public: diff --git a/libraries/script-engine/src/Quat.cpp b/libraries/script-engine/src/Quat.cpp index 14025f0c67..c939811db4 100644 --- a/libraries/script-engine/src/Quat.cpp +++ b/libraries/script-engine/src/Quat.cpp @@ -22,14 +22,22 @@ glm::quat Quat::multiply(const glm::quat& q1, const glm::quat& q2) { return q1 * q2; } -glm::quat Quat::fromVec3(const glm::vec3& eulerAngles) { +glm::quat Quat::fromVec3Degrees(const glm::vec3& eulerAngles) { return glm::quat(glm::radians(eulerAngles)); } -glm::quat Quat::fromPitchYawRoll(float pitch, float yaw, float roll) { +glm::quat Quat::fromVec3Radians(const glm::vec3& eulerAngles) { + return glm::quat(eulerAngles); +} + +glm::quat Quat::fromPitchYawRollDegrees(float pitch, float yaw, float roll) { return glm::quat(glm::radians(glm::vec3(pitch, yaw, roll))); } +glm::quat Quat::fromPitchYawRollRadians(float pitch, float yaw, float roll) { + return glm::quat(glm::vec3(pitch, yaw, roll)); +} + glm::quat Quat::inverse(const glm::quat& q) { return glm::inverse(q); } diff --git a/libraries/script-engine/src/Quat.h b/libraries/script-engine/src/Quat.h index 3e5f46682c..02c0a3e147 100644 --- a/libraries/script-engine/src/Quat.h +++ b/libraries/script-engine/src/Quat.h @@ -23,8 +23,10 @@ class Quat : public QObject { public slots: glm::quat multiply(const glm::quat& q1, const glm::quat& q2); - glm::quat fromVec3(const glm::vec3& vec3); - glm::quat fromPitchYawRoll(float pitch, float yaw, float roll); // degrees + glm::quat fromVec3Degrees(const glm::vec3& vec3); // degrees + glm::quat fromVec3Radians(const glm::vec3& vec3); // radians + glm::quat fromPitchYawRollDegrees(float pitch, float yaw, float roll); // degrees + glm::quat fromPitchYawRollRadians(float pitch, float yaw, float roll); // radians glm::quat inverse(const glm::quat& q); glm::vec3 getFront(const glm::quat& orientation); glm::vec3 getRight(const glm::quat& orientation);