Skip to content

Commit

Permalink
Beginnings of multiple orientation support. Added auto-rotation of vi…
Browse files Browse the repository at this point in the history
…ews based on a delegate callback. Made the center coordinate more robust for multiple orientations.
  • Loading branch information
Zac White committed Oct 12, 2009
1 parent 41ae2ef commit ee18939
Show file tree
Hide file tree
Showing 8 changed files with 278 additions and 43 deletions.
6 changes: 6 additions & 0 deletions ARKitDemo/ARKitDemo.xcodeproj/project.pbxproj
Expand Up @@ -23,6 +23,7 @@
1171B3DD106EE83500CC3630 /* ARGeoCoordinate.m in Sources */ = {isa = PBXBuildFile; fileRef = CE169F571025704E00556F8F /* ARGeoCoordinate.m */; };
1171B3DE106EE83500CC3630 /* ARGeoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 11609B0A1026014F00A964C8 /* ARGeoViewController.m */; };
1171B42C106EEB3600CC3630 /* LogicTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1171B42B106EEB3600CC3630 /* LogicTests.m */; };
117BCE9210829C1E007A27AB /* ARVector.m in Sources */ = {isa = PBXBuildFile; fileRef = 117BCE9110829C1E007A27AB /* ARVector.m */; };
1D3623260D0F684500981E51 /* ARKitDemoAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* ARKitDemoAppDelegate.m */; };
1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; };
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
Expand Down Expand Up @@ -56,6 +57,8 @@
1171B42A106EEB3600CC3630 /* LogicTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LogicTests.h; sourceTree = "<group>"; };
1171B42B106EEB3600CC3630 /* LogicTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LogicTests.m; sourceTree = "<group>"; };
1171B440106EEBDB00CC3630 /* UnitTests-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "UnitTests-Info.plist"; sourceTree = "<group>"; };
117BCE9010829C1E007A27AB /* ARVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARVector.h; sourceTree = "<group>"; };
117BCE9110829C1E007A27AB /* ARVector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARVector.m; sourceTree = "<group>"; };
1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
1D3623240D0F684500981E51 /* ARKitDemoAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARKitDemoAppDelegate.h; sourceTree = "<group>"; };
1D3623250D0F684500981E51 /* ARKitDemoAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARKitDemoAppDelegate.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -122,6 +125,8 @@
children = (
112543A81024DE590086106E /* ARCoordinate.h */,
112543A91024DE590086106E /* ARCoordinate.m */,
117BCE9010829C1E007A27AB /* ARVector.h */,
117BCE9110829C1E007A27AB /* ARVector.m */,
111A142B1024C8A6002D39A1 /* ARViewController.h */,
111A142A1024C8A6002D39A1 /* ARViewController.m */,
CE169F561025704E00556F8F /* ARGeoCoordinate.h */,
Expand Down Expand Up @@ -291,6 +296,7 @@
1171B3DD106EE83500CC3630 /* ARGeoCoordinate.m in Sources */,
1171B3DE106EE83500CC3630 /* ARGeoViewController.m in Sources */,
1171B42C106EEB3600CC3630 /* LogicTests.m in Sources */,
117BCE9210829C1E007A27AB /* ARVector.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
1 change: 1 addition & 0 deletions ARKitDemo/Classes/ARKitDemoAppDelegate.h
Expand Up @@ -15,6 +15,7 @@
}

- (UIView *)viewForCoordinate:(ARCoordinate *)coordinate;
- (BOOL)shouldAutorotateViewsToInterfaceOrientation:(UIInterfaceOrientation)possibleOrientation;

@property (nonatomic, retain) IBOutlet UIWindow *window;

Expand Down
6 changes: 5 additions & 1 deletion ARKitDemo/Classes/ARKitDemoAppDelegate.m
Expand Up @@ -246,7 +246,7 @@ - (UIView *)viewForCoordinate:(ARCoordinate *)coordinate {
CGRect theFrame = CGRectMake(0, 0, BOX_WIDTH, BOX_HEIGHT);
UIView *tempView = [[UIView alloc] initWithFrame:theFrame];

//tempView.backgroundColor = [UIColor colorWithWhite:.5 alpha:.3];
tempView.backgroundColor = [UIColor colorWithWhite:.5 alpha:.3];

UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, BOX_WIDTH, 20.0)];
titleLabel.backgroundColor = [UIColor colorWithWhite:.3 alpha:.8];
Expand All @@ -270,6 +270,10 @@ - (UIView *)viewForCoordinate:(ARCoordinate *)coordinate {
return [tempView autorelease];
}

- (BOOL)shouldAutorotateViewsToInterfaceOrientation:(UIInterfaceOrientation)possibleOrientation {
return (possibleOrientation != UIInterfaceOrientationPortraitUpsideDown);
}


- (void)dealloc {

Expand Down
24 changes: 24 additions & 0 deletions ARKitDemo/Classes/ARVector.h
@@ -0,0 +1,24 @@
//
// ARVector.h
// ARKitDemo
//
// Created by Zac White on 10/11/09.
// Copyright 2009 Zac White. All rights reserved.
//

#import <Foundation/Foundation.h>


@interface ARVector : NSObject {
double x;
double y;
double z;
}

@property double x;
@property double y;
@property double z;

- (ARVector *)dotProductWithVector:(ARVector *)vector;

@end
23 changes: 23 additions & 0 deletions ARKitDemo/Classes/ARVector.m
@@ -0,0 +1,23 @@
//
// ARVector.m
// ARKitDemo
//
// Created by Zac White on 10/11/09.
// Copyright 2009 Zac White. All rights reserved.
//

#import "ARVector.h"

@implementation ARVector

@synthesize x, y, z;

- (double)dotProductWithVector:(ARVector *)vector {
return vector.x * self.x + vector.y * self.y + vector.z * self.z;
}

- (ARVector *)crossProductWithVector:(ARVector *)vector {

}

@end
19 changes: 17 additions & 2 deletions ARKitDemo/Classes/ARViewController.h
Expand Up @@ -16,6 +16,9 @@

- (UIView *)viewForCoordinate:(ARCoordinate *)coordinate;

@optional
- (BOOL)shouldAutorotateViewsToInterfaceOrientation:(UIInterfaceOrientation)possibleOrientation;

@end


Expand All @@ -35,7 +38,17 @@
double maximumDistance;
double minimumScaleFactor;

UIInterfaceOrientation viewInterfaceOrientation;

@private
double _latestHeading;
UIAccelerationValue _latestXAcceleration;
UIAccelerationValue _latestYAcceleration;
UIAccelerationValue _latestZAcceleration;

//in radians.
double _viewportRotation;

BOOL ar_debugMode;

UIView *ar_overlayView;
Expand All @@ -54,6 +67,8 @@
@property double maximumDistance;
@property double minimumScaleFactor;

@property (readonly) UIInterfaceOrientation viewInterfaceOrientation;

//adding coordinates to the underlying data model.
- (void)addCoordinate:(ARCoordinate *)coordinate;
- (void)addCoordinate:(ARCoordinate *)coordinate animated:(BOOL)animated;
Expand All @@ -72,9 +87,9 @@
- (void)startListening;
- (void)updateLocations;

- (CGPoint)pointInView:(UIView *)realityView forCoordinate:(ARCoordinate *)coordinate;
- (CGPoint)pointInView:(UIView *)realityView withView:(UIView *)viewToDraw forCoordinate:(ARCoordinate *)coordinate;

- (BOOL)viewportContainsCoordinate:(ARCoordinate *)coordinate;
- (BOOL)viewportContainsView:(UIView *)viewToDraw forCoordinate:(ARCoordinate *)coordinate;

@property (nonatomic, retain) UIImagePickerController *cameraController;

Expand Down

0 comments on commit ee18939

Please sign in to comment.