mirror of
https://github.com/tappollo/Panorama.git
synced 2026-04-29 20:35:09 +08:00
azimuth corrections
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<dict>
|
||||
<key>SchemeUserState</key>
|
||||
<dict>
|
||||
<key>Spherical.xcscheme</key>
|
||||
<key>Panorama.xcscheme</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>0</integer>
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user