Showing the changes to interface/src/Camera.cpp (1 of 35 files). Show all
Unified · Split
| @@ -17,7 +17,6 @@ · 16 unmodified lines | |||
| 17 | #include "Camera.h" | 17 | #include "Camera.h" |
| 18 | #include "Menu.h" | 18 | #include "Menu.h" |
| 19 | #include "Util.h" | 19 | #include "Util.h" |
| 20 | #include "devices/OculusManager.h" | ||
| 21 | 20 | ||
| 22 | 21 | ||
| 23 | CameraMode stringToMode(const QString& mode) { | 22 | CameraMode stringToMode(const QString& mode) { |
| @@ -54,42 +53,24 @@ Camera::Camera() : · 30 unmodified lines | |||
| 54 | _nearClip(DEFAULT_NEAR_CLIP), // default | 53 | _nearClip(DEFAULT_NEAR_CLIP), // default |
| 55 | _farClip(DEFAULT_FAR_CLIP), // default | 54 | _farClip(DEFAULT_FAR_CLIP), // default |
| 56 | _hmdPosition(), | 55 | _hmdPosition(), |
| 57 | _hmdRotation(), | 56 | _hmdRotation() |
| 58 | _isKeepLookingAt(false), | ||
| 59 | _lookingAt(0.0f, 0.0f, 0.0f) | ||
| 60 | { | 57 | { |
| 61 | } | 58 | } |
| 62 | 59 | ||
| 63 | void Camera::update(float deltaTime) { | ||
| 64 | if (_isKeepLookingAt) { | ||
| 65 | lookAt(_lookingAt); | ||
| 66 | } | ||
| 67 | return; | ||
| 68 | } | ||
| 69 | |||
| 70 | void Camera::setPosition(const glm::vec3& position) { | 60 | void Camera::setPosition(const glm::vec3& position) { |
| 71 | _position = position; | 61 | _position = position; |
| 72 | } | 62 | } |
| 73 | 63 | ||
| 74 | void Camera::setRotation(const glm::quat& rotation) { | 64 | void Camera::setRotation(const glm::quat& rotation) { |
| 75 | _rotation = rotation; | 65 | _rotation = rotation; |
| 76 | if (_isKeepLookingAt) { | ||
| 77 | lookAt(_lookingAt); | ||
| 78 | } | ||
| 79 | } | 66 | } |
| 80 | 67 | ||
| 81 | void Camera::setHmdPosition(const glm::vec3& hmdPosition) { | 68 | void Camera::setHmdPosition(const glm::vec3& hmdPosition) { |
| 82 | _hmdPosition = hmdPosition; | 69 | _hmdPosition = hmdPosition; |
| 83 | if (_isKeepLookingAt) { | ||
| 84 | lookAt(_lookingAt); | ||
| 85 | } | ||
| 86 | } | 70 | } |
| 87 | 71 | ||
| 88 | void Camera::setHmdRotation(const glm::quat& hmdRotation) { | 72 | void Camera::setHmdRotation(const glm::quat& hmdRotation) { |
| 89 | _hmdRotation = hmdRotation; | 73 | _hmdRotation = hmdRotation; |
| 90 | if (_isKeepLookingAt) { | ||
| 91 | lookAt(_lookingAt); | ||
| 92 | } | ||
| 93 | } | 74 | } |
| 94 | 75 | ||
| 95 | float Camera::getFarClip() const { | 76 | float Camera::getFarClip() const { |
| @@ -120,21 +101,6 @@ void Camera::setFarClip(float f) { · 24 unmodified lines | |||
| 120 | _farClip = f; | 101 | _farClip = f; |
| 121 | } | 102 | } |
| 122 | 103 | ||
| 123 | PickRay Camera::computePickRay(float x, float y) { | ||
| 124 | auto glCanvas = Application::getInstance()->getGLWidget(); | ||
| 125 | return computeViewPickRay(x / glCanvas->width(), y / glCanvas->height()); | ||
| 126 | } | ||
| 127 | |||
| 128 | PickRay Camera::computeViewPickRay(float xRatio, float yRatio) { | ||
| 129 | PickRay result; | ||
| 130 | if (OculusManager::isConnected()) { | ||
| 131 | Application::getInstance()->getApplicationOverlay().computeOculusPickRay(xRatio, yRatio, result.origin, result.direction); | ||
| 132 | } else { | ||
| 133 | Application::getInstance()->getViewFrustum()->computePickRay(xRatio, yRatio, result.origin, result.direction); | ||
| 134 | } | ||
| 135 | return result; | ||
| 136 | } | ||
| 137 | |||
| 138 | void Camera::setModeString(const QString& mode) { | 104 | void Camera::setModeString(const QString& mode) { |
| 139 | CameraMode targetMode = stringToMode(mode); | 105 | CameraMode targetMode = stringToMode(mode); |
| 140 | 106 | ||
| @@ -163,17 +129,3 @@ void Camera::setModeString(const QString& mode) { · 22 unmodified lines | |||
| 163 | QString Camera::getModeString() const { | 129 | QString Camera::getModeString() const { |
| 164 | return modeToString(_mode); | 130 | return modeToString(_mode); |
| 165 | } | 131 | } |
| 166 | |||
| 167 | void Camera::lookAt(const glm::vec3& lookAt) { | ||
| 168 | glm::vec3 up = IDENTITY_UP; | ||
| 169 | glm::mat4 lookAtMatrix = glm::lookAt(_position, lookAt, up); | ||
| 170 | glm::quat rotation = glm::quat_cast(lookAtMatrix); | ||
| 171 | rotation.w = -rotation.w; // Rosedale approved | ||
| 172 | _rotation = rotation; | ||
| 173 | } | ||
| 174 | |||
| 175 | void Camera::keepLookingAt(const glm::vec3& point) { | ||
| 176 | lookAt(point); | ||
| 177 | _isKeepLookingAt = true; | ||
| 178 | _lookingAt = point; | ||
| 179 | } | ||