Saturday, January 16, 2010 at 5:35PM Progress made to the Augmented Reality Toolkit. Now a static library!
augmented reality,
github,
iPhone |
Niels Hansen Today we're please to announce that we've updated the source code on Github. The latest set of changes made this week fixes the orientation issue that's been driving me nuts.
A Static Library - Finally!
The project now has the core of the toolkit put into a static library. Why is this important? In the future when this project has matured, it will allow anyone to add the library to their projects.
We've still have a long way to go. One of the changes we want to have is the ability for any type of view to be added to augmented Reality layer.
Orientation works in both landscape and portrait modes
Woot! We finally got this one piece of code figured out. It really came down to some simple math. When the orientation of the phone changes, we need to adjust the azimuth. We also fixed a stupid mistake where we were checking the same orientation direction instead of checking the left AND right.
The final a-ha moment came in the determining the angle of the phone to know where to draw the y position of a view.
1: switch (currentOrientation) {
2: case UIDeviceOrientationLandscapeLeft:
3: viewAngle = atan2(acceleration.x, acceleration.z);
4: break;
5:
6: case UIDeviceOrientationLandscapeRight:
7: viewAngle = atan2(-acceleration.x, acceleration.z);
8: break;
9:
10: case UIDeviceOrientationPortrait:
11: viewAngle = atan2(acceleration.y, acceleration.z);
12: break;
13:
14: case UIDeviceOrientationPortraitUpsideDown:
15: viewAngle = atan2(-acceleration.y, acceleration.z);
16: break;
17:
18: default:
19: break;
20: }
