mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 17:53:32 +02:00
Add pitch/yaw scale preference to control degree of view rotation.
This commit is contained in:
parent
ffc1c33455
commit
e0e94481c9
5 changed files with 21 additions and 9 deletions
|
@ -26,6 +26,7 @@
|
|||
#include <QColorDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QDesktopWidget>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QFormLayout>
|
||||
#include <QGLWidget>
|
||||
#include <QKeyEvent>
|
||||
|
@ -144,6 +145,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
_viewFrustumOffsetUp(0.0),
|
||||
_audioScope(256, 200, true),
|
||||
_manualFirstPerson(false),
|
||||
_headCameraPitchYawScale(0.0f),
|
||||
_mouseX(0),
|
||||
_mouseY(0),
|
||||
_mousePressed(false),
|
||||
|
@ -311,11 +313,11 @@ void Application::paintGL() {
|
|||
} else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
|
||||
_myCamera.setTightness(0.0f); // In first person, camera follows head exactly without delay
|
||||
_myCamera.setTargetPosition(_myAvatar.getBallPosition(AVATAR_JOINT_HEAD_BASE));
|
||||
_myCamera.setTargetRotation(_myAvatar.getHead().getCameraOrientation());
|
||||
_myCamera.setTargetRotation(_myAvatar.getHead().getCameraOrientation(_headCameraPitchYawScale));
|
||||
|
||||
} else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
|
||||
_myCamera.setTargetPosition(_myAvatar.getHeadJointPosition());
|
||||
_myCamera.setTargetRotation(_myAvatar.getHead().getCameraOrientation());
|
||||
_myCamera.setTargetRotation(_myAvatar.getHead().getCameraOrientation(_headCameraPitchYawScale));
|
||||
}
|
||||
|
||||
// Update camera position
|
||||
|
@ -1026,6 +1028,10 @@ void Application::editPreferences() {
|
|||
avatarURL->setMinimumWidth(400);
|
||||
form->addRow("Avatar URL:", avatarURL);
|
||||
|
||||
QDoubleSpinBox* headCameraPitchYawScale = new QDoubleSpinBox();
|
||||
headCameraPitchYawScale->setValue(_headCameraPitchYawScale);
|
||||
form->addRow("Head Camera Pitch/Yaw Scale:", headCameraPitchYawScale);
|
||||
|
||||
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
dialog.connect(buttons, SIGNAL(accepted()), SLOT(accept()));
|
||||
dialog.connect(buttons, SIGNAL(rejected()), SLOT(reject()));
|
||||
|
@ -1038,6 +1044,8 @@ void Application::editPreferences() {
|
|||
_settings->setValue("avatarURL", url);
|
||||
_myAvatar.getVoxels()->setVoxelURL(url);
|
||||
sendAvatarVoxelURLMessage(url);
|
||||
|
||||
_headCameraPitchYawScale = headCameraPitchYawScale->value();
|
||||
}
|
||||
|
||||
void Application::pair() {
|
||||
|
@ -2538,6 +2546,7 @@ void Application::loadSettings(QSettings* set) {
|
|||
|
||||
scanMenuBar(&Application::loadAction, set);
|
||||
getAvatar()->loadData(set);
|
||||
_headCameraPitchYawScale = set->value("headCameraPitchYawScale").toFloat();
|
||||
}
|
||||
|
||||
void Application::saveSettings(QSettings* set) {
|
||||
|
@ -2545,6 +2554,7 @@ void Application::saveSettings(QSettings* set) {
|
|||
|
||||
scanMenuBar(&Application::saveAction, set);
|
||||
getAvatar()->saveData(set);
|
||||
set->setValue("headCameraPitchYawScale", _headCameraPitchYawScale);
|
||||
}
|
||||
|
||||
void Application::importSettings() {
|
||||
|
|
|
@ -248,6 +248,7 @@ private:
|
|||
|
||||
int _headMouseX, _headMouseY;
|
||||
bool _manualFirstPerson;
|
||||
float _headCameraPitchYawScale;
|
||||
|
||||
HandControl _handControl;
|
||||
|
||||
|
|
|
@ -314,9 +314,10 @@ glm::quat Head::getOrientation() const {
|
|||
glm::vec3(_pitch, -_yaw, -_roll) : glm::vec3(_pitch, _yaw, _roll)));
|
||||
}
|
||||
|
||||
glm::quat Head::getCameraOrientation () const {
|
||||
glm::quat Head::getCameraOrientation (float pitchYawScale) const {
|
||||
Avatar* owningAvatar = static_cast<Avatar*>(_owningAvatar);
|
||||
return owningAvatar->getWorldAlignedOrientation() * glm::quat(glm::radians(glm::vec3(_pitch, _yaw, 0.0f)));
|
||||
return owningAvatar->getWorldAlignedOrientation() * glm::quat(glm::radians(glm::vec3(
|
||||
_pitch * pitchYawScale, _yaw * pitchYawScale, 0.0f)));
|
||||
}
|
||||
|
||||
void Head::renderHeadSphere() {
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
void setRenderLookatVectors(bool onOff ) { _renderLookatVectors = onOff; }
|
||||
|
||||
glm::quat getOrientation() const;
|
||||
glm::quat getCameraOrientation () const;
|
||||
glm::quat getCameraOrientation (float pitchYawScale) const;
|
||||
|
||||
glm::vec3 getRightDirection() const { return getOrientation() * IDENTITY_RIGHT; }
|
||||
glm::vec3 getUpDirection () const { return getOrientation() * IDENTITY_UP; }
|
||||
|
|
|
@ -215,7 +215,7 @@ void SerialInterface::readData(float deltaTime) {
|
|||
// From MPU-9150 register map, with setting on
|
||||
// highest resolution = +/- 2G
|
||||
|
||||
_lastAcceleration = glm::vec3(accelXRate, accelYRate, accelZRate) * LSB_TO_METERS_PER_SECOND2;
|
||||
_lastAcceleration = glm::vec3(-accelXRate, -accelYRate, -accelZRate) * LSB_TO_METERS_PER_SECOND2;
|
||||
|
||||
int rollRate, yawRate, pitchRate;
|
||||
|
||||
|
@ -225,9 +225,9 @@ void SerialInterface::readData(float deltaTime) {
|
|||
|
||||
// Convert the integer rates to floats
|
||||
const float LSB_TO_DEGREES_PER_SECOND = 1.f / 16.4f; // From MPU-9150 register map, 2000 deg/sec.
|
||||
_lastRotationRates[0] = ((float) pitchRate) * LSB_TO_DEGREES_PER_SECOND;
|
||||
_lastRotationRates[1] = ((float) yawRate) * LSB_TO_DEGREES_PER_SECOND;
|
||||
_lastRotationRates[2] = ((float) rollRate) * LSB_TO_DEGREES_PER_SECOND;
|
||||
_lastRotationRates[0] = ((float) -pitchRate) * LSB_TO_DEGREES_PER_SECOND;
|
||||
_lastRotationRates[1] = ((float) -yawRate) * LSB_TO_DEGREES_PER_SECOND;
|
||||
_lastRotationRates[2] = ((float) -rollRate) * LSB_TO_DEGREES_PER_SECOND;
|
||||
|
||||
// Update raw rotation estimates
|
||||
glm::quat estimatedRotation = glm::quat(glm::radians(_estimatedRotation)) *
|
||||
|
|
Loading…
Reference in a new issue