-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
quaternion panning, aligned to identity, FPS
- Loading branch information
Showing
5 changed files
with
168 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,97 @@ | ||
// | ||
// PanoramaView.h | ||
// Panorama | ||
// | ||
// Created by Robby Kraft on 8/24/13. | ||
// Copyright (c) 2013 Robby Kraft. All Rights Reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
/** | ||
* @class Panorama View | ||
* @author Robby Kraft | ||
* @date 8/24/13 | ||
* | ||
* @availability iOS (5.0 and later) | ||
* | ||
* @discussion a dynamic GLKView with a touch and motion sensor interface to align and immerse the perspective inside an equirectangular panorama projection | ||
*/ | ||
@interface PanoramaView : GLKView | ||
|
||
-(id) init; // recommended init method. if landscape, corrects aspect-ratio. auto full-screen. | ||
-(void) draw; | ||
-(void) setImage:(NSString*)fileName; // path or bundle. will check at both | ||
|
||
/* all operatons are in RADIANS */ | ||
-(id) init; // recommended init method | ||
|
||
-(void) draw; // place in GLKViewController's glkView:drawInRect: | ||
|
||
/// Set image by path or bundle - will check at both | ||
-(void) setImage:(NSString*)fileName; | ||
|
||
/* projection */ | ||
@property (nonatomic) float fieldOfView; | ||
@property (nonatomic) BOOL pinchToZoom; // pinch to change field of view | ||
-(CGPoint) imagePixelAtScreenLocation:(CGPoint)point; // which pixel did you touch? | ||
|
||
/* orientation */ | ||
@property (nonatomic) BOOL orientToDevice; // YES: activate accel/gyro. NO: use touch pan gesture | ||
@property (nonatomic) BOOL touchToPan; // default: YES | ||
// below uses gl look at, with a fixed up-vector, so flipping will occur at the poles | ||
|
||
/// forward vector axis (into the screen) | ||
@property (nonatomic, readonly) GLKVector3 lookVector; | ||
|
||
/// forward horizontal azimuth (-π to π) | ||
@property (nonatomic, readonly) float lookAzimuth; | ||
|
||
/// forward vertical altitude (-.5π to .5π) | ||
@property (nonatomic, readonly) float lookAltitude; | ||
|
||
|
||
// At this point, it's still recommended to activate either OrientToDevice or TouchToPan, not both | ||
// it's possible to have them simultaneously, but the effect is confusing and disorienting | ||
|
||
|
||
/// Activates accelerometer + gyro orientation | ||
@property (nonatomic) BOOL orientToDevice; | ||
|
||
/// Enables UIPanGestureRecognizer to affect view orientation | ||
@property (nonatomic) BOOL touchToPan; | ||
|
||
/// Fixes up-vector during panning. (trade off: no panning past the poles) | ||
//@property (nonatomic) BOOL preventHeadTilt; | ||
|
||
/** | ||
* Align Z coordinate axis (into the screen) to a GLKVector. | ||
* (due to a fixed up-vector, flipping will occur at the poles) | ||
* | ||
* @param GLKVector3 can be non-normalized | ||
*/ | ||
-(void) orientToVector:(GLKVector3)vector; | ||
|
||
/** | ||
* Align Z coordinate axis (into the screen) to azimuth and altitude. | ||
* (due to a fixed up-vector, flipping will occur at the poles) | ||
* | ||
* @param Azimuth(-π to π) Altitude(-.5π to .5π) | ||
*/ | ||
-(void) orientToAzimuth:(float) azimuth Altitude:(float)altitude; | ||
|
||
@property (nonatomic, readonly) GLKVector3 lookVector; // forward vector | ||
@property (nonatomic, readonly) float lookAzimuth; // -π to π | ||
@property (nonatomic, readonly) float lookAltitude; // -.5π to .5π | ||
|
||
/* touches */ | ||
@property (nonatomic) BOOL showTouches; // overlay latitude longitude lines | ||
/* projection & touches */ | ||
|
||
|
||
@property (nonatomic, readonly) NSSet *touches; | ||
|
||
@property (nonatomic, readonly) NSInteger numberOfTouches; | ||
-(bool) touchInRect:(CGRect)rect; // hotspot touchInRect validation. rect defined by image pixel coordinates | ||
|
||
/// Field of view in DEGREES | ||
@property (nonatomic) float fieldOfView; | ||
|
||
/// Enables UIPinchGestureRecognizer to affect FieldOfView | ||
@property (nonatomic) BOOL pinchToZoom; | ||
|
||
/// Dynamic overlay of latitude and longitude intersection lines for all touches | ||
@property (nonatomic) BOOL showTouches; | ||
/** | ||
* Converts screen coordinate to image pixel coordinate | ||
* | ||
* @param CGPoint device screen coordinate | ||
* @return CGPoint image coordinate in pixels, or betwee 0.0 and 1.0 if no image | ||
*/ | ||
-(CGPoint) imagePixelAtScreenLocation:(CGPoint)point; | ||
/** | ||
* Hit-detection for all active touches | ||
* | ||
* @param CGRect defined in image pixel coordinates | ||
* @return YES if touch is inside CGRect, NO otherwise | ||
*/ | ||
-(BOOL) touchInRect:(CGRect)rect; | ||
|
||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.