History

Fixing sixense and restoring lookat

Bradley Austin Davis committed 11 years ago

Commit 098a9bd1 parent fb3e3096 files · +65 −8Browse files

Showing the changes to interface/src/Camera.cpp (1 of 6 files). Show all

Unified · Split

interface/src/Camera.cpp+37−1
@@ -53,24 +53,42 @@ Camera::Camera() : · 52 unmodified lines
53 _nearClip(DEFAULT_NEAR_CLIP), // default53 _nearClip(DEFAULT_NEAR_CLIP), // default
54 _farClip(DEFAULT_FAR_CLIP), // default54 _farClip(DEFAULT_FAR_CLIP), // default
55 _hmdPosition(),55 _hmdPosition(),
56 _hmdRotation()56 _hmdRotation(),
57 _isKeepLookingAt(false),
58 _lookingAt(0.0f, 0.0f, 0.0f)
57{59{
58}60}
59 61
62void Camera::update(float deltaTime) {
63 if (_isKeepLookingAt) {
64 lookAt(_lookingAt);
65 }
66 return;
67}
68
60void Camera::setPosition(const glm::vec3& position) {69void Camera::setPosition(const glm::vec3& position) {
61 _position = position; 70 _position = position;
62}71}
63 72
64void Camera::setRotation(const glm::quat& rotation) {73void Camera::setRotation(const glm::quat& rotation) {
65 _rotation = rotation; 74 _rotation = rotation;
75 if (_isKeepLookingAt) {
76 lookAt(_lookingAt);
77 }
66}78}
67 79
68void Camera::setHmdPosition(const glm::vec3& hmdPosition) {80void Camera::setHmdPosition(const glm::vec3& hmdPosition) {
69 _hmdPosition = hmdPosition; 81 _hmdPosition = hmdPosition;
82 if (_isKeepLookingAt) {
83 lookAt(_lookingAt);
84 }
70}85}
71 86
72void Camera::setHmdRotation(const glm::quat& hmdRotation) {87void Camera::setHmdRotation(const glm::quat& hmdRotation) {
73 _hmdRotation = hmdRotation; 88 _hmdRotation = hmdRotation;
89 if (_isKeepLookingAt) {
90 lookAt(_lookingAt);
91 }
74}92}
75 93
76float Camera::getFarClip() const {94float Camera::getFarClip() const {
@@ -101,6 +119,10 @@ void Camera::setFarClip(float f) { · 24 unmodified lines
101 _farClip = f;119 _farClip = f;
102}120}
103 121
122PickRay Camera::computePickRay(float x, float y) {
123 return qApp->computePickRay(x, y);
124}
125
104void Camera::setModeString(const QString& mode) {126void Camera::setModeString(const QString& mode) {
105 CameraMode targetMode = stringToMode(mode);127 CameraMode targetMode = stringToMode(mode);
106 128
@@ -129,3 +151,17 @@ void Camera::setModeString(const QString& mode) { · 22 unmodified lines
129QString Camera::getModeString() const {151QString Camera::getModeString() const {
130 return modeToString(_mode);152 return modeToString(_mode);
131}153}
154
155void Camera::lookAt(const glm::vec3& lookAt) {
156 glm::vec3 up = IDENTITY_UP;
157 glm::mat4 lookAtMatrix = glm::lookAt(_position, lookAt, up);
158 glm::quat rotation = glm::quat_cast(lookAtMatrix);
159 rotation.w = -rotation.w; // Rosedale approved
160 _rotation = rotation;
161}
162
163void Camera::keepLookingAt(const glm::vec3& point) {
164 lookAt(point);
165 _isKeepLookingAt = true;
166 _lookingAt = point;
167}