mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-10 04:27:44 +02:00
making changes
This commit is contained in:
parent
c949b44f0c
commit
272f71b940
2 changed files with 20 additions and 56 deletions
|
@ -2789,37 +2789,22 @@ void Application::updateCamera(RenderArgs& renderArgs, float deltaTime) {
|
||||||
}
|
}
|
||||||
else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||||
_thirdPersonHMDCameraBoomValid= false;
|
_thirdPersonHMDCameraBoomValid= false;
|
||||||
if (isHMDMode()) {
|
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
||||||
auto mirrorBodyOrientation = myAvatar->getWorldOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f));
|
const float YAW_SPEED = 70.0f;
|
||||||
|
float targetSpeed = userInputMapper->getActionState(controller::Action::YAW) * YAW_SPEED;
|
||||||
glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());
|
if (targetSpeed != 0.0f) {
|
||||||
// Mirror HMD yaw and roll
|
const float ROTATION_TIMESCALE = 20.0f;
|
||||||
glm::vec3 mirrorHmdEulers = glm::eulerAngles(hmdRotation);
|
float blend = deltaTime / ROTATION_TIMESCALE;
|
||||||
mirrorHmdEulers.y = -mirrorHmdEulers.y;
|
if (blend > 1.0f) {
|
||||||
mirrorHmdEulers.z = -mirrorHmdEulers.z;
|
blend = 1.0f;
|
||||||
glm::quat mirrorHmdRotation = glm::quat(mirrorHmdEulers);
|
}
|
||||||
|
_rotateMirror = (1.0f - blend) * _rotateMirror + blend * targetSpeed;
|
||||||
glm::quat worldMirrorRotation = mirrorBodyOrientation * mirrorHmdRotation;
|
|
||||||
|
|
||||||
_myCamera.setOrientation(worldMirrorRotation);
|
|
||||||
|
|
||||||
glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix());
|
|
||||||
// Mirror HMD lateral offsets
|
|
||||||
hmdOffset.x = -hmdOffset.x;
|
|
||||||
|
|
||||||
_myCamera.setPosition(myAvatar->getDefaultEyePosition()
|
|
||||||
+ glm::vec3(0, _raiseMirror * myAvatar->getModelScale(), 0)
|
|
||||||
+ mirrorBodyOrientation * glm::vec3(0.0f, 0.0f, 1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror
|
|
||||||
+ mirrorBodyOrientation * hmdOffset);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_myCamera.setOrientation(myAvatar->getWorldOrientation()
|
|
||||||
* glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
|
|
||||||
_myCamera.setPosition(myAvatar->getDefaultEyePosition()
|
|
||||||
+ glm::vec3(0, _raiseMirror * myAvatar->getModelScale(), 0)
|
|
||||||
+ (myAvatar->getWorldOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
|
|
||||||
glm::vec3(0.0f, 0.0f, -1.0f) * myAvatar->getBoomLength() * _scaleMirror);
|
|
||||||
}
|
}
|
||||||
|
_myCamera.setOrientation(glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
|
||||||
|
_myCamera.setPosition(myAvatar->getDefaultEyePosition()
|
||||||
|
+ glm::vec3(0, _raiseMirror * myAvatar->getModelScale(), 0)
|
||||||
|
+ (glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
|
||||||
|
glm::vec3(0.0f, 0.0f, -1.0f) * myAvatar->getBoomLength() * _scaleMirror);
|
||||||
renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
|
renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
|
||||||
}
|
}
|
||||||
else if (_myCamera.getMode() == CAMERA_MODE_ENTITY) {
|
else if (_myCamera.getMode() == CAMERA_MODE_ENTITY) {
|
||||||
|
@ -3408,7 +3393,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_P:
|
case Qt::Key_Print:
|
||||||
if (!isOption && !isShifted && isMeta) {
|
if (!isOption && !isShifted && isMeta) {
|
||||||
AudioInjectorOptions options;
|
AudioInjectorOptions options;
|
||||||
options.localOnly = true;
|
options.localOnly = true;
|
||||||
|
@ -3448,26 +3433,6 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
Menu::getInstance()->triggerOption(MenuOption::Chat);
|
Menu::getInstance()->triggerOption(MenuOption::Chat);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Up:
|
|
||||||
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
|
||||||
if (!isShifted) {
|
|
||||||
_scaleMirror *= 0.95f;
|
|
||||||
} else {
|
|
||||||
_raiseMirror += 0.05f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Qt::Key_Down:
|
|
||||||
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
|
||||||
if (!isShifted) {
|
|
||||||
_scaleMirror *= 1.05f;
|
|
||||||
} else {
|
|
||||||
_raiseMirror -= 0.05f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Qt::Key_Left:
|
case Qt::Key_Left:
|
||||||
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||||
_rotateMirror += PI / 20.0f;
|
_rotateMirror += PI / 20.0f;
|
||||||
|
@ -5133,7 +5098,7 @@ void Application::update(float deltaTime) {
|
||||||
myAvatar->setDriveKey(MyAvatar::TRANSLATE_Z, -1.0f * userInputMapper->getActionState(controller::Action::TRANSLATE_Z));
|
myAvatar->setDriveKey(MyAvatar::TRANSLATE_Z, -1.0f * userInputMapper->getActionState(controller::Action::TRANSLATE_Z));
|
||||||
myAvatar->setDriveKey(MyAvatar::TRANSLATE_Y, userInputMapper->getActionState(controller::Action::TRANSLATE_Y));
|
myAvatar->setDriveKey(MyAvatar::TRANSLATE_Y, userInputMapper->getActionState(controller::Action::TRANSLATE_Y));
|
||||||
myAvatar->setDriveKey(MyAvatar::TRANSLATE_X, userInputMapper->getActionState(controller::Action::TRANSLATE_X));
|
myAvatar->setDriveKey(MyAvatar::TRANSLATE_X, userInputMapper->getActionState(controller::Action::TRANSLATE_X));
|
||||||
if (deltaTime > FLT_EPSILON) {
|
if (deltaTime > FLT_EPSILON && _myCamera.getMode() != CAMERA_MODE_MIRROR) {
|
||||||
myAvatar->setDriveKey(MyAvatar::PITCH, -1.0f * userInputMapper->getActionState(controller::Action::PITCH));
|
myAvatar->setDriveKey(MyAvatar::PITCH, -1.0f * userInputMapper->getActionState(controller::Action::PITCH));
|
||||||
myAvatar->setDriveKey(MyAvatar::YAW, -1.0f * userInputMapper->getActionState(controller::Action::YAW));
|
myAvatar->setDriveKey(MyAvatar::YAW, -1.0f * userInputMapper->getActionState(controller::Action::YAW));
|
||||||
myAvatar->setDriveKey(MyAvatar::STEP_YAW, -1.0f * userInputMapper->getActionState(controller::Action::STEP_YAW));
|
myAvatar->setDriveKey(MyAvatar::STEP_YAW, -1.0f * userInputMapper->getActionState(controller::Action::STEP_YAW));
|
||||||
|
@ -5143,7 +5108,6 @@ void Application::update(float deltaTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
myAvatar->setSprintMode((bool)userInputMapper->getActionState(controller::Action::SPRINT));
|
myAvatar->setSprintMode((bool)userInputMapper->getActionState(controller::Action::SPRINT));
|
||||||
|
|
||||||
static const std::vector<controller::Action> avatarControllerActions = {
|
static const std::vector<controller::Action> avatarControllerActions = {
|
||||||
controller::Action::LEFT_HAND,
|
controller::Action::LEFT_HAND,
|
||||||
controller::Action::RIGHT_HAND,
|
controller::Action::RIGHT_HAND,
|
||||||
|
|
|
@ -226,21 +226,21 @@ Menu::Menu() {
|
||||||
|
|
||||||
// View > First Person
|
// View > First Person
|
||||||
auto firstPersonAction = cameraModeGroup->addAction(addCheckableActionToQMenuAndActionHash(
|
auto firstPersonAction = cameraModeGroup->addAction(addCheckableActionToQMenuAndActionHash(
|
||||||
viewMenu, MenuOption::FirstPerson, Qt::SHIFT | Qt::Key_F,
|
viewMenu, MenuOption::FirstPerson, Qt::Key_1,
|
||||||
true, qApp, SLOT(cameraMenuChanged())));
|
true, qApp, SLOT(cameraMenuChanged())));
|
||||||
|
|
||||||
firstPersonAction->setProperty(EXCLUSION_GROUP_KEY, QVariant::fromValue(cameraModeGroup));
|
firstPersonAction->setProperty(EXCLUSION_GROUP_KEY, QVariant::fromValue(cameraModeGroup));
|
||||||
|
|
||||||
// View > Third Person
|
// View > Third Person
|
||||||
auto thirdPersonAction = cameraModeGroup->addAction(addCheckableActionToQMenuAndActionHash(
|
auto thirdPersonAction = cameraModeGroup->addAction(addCheckableActionToQMenuAndActionHash(
|
||||||
viewMenu, MenuOption::ThirdPerson, Qt::SHIFT | Qt::Key_G,
|
viewMenu, MenuOption::ThirdPerson, Qt::Key_3,
|
||||||
false, qApp, SLOT(cameraMenuChanged())));
|
false, qApp, SLOT(cameraMenuChanged())));
|
||||||
|
|
||||||
thirdPersonAction->setProperty(EXCLUSION_GROUP_KEY, QVariant::fromValue(cameraModeGroup));
|
thirdPersonAction->setProperty(EXCLUSION_GROUP_KEY, QVariant::fromValue(cameraModeGroup));
|
||||||
|
|
||||||
// View > Mirror
|
// View > Mirror
|
||||||
auto viewMirrorAction = cameraModeGroup->addAction(addCheckableActionToQMenuAndActionHash(
|
auto viewMirrorAction = cameraModeGroup->addAction(addCheckableActionToQMenuAndActionHash(
|
||||||
viewMenu, MenuOption::FullscreenMirror, Qt::SHIFT | Qt::Key_H,
|
viewMenu, MenuOption::FullscreenMirror, Qt::Key_2,
|
||||||
false, qApp, SLOT(cameraMenuChanged())));
|
false, qApp, SLOT(cameraMenuChanged())));
|
||||||
|
|
||||||
viewMirrorAction->setProperty(EXCLUSION_GROUP_KEY, QVariant::fromValue(cameraModeGroup));
|
viewMirrorAction->setProperty(EXCLUSION_GROUP_KEY, QVariant::fromValue(cameraModeGroup));
|
||||||
|
|
Loading…
Reference in a new issue