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: }


Reader Comments (7)
Hello,
I love this project. It works nice, please keep on going becuase it is great.
I would like to ask you one thing.. it is possible to do not use the window object, instead use a View Controller. I woul like to use the static library on a Tab Bar app.. I'm very new on iphone development so I'm still learning, maybe I'm asking something very silly...
thank you!
This was the first thing we changed. Make sure you grab the latest code base. We have a static library started but its not under the master branch. You need to switch over to the static library branch.
I'm glad you like it so far. Let us know if there is anything you'd like to see us add to it.
yes, you're right, I've grab the latest code, and I have the static library started.. I know that is me (im a real beginner on this), I can't see the view on a tabBar app. I see how it works in the console but the view is not showing..
Maybe I'm loosing something.. here is what I'm doing:
I create a new UIViewController SubClass; then I import ARViewContrller.h and Geolocations.h, then on viewDidLoad. I alloc and init an ARViewController like this :
- (void)viewDidLoad {
ARViewController *viewController = [[ARViewController alloc] init];
[viewController view];
[super viewDidLoad];
}
Whe I run the app I change to view whitout any errors and on console I see :
2010-01-25 14:18:02.647 pruebas2[2836:207] distance is 895289773, angle is 1094049360, azimuth is 0
2010-01-25 14:18:02.648 pruebas2[2836:207] distance is -137817117, angle is 1093390979, azimuth is 0
2010-01-25 14:18:02.648 pruebas2[2836:207] distance is 1014173419, angle is 1095148584, azimuth is 0
2010-01-25 14:18:02.648 pruebas2[2836:207] distance is -2135402882, angle is 1094848403, azimuth is 0
but the view is blank; I can't see the camera image or position targets.
thank you anyway... I need to learn more... I know, and this is helping me a lot.
please discard my last comment, I saw that you have update the branch with new examples on how to work with the viewController.. so I will first to understand how, and then ask...
thank you!
Ok, actually it works nice but I can't see the camera on the background:
- (IBAction)pinchaAR
{
MapaAR *mapaAR = [[MapaAR alloc] init];
[self.view addSubview: [mapaAR view]];
}
I see all the elements moving arround but the camera is not initializing.. this is an issue or is something that I'm doing wrong?
If I try to init on the beginnig of the app and not on a viewDidLoad it works.
Have you tried it with the sample demo first without adding it to your own app to verify that it's running? I'm in the process of making additional changes to the library so that it can load in any size View controller. This should be released in the next couple of days. Please confirm that you're able to get the demo working.
yes demo is working perfect... I whant to see if a have a problem in my program so I try to create something from scratch so I create a new Tab Bar application, and if you init the library on root you have no problems, but this means that the camera is runnig from init and on all tabs (you need to hide the view if you want to see the camera on an specified tab)