azimuth corrections

This commit is contained in:
robbykraft
2014-01-13 11:35:01 -08:00
parent 7dc8cfff57
commit fd1cf01313
2 changed files with 9 additions and 8 deletions

View File

@@ -4,7 +4,7 @@
<dict>
<key>SchemeUserState</key>
<dict>
<key>Spherical.xcscheme</key>
<key>Panorama.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>

View File

@@ -130,16 +130,16 @@
if(motionManager.isDeviceMotionAvailable){
[motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue currentQueue] withHandler:^(CMDeviceMotion *deviceMotion, NSError *error) {
CMRotationMatrix a = deviceMotion.attitude.rotationMatrix;
// matrix has a built-in 90 rotation, and reflection across the X to correct the inverted texture
// matrix has a built-in 90 rotation, and reflection across the Z to correct the inverted texture
_attitudeMatrix =
GLKMatrix4Make(-a.m11,-a.m21,-a.m31, 0.0f,
GLKMatrix4Make( a.m11, a.m21, a.m31, 0.0f,
a.m13, a.m23, a.m33, 0.0f,
-a.m12,-a.m22,-a.m32, 0.0f,
a.m12, a.m22, a.m32, 0.0f,
0.0f , 0.0f , 0.0f , 1.0f);
_lookVector = GLKVector3Make(_attitudeMatrix.m02, // if not for texture correction, this would be negative
_lookVector = GLKVector3Make(-_attitudeMatrix.m02,
-_attitudeMatrix.m12,
-_attitudeMatrix.m22);
_lookAzimuth = atan2f(_lookVector.z, _lookVector.x);
_lookAzimuth = atan2f(_lookVector.x, _lookVector.z);
_lookAltitude = asinf(_lookVector.y);
}];
}
@@ -161,8 +161,9 @@
if(_orientToDevice)
glMultMatrixf(_attitudeMatrix.m);
else{
glRotatef(panY/5., -1, 0, 0);
glRotatef(panX/5., 0, -1, 0);
glScalef(1, 1, -1);
glRotatef(panY/5., 1, 0, 0);
glRotatef(panX/5., 0, 1, 0);
}
[sphere execute];
glPopMatrix();