├── .DS_Store ├── .gitignore ├── LICENSE ├── PanoramaGL.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── PanoramaGL ├── .DS_Store ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── LaunchScreen.storyboard ├── PanoramaGL │ ├── .DS_Store │ ├── CHANGES.txt │ ├── LICENSE.txt │ ├── PLCamera.h │ ├── PLCamera.m │ ├── PLCameraProtected.h │ ├── PLConstants.h │ ├── PLCubicPanorama.h │ ├── PLCubicPanorama.m │ ├── PLCylindricalPanorama.h │ ├── PLCylindricalPanorama.m │ ├── PLEnums.h │ ├── PLHotspot.h │ ├── PLHotspot.m │ ├── PLIInitializeObject.h │ ├── PLILoader.h │ ├── PLIObject.h │ ├── PLIPanorama.h │ ├── PLIRenderableElement.h │ ├── PLIRenderer.h │ ├── PLIScene.h │ ├── PLIView.h │ ├── PLImage.h │ ├── PLImage.m │ ├── PLIntersection.h │ ├── PLIntersection.m │ ├── PLJSONLoader.h │ ├── PLJSONLoader.m │ ├── PLLog.h │ ├── PLLog.m │ ├── PLMath.h │ ├── PLMath.m │ ├── PLObject.h │ ├── PLObject.m │ ├── PLObjectBase.h │ ├── PLObjectBase.m │ ├── PLObjectBaseProtected.h │ ├── PLObjectProtected.h │ ├── PLOpenGLSupport.h │ ├── PLOpenGLSupport.m │ ├── PLPanoramaBase.h │ ├── PLPanoramaBase.m │ ├── PLPanoramaBaseProtected.h │ ├── PLRenderableElementBase.h │ ├── PLRenderableElementBase.m │ ├── PLRenderableElementBaseProtected.h │ ├── PLRenderer.h │ ├── PLRenderer.m │ ├── PLScene.h │ ├── PLScene.m │ ├── PLSceneElement.h │ ├── PLSceneElement.m │ ├── PLSceneElementBase.h │ ├── PLSceneElementBase.m │ ├── PLSceneElementBaseProtected.h │ ├── PLSceneElementProtected.h │ ├── PLSpherical2Panorama.h │ ├── PLSpherical2Panorama.m │ ├── PLSphericalPanorama.h │ ├── PLSphericalPanorama.m │ ├── PLSphericalRatioPanorama.h │ ├── PLSphericalRatioPanorama.m │ ├── PLStructs.h │ ├── PLTexture.h │ ├── PLTexture.m │ ├── PLTextureDelegate.h │ ├── PLTransition.h │ ├── PLTransition.m │ ├── PLTransitionDelegate.h │ ├── PLTransitionFadeBase.h │ ├── PLTransitionFadeBase.m │ ├── PLTransitionFadeBaseProtected.h │ ├── PLTransitionFadeIn.h │ ├── PLTransitionFadeIn.m │ ├── PLTransitionFadeOut.h │ ├── PLTransitionFadeOut.m │ ├── PLTransitionProtected.h │ ├── PLUtils.h │ ├── PLUtils.m │ ├── PLVector3.h │ ├── PLVector3.m │ ├── PLView.h │ ├── PLView.m │ ├── PLViewBase.h │ ├── PLViewBase.m │ ├── PLViewBaseProtected.h │ ├── PLViewDelegate.h │ ├── README.txt │ └── glues │ │ ├── glu.h │ │ ├── glues.h │ │ ├── glues_error.c │ │ ├── glues_error.h │ │ ├── glues_mipmap.c │ │ ├── glues_mipmap.h │ │ ├── glues_project.c │ │ ├── glues_project.h │ │ ├── glues_quad.c │ │ ├── glues_quad.h │ │ ├── glues_registry.c │ │ └── glues_registry.h ├── Resources │ ├── Car │ │ ├── back.jpg │ │ ├── down.jpg │ │ ├── front.jpg │ │ ├── left.jpg │ │ ├── right.jpg │ │ └── up.jpg │ ├── hotspot.png │ ├── json.data │ ├── json_cubic.data │ ├── json_s2.data │ ├── pano_b.jpg │ ├── pano_d.jpg │ ├── pano_f.jpg │ ├── pano_l.jpg │ ├── pano_preview.jpg │ ├── pano_r.jpg │ ├── pano_sphere.jpg │ ├── pano_sphere2.jpg │ ├── pano_sphere_preview.jpg │ └── pano_u.jpg ├── ViewController.h ├── ViewController.m ├── ViewController.xib └── main.m ├── README.md ├── demo.gif └── pano2vr.png /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | #Pods/ 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /PanoramaGL.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PanoramaGL/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/PanoramaGL/.DS_Store -------------------------------------------------------------------------------- /PanoramaGL/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // PanoramaGL 4 | // 5 | // Created by Jakey on 15/8/13. 6 | // Copyright © 2015年 Jakey. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class ViewController; 12 | 13 | @interface AppDelegate : UIResponder 14 | 15 | @property (strong, nonatomic) UIWindow *window; 16 | 17 | @property (strong, nonatomic) ViewController *viewController; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /PanoramaGL/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // PanoramaGL 4 | // 5 | // Created by Jakey on 15/8/13. 6 | // Copyright © 2015年 Jakey. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "ViewController.h" 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | 20 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 21 | // Override point for customization after application launch. 22 | self.window.backgroundColor = [UIColor whiteColor]; 23 | self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; 24 | 25 | self.window.rootViewController = self.viewController; 26 | [self.window makeKeyAndVisible]; 27 | 28 | return YES; 29 | } 30 | 31 | - (void)applicationWillResignActive:(UIApplication *)application { 32 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 33 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 34 | } 35 | 36 | - (void)applicationDidEnterBackground:(UIApplication *)application { 37 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 38 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 39 | } 40 | 41 | - (void)applicationWillEnterForeground:(UIApplication *)application { 42 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 43 | } 44 | 45 | - (void)applicationDidBecomeActive:(UIApplication *)application { 46 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 47 | } 48 | 49 | - (void)applicationWillTerminate:(UIApplication *)application { 50 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /PanoramaGL/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "ipad", 5 | "size" : "29x29", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "ipad", 10 | "size" : "29x29", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "ipad", 15 | "size" : "40x40", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "ipad", 20 | "size" : "40x40", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "ipad", 25 | "size" : "76x76", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "ipad", 30 | "size" : "76x76", 31 | "scale" : "2x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /PanoramaGL/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations~ipad 32 | 33 | UIInterfaceOrientationLandscapeLeft 34 | UIInterfaceOrientationLandscapeRight 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /PanoramaGL/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 26 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/PanoramaGL/PanoramaGL/.DS_Store -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/CHANGES.txt: -------------------------------------------------------------------------------- 1 | 0.1 by skyfox 2 | ================ 3 | - Spherical images supports up 4096x2048 texture (see PLSpherical2Panorama class). 4 | - CubicPanorama images supports up 2048x2048 texture 5 | 6 | Bugs fixes: 7 | remove some warming 8 | 9 | 10 | 0.1 by skyfox 11 | ================ 12 | Bugs fixes: 13 | Hotspots arm64 click bug 14 | 15 | 16 | 0.1 (July/2012): 17 | ================ 18 | 19 | The version 0.1 is different than 0.1 Beta and 0.1 Beta 2, the library structure was changed for improvements. If you are using older version of PanoramaGL, you need change a little your code to work with 0.1 version. 20 | 21 | Please check the last version of "HelloPanoramaGL" example. 22 | 23 | Bugs fixes: 24 | 25 | - Appearance of images (distortion) when orientation change. 26 | - Render problems with iOS >= 4.x. 27 | - Memory leaks. 28 | 29 | Improvements: 30 | 31 | - Change of LGPL license to Apache 2.0 license. 32 | - Support for iOS >= 4.x. 33 | - Support for iPad. 34 | - Support for Hotspots (see PLHotspot class). 35 | - Spherical images supports up 2048x1024 texture (see PLSpherical2Panorama class). 36 | - Support for simulated gyroscope (see startSensorialRotation method on PLView class). 37 | - Support for simple JSON protocol (see PLJSONLoader class and load method on PLView class). 38 | 39 | Note 1: This version does not support Zoom Controls like previous version (If you need zoom controls you can add any UIView to PLView) 40 | Note 2: I do not give real support for gyroscope, because I do not have a device that support it : (, but you can try to modify PLViewBase.m and change startSensorialRotation and doGyroUpdate methods. 41 | 42 | 0.1 Beta 2 (July/2010): 43 | ======================= 44 | 45 | Bugs fixes: 46 | 47 | - Appearance of images (Distortion) when orientation changed. 48 | - Fov range problem (Zoom In and Zoom Out range). 49 | - Fov and Reset detection problem (Problem detecting two and three fingers on screen). 50 | - Dependences error in PLViewDelegate. 51 | 52 | Improvements: 53 | 54 | - Support reset when device shake. 55 | - Zoom controls. 56 | 57 | 0.1 Beta (April/2010): 58 | ====================== 59 | 60 | Bugs fixes: 61 | 62 | - Memory problem loading new textures. 63 | - Appearance of images (Distortion). 64 | - Error using the view orientation. 65 | - Error detecting touches to use objects over view. 66 | 67 | Improvements: 68 | 69 | - Support for events on PLView (See PLViewDelegate). -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLCamera.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLRenderableElementBase.h" 20 | 21 | @interface PLCamera : PLRenderableElementBase 22 | { 23 | #pragma mark - 24 | #pragma mark member variables 25 | @private 26 | BOOL isFovEnabled; 27 | float fov, fovFactor, fovSensitivity; 28 | PLRange fovRange; 29 | NSUInteger minDistanceToEnableFov; 30 | PLRotation initialLookAt; 31 | } 32 | 33 | #pragma mark - 34 | #pragma mark properties 35 | 36 | @property(nonatomic) BOOL isFovEnabled; 37 | @property(nonatomic) float fov, fovSensitivity; 38 | @property(nonatomic, readonly) float fovFactor; 39 | @property(nonatomic, readonly, getter=getFOVFactorCorrected) float fovFactorCorrected; 40 | @property(nonatomic) PLRange fovRange; 41 | @property(nonatomic) NSUInteger minDistanceToEnableFov; 42 | @property(nonatomic) PLRotation initialLookAt; 43 | @property(nonatomic, readonly, getter=getAbsoluteRotation) PLRotation absoluteRotation; 44 | 45 | #pragma mark - 46 | #pragma mark init methods 47 | 48 | +(id)camera; 49 | 50 | #pragma mark - 51 | #pragma mark property methods 52 | 53 | -(float)getFOVFactorCorrected; 54 | -(PLRotation)getAbsoluteRotation; 55 | 56 | #pragma mark - 57 | #pragma mark fov methods 58 | 59 | -(void)addFovWithDistance:(float)distance; 60 | -(void)addFovWithStartPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint sign:(int)sign; 61 | 62 | #pragma mark - 63 | #pragma mark lookat methods 64 | 65 | -(void)setInitialLookAtWithPitch:(float)pitch yaw:(float)yaw; 66 | -(void)lookAtWithPitch:(float)pitch yaw:(float)yaw; 67 | 68 | #pragma mark - 69 | #pragma mark clone methods 70 | 71 | -(void)cloneCameraProperties:(PLCamera *)value; 72 | 73 | 74 | - (void)resetCurrentC:(PLRotation)rotation Pitch:(float)pitch yaw:(float)yaw; 75 | @end -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLCamera.m: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLCameraProtected.h" 20 | 21 | @implementation PLCamera 22 | 23 | @synthesize isFovEnabled; 24 | @synthesize fov, fovSensitivity; 25 | @synthesize fovFactor; 26 | @synthesize fovRange; 27 | @synthesize minDistanceToEnableFov; 28 | @synthesize initialLookAt; 29 | 30 | #pragma mark - 31 | #pragma mark init methods 32 | 33 | +(id)camera 34 | { 35 | return [[[PLCamera alloc] init] autorelease]; 36 | } 37 | 38 | -(void)initializeValues 39 | { 40 | fovRange = PLRangeMake(kDefaultFovMinValue, kDefaultFovMaxValue); 41 | self.fov = kDefaultFov; 42 | // isFovEnabled = YES; 43 | fovSensitivity = kDefaultFovSensitivity; 44 | minDistanceToEnableFov = kDefaultMinDistanceToEnableFov; 45 | initialLookAt = PLRotationMake(0.0f, 0.0f, 0.0f); 46 | [super initializeValues]; 47 | [self setIsReverseRotation:YES]; 48 | [self setIsValid:YES]; 49 | } 50 | 51 | #pragma mark - 52 | #pragma mark reset methods 53 | - (void)resetCurrentC:(PLRotation)rotation Pitch:(float)pitch yaw:(float)yaw 54 | { 55 | self.fov = kDefaultFov; 56 | [super resetC:rotation]; 57 | [self lookAtWithPitch:rotation.pitch yaw:rotation.yaw]; 58 | } 59 | -(void)reset 60 | { 61 | self.fov = kDefaultFov; 62 | [super reset]; 63 | [self lookAtWithPitch:initialLookAt.pitch yaw:initialLookAt.yaw]; 64 | } 65 | 66 | #pragma mark - 67 | #pragma mark property methods 68 | 69 | -(void)setFovRange:(PLRange)value 70 | { 71 | if(value.max >= value.min) 72 | { 73 | fovRange = PLRangeMake(value.min < kFovMinValue ? kFovMinValue : value.min, value.max > kFovMaxValue ? kFovMaxValue : value.max); 74 | self.fov = fov; 75 | } 76 | } 77 | 78 | -(void)setMinDistanceToEnableFov:(NSUInteger)value 79 | { 80 | if(value > 0) 81 | minDistanceToEnableFov = value; 82 | } 83 | 84 | -(void)setFovSensitivity:(float)value 85 | { 86 | if(value > 0.0f) 87 | fovSensitivity = value; 88 | } 89 | 90 | -(void)setFov:(float)value 91 | { 92 | if(isFovEnabled) 93 | { 94 | fov = [PLMath normalizeFov:value range:fovRange]; 95 | if(fov < 0.0f) 96 | fovFactor = kFovFactorOffsetValue + kFovFactorNegativeOffsetValue * (fov / kDefaultFovFactorMinValue); 97 | else if(fov >= 0.0f) 98 | fovFactor = kFovFactorOffsetValue + kFovFactorPositiveOffsetValue * (fov / kDefaultFovFactorMaxValue); 99 | } 100 | } 101 | 102 | -(float)getFOVFactorCorrected 103 | { 104 | float value = 1.0f; 105 | if(fov < 0.0f) 106 | value = kFovFactorOffsetValue + kFOVFactorCorrectedNegativeOffsetValue * (fov / kDefaultFOVFactorCorrectedMinValue); 107 | else if(fov >= 0.0f) 108 | value = kFovFactorOffsetValue + kFOVFactorCorrectedPositiveOffsetValue * (fov / kDefaultFOVFactorCorrectedMaxValue); 109 | return value; 110 | } 111 | 112 | -(PLRotation)getAbsoluteRotation 113 | { 114 | PLRotation rotation = self.rotation; 115 | return PLRotationMake(-rotation.pitch, -rotation.yaw, rotation.roll); 116 | } 117 | 118 | #pragma mark - 119 | #pragma mark fov methods 120 | 121 | -(void)addFovWithDistance:(float)distance; 122 | { 123 | self.fov += ((distance < 0 ? distance / 2.5 : distance) / fovSensitivity); 124 | } 125 | 126 | -(void)addFovWithStartPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint sign:(int)sign 127 | { 128 | [self addFovWithDistance: [PLMath distanceBetweenPoints:startPoint :endPoint] * (sign < 0 ? -1 : 1)]; 129 | } 130 | 131 | #pragma mark - 132 | #pragma mark render methods 133 | 134 | -(void)beginRender 135 | { 136 | [self rotate]; 137 | [self translate]; 138 | } 139 | 140 | -(void)endRender 141 | { 142 | } 143 | 144 | -(void)internalRender 145 | { 146 | } 147 | 148 | #pragma mark - 149 | #pragma mark lookat methods 150 | 151 | -(void)lookAtWithPitch:(float)pitch yaw:(float)yaw 152 | { 153 | [self rotateWithPitch:-pitch yaw:-yaw]; 154 | } 155 | 156 | -(void)setInitialLookAtWithPitch:(float)pitch yaw:(float)yaw 157 | { 158 | initialLookAt.pitch = pitch; 159 | initialLookAt.yaw = yaw; 160 | } 161 | 162 | #pragma mark - 163 | #pragma mark clone methods 164 | 165 | -(void)cloneCameraProperties:(PLCamera *)value 166 | { 167 | [super clonePropertiesOf:(PLObject *)value]; 168 | fovRange = value.fovRange; 169 | isFovEnabled = value.isFovEnabled; 170 | fovSensitivity = value.fovSensitivity; 171 | minDistanceToEnableFov = value.minDistanceToEnableFov; 172 | self.fov = value.fov; 173 | } 174 | 175 | @end 176 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLCameraProtected.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLRenderableElementBaseProtected.h" 20 | #import "PLCamera.h" 21 | 22 | @interface PLCamera(Protected) 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLConstants.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #pragma mark - 20 | #pragma mark utility consts 21 | 22 | #define kPI 3.14159265358979323846f 23 | #define kFloatMinValue -1000000.0f 24 | #define kFloatMaxValue FLT_MAX 25 | 26 | #pragma mark - 27 | #pragma mark object consts 28 | 29 | #define kObjectDefaultAlpha 1.0f 30 | 31 | #pragma mark - 32 | #pragma mark buffer consts 33 | 34 | #define kUseDepthBuffer 0 35 | 36 | #pragma mark - 37 | #pragma mark texture consts 38 | 39 | //#define kTextureMaxWidth 1024 40 | //#define kTextureMaxHeight 1024 41 | #define kTextureMaxWidth 8192 //方块高 42 | #define kTextureMaxHeight 8192 43 | 44 | 45 | #pragma mark - 46 | #pragma mark cube consts 47 | 48 | #define kCubeFrontFaceIndex 0 49 | #define kCubeBackFaceIndex 1 50 | #define kCubeLeftFaceIndex 2 51 | #define kCubeRightFaceIndex 3 52 | #define kCubeTopFaceIndex 4 53 | #define kCubeBottomFaceIndex 5 54 | 55 | #pragma mark - 56 | #pragma mark sphere consts 57 | 58 | #define kDefaultSphereDivs 30 59 | 60 | #pragma mark - 61 | #pragma mark hemisphere consts 62 | 63 | #define kDefaultHemisphereDivs 20 64 | #define kDefaultHemispherePreviewDivs 30 65 | 66 | #pragma mark - 67 | #pragma mark cylinder consts 68 | 69 | #define kDefaultCylinderDivs 60 70 | #define kDefaultCylinderHeight 3.0f 71 | #define kDefaultCylinderHeightCalculated NO 72 | 73 | #pragma mark - 74 | #pragma mark rotation consts 75 | 76 | #define kDefaultRotateSensitivity 110.0f 77 | #define kDefaultAnimationTimerInterval 1.0f/30.0f 78 | #define kDefaultAnimationTimerIntervalByFrame 1.0f/30.f 79 | #define kDefaultAnimationFrameInterval 1 80 | 81 | #define kDefaultRotateMinRange -180.0f 82 | #define kDefaultRotateMaxRange 180.0f 83 | 84 | #define kDefaultYawMinRange -180.f 85 | #define kDefaultYawMaxRange 180.f 86 | 87 | #define kDefaultPitchMinRange -90.0f 88 | #define kDefaultPitchMaxRange 90.0f 89 | 90 | #pragma mark - 91 | #pragma mark fov (field of view) consts 92 | 93 | #define kDefaultFov -0.2f 94 | #define kDefaultFovSensitivity -1.0f 95 | 96 | #define kFovMinValue -1.0f 97 | #define kFovMaxValue 1.0f 98 | 99 | #define kDefaultFovMinValue -0.2f 100 | #define kDefaultFovMaxValue kFovMaxValue 101 | 102 | #define kDefaultFovFactorMinValue 0.8f 103 | #define kDefaultFovFactorMaxValue 1.20f 104 | 105 | #define kFovFactorOffsetValue 1.0f 106 | #define kFovFactorNegativeOffsetValue (kFovFactorOffsetValue - kDefaultFovFactorMinValue) 107 | #define kFovFactorPositiveOffsetValue (kDefaultFovFactorMaxValue - kFovFactorOffsetValue) 108 | 109 | #define kDefaultFOVFactorCorrectedMinValue 0.774f 110 | #define kDefaultFOVFactorCorrectedMaxValue 1.108f 111 | 112 | #define kFOVFactorCorrectedNegativeOffsetValue (kFovFactorOffsetValue - kDefaultFOVFactorCorrectedMinValue) 113 | #define kFOVFactorCorrectedPositiveOffsetValue (kDefaultFOVFactorCorrectedMaxValue - kFovFactorOffsetValue) 114 | 115 | #define kDefaultMinDistanceToEnableFov 8 116 | 117 | #define kDefaultFovControlIncreaseDistance 1600.0f 118 | 119 | #define kDefaultFovMinCounter 5 120 | 121 | #pragma mark - 122 | #pragma mark reset consts 123 | 124 | #define kDefaultNumberOfTouchesForReset 4 125 | 126 | #pragma mark - 127 | #pragma mark inertia consts 128 | 129 | #define kDefaultInertiaInterval 3 130 | 131 | #pragma mark - 132 | #pragma mark accelerometer consts 133 | 134 | #define kDefaultAccelerometerSensitivity 7.0f 135 | #define kDefaultAccelerometerInterval 1.0f/60.0f 136 | #define kAccelerometerSensitivityMinValue 1.0f 137 | #define kAccelerometerSensitivityMaxValue 10.0f 138 | #define kAccelerometerMultiplyFactor 100.0f 139 | 140 | #pragma mark - 141 | #pragma mark scrolling consts 142 | 143 | #define kDefaultMinDistanceToEnableScrolling 50 144 | 145 | #pragma mark - 146 | #pragma mark perspective consts 147 | 148 | #define kPerspectiveValue 290.0f 149 | #define kPerspectiveZNear 0.01f 150 | #define kPerspectiveZFar 100.0f 151 | 152 | #pragma mark - 153 | #pragma mark scene-elements consts 154 | 155 | #define kRatio 1.0f 156 | 157 | #pragma mark - 158 | #pragma mark shake consts 159 | 160 | #define kShakeThreshold 100.0f 161 | #define kShakeDiffTime 100 162 | 163 | #pragma mark - 164 | #pragma mark control consts 165 | 166 | #define kZoomControlMinWidth 64 167 | #define kZoomControlMinHeight 40 168 | #define kZoomControlWidthPercentage 0.21f 169 | #define kZoomControlHeightPercentage 0.08f 170 | 171 | #pragma mark - 172 | #pragma mark transition consts 173 | 174 | #define kDefaultStepFade 0.05f 175 | 176 | #pragma mark - 177 | #pragma mark hotspot consts 178 | 179 | #define kDefaultHotspotSize 0.05f 180 | #define kDefaultHotspotAlpha 0.8f 181 | #define kDefaultHotspotOverAlpha 1.0f 182 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLCubicPanorama.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLPanoramaBase.h" 20 | 21 | @interface PLCubicPanorama : PLPanoramaBase 22 | { 23 | } 24 | 25 | #pragma mark - 26 | #pragma mark property methods 27 | 28 | -(void)setImage:(PLImage *)image face:(PLCubeFaceOrientation)face; 29 | 30 | -(void)setTexture:(PLTexture *)texture face:(PLCubeFaceOrientation)face; 31 | 32 | +(GLfloat *)coordinates; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLCubicPanorama.m: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLPanoramaBaseProtected.h" 20 | #import "PLCubicPanorama.h" 21 | 22 | #pragma mark - 23 | #pragma mark constants 24 | 25 | #define R kRatio 26 | 27 | #pragma mark - 28 | #pragma mark static variables 29 | 30 | static GLfloat cube[] = 31 | { 32 | // Front Face 33 | -R, -R, R, 34 | R, -R, R, 35 | -R, R, R, 36 | R, R, R, 37 | // Back Face 38 | -R, -R, -R, 39 | -R, R, -R, 40 | R, -R, -R, 41 | R, R, -R, 42 | // Right Face 43 | -R, -R, R, 44 | -R, R, R, 45 | -R, -R, -R, 46 | -R, R, -R, 47 | // Left Face 48 | R, -R, -R, 49 | R, R, -R, 50 | R, -R, R, 51 | R, R, R, 52 | // Top Face 53 | -R, R, R, 54 | R, R, R, 55 | -R, R, -R, 56 | R, R, -R, 57 | // Bottom Face 58 | -R, -R, R, 59 | -R, -R, -R, 60 | R, -R, R, 61 | R, -R, -R, 62 | }; 63 | 64 | static GLfloat textureCoords[] = 65 | { 66 | // Front Face 67 | 1.0f, 1.0f, 68 | 0.0f, 1.0f, 69 | 1.0f, 0.0f, 70 | 0.0f, 0.0f, 71 | // Back Face 72 | 0.0f, 1.0f, 73 | 0.0f, 0.0f, 74 | 1.0f, 1.0f, 75 | 1.0f, 0.0f, 76 | // Right Face 77 | 0.0f, 1.0f, 78 | 0.0f, 0.0f, 79 | 1.0f, 1.0f, 80 | 1.0f, 0.0f, 81 | // Left Face 82 | 0.0f, 1.0f, 83 | 0.0f, 0.0f, 84 | 1.0f, 1.0f, 85 | 1.0f, 0.0f, 86 | // Top Face 87 | 1.0f, 1.0f, 88 | 0.0f, 1.0f, 89 | 1.0f, 0.0f, 90 | 0.0f, 0.0f, 91 | // Bottom Face 92 | 1.0f, 0.0f, 93 | 1.0f, 1.0f, 94 | 0.0f, 0.0f, 95 | 0.0f, 1.0f, 96 | }; 97 | 98 | @interface PLCubicPanorama(Private) 99 | 100 | -(BOOL)bindTextureBySide:(int)side; 101 | 102 | @end 103 | 104 | @implementation PLCubicPanorama 105 | 106 | #pragma mark - 107 | #pragma mark init methods 108 | 109 | +(id)panorama 110 | { 111 | return [[[PLCubicPanorama alloc] init] autorelease]; 112 | } 113 | 114 | #pragma mark - 115 | #pragma mark property methods 116 | 117 | -(PLSceneElementType)getType 118 | { 119 | return PLSceneElementTypePanorama; 120 | } 121 | 122 | -(int)getPreviewSides 123 | { 124 | return 6; 125 | } 126 | 127 | -(int)getSides 128 | { 129 | return 6; 130 | } 131 | 132 | -(void)setImage:(PLImage *)image face:(PLCubeFaceOrientation)face 133 | { 134 | if(image) 135 | [self setTexture:[PLTexture textureWithImage:image] face:face]; 136 | } 137 | 138 | -(void)setTexture:(PLTexture *)texture face:(PLCubeFaceOrientation)face 139 | { 140 | if(texture) 141 | { 142 | @synchronized(self) 143 | { 144 | PLTexture **textures = [self getTextures]; 145 | PLTexture *currentTexture = textures[(int)face]; 146 | if(currentTexture) 147 | [currentTexture release]; 148 | textures[(int)face] = [texture retain]; 149 | } 150 | } 151 | } 152 | 153 | +(GLfloat *)coordinates 154 | { 155 | return cube; 156 | } 157 | 158 | #pragma mark - 159 | #pragma mark render methods 160 | 161 | -(BOOL)bindTextureBySide:(int)side 162 | { 163 | BOOL result = NO; 164 | @try 165 | { 166 | PLTexture **textures = [self getTextures]; 167 | PLTexture *texture = textures[side]; 168 | if(texture && texture.textureID != 0) 169 | { 170 | glBindTexture(GL_TEXTURE_2D, texture.textureID); 171 | result = YES; 172 | PLTexture **previewTextures = [self getPreviewTextures]; 173 | texture = previewTextures[side]; 174 | if(texture) 175 | [self removePreviewTextureAtIndex:side]; 176 | } 177 | else 178 | { 179 | PLTexture **previewTextures = [self getPreviewTextures]; 180 | texture = previewTextures[side]; 181 | if(texture && texture.textureID != 0) 182 | { 183 | glBindTexture(GL_TEXTURE_2D, texture.textureID); 184 | result = YES; 185 | } 186 | } 187 | } 188 | @catch(NSException *e) 189 | { 190 | } 191 | return result; 192 | } 193 | 194 | -(void)internalRender 195 | { 196 | glRotatef(90.0f, 1.0f, 0.0f, 0.0f); 197 | 198 | glEnable(GL_TEXTURE_2D); 199 | 200 | glVertexPointer(3, GL_FLOAT, 0, cube); 201 | glTexCoordPointer(2, GL_FLOAT, 0, textureCoords); 202 | glEnableClientState(GL_VERTEX_ARRAY); 203 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); 204 | 205 | glEnable(GL_CULL_FACE); 206 | glCullFace(GL_FRONT); 207 | glShadeModel(GL_SMOOTH); 208 | 209 | // Front Face 210 | if([self bindTextureBySide:kCubeFrontFaceIndex]) 211 | { 212 | glNormal3f(0.0f, 0.0f, 1.0f); 213 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 214 | } 215 | 216 | // Back Face 217 | if([self bindTextureBySide:kCubeBackFaceIndex]) 218 | { 219 | glNormal3f(0.0f, 0.0f, -1.0f); 220 | glDrawArrays(GL_TRIANGLE_STRIP, 4, 4); 221 | } 222 | 223 | // Right Face 224 | if([self bindTextureBySide:kCubeRightFaceIndex]) 225 | { 226 | glNormal3f(-1.0f, 0.0f, 0.0f); 227 | glDrawArrays(GL_TRIANGLE_STRIP, 8, 4); 228 | } 229 | 230 | // Left Face 231 | if([self bindTextureBySide:kCubeLeftFaceIndex]) 232 | { 233 | glNormal3f(1.0f, 0.0f, 0.0f); 234 | glDrawArrays(GL_TRIANGLE_STRIP, 12, 4); 235 | } 236 | 237 | // Top Face 238 | if([self bindTextureBySide:kCubeTopFaceIndex]) 239 | { 240 | glNormal3f(0.0f, 1.0f, 0.0f); 241 | glDrawArrays(GL_TRIANGLE_STRIP, 16, 4); 242 | } 243 | 244 | // Bottom Face 245 | if([self bindTextureBySide:kCubeBottomFaceIndex]) 246 | { 247 | glNormal3f(0.0f, -1.0f, 0.0f); 248 | glDrawArrays(GL_TRIANGLE_STRIP, 20, 4); 249 | } 250 | 251 | glDisableClientState(GL_VERTEX_ARRAY); 252 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); 253 | glDisable(GL_CULL_FACE); 254 | glDisable(GL_TEXTURE_2D); 255 | 256 | [super internalRender]; 257 | } 258 | 259 | @end 260 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLCylindricalPanorama.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLPanoramaBase.h" 20 | 21 | @interface PLCylindricalPanorama : PLPanoramaBase 22 | { 23 | #pragma mark - 24 | #pragma mark member variables 25 | @private 26 | NSUInteger divs; 27 | GLUquadric *quadratic; 28 | BOOL isHeightCalculated; 29 | float height; 30 | } 31 | 32 | #pragma mark - 33 | #pragma mark properties 34 | 35 | @property(nonatomic) NSUInteger divs; 36 | 37 | @property(nonatomic) BOOL isHeightCalculated; 38 | @property(nonatomic) float height; 39 | 40 | #pragma mark - 41 | #pragma mark property methods 42 | 43 | -(void)setImage:(PLImage *)image; 44 | 45 | -(void)setTexture:(PLTexture *)texture; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLCylindricalPanorama.m: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLCylindricalPanorama.h" 20 | #import "PLPanoramaBaseProtected.h" 21 | 22 | @implementation PLCylindricalPanorama 23 | 24 | @synthesize divs; 25 | @synthesize isHeightCalculated; 26 | @synthesize height; 27 | 28 | #pragma mark - 29 | #pragma mark init methods 30 | 31 | +(id)panorama 32 | { 33 | return [[[PLCylindricalPanorama alloc] init] autorelease]; 34 | } 35 | 36 | -(void)initializeValues 37 | { 38 | [super initializeValues]; 39 | quadratic = gluNewQuadric(); 40 | gluQuadricNormals(quadratic, GLU_SMOOTH); 41 | gluQuadricTexture(quadratic, YES); 42 | height = kDefaultCylinderHeight; 43 | divs = kDefaultCylinderDivs; 44 | isHeightCalculated = kDefaultCylinderHeightCalculated; 45 | self.pitchRange = PLRangeMake(0.0f, 0.0f); 46 | self.isXAxisEnabled = NO; 47 | } 48 | 49 | #pragma mark - 50 | #pragma mark property methods 51 | 52 | -(PLSceneElementType)getType 53 | { 54 | return PLSceneElementTypePanorama; 55 | } 56 | 57 | -(int)getPreviewSides 58 | { 59 | return 1; 60 | } 61 | 62 | -(int)getSides 63 | { 64 | return 1; 65 | } 66 | 67 | -(void)setImage:(PLImage *)image 68 | { 69 | if(image) 70 | [self setTexture:[PLTexture textureWithImage:image]]; 71 | } 72 | 73 | -(void)setTexture:(PLTexture *)texture 74 | { 75 | if(texture) 76 | { 77 | @synchronized(self) 78 | { 79 | PLTexture **textures = [self getTextures]; 80 | PLTexture *currentTexture = textures[0]; 81 | if(currentTexture) 82 | [currentTexture release]; 83 | textures[0] = [texture retain]; 84 | if(isHeightCalculated) 85 | height = -1.0f; 86 | } 87 | } 88 | } 89 | 90 | -(void)setHeight:(float)value 91 | { 92 | if(!isHeightCalculated) 93 | height = ABS(value); 94 | } 95 | 96 | #pragma mark - 97 | #pragma mark render methods 98 | 99 | -(void)internalRender 100 | { 101 | PLTexture *previewTexture = [self getPreviewTextures][0]; 102 | PLTexture *texture = [self getTextures][0]; 103 | 104 | BOOL previewTextureIsValid = (previewTexture && previewTexture.textureID); 105 | BOOL textureIsValid = (texture && texture.textureID); 106 | 107 | if(isHeightCalculated && textureIsValid && height == -1.0f) 108 | { 109 | int textureWidth = texture.width; 110 | int textureHeight = texture.height; 111 | height = (textureWidth > textureHeight ? (float)textureWidth/textureHeight : (float)textureHeight/textureWidth); 112 | } 113 | 114 | float h2 = height/2.0f; 115 | 116 | glRotatef(180.0f, 0.0f, 1.0f, 0.0f); 117 | glTranslatef(0.0f, 0.0f, -h2); 118 | 119 | glEnable(GL_TEXTURE_2D); 120 | 121 | if(textureIsValid) 122 | { 123 | glBindTexture(GL_TEXTURE_2D, texture.textureID); 124 | if(previewTextureIsValid) 125 | [self removePreviewTextureAtIndex:0]; 126 | } 127 | else if(previewTextureIsValid) 128 | glBindTexture(GL_TEXTURE_2D, previewTexture.textureID); 129 | 130 | gluCylinder(quadratic, kRatio, kRatio, height, (GLint)divs, (GLint)divs); 131 | 132 | glDisable(GL_TEXTURE_2D); 133 | 134 | glTranslatef(0.0f, 0.0f, h2); 135 | glRotatef(-180.0f, 0.0f, 1.0f, 0.0f); 136 | glRotatef(90.0f, 1.0f, 0.0f, 0.0f); 137 | 138 | [super internalRender]; 139 | } 140 | 141 | #pragma mark - 142 | #pragma mark dealloc methods 143 | 144 | -(void)dealloc 145 | { 146 | if(quadratic) 147 | { 148 | gluDeleteQuadric(quadratic); 149 | quadratic = nil; 150 | } 151 | [super dealloc]; 152 | } 153 | 154 | @end 155 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLEnums.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #pragma mark - 20 | #pragma mark enums definitions 21 | 22 | typedef enum 23 | { 24 | PLPanoramaTypeUnknow = 0, 25 | PLPanoramaTypeCubic, 26 | PLPanoramaTypeSpherical, 27 | PLPanoramaTypeSpherical2, 28 | PLPanoramaTypeSphericalRatio, 29 | PLPanoramaTypeCylindrical, 30 | } PLPanoramaType; 31 | 32 | typedef enum 33 | { 34 | PLSensorTypeUnknow = 0, 35 | PLSensorTypeGyroscope, 36 | PLSensorTypeMagnetometer, 37 | } PLSensorType; 38 | 39 | typedef enum 40 | { 41 | PLOpenGLVersionUnknow = 0, 42 | PLOpenGLVersion1_0, 43 | PLOpenGLVersion1_1, 44 | PLOpenGLVersion2_0, 45 | } PLOpenGLVersion; 46 | 47 | typedef enum 48 | { 49 | PLTouchEventTypeBegan = 0, 50 | PLTouchEventTypeMoved, 51 | PLTouchEventTypeEnded 52 | } PLTouchEventType; 53 | 54 | typedef enum 55 | { 56 | PLCubeFaceOrientationFront = 0, 57 | PLCubeFaceOrientationBack = 1, 58 | PLCubeFaceOrientationLeft = 2, 59 | PLCubeFaceOrientationRight = 3, 60 | PLCubeFaceOrientationTop = 4, 61 | PLCubeFaceOrientationBottom = 5, 62 | PLCubeFaceOrientationUp = 4, 63 | PLCubeFaceOrientationDown = 5, 64 | } PLCubeFaceOrientation; 65 | 66 | typedef enum 67 | { 68 | PLSpherical2FaceOrientationLeft = 0, 69 | PLSpherical2FaceOrientationRight, 70 | PLSpherical2FaceOrientationFront, 71 | PLSpherical2FaceOrientationBack, 72 | } PLSpherical2FaceOrientation; 73 | 74 | typedef enum 75 | { 76 | PLTransitionTypeFadeIn = 0, 77 | PLTransitionTypeFadeOut 78 | } PLTransitionType; 79 | 80 | typedef enum 81 | { 82 | PLTouchStatusNone = 0, 83 | PLTouchStatusMoved, 84 | PLTouchStatusEnded, 85 | PLTouchStatusBegan, 86 | PLTouchStatusFirstSingleTapCount, 87 | PLTouchStatusSingleTapCount, 88 | PLTouchStatusDoubleTapCount 89 | } PLTouchStatus; 90 | 91 | typedef enum 92 | { 93 | PLSceneElementTypeNone = 0, 94 | PLSceneElementTypePanorama, 95 | PLSceneElementTypeHotspot, 96 | PLSceneElementTypeObject 97 | } PLSceneElementType; 98 | 99 | typedef enum 100 | { 101 | PLHotspotTouchStatusOut = 0, 102 | PLHotspotTouchStatusOver, 103 | PLHotspotTouchStatusMove, 104 | PLHotspotTouchDown 105 | } PLHotspotTouchStatus; 106 | 107 | typedef enum 108 | { 109 | PLTextureColorFormatUnknown = 0, 110 | PLTextureColorFormatRGBA8888 = 1, 111 | PLTextureColorFormatRGB565 = 2, 112 | PLTextureColorFormatRGBA4444 = 3 113 | } PLTextureColorFormat; 114 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLHotspot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLSceneElement.h" 20 | #import "PLVector3.h" 21 | 22 | @interface PLHotspot : PLSceneElement 23 | { 24 | #pragma mark - 25 | #pragma mark member variables 26 | @private 27 | float width, height; 28 | 29 | float atv, ath; 30 | 31 | GLfloat *cube, *textureCoords; 32 | 33 | float overAlpha, defaultOverAlpha; 34 | 35 | BOOL hasChangedCoordProperty; 36 | 37 | BOOL isTouchBlock; 38 | PLHotspotTouchStatus touchStatus; 39 | } 40 | 41 | #pragma mark - 42 | #pragma mark properties 43 | 44 | @property(nonatomic, assign) float atv, ath; 45 | @property(nonatomic, assign) float width, height; 46 | @property(nonatomic, assign) PLCubeFaceOrientation faceOrientation; 47 | @property(nonatomic, readonly, getter=getRect) PLRect rect; 48 | @property(nonatomic, readonly, getter=getVertexs) GLfloat * vertexs; 49 | @property(nonatomic, assign) float overAlpha, defaultOverAlpha; 50 | @property(nonatomic, readonly) PLHotspotTouchStatus touchStatus; 51 | @property(nonatomic, assign) BOOL isTouchBlock; 52 | 53 | #pragma mark - 54 | #pragma mark init methods 55 | 56 | -(id)initWithId:(long long)identifier atv:(float)atv ath:(float)ath; 57 | -(id)initWithId:(long long)identifier texture:(PLTexture *)texture atv:(float)atv ath:(float)ath; 58 | -(id)initWithId:(long long)identifier texture:(PLTexture *)texture atv:(float)atv ath:(float)ath width:(float)width height:(float)height; 59 | 60 | +(id)hotspotWithId:(long long)identifier atv:(float)atv ath:(float)ath; 61 | +(id)hotspotWithId:(long long)identifier texture:(PLTexture *)texture atv:(float)atv ath:(float)ath; 62 | +(id)hotspotWithId:(long long)identifier texture:(PLTexture *)texture atv:(float)atv ath:(float)ath width:(float)width height:(float)height; 63 | 64 | #pragma mark - 65 | #pragma mark property methods 66 | 67 | -(PLRect)getRect; 68 | -(GLfloat *)getVertexs; 69 | 70 | #pragma mark - 71 | #pragma mark layout methods 72 | 73 | -(void)setLayout:(float)xValue :(float)yValue :(float)widthValue :(float)heightValue; 74 | 75 | #pragma mark - 76 | #pragma mark touch methods 77 | 78 | -(void)touchBlock; 79 | -(void)touchUnblock; 80 | -(void)touchOver:(NSObject *)sender; 81 | -(void)touchMove:(NSObject *)sender; 82 | -(void)touchOut:(NSObject *)sender; 83 | -(void)touchDown:(NSObject *)sender; 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLIInitializeObject.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import 20 | 21 | @protocol PLIInitializeObject 22 | 23 | @required 24 | 25 | #pragma mark - 26 | #pragma mark init methods 27 | 28 | -(void)initializeValues; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLILoader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import 20 | 21 | @protocol PLIView; 22 | 23 | @protocol PLILoader 24 | 25 | @required 26 | 27 | #pragma mark - 28 | #pragma mark init methods 29 | 30 | -(id)initWithString:(NSString *)string; 31 | -(id)initWithPath:(NSString *)path; 32 | 33 | +(id)loaderWithString:(NSString *)string; 34 | +(id)loaderWithPath:(NSString *)path; 35 | 36 | #pragma mark - 37 | #pragma mark load methods 38 | 39 | -(void)load:(UIView *)view; 40 | 41 | @end -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLIObject.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import 20 | #import "PLStructs.h" 21 | 22 | @protocol PLIObject 23 | 24 | @required 25 | 26 | #pragma mark - 27 | #pragma mark properties 28 | 29 | @property(nonatomic, assign) BOOL isXAxisEnabled, isYAxisEnabled, isZAxisEnabled; 30 | @property(nonatomic, assign) PLPosition position; 31 | @property(nonatomic, getter=getX, setter=setX:) float x; 32 | @property(nonatomic, getter=getY, setter=setY:) float y; 33 | @property(nonatomic, getter=getZ, setter=setZ:) float z; 34 | @property(nonatomic, assign) PLRange xRange, yRange, zRange; 35 | 36 | @property(nonatomic, assign) BOOL isPitchEnabled, isYawEnabled, isRollEnabled, isReverseRotation, isYZAxisInverseRotation; 37 | @property(nonatomic, assign) PLRotation rotation; 38 | @property(nonatomic, getter=getPitch, setter=setPitch:) float pitch; 39 | @property(nonatomic, getter=getYaw, setter=setYaw:) float yaw; 40 | @property(nonatomic, getter=getRoll, setter=setRoll:) float roll; 41 | @property(nonatomic, assign) PLRange pitchRange, yawRange, rollRange; 42 | @property(nonatomic, assign) float rotateSensitivity; 43 | 44 | @property(nonatomic, assign) float alpha, defaultAlpha; 45 | 46 | #pragma mark - 47 | #pragma mark reset methods 48 | 49 | -(void)reset; 50 | 51 | #pragma mark - 52 | #pragma mark property methods 53 | 54 | -(float)getX; 55 | -(void)setX:(float)value; 56 | -(float)getY; 57 | -(void)setY:(float)value; 58 | -(float)getZ; 59 | -(void)setZ:(float)value; 60 | 61 | -(float)getPitch; 62 | -(void)setPitch:(float)value; 63 | -(float)getYaw; 64 | -(void)setYaw:(float)value; 65 | -(float)getRoll; 66 | -(void)setRoll:(float)value; 67 | 68 | #pragma mark - 69 | #pragma mark translate methods 70 | 71 | -(void)translateWithX:(float)xValue y:(float)yValue; 72 | -(void)translateWithX:(float)xValue y:(float)yValue z:(float)zValue; 73 | 74 | #pragma mark - 75 | #pragma mark rotate methods 76 | 77 | -(void)rotateWithPitch:(float)pitchValue yaw:(float)yawValue; 78 | -(void)rotateWithPitch:(float)pitchValue yaw:(float)yawValue roll:(float)rollValue; 79 | -(void)rotateWithStartPoint:(CGPoint)startPoint endPoint:(CGPoint) endPoint; 80 | -(void)rotateWithStartPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint sensitivity:(float)sensitivity; 81 | 82 | #pragma mark - 83 | #pragma mark clone methods 84 | 85 | -(void)clonePropertiesOf:(NSObject *)value; 86 | 87 | @end -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLIPanorama.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLIScene.h" 20 | #import "PLImage.h" 21 | #import "PLHotspot.h" 22 | 23 | @protocol PLIPanorama 24 | 25 | @required 26 | 27 | #pragma mark - 28 | #pragma mark properties 29 | 30 | @property(nonatomic, readonly, getter=getSides) int sides; 31 | 32 | #pragma mark - 33 | #pragma mark init methods 34 | 35 | +(id)panorama; 36 | 37 | #pragma mark - 38 | #pragma mark property methods 39 | 40 | -(int)getPreviewSides; 41 | -(void)setPreviewImage:(PLImage *)value; 42 | -(int)getSides; 43 | 44 | #pragma mark - 45 | #pragma mark texture remove methods 46 | 47 | -(void)removePreviewTextureAtIndex:(NSUInteger)index; 48 | -(void)removeAllPreviewTextures; 49 | 50 | -(void)removeAllTextures; 51 | 52 | #pragma mark - 53 | #pragma mark clear methods 54 | 55 | -(void)clearPanorama; 56 | 57 | #pragma mark - 58 | #pragma mark hotspot methods 59 | 60 | -(void)addHotspot:(PLHotspot *)hotspot; 61 | -(void)removeHotspot:(PLHotspot *)hotspot; 62 | -(void)removeHotspotAtIndex:(NSUInteger)index; 63 | -(void)removeAllHotspots; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLIRenderableElement.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLIObject.h" 20 | 21 | @protocol PLIRenderableElement 22 | 23 | @required 24 | 25 | #pragma mark - 26 | #pragma mark properties 27 | 28 | @property(nonatomic) BOOL isVisible; 29 | @property(nonatomic, readonly) BOOL isValid; 30 | 31 | #pragma mark - 32 | #pragma mark render methods 33 | 34 | -(BOOL)render; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLIRenderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLIView.h" 20 | 21 | @protocol PLIRenderer 22 | 23 | @required 24 | 25 | #pragma mark - 26 | #pragma mark properties 27 | 28 | @property(nonatomic, assign) UIView *view; 29 | @property(nonatomic, assign) NSObject *scene; 30 | @property(nonatomic, readonly) BOOL isValid; 31 | @property(nonatomic, readonly, getter = isRunning) BOOL isRunning; 32 | @property(nonatomic, readonly) GLint backingWidth, backingHeight; 33 | 34 | #pragma mark - 35 | #pragma mark init methods 36 | 37 | -(id)initWithView:(UIView *)view scene:(NSObject *)scene; 38 | +(id)rendererWithView:(UIView *)view scene:(NSObject *)scene; 39 | 40 | #pragma mark - 41 | #pragma mark render methods 42 | 43 | -(void)render; 44 | -(void)renderNTimes:(NSUInteger)times; 45 | 46 | #pragma mark - 47 | #pragma mark buffer methods 48 | 49 | -(BOOL)resizeFromLayer; 50 | 51 | #pragma mark - 52 | #pragma mark control methods 53 | 54 | -(void)start; 55 | -(BOOL)isRunning; 56 | -(void)stop; 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLIScene.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLIRenderableElement.h" 20 | #import "PLCamera.h" 21 | #import "PLSceneElement.h" 22 | 23 | @protocol PLIView; 24 | 25 | @protocol PLIScene 26 | 27 | @required 28 | 29 | #pragma mark - 30 | #pragma mark properties 31 | 32 | @property(nonatomic, readonly) NSMutableArray *cameras; 33 | @property(nonatomic, readonly) PLCamera *currentCamera; 34 | @property(nonatomic, assign) NSUInteger cameraIndex; 35 | @property(nonatomic, readonly) NSMutableArray *elements; 36 | @property(nonatomic, readonly) UIView *view; 37 | 38 | #pragma mark - 39 | #pragma mark init methods 40 | 41 | -(id)initWithCamera:(PLCamera *)camera; 42 | -(id)initWithElement:(PLSceneElement *)element; 43 | -(id)initWithElement:(PLSceneElement *)element camera:(PLCamera *)camera; 44 | 45 | -(id)initWithView:(UIView *)view; 46 | -(id)initWithView:(UIView *)view camera:(PLCamera *)camera; 47 | -(id)initWithView:(UIView *)view element:(PLSceneElement *)element; 48 | -(id)initWithView:(UIView *)view element:(PLSceneElement *)element camera:(PLCamera *)camera; 49 | 50 | #pragma mark - 51 | #pragma mark reset methods 52 | 53 | -(void)resetAlpha; 54 | 55 | #pragma mark - 56 | #pragma mark camera methods 57 | 58 | -(void)addCamera:(PLCamera *)camera; 59 | -(void)removeCameraAtIndex:(NSUInteger)index; 60 | -(void)removeCamera:(PLCamera *)camera; 61 | -(void)removeAllCameras; 62 | 63 | #pragma mark - 64 | #pragma mark element methods 65 | 66 | -(void)addElement:(PLSceneElement *)element; 67 | -(void)removeElementAtIndex:(NSUInteger)index; 68 | -(void)removeElement:(PLSceneElement *)element; 69 | -(void)removeAllElements; 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLIView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import 20 | #import 21 | #import 22 | #import 23 | #import 24 | #import 25 | 26 | #import "PLEnums.h" 27 | #import "PLMath.h" 28 | #import "PLIPanorama.h" 29 | #import "PLCamera.h" 30 | #import "PLViewDelegate.h" 31 | #import "PLILoader.h" 32 | 33 | #import "PLTransition.h" 34 | #import "PLTransitionDelegate.h" 35 | 36 | @protocol PLIView 37 | 38 | @required 39 | 40 | #pragma mark - 41 | #pragma mark properties 42 | 43 | @property(nonatomic, retain) NSObject *panorama; 44 | 45 | @property(nonatomic, readonly, getter=getCamera) PLCamera *camera; 46 | 47 | @property(nonatomic) NSTimeInterval animationInterval; 48 | @property(nonatomic) NSUInteger animationFrameInterval; 49 | 50 | @property(nonatomic) BOOL isBlocked; 51 | 52 | @property(nonatomic) BOOL isAccelerometerEnabled, isAccelerometerLeftRightEnabled, isAccelerometerUpDownEnabled; 53 | @property(nonatomic) float accelerometerSensitivity; 54 | @property(nonatomic) NSTimeInterval accelerometerInterval; 55 | 56 | @property(nonatomic) CGPoint startPoint, endPoint; 57 | @property(nonatomic, readonly) CGPoint startFovPoint, endFovPoint; 58 | 59 | @property(nonatomic) BOOL isScrollingEnabled; 60 | @property(nonatomic) NSUInteger minDistanceToEnableScrolling; 61 | 62 | @property(nonatomic) BOOL isInertiaEnabled; 63 | @property(nonatomic) NSTimeInterval inertiaInterval; 64 | 65 | @property(nonatomic) BOOL isResetEnabled, isShakeResetEnabled; 66 | @property(nonatomic) uint8_t numberOfTouchesForReset; 67 | 68 | @property(nonatomic, readonly) BOOL isValidForFov; 69 | 70 | @property(nonatomic) float shakeThreshold; 71 | 72 | @property(nonatomic) BOOL isDisplayLinkSupported; 73 | @property(nonatomic, readonly) BOOL isAnimating, isSensorialRotationRunning; 74 | 75 | @property(nonatomic, assign) NSObject *delegate; 76 | 77 | @property(nonatomic, readonly, getter=getIsValidForTransition) BOOL isValidForTransition; 78 | 79 | @property(nonatomic, readonly) PLTouchStatus touchStatus; 80 | @property(nonatomic) BOOL isPointerVisible; 81 | 82 | #pragma mark - 83 | #pragma mark property methods 84 | 85 | -(PLCamera *)getCamera; 86 | 87 | -(void)setSceneAlpha:(float)value; 88 | 89 | -(BOOL)getIsValidForTransition; 90 | 91 | -(UIInterfaceOrientation)currentDeviceOrientation; 92 | 93 | +(Class)layerClass; 94 | 95 | #pragma mark - 96 | #pragma mark reset methods 97 | 98 | -(void)reset; 99 | -(void)resetWithoutAlpha; 100 | -(void)resetSceneAlpha; 101 | 102 | #pragma mark - 103 | #pragma mark draw methods 104 | 105 | -(void)drawView; 106 | -(void)drawViewNTimes:(NSUInteger)times; 107 | 108 | #pragma mark - 109 | #pragma mark render buffer methods 110 | 111 | -(void)regenerateRenderBuffer; 112 | 113 | #pragma mark - 114 | #pragma mark animation methods 115 | 116 | -(void)startAnimation; 117 | -(void)stopAnimation; 118 | 119 | #pragma mark - 120 | #pragma mark sensorial rotation methods 121 | 122 | -(void)startSensorialRotation; 123 | -(void)stopSensorialRotation; 124 | 125 | #pragma mark - 126 | #pragma mark transition methods 127 | 128 | -(BOOL)executeTransition:(PLTransition *)transition; 129 | 130 | @optional 131 | 132 | #pragma mark - 133 | #pragma mark progressbar methods 134 | 135 | -(BOOL)showProgressBar; 136 | -(void)resetProgressBar; 137 | -(BOOL)hideProgressBar; 138 | 139 | #pragma mark - 140 | #pragma mark clear methods 141 | 142 | -(void)clear; 143 | 144 | #pragma mark - 145 | #pragma mark load methods 146 | 147 | -(void)load:(NSObject *)loader; 148 | 149 | @end 150 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLImage.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import 20 | #import 21 | 22 | @interface PLImage : NSObject 23 | { 24 | #pragma mark - 25 | #pragma mark member variables 26 | @private 27 | CGImageRef cgImage; 28 | NSUInteger width, height; 29 | BOOL isRecycled; 30 | } 31 | 32 | #pragma mark - 33 | #pragma mark properties 34 | 35 | @property(nonatomic, readonly, getter=getWidth) NSUInteger width; 36 | @property(nonatomic, readonly, getter=getHeight) NSUInteger height; 37 | 38 | @property(nonatomic, readonly, getter=getCGImage) CGImageRef CGImage; 39 | 40 | @property(nonatomic, readonly, getter=getCount) NSUInteger count; 41 | @property(nonatomic, readonly, getter=getBits) unsigned char * bits; 42 | 43 | @property(nonatomic, readonly, getter=isRecycled) BOOL isRecycled; 44 | 45 | #pragma mark - 46 | #pragma mark init methods 47 | 48 | -(id)initWithCGImage:(CGImageRef)image; 49 | -(id)initWithSize:(CGSize)size; 50 | -(id)initWithDimensions:(NSUInteger)width :(NSUInteger)height; 51 | -(id)initWithPath:(NSString *)path; 52 | -(id)initWithBuffer:(NSData *)buffer; 53 | 54 | +(id)imageWithSizeZero; 55 | +(id)imageWithCGImage:(CGImageRef)image; 56 | +(id)imageWithSize:(CGSize)size; 57 | +(id)imageWithDimensions:(NSUInteger)width :(NSUInteger)height; 58 | +(id)imageWithPath:(NSString *)path; 59 | +(id)imageWithBuffer:(NSData *)buffer; 60 | 61 | #pragma mark - 62 | #pragma mark property methods 63 | 64 | -(NSUInteger)getWidth; 65 | -(NSUInteger)getHeight; 66 | -(CGSize)getSize; 67 | -(CGRect)getRect; 68 | 69 | -(CGImageRef)getCGImage; 70 | 71 | -(NSUInteger)getCount; 72 | -(unsigned char *)getBits; 73 | 74 | -(BOOL)isValid; 75 | 76 | -(BOOL)isRecycled; 77 | 78 | #pragma mark - 79 | #pragma mark operation methods 80 | 81 | -(BOOL)equals:(PLImage *)image; 82 | -(PLImage *)assign:(PLImage *)image; 83 | 84 | #pragma mark - 85 | #pragma mark crop methods 86 | 87 | -(PLImage *)crop:(CGRect)rect; 88 | 89 | #pragma mark - 90 | #pragma mark scale methods 91 | 92 | -(PLImage *)scale:(CGSize)size; 93 | 94 | #pragma mark - 95 | #pragma mark rotate methods 96 | 97 | -(PLImage *)rotate:(NSInteger)angle; 98 | 99 | #pragma mark - 100 | #pragma mark mirror methods 101 | 102 | -(PLImage *)mirrorHorizontally; 103 | -(PLImage *)mirrorVertically; 104 | -(PLImage *)mirror:(BOOL)horizontally :(BOOL)vertically; 105 | 106 | #pragma mark - 107 | #pragma mark save methods 108 | 109 | -(BOOL)save:(NSString *)path; 110 | -(BOOL)save:(NSString *)path quality:(NSUInteger)quality; 111 | 112 | #pragma mark - 113 | #pragma mark sub-image methods 114 | 115 | -(PLImage *)getSubImageWithRect:(CGRect)rect; 116 | +(PLImage *)joinImagesHorizontally:(PLImage *)leftImage rightImage:(PLImage *)rightImage; 117 | 118 | #pragma mark - 119 | #pragma mark recycle methods 120 | 121 | -(void)recycle; 122 | 123 | #pragma mark - 124 | #pragma mark clone methods 125 | 126 | -(CGImageRef)cloneCGImage; 127 | -(PLImage *)clone; 128 | 129 | @end -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLIntersection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | /* 20 | * This functions are a port from C++ to Objective-C of 21 | * "Demonstration of a line mesh intersection test (Sample1-Mesh_Line_Intersection.zip)" 22 | * example by Jonathan Kreuzer http://www.3dkingdoms.com/weekly. 23 | * See checkLineBoxWithRay.h and checkLineBoxWithRay.cpp. 24 | */ 25 | 26 | #import "PLVector3.h" 27 | 28 | @interface PLIntersection : NSObject 29 | 30 | #pragma mark - 31 | #pragma mark check methods 32 | 33 | +(BOOL)checkLineBoxWithRay:(PLVector3 **)ray startBound:(PLVector3 *)startBound endBound:(PLVector3 *)endBound hitPoint:(PLVector3 **)hitPoint; 34 | +(BOOL)checkLineBoxWithRay:(PLVector3 **)ray point1:(PLVector3 *)point1 point2:(PLVector3 *)point2 point3:(PLVector3 *)point3 point4:(PLVector3 *)point4 hitPoint:(PLVector3 **)hitPoint; 35 | +(BOOL)checkLineTriangleWithRay:(PLVector3 **)ray firstVertex:(PLVector3 *)firstVertex secondVertex:(PLVector3 *)secondVertex thirdVertex:(PLVector3 *)thirdVertex hitPoint:(PLVector3 **)hitPoint; 36 | 37 | @end 38 | 39 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLJSONLoader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLObjectBase.h" 20 | #import "PLILoader.h" 21 | 22 | @interface PLJSONLoader : PLObjectBase 23 | { 24 | #pragma mark - 25 | #pragma mark member variables 26 | @private 27 | NSDictionary *hotspotTextures; 28 | NSDictionary *json; 29 | } 30 | - (instancetype)init __attribute__((unavailable("Forbidden use init!"))); 31 | @end 32 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLLog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import 20 | 21 | @interface PLLog : NSObject 22 | 23 | #pragma mark - 24 | #pragma mark log methods 25 | 26 | +(void)debug:(NSString *)tag format:(NSString *)format, ...; 27 | +(void)error:(NSString *)tag format:(NSString *)format, ...; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLLog.m: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLLog.h" 20 | 21 | @implementation PLLog 22 | 23 | #pragma mark - 24 | #pragma mark log methods 25 | 26 | +(void)debug:(NSString *)tag format:(NSString *)format, ... 27 | { 28 | va_list args; 29 | va_start(args, format); 30 | NSLog([[[NSString alloc] initWithFormat:format arguments:args] autorelease], nil); 31 | va_end(args); 32 | } 33 | 34 | +(void)error:(NSString *)tag format:(NSString *)format, ... 35 | { 36 | va_list args; 37 | va_start(args, format); 38 | NSLog([[[NSString alloc] initWithFormat:format arguments:args] autorelease], nil); 39 | va_end(args); 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLMath.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLStructs.h" 20 | 21 | @interface PLMath : NSObject 22 | 23 | #pragma mark - 24 | #pragma mark distance methods 25 | 26 | +(float)distanceBetweenPoints:(CGPoint)point1 :(CGPoint)point2; 27 | 28 | #pragma mark - 29 | #pragma mark range methods 30 | 31 | +(float)valueInRange:(float)value range:(PLRange)range; 32 | 33 | #pragma mark - 34 | #pragma mark normalize methods 35 | 36 | +(float)normalizeAngle:(float)angle range:(PLRange)range; 37 | +(float)normalizeFov:(float)fov range:(PLRange)range; 38 | 39 | #pragma mark - 40 | #pragma mark pow methods 41 | 42 | +(BOOL)isPowerOfTwo:(int)value; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLMath.m: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLMath.h" 20 | 21 | @implementation PLMath 22 | 23 | #pragma mark - 24 | #pragma mark init methods 25 | 26 | -(id)init 27 | { 28 | return nil; 29 | } 30 | 31 | #pragma mark - 32 | #pragma mark distance methods 33 | 34 | +(float)distanceBetweenPoints:(CGPoint)point1 :(CGPoint)point2; 35 | { 36 | return sqrt(((point2.x - point1.x) * (point2.x - point1.x)) + ((point2.y - point1.y) * (point2.y - point1.y))); 37 | } 38 | 39 | #pragma mark - 40 | #pragma mark range methods 41 | 42 | +(float)valueInRange:(float)value range:(PLRange)range 43 | { 44 | return MAX(range.min, MIN(value, range.max)); 45 | } 46 | 47 | #pragma mark - 48 | #pragma mark normalize methods 49 | 50 | +(float)normalizeAngle:(float)angle range:(PLRange)range; 51 | { 52 | float result = angle; 53 | if(range.min < 0.0f) 54 | { 55 | while(result <= -180.0f) result += 360.0f; 56 | while(result > 180.0f) result -= 360.0f; 57 | } 58 | else 59 | { 60 | while(result < 0.0f) result += 360.0f; 61 | while(result >= 360.0f) result -= 360.0f; 62 | } 63 | return [PLMath valueInRange:result range:range]; 64 | } 65 | 66 | +(float)normalizeFov:(float)fov range:(PLRange)range 67 | { 68 | return [PLMath valueInRange:fov range:range]; 69 | } 70 | 71 | #pragma mark - 72 | #pragma mark pow methods 73 | //判断是否是2的乘方 74 | +(BOOL)isPowerOfTwo:(int)value 75 | { 76 | while(!(value & 1)) 77 | value = value >> 1; 78 | return (value == 1); 79 | } 80 | 81 | @end 82 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLObject.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLObjectBase.h" 20 | #import "PLIObject.h" 21 | 22 | @interface PLObject : PLObjectBase 23 | { 24 | #pragma mark - 25 | #pragma mark member variables 26 | @private 27 | BOOL isXAxisEnabled, isYAxisEnabled, isZAxisEnabled; 28 | PLPosition position; 29 | PLRange xRange, yRange, zRange; 30 | 31 | BOOL isPitchEnabled, isYawEnabled, isRollEnabled, isReverseRotation, isYZAxisInverseRotation; 32 | PLRotation rotation; 33 | PLRange pitchRange, yawRange, rollRange; 34 | float rotateSensitivity; 35 | 36 | float alpha, defaultAlpha; 37 | } 38 | - (void)resetC:(PLRotation)rotationtm; 39 | @end 40 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLObject.m: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLObjectProtected.h" 20 | 21 | @implementation PLObject 22 | 23 | @synthesize isXAxisEnabled, isYAxisEnabled, isZAxisEnabled; 24 | @synthesize position; 25 | @synthesize xRange, yRange, zRange; 26 | 27 | @synthesize isPitchEnabled, isYawEnabled, isRollEnabled, isReverseRotation, isYZAxisInverseRotation; 28 | @synthesize rotation; 29 | @synthesize pitchRange, yawRange, rollRange; 30 | @synthesize rotateSensitivity; 31 | 32 | @synthesize alpha, defaultAlpha; 33 | 34 | #pragma mark - 35 | #pragma mark init methods 36 | 37 | -(void)initializeValues 38 | { 39 | [super initializeValues]; 40 | xRange = yRange = zRange = PLRangeMake(kFloatMinValue, kFloatMaxValue); 41 | 42 | pitchRange = PLRangeMake(kDefaultPitchMinRange, kDefaultPitchMaxRange); 43 | yawRange = PLRangeMake(kDefaultYawMinRange, kDefaultYawMaxRange); 44 | rollRange = PLRangeMake(kDefaultRotateMinRange, kDefaultRotateMaxRange); 45 | 46 | isXAxisEnabled = isYAxisEnabled = isZAxisEnabled = YES; 47 | isPitchEnabled = isYawEnabled = isRollEnabled = YES; 48 | 49 | rotateSensitivity = kDefaultRotateSensitivity; 50 | isReverseRotation = NO; 51 | 52 | isYZAxisInverseRotation = YES; 53 | 54 | position = PLPositionMake(0.0f, 0.0f, 0.0f); 55 | 56 | defaultAlpha = kObjectDefaultAlpha; 57 | 58 | [self reset]; 59 | } 60 | 61 | #pragma mark - 62 | #pragma mark reset methods 63 | 64 | - (void)resetC:(PLRotation)rotationtmp 65 | { 66 | // rotation = rotationtmp; 67 | alpha = defaultAlpha; 68 | } 69 | 70 | -(void)reset 71 | { 72 | NSLog(@"rotation###%f---%f--%f",rotation.pitch,rotation.yaw,rotation.roll); 73 | NSLog(@"alpha ###%f",alpha); 74 | rotation = PLRotationMake(0.0f, 0.0f, 0.0f); 75 | alpha = defaultAlpha; 76 | } 77 | 78 | #pragma mark - 79 | #pragma mark property methods 80 | 81 | -(void)setPosition:(PLPosition)value 82 | { 83 | [self setX:value.x]; 84 | [self setY:value.y]; 85 | [self setZ:value.z]; 86 | } 87 | 88 | -(float)getX 89 | { 90 | return position.x; 91 | } 92 | 93 | -(void)setX:(float)value 94 | { 95 | if(isXAxisEnabled) 96 | position.x = [PLMath valueInRange:value range:xRange]; 97 | } 98 | 99 | -(float)getY 100 | { 101 | return position.y; 102 | } 103 | 104 | -(void)setY:(float)value 105 | { 106 | if(isYAxisEnabled) 107 | position.y = [PLMath valueInRange:value range:yRange]; 108 | } 109 | 110 | -(float)getZ 111 | { 112 | return position.z; 113 | } 114 | 115 | -(void)setZ:(float)value 116 | { 117 | if(isZAxisEnabled) 118 | position.z = [PLMath valueInRange:value range:zRange]; 119 | } 120 | 121 | -(void)setRotation:(PLRotation)value 122 | { 123 | [self setPitch:value.pitch]; 124 | [self setYaw:value.yaw]; 125 | [self setRoll:value.roll]; 126 | } 127 | 128 | -(float)getPitch 129 | { 130 | return rotation.pitch; 131 | } 132 | 133 | -(void)setPitch:(float)value 134 | { 135 | if(isPitchEnabled) 136 | rotation.pitch = [PLMath normalizeAngle:value range:pitchRange]; 137 | } 138 | 139 | -(float)getYaw 140 | { 141 | return rotation.yaw; 142 | } 143 | 144 | -(void)setYaw:(float)value 145 | { 146 | if(isYawEnabled) 147 | rotation.yaw = [PLMath normalizeAngle:value range:PLRangeMake(-yawRange.max, -yawRange.min)]; 148 | } 149 | 150 | -(float)getRoll 151 | { 152 | return rotation.roll; 153 | } 154 | 155 | -(void)setRoll:(float)value 156 | { 157 | if(isRollEnabled) 158 | rotation.roll = [PLMath normalizeAngle:value range:rollRange]; 159 | } 160 | 161 | -(void)setDefaultAlpha:(float)value 162 | { 163 | defaultAlpha = value; 164 | alpha = value; 165 | } 166 | 167 | #pragma mark - 168 | #pragma mark translate methods 169 | 170 | -(void)translateWithX:(float)xValue y:(float)yValue 171 | { 172 | position.x = xValue; 173 | position.y = yValue; 174 | } 175 | 176 | -(void)translateWithX:(float)xValue y:(float)yValue z:(float)zValue 177 | { 178 | position = PLPositionMake(xValue, yValue, zValue); 179 | } 180 | 181 | #pragma mark - 182 | #pragma mark rotate methods 183 | 184 | -(void)rotateWithPitch:(float)pitchValue yaw:(float)yawValue 185 | { 186 | self.pitch = pitchValue; 187 | self.yaw = yawValue; 188 | } 189 | 190 | -(void)rotateWithPitch:(float)pitchValue yaw:(float)yawValue roll:(float)rollValue 191 | { 192 | self.rotation = PLRotationMake(pitchValue, yawValue, rollValue); 193 | } 194 | 195 | -(void)rotateWithStartPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint 196 | { 197 | [self rotateWithStartPoint:startPoint endPoint:endPoint sensitivity:rotateSensitivity]; 198 | } 199 | 200 | -(void)rotateWithStartPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint sensitivity:(float)sensitivity 201 | { 202 | self.pitch += (endPoint.y - startPoint.y) / sensitivity; 203 | self.yaw += (startPoint.x - endPoint.x) / sensitivity; 204 | } 205 | 206 | #pragma mark - 207 | #pragma mark clone methods 208 | 209 | -(void)clonePropertiesOf:(NSObject *)value 210 | { 211 | self.isXAxisEnabled = value.isXAxisEnabled; 212 | self.isYAxisEnabled = value.isYAxisEnabled; 213 | self.isZAxisEnabled = value.isZAxisEnabled; 214 | 215 | self.isPitchEnabled = value.isPitchEnabled; 216 | self.isYawEnabled = value.isYawEnabled; 217 | self.isRollEnabled = value.isRollEnabled; 218 | 219 | self.isReverseRotation = value.isReverseRotation; 220 | 221 | self.isYZAxisInverseRotation = value.isYZAxisInverseRotation; 222 | 223 | self.rotateSensitivity = value.rotateSensitivity; 224 | 225 | self.xRange = value.xRange; 226 | self.yRange = value.yRange; 227 | self.zRange = value.zRange; 228 | 229 | self.pitchRange = value.pitchRange; 230 | self.yawRange = value.yawRange; 231 | self.rollRange = value.rollRange; 232 | 233 | self.x = value.x; 234 | self.y = value.y; 235 | self.z = value.z; 236 | 237 | self.pitch = value.pitch; 238 | self.yaw = value.yaw; 239 | self.roll = value.roll; 240 | 241 | self.defaultAlpha = value.defaultAlpha; 242 | self.alpha = value.alpha; 243 | } 244 | 245 | @end 246 | 247 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLObjectBase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import 20 | 21 | #import "PLMath.h" 22 | #import "PLConstants.h" 23 | #import 24 | #import 25 | 26 | @interface PLObjectBase : NSObject 27 | { 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLObjectBase.m: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLObjectBaseProtected.h" 20 | 21 | @implementation PLObjectBase 22 | 23 | #pragma mark - 24 | #pragma mark init methods 25 | 26 | -(id)init 27 | { 28 | if(self = [super init]) 29 | [self initializeValues]; 30 | return self; 31 | } 32 | 33 | -(void)initializeValues 34 | { 35 | } 36 | 37 | #pragma mark - 38 | #pragma mark native object methods 39 | 40 | -(BOOL)isEqual:(id)object 41 | { 42 | return (object && [self hash] == [object hash]); 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLObjectBaseProtected.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLObjectBase.h" 20 | #import "PLIInitializeObject.h" 21 | 22 | @interface PLObjectBase(Protected) 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLObjectProtected.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLObjectBaseProtected.h" 20 | #import "PLObject.h" 21 | 22 | @interface PLObject(Protected) 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLOpenGLSupport.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import 20 | #import 21 | #import 22 | #import "PLEnums.h" 23 | 24 | @interface PLOpenGLSupport : NSObject 25 | 26 | #pragma mark - 27 | #pragma mark property methods 28 | 29 | +(PLOpenGLVersion)getOpenGLVersion; 30 | 31 | @end -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLOpenGLSupport.m: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLOpenGLSupport.h" 20 | 21 | static PLOpenGLVersion glVersion = PLOpenGLVersionUnknow; 22 | 23 | @implementation PLOpenGLSupport 24 | 25 | #pragma mark - 26 | #pragma mark property methods 27 | 28 | +(PLOpenGLVersion)getOpenGLVersion 29 | { 30 | if(glVersion == PLOpenGLVersionUnknow) 31 | { 32 | NSString *version = [NSString stringWithCString:(const char *)glGetString(GL_VERSION) encoding:NSUTF8StringEncoding]; 33 | if([version rangeOfString:@"1.1"].location != NSNotFound) 34 | glVersion = PLOpenGLVersion1_1; 35 | else 36 | glVersion = PLOpenGLVersion2_0; 37 | } 38 | return glVersion; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLPanoramaBase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLScene.h" 20 | #import "PLIPanorama.h" 21 | #import "PLTexture.h" 22 | #import "PLLog.h" 23 | 24 | @interface PLPanoramaBase : PLScene 25 | { 26 | #pragma mark - 27 | #pragma mark member variables 28 | @private 29 | // PLTexture **previewTextures; 30 | // PLTexture **textures; 31 | PLTexture *__unsafe_unretained *previewTextures; 32 | PLTexture *__unsafe_unretained *textures; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLPanoramaBase.m: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLPanoramaBaseProtected.h" 20 | 21 | #pragma mark - 22 | #pragma mark static variables 23 | 24 | static int sPreviewFacesOrder[] = { 1, 3, 0, 2, 4, 5 }; 25 | 26 | @implementation PLPanoramaBase 27 | 28 | #pragma mark - 29 | #pragma mark init methods 30 | 31 | +(id)panorama 32 | { 33 | return nil; 34 | } 35 | 36 | -(void)initializeValues 37 | { 38 | [super initializeValues]; 39 | int sides = [self getSides]; 40 | int previewSides = [self getPreviewSides]; 41 | textures = (PLTexture **)malloc(sizeof(PLTexture *) * sides); 42 | previewTextures = (PLTexture **)malloc(sizeof(PLTexture *) * previewSides); 43 | int i; 44 | for(i = 0; i < sides; i++) 45 | textures[i] = nil; 46 | for(i = 0; i < previewSides; i++) 47 | previewTextures[i] = nil; 48 | [self setIsValid:YES]; 49 | } 50 | 51 | #pragma mark - 52 | #pragma mark property methods 53 | 54 | -(PLTexture **)getTextures 55 | { 56 | return textures; 57 | } 58 | 59 | -(int)getPreviewSides 60 | { 61 | return 1; 62 | } 63 | 64 | -(int)getSides 65 | { 66 | return 1; 67 | } 68 | 69 | #pragma mark - 70 | #pragma mark preview texture methods 71 | 72 | -(PLTexture **)getPreviewTextures 73 | { 74 | return previewTextures; 75 | } 76 | 77 | -(void)setPreviewImage:(PLImage *)value 78 | { 79 | @synchronized(self) 80 | { 81 | [self removeAllPreviewTextures]; 82 | if(value && [value isValid]) 83 | { 84 | value = [value retain]; 85 | int width = (int)[value getWidth]; 86 | int height = (int)[value getHeight]; 87 | if([PLMath isPowerOfTwo:width] && (height % width == 0 || width % height == 0)) 88 | { 89 | int sides = [self getPreviewSides], counter = 0; 90 | BOOL isSideByDefault = (sides == 1); 91 | for(int i = 0; i < sides; i++) 92 | { 93 | @try 94 | { 95 | PLImage *subImage = [value getSubImageWithRect:CGRectMake(0, ((isSideByDefault ? i : sPreviewFacesOrder[i]) * width), width, (isSideByDefault ? height : width))]; 96 | previewTextures[counter++] = [[PLTexture alloc] initWithImage:subImage]; 97 | } 98 | @catch(NSException *e) 99 | { 100 | [self removeAllPreviewTextures]; 101 | [PLLog error:@"PLPanoramaBase::setPreviewTexture" format:@"setPreviewTexture fails: %@", e.reason]; 102 | break; 103 | } 104 | } 105 | } 106 | [value release]; 107 | } 108 | } 109 | } 110 | 111 | #pragma mark - 112 | #pragma mark remove texture methods 113 | 114 | -(void)removePreviewTextureAtIndex:(NSUInteger)index 115 | { 116 | @synchronized(self) 117 | { 118 | if(index < [self getPreviewSides]) 119 | { 120 | PLTexture *texture = previewTextures[index]; 121 | if(texture) 122 | { 123 | [texture recycle]; 124 | [texture release]; 125 | previewTextures[index] = nil; 126 | } 127 | } 128 | } 129 | } 130 | 131 | -(void)removeAllPreviewTextures 132 | { 133 | @synchronized(self) 134 | { 135 | int sides = [self getPreviewSides]; 136 | for(int i = 0; i < sides; i++) 137 | { 138 | PLTexture *texture = previewTextures[i]; 139 | if(texture) 140 | { 141 | [texture recycle]; 142 | [texture release]; 143 | previewTextures[i] = nil; 144 | } 145 | } 146 | } 147 | } 148 | 149 | -(void)removeAllTextures 150 | { 151 | @synchronized(self) 152 | { 153 | int sides = [self getSides]; 154 | for(int i = 0; i < sides; i++) 155 | { 156 | PLTexture *texture = textures[i]; 157 | if(texture) 158 | { 159 | [texture release]; 160 | textures[i] = nil; 161 | } 162 | } 163 | } 164 | } 165 | 166 | #pragma mark - 167 | #pragma mark clear methods 168 | 169 | -(void)clearPanorama 170 | { 171 | [self removeAllPreviewTextures]; 172 | [self removeAllTextures]; 173 | [self removeAllHotspots]; 174 | } 175 | 176 | #pragma mark - 177 | #pragma mark hotspot methods 178 | 179 | -(void)addHotspot:(PLHotspot *)hotspot 180 | { 181 | [self addElement:hotspot]; 182 | } 183 | 184 | -(void)removeHotspot:(PLHotspot *)hotspot 185 | { 186 | [self removeElement:hotspot]; 187 | } 188 | 189 | -(void)removeHotspotAtIndex:(NSUInteger)index 190 | { 191 | [self removeElementAtIndex:index]; 192 | } 193 | 194 | -(void)removeAllHotspots 195 | { 196 | [self removeAllElements]; 197 | } 198 | 199 | #pragma mark - 200 | #pragma mark dealloc methods 201 | 202 | -(void)dealloc 203 | { 204 | [self clearPanorama]; 205 | free(previewTextures); 206 | free(textures); 207 | [super dealloc]; 208 | } 209 | 210 | @end -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLPanoramaBaseProtected.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLSceneElementProtected.h" 20 | #import "PLPanoramaBase.h" 21 | 22 | @interface PLPanoramaBase(Protected) 23 | 24 | #pragma mark - 25 | #pragma mark properties 26 | 27 | @property(nonatomic, readonly, getter=getTextures) PLTexture **textures; 28 | @property(nonatomic, readonly, getter=getPreviewTextures) PLTexture **previewTextures; 29 | 30 | #pragma mark - 31 | #pragma mark property methods 32 | 33 | -(PLTexture **)getPreviewTextures; 34 | -(PLTexture **)getTextures; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLRenderableElementBase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLObject.h" 20 | #import "PLIRenderableElement.h" 21 | 22 | @interface PLRenderableElementBase : PLObject 23 | { 24 | #pragma mark - 25 | #pragma mark member variables 26 | @private 27 | BOOL isVisible, isValid; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLRenderableElementBase.m: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLRenderableElementBaseProtected.h" 20 | 21 | @implementation PLRenderableElementBase 22 | 23 | @synthesize isVisible, isValid; 24 | 25 | #pragma mark - 26 | #pragma mark init methods 27 | 28 | -(void)initializeValues 29 | { 30 | [super initializeValues]; 31 | isVisible = YES; 32 | isValid = NO; 33 | } 34 | 35 | #pragma mark - 36 | #pragma mark property methods 37 | 38 | -(void)setIsValid:(BOOL)value 39 | { 40 | isValid = value; 41 | } 42 | 43 | #pragma mark - 44 | #pragma mark translate methods 45 | 46 | -(void)translate 47 | { 48 | PLPosition position = self.position; 49 | float yValue = self.isYZAxisInverseRotation ? position.z : position.y, zValue = self.isYZAxisInverseRotation ? position.y : position.z; 50 | glTranslatef(self.isXAxisEnabled ? position.x : 0.0f, self.isYAxisEnabled ? yValue : 0.0f, self.isZAxisEnabled ? zValue : 0.0f); 51 | } 52 | 53 | #pragma mark - 54 | #pragma mark rotate methods 55 | 56 | -(void)rotate 57 | { 58 | [self internalRotate:self.rotation]; 59 | } 60 | 61 | -(void)internalRotate:(PLRotation)rotationValue 62 | { 63 | float yDirection = self.isYZAxisInverseRotation ? 0.0f : 1.0f, zDirection = self.isYZAxisInverseRotation ? 1.0f : 0.0f; 64 | if(self.isPitchEnabled) 65 | glRotatef(rotationValue.pitch * (self.isReverseRotation ? 1.0f : -1.0f), 1.0f, 0.0f, 0.0f); 66 | if(self.isYawEnabled) 67 | glRotatef(rotationValue.yaw * (self.isReverseRotation ? 1.0f : -1.0f), 0.0f, yDirection, zDirection); 68 | if(self.isRollEnabled) 69 | glRotatef(rotationValue.roll * (self.isReverseRotation ? 1.0f : -1.0f), 0.0f, yDirection, zDirection); 70 | } 71 | 72 | #pragma mark - 73 | #pragma mark alpha methods 74 | 75 | -(void)beginAlpha 76 | { 77 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 78 | glEnable(GL_BLEND); 79 | glColor4f(1.0f, 1.0f, 1.0f, self.alpha); 80 | } 81 | 82 | -(void)endAlpha 83 | { 84 | glDisable(GL_BLEND); 85 | glColor4f(1.0f, 1.0f, 1.0f, 1.0f); 86 | } 87 | 88 | #pragma mark - 89 | #pragma mark render methods 90 | 91 | -(void)beginRender 92 | { 93 | glPushMatrix(); 94 | [self rotate]; 95 | [self translate]; 96 | [self beginAlpha]; 97 | } 98 | 99 | -(void)endRender 100 | { 101 | [self endAlpha]; 102 | glPopMatrix(); 103 | } 104 | 105 | -(BOOL)render 106 | { 107 | @try 108 | { 109 | if(isVisible && isValid) 110 | { 111 | [self beginRender]; 112 | [self internalRender]; 113 | [self endRender]; 114 | return YES; 115 | } 116 | } 117 | @catch(NSException *e) 118 | { 119 | } 120 | return NO; 121 | } 122 | 123 | -(void)internalRender 124 | { 125 | } 126 | 127 | @end 128 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLRenderableElementBaseProtected.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLObjectProtected.h" 20 | #import "PLRenderableElementBase.h" 21 | 22 | @interface PLRenderableElementBase(Protected) 23 | 24 | #pragma mark - 25 | #pragma mark property methods 26 | 27 | -(void)setIsValid:(BOOL)value; 28 | 29 | #pragma mark - 30 | #pragma mark action methods 31 | 32 | -(void)translate; 33 | -(void)rotate; 34 | -(void)internalRotate:(PLRotation)rotationValue; 35 | 36 | #pragma mark - 37 | #pragma mark render methods 38 | 39 | -(void)beginRender; 40 | -(void)endRender; 41 | -(void)internalRender; 42 | 43 | #pragma mark - 44 | #pragma mark alpha methods 45 | 46 | -(void)beginAlpha; 47 | -(void)endAlpha; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLRenderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import 20 | #import 21 | #import 22 | #import "glu.h" 23 | 24 | #import "PLIRenderer.h" 25 | #import "PLObjectBase.h" 26 | #import "PLStructs.h" 27 | #import "PLCamera.h" 28 | #import "PLScene.h" 29 | #import "PLSceneElement.h" 30 | 31 | #import "PLVector3.h" 32 | #import "PLIntersection.h" 33 | #import "PLHotspot.h" 34 | 35 | @interface PLRenderer : PLObjectBase 36 | { 37 | #pragma mark - 38 | #pragma mark member variables 39 | @private 40 | BOOL isValid; 41 | 42 | EAGLContext *context; 43 | GLuint program; 44 | 45 | GLint backingWidth, backingHeight; 46 | 47 | GLuint defaultFramebuffer, colorRenderbuffer; 48 | 49 | UIView *view; 50 | NSObject *scene; 51 | 52 | float aspect; 53 | 54 | float mvmatrix[16]; 55 | float projmatrix[16]; 56 | int viewport[4]; 57 | 58 | PLVector3 *ray[2]; 59 | PLVector3 *hitPoint; 60 | PLVector3 *points[4]; 61 | } 62 | 63 | @end -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLScene.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLRenderableElementBase.h" 20 | #import "PLIScene.h" 21 | 22 | @interface PLScene : PLRenderableElementBase 23 | { 24 | #pragma mark - 25 | #pragma mark member variables 26 | @private 27 | NSMutableArray *cameras; 28 | PLCamera *currentCamera; 29 | NSUInteger cameraIndex; 30 | NSMutableArray *elements; 31 | UIView *view; 32 | } 33 | 34 | #pragma mark - 35 | #pragma mark init methods 36 | 37 | +(id)scene; 38 | +(id)sceneWithCamera:(PLCamera *)camera; 39 | +(id)sceneWithElement:(PLSceneElement *)element; 40 | +(id)sceneWithElement:(PLSceneElement *)element camera:(PLCamera *)camera; 41 | 42 | +(id)sceneWithView:(UIView *)view; 43 | +(id)sceneWithView:(UIView *)view camera:(PLCamera *)camera; 44 | +(id)sceneWithView:(UIView *)view element:(PLSceneElement *)element; 45 | +(id)sceneWithView:(UIView *)view element:(PLSceneElement *)element camera:(PLCamera *)camera; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLSceneElement.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLSceneElementBase.h" 20 | 21 | @interface PLSceneElement : PLSceneElementBase 22 | { 23 | #pragma mark - 24 | #pragma mark member variables 25 | @private 26 | NSMutableArray *textures; 27 | } 28 | 29 | #pragma mark - 30 | #pragma mark init methods 31 | 32 | -(id)initWithId:(long long)identifier; 33 | -(id)initWithId:(long long)identifier texture:(PLTexture *)texture; 34 | -(id)initWithTexture:(PLTexture *)texture; 35 | 36 | #pragma mark - 37 | #pragma mark texture methods 38 | 39 | -(void)addTexture:(PLTexture *)texture; 40 | -(void)removeTexture:(PLTexture *)texture; 41 | -(void)removeTextureAtIndex:(NSUInteger)index; 42 | -(void)removeAllTextures; 43 | 44 | @end -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLSceneElement.m: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLSceneElementProtected.h" 20 | 21 | @implementation PLSceneElement 22 | 23 | #pragma mark - 24 | #pragma mark init methods 25 | 26 | -(id)initWithId:(long long)identifierValue 27 | { 28 | if(self = [super init]) 29 | self.identifier = identifierValue; 30 | return self; 31 | } 32 | 33 | -(id)initWithId:(long long)identifierValue texture:(PLTexture *)texture 34 | { 35 | if(self = [super init]) 36 | { 37 | self.identifier = identifierValue; 38 | [self addTexture:texture]; 39 | } 40 | return self; 41 | } 42 | 43 | -(id)initWithTexture:(PLTexture *)texture 44 | { 45 | if(self = [super init]) 46 | [self addTexture:texture]; 47 | return self; 48 | } 49 | 50 | -(void)initializeValues 51 | { 52 | [super initializeValues]; 53 | textures = [[NSMutableArray alloc] init]; 54 | } 55 | 56 | #pragma mark - 57 | #pragma mark property methods 58 | 59 | -(PLSceneElementType)getType 60 | { 61 | return PLSceneElementTypeObject; 62 | } 63 | 64 | -(NSMutableArray *)getTextures 65 | { 66 | return textures; 67 | } 68 | 69 | #pragma mark - 70 | #pragma mark texture methods 71 | 72 | -(void)addTexture:(PLTexture *)texture 73 | { 74 | if(texture) 75 | { 76 | [textures addObject:texture]; 77 | [self evaluateIfElementIsValid]; 78 | } 79 | } 80 | 81 | -(void)removeTexture:(PLTexture *)texture 82 | { 83 | if(texture) 84 | { 85 | [textures removeObject:texture]; 86 | [self evaluateIfElementIsValid]; 87 | } 88 | } 89 | 90 | -(void)removeTextureAtIndex:(NSUInteger)index 91 | { 92 | [textures removeObjectAtIndex:index]; 93 | [self evaluateIfElementIsValid]; 94 | } 95 | 96 | -(void)removeAllTextures 97 | { 98 | [textures removeAllObjects]; 99 | [self evaluateIfElementIsValid]; 100 | } 101 | 102 | #pragma mark - 103 | #pragma mark eval methods 104 | 105 | -(void)evaluateIfElementIsValid 106 | { 107 | [self setIsValid:[textures count] > 0]; 108 | } 109 | 110 | #pragma mark - 111 | #pragma mark dealloc methods 112 | 113 | -(void)dealloc 114 | { 115 | if(textures) 116 | { 117 | [self removeAllTextures]; 118 | [textures release]; 119 | } 120 | [super dealloc]; 121 | } 122 | 123 | @end -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLSceneElementBase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import 20 | #import "glu.h" 21 | 22 | #import "PLRenderableElementBase.h" 23 | #import "PLStructs.h" 24 | #import "PLUtils.h" 25 | #import "PLTexture.h" 26 | 27 | @interface PLSceneElementBase : PLRenderableElementBase 28 | { 29 | #pragma mark - 30 | #pragma mark member variables 31 | @private 32 | long long identifier; 33 | } 34 | 35 | #pragma mark - 36 | #pragma mark properties 37 | 38 | @property(nonatomic, assign) long long identifier; 39 | @property(nonatomic, readonly, getter=getType) PLSceneElementType type; 40 | 41 | #pragma mark - 42 | #pragma mark property methods 43 | 44 | -(PLSceneElementType)getType; 45 | 46 | @end -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLSceneElementBase.m: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLSceneElementBaseProtected.h" 20 | 21 | @implementation PLSceneElementBase 22 | 23 | @synthesize identifier; 24 | 25 | #pragma mark - 26 | #pragma mark property methods 27 | 28 | -(PLSceneElementType)getType 29 | { 30 | return PLSceneElementTypeNone; 31 | } 32 | 33 | @end -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLSceneElementBaseProtected.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLRenderableElementBaseProtected.h" 20 | #import "PLSceneElementBase.h" 21 | 22 | @interface PLSceneElementBase(Protected) 23 | 24 | @end -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLSceneElementProtected.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLSceneElementBaseProtected.h" 20 | #import "PLSceneElement.h" 21 | 22 | @interface PLSceneElement(Protected) 23 | 24 | #pragma mark - 25 | #pragma mark properties 26 | 27 | @property(nonatomic, readonly, getter=getTextures) NSMutableArray *textures; 28 | 29 | #pragma mark - 30 | #pragma mark property methods 31 | 32 | -(NSMutableArray *)getTextures; 33 | 34 | #pragma mark - 35 | #pragma mark eval methods 36 | 37 | -(void)evaluateIfElementIsValid; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLSpherical2Panorama.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLPanoramaBase.h" 20 | 21 | @interface PLSpherical2Panorama : PLPanoramaBase 22 | { 23 | #pragma mark - 24 | #pragma mark member variables 25 | @private 26 | NSUInteger divs, previewDivs; 27 | GLUquadric *quadratic; 28 | } 29 | 30 | #pragma mark - 31 | #pragma mark properties 32 | 33 | @property(nonatomic, assign) NSUInteger divs, previewDivs; 34 | 35 | #pragma mark - 36 | #pragma mark property methods 37 | 38 | -(void)setImage:(PLImage *)image; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLSpherical2Panorama.m: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLPanoramaBaseProtected.h" 20 | #import "PLSpherical2Panorama.h" 21 | 22 | @interface PLSpherical2Panorama(Private) 23 | 24 | -(void)setTexture:(PLTexture *)texture face:(PLSpherical2FaceOrientation)face; 25 | 26 | @end 27 | 28 | @implementation PLSpherical2Panorama 29 | 30 | @synthesize divs, previewDivs; 31 | 32 | #pragma mark - 33 | #pragma mark init methods 34 | 35 | +(id)panorama 36 | { 37 | return [[[PLSpherical2Panorama alloc] init] autorelease]; 38 | } 39 | 40 | -(void)initializeValues 41 | { 42 | [super initializeValues]; 43 | quadratic = gluNewQuadric(); 44 | gluQuadricNormals(quadratic, GLU_SMOOTH); 45 | gluQuadricTexture(quadratic, YES); 46 | divs = kDefaultHemisphereDivs; 47 | previewDivs = kDefaultHemispherePreviewDivs; 48 | } 49 | 50 | #pragma mark - 51 | #pragma mark property methods 52 | 53 | -(PLSceneElementType)getType 54 | { 55 | return PLSceneElementTypePanorama; 56 | } 57 | 58 | -(int)getPreviewSides 59 | { 60 | return 1; 61 | } 62 | 63 | -(int)getSides 64 | { 65 | return 4; 66 | } 67 | 68 | -(void)setImage:(PLImage *)image 69 | { 70 | // if(image && [image getWidth] == 2048 && [image getHeight] == 1024) 71 | 72 | CGFloat scale = 4096.0/2048.0; 73 | 74 | if(image && [image getWidth] == scale*2048 && [image getHeight] == scale*1024) 75 | { 76 | PLImage *frontImage = [[image clone] crop:CGRectMake(scale*768.0f, 0.0f, scale*512.0f, scale*1024.0f)]; 77 | PLImage *backImage = [PLImage joinImagesHorizontally:[[image clone] crop:CGRectMake(scale*1792.0f, 0.0f, scale*256.0f, scale*1024.0f)] rightImage:[[image clone] crop:CGRectMake(0.0f, 0.0f, scale*256.0f, scale*1024.0f)]]; 78 | PLImage *rightImage = [[image clone] crop:CGRectMake(scale*1024.0f, 0.0f, scale*1024.0f, scale*1024.0f)]; 79 | [image crop:CGRectMake(0.0, 0.0f, scale*1024.0f, scale*1024.0f)]; 80 | [self setTexture:[PLTexture textureWithImage:frontImage] face:PLSpherical2FaceOrientationFront]; 81 | [self setTexture:[PLTexture textureWithImage:image] face:PLSpherical2FaceOrientationLeft]; 82 | [self setTexture:[PLTexture textureWithImage:rightImage] face:PLSpherical2FaceOrientationRight]; 83 | [self setTexture:[PLTexture textureWithImage:backImage] face:PLSpherical2FaceOrientationBack]; 84 | } 85 | } 86 | 87 | -(void)setTexture:(PLTexture *)texture face:(PLSpherical2FaceOrientation)face 88 | { 89 | if(texture) 90 | { 91 | @synchronized(self) 92 | { 93 | PLTexture **textures = [self getTextures]; 94 | PLTexture *currentTexture = textures[face]; 95 | if(currentTexture) 96 | [currentTexture release]; 97 | textures[face] = [texture retain]; 98 | } 99 | } 100 | } 101 | 102 | #pragma mark - 103 | #pragma mark render methods 104 | 105 | -(void)internalRender 106 | { 107 | glRotatef(180.0f, 0.0f, 1.0f, 0.0f); 108 | 109 | glEnable(GL_TEXTURE_2D); 110 | 111 | PLTexture *previewTexture = [self getPreviewTextures][0]; 112 | PLTexture **textures = [self getTextures]; 113 | PLTexture *frontTexture = textures[PLSpherical2FaceOrientationFront]; 114 | PLTexture *backTexture = textures[PLSpherical2FaceOrientationBack]; 115 | PLTexture *leftTexture = textures[PLSpherical2FaceOrientationLeft]; 116 | PLTexture *rightTexture = textures[PLSpherical2FaceOrientationRight]; 117 | 118 | BOOL previewTextureIsValid = (previewTexture && previewTexture.textureID); 119 | BOOL frontTextureIsValud = (frontTexture && frontTexture.textureID); 120 | BOOL backTextureIsValid = (backTexture && backTexture.textureID); 121 | BOOL leftTextureIsValid = (leftTexture && leftTexture.textureID); 122 | BOOL rightTextureIsValid = (rightTexture && rightTexture.textureID); 123 | 124 | if(previewTextureIsValid) 125 | { 126 | if(frontTextureIsValud && backTextureIsValid && leftTextureIsValid && rightTextureIsValid) 127 | [self removePreviewTextureAtIndex:0]; 128 | else 129 | { 130 | glBindTexture(GL_TEXTURE_2D, previewTexture.textureID); 131 | gluSphere(quadratic, kRatio + 0.05f, (GLint)previewDivs, (GLint)previewDivs); 132 | } 133 | } 134 | if(frontTextureIsValud) 135 | { 136 | glBindTexture(GL_TEXTURE_2D, frontTexture.textureID); 137 | glu3DArc(quadratic, M_PI_2, -M_PI_4, NO, kRatio, (GLint)divs, (GLint)divs); 138 | } 139 | if(backTextureIsValid) 140 | { 141 | glBindTexture(GL_TEXTURE_2D, backTexture.textureID); 142 | glu3DArc(quadratic, M_PI_2, -M_PI_4, YES, kRatio, (GLint)divs, (GLint)divs); 143 | } 144 | if(leftTextureIsValid) 145 | { 146 | glBindTexture(GL_TEXTURE_2D, leftTexture.textureID); 147 | gluHemisphere(quadratic, NO, kRatio, (GLint)divs, (GLint)divs); 148 | } 149 | if(rightTextureIsValid) 150 | { 151 | glBindTexture(GL_TEXTURE_2D, rightTexture.textureID); 152 | gluHemisphere(quadratic, YES, kRatio, (GLint)divs, (GLint)divs); 153 | } 154 | 155 | glDisable(GL_TEXTURE_2D); 156 | 157 | glRotatef(-180.0f, 0.0f, 1.0f, 0.0f); 158 | glRotatef(90.0f, 1.0f, 0.0f, 0.0f); 159 | 160 | [super internalRender]; 161 | } 162 | 163 | #pragma mark - 164 | #pragma mark dealloc methods 165 | 166 | -(void)dealloc 167 | { 168 | if(quadratic) 169 | { 170 | gluDeleteQuadric(quadratic); 171 | quadratic = nil; 172 | } 173 | [super dealloc]; 174 | } 175 | 176 | @end 177 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLSphericalPanorama.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLPanoramaBase.h" 20 | 21 | @interface PLSphericalPanorama : PLPanoramaBase 22 | { 23 | #pragma mark - 24 | #pragma mark member variables 25 | @private 26 | NSUInteger divs; 27 | GLUquadric *quadratic; 28 | } 29 | 30 | #pragma mark - 31 | #pragma mark properties 32 | 33 | @property(nonatomic, assign) NSUInteger divs; 34 | 35 | #pragma mark - 36 | #pragma mark property methods 37 | 38 | -(void)setImage:(PLImage *)image; 39 | 40 | -(void)setTexture:(PLTexture *)texture; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLSphericalPanorama.m: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLSphericalPanorama.h" 20 | #import "PLPanoramaBaseProtected.h" 21 | 22 | @implementation PLSphericalPanorama 23 | 24 | @synthesize divs; 25 | 26 | #pragma mark - 27 | #pragma mark init methods 28 | 29 | +(id)panorama 30 | { 31 | return [[[PLSphericalPanorama alloc] init] autorelease]; 32 | } 33 | 34 | -(void)initializeValues 35 | { 36 | [super initializeValues]; 37 | quadratic = gluNewQuadric(); 38 | gluQuadricNormals(quadratic, GLU_SMOOTH); 39 | gluQuadricTexture(quadratic, YES); 40 | divs = kDefaultSphereDivs; 41 | } 42 | 43 | #pragma mark - 44 | #pragma mark property methods 45 | 46 | -(PLSceneElementType)getType 47 | { 48 | return PLSceneElementTypePanorama; 49 | } 50 | 51 | -(int)getPreviewSides 52 | { 53 | return 1; 54 | } 55 | 56 | -(int)getSides 57 | { 58 | return 1; 59 | } 60 | 61 | -(void)setImage:(PLImage *)image 62 | { 63 | if(image) 64 | [self setTexture:[PLTexture textureWithImage:image]]; 65 | } 66 | 67 | -(void)setTexture:(PLTexture *)texture 68 | { 69 | if(texture) 70 | { 71 | @synchronized(self) 72 | { 73 | PLTexture **textures = [self getTextures]; 74 | PLTexture *currentTexture = textures[0]; 75 | if(currentTexture) 76 | [currentTexture release]; 77 | textures[0] = [texture retain]; 78 | } 79 | } 80 | } 81 | 82 | #pragma mark - 83 | #pragma mark render methods 84 | 85 | -(void)internalRender 86 | { 87 | glRotatef(180.0f, 0.0f, 1.0f, 0.0f); 88 | 89 | glEnable(GL_TEXTURE_2D); 90 | 91 | PLTexture *previewTexture = [self getPreviewTextures][0]; 92 | PLTexture *texture = [self getTextures][0]; 93 | 94 | BOOL previewTextureIsValid = (previewTexture && previewTexture.textureID); 95 | 96 | if(texture && texture.textureID) 97 | { 98 | glBindTexture(GL_TEXTURE_2D, texture.textureID); 99 | if(previewTextureIsValid) 100 | [self removePreviewTextureAtIndex:0]; 101 | } 102 | else if(previewTextureIsValid) 103 | glBindTexture(GL_TEXTURE_2D, previewTexture.textureID); 104 | 105 | gluSphere(quadratic, kRatio, (GLint)divs, (GLint)divs); 106 | 107 | glDisable(GL_TEXTURE_2D); 108 | 109 | glRotatef(-180.0f, 0.0f, 1.0f, 0.0f); 110 | glRotatef(90.0f, 1.0f, 0.0f, 0.0f); 111 | 112 | [super internalRender]; 113 | } 114 | 115 | #pragma mark - 116 | #pragma mark dealloc methods 117 | 118 | -(void)dealloc 119 | { 120 | if(quadratic) 121 | { 122 | gluDeleteQuadric(quadratic); 123 | quadratic = nil; 124 | } 125 | [super dealloc]; 126 | } 127 | 128 | @end 129 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLSphericalRatioPanorama.h: -------------------------------------------------------------------------------- 1 | // 2 | // PLSphericalRatioPanorama.h 3 | // PanoramaGL 4 | // 5 | // Created by Jakey on 2017/9/28. 6 | // Copyright © 2017年 www.skyfox.org. All rights reserved. 7 | // 8 | 9 | #import "PLPanoramaBase.h" 10 | /// image等比即可 11 | @interface PLSphericalRatioPanorama : PLPanoramaBase 12 | { 13 | #pragma mark - 14 | #pragma mark member variables 15 | @private 16 | NSUInteger divs,previewDivs; 17 | GLUquadric *quadratic; 18 | } 19 | 20 | #pragma mark - 21 | #pragma mark properties 22 | 23 | @property(nonatomic, assign) NSUInteger divs,previewDivs; 24 | 25 | #pragma mark - 26 | #pragma mark property methods 27 | 28 | - (void)setImage:(PLImage *)image ifNoPowerOfTwoConvertUpDimension:(BOOL)convertUpDimension; 29 | 30 | //-(void)setTexture:(PLTexture *)texture; 31 | @end 32 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLStructs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #import 19 | #pragma mark - 20 | #pragma mark structs definitions 21 | 22 | struct PLRange 23 | { 24 | CGFloat min; 25 | CGFloat max; 26 | }; 27 | typedef struct PLRange PLRange; 28 | 29 | struct PLVertex 30 | { 31 | // CGFloat x, y, z; 32 | GLfloat x, y, z; 33 | }; 34 | typedef struct PLVertex PLVertex; 35 | typedef struct PLVertex PLPosition; 36 | 37 | struct PLRotation 38 | { 39 | // CGFloat pitch, yaw, roll; 40 | GLfloat pitch, yaw, roll; 41 | }; 42 | typedef struct PLRotation PLRotation; 43 | 44 | struct PLShakeData 45 | { 46 | long lastTime; 47 | PLPosition shakePosition; 48 | PLPosition shakeLastPosition; 49 | }; 50 | typedef struct PLShakeData PLShakeData; 51 | 52 | struct PLRect 53 | { 54 | PLPosition leftTop; 55 | PLPosition rightBottom; 56 | }; 57 | typedef struct PLRect PLRect; 58 | 59 | struct PLRGBA 60 | { 61 | float red, green, blue, alpha; 62 | }; 63 | typedef struct PLRGBA PLRGBA; 64 | 65 | #pragma mark - 66 | #pragma mark structs constructors 67 | 68 | CG_INLINE PLRange 69 | PLRangeMake(CGFloat min, CGFloat max) 70 | { 71 | PLRange range = {min, max}; 72 | return range; 73 | } 74 | 75 | CG_INLINE PLVertex 76 | PLVertexMake(CGFloat x, CGFloat y, CGFloat z) 77 | { 78 | PLVertex vertex = {x, y, z}; 79 | return vertex; 80 | } 81 | 82 | CG_INLINE PLPosition 83 | PLPositionMake(CGFloat x, CGFloat y, CGFloat z) 84 | { 85 | PLPosition position = {x, y, z}; 86 | return position; 87 | } 88 | 89 | CG_INLINE PLRotation 90 | PLRotationMake(CGFloat pitch, CGFloat yaw, CGFloat roll) 91 | { 92 | PLRotation rotation = {pitch, yaw, roll}; 93 | return rotation; 94 | } 95 | 96 | CG_INLINE PLShakeData 97 | PLShakeDataMake(long lastTime) 98 | { 99 | PLShakeData shakeData = {lastTime, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}; 100 | return shakeData; 101 | } 102 | 103 | CG_INLINE PLRect 104 | PLRectMake(CGFloat left, CGFloat top, CGFloat zLeftTop, CGFloat right, CGFloat bottom, CGFloat zRightBottom) 105 | { 106 | PLRect rect = {left, top, zLeftTop, right, bottom, zRightBottom}; 107 | return rect; 108 | } 109 | 110 | CG_INLINE PLRGBA 111 | PLRGBAMake(float red, float green, float blue, float alpha) 112 | { 113 | PLRGBA rgb = {red, green, blue, alpha}; 114 | return rgb; 115 | } -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLTexture.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import 20 | #import "glu.h" 21 | 22 | #import "PLObjectBase.h" 23 | 24 | #import "PLEnums.h" 25 | #import "PLImage.h" 26 | #import "PLLog.h" 27 | #import "PLTextureDelegate.h" 28 | 29 | @interface PLTexture : PLObjectBase 30 | { 31 | #pragma mark - 32 | #pragma mark member variables 33 | @private 34 | GLuint *textureID; 35 | PLImage *image; 36 | BOOL isRecycled; 37 | int width, height; 38 | BOOL isValid; 39 | PLTextureColorFormat format; 40 | NSObject *delegate; 41 | } 42 | 43 | #pragma mark - 44 | #pragma mark properties 45 | 46 | @property(nonatomic, readonly, getter=getTextureID) GLuint textureID; 47 | @property(nonatomic, readonly, getter=getWidth) int width; 48 | @property(nonatomic, readonly, getter=getHeight) int height; 49 | @property(nonatomic, readonly, getter=isValid) BOOL isValid; 50 | @property(nonatomic, readonly, getter=isRecycled) BOOL isRecycled; 51 | @property(nonatomic, getter=getFormat, setter=setFormat:) PLTextureColorFormat format; 52 | @property(nonatomic, assign) NSObject *delegate; 53 | 54 | #pragma mark - 55 | #pragma mark init methods 56 | 57 | -(id)initWithImage:(PLImage *)image; 58 | +(id)textureWithImage:(PLImage *)image; 59 | 60 | #pragma mark - 61 | #pragma mark property methods 62 | 63 | -(GLuint)getTextureID; 64 | -(int)getWidth; 65 | -(int)getHeight; 66 | -(BOOL)isValid; 67 | -(BOOL)isRecycled; 68 | -(PLTextureColorFormat)getFormat; 69 | -(void)setFormat:(PLTextureColorFormat)value; 70 | 71 | #pragma mark - 72 | #pragma mark recycle methods 73 | 74 | -(void)recycle; 75 | 76 | @end -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLTextureDelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | @class PLTexture; 20 | 21 | @protocol PLTextureDelegate 22 | 23 | #pragma mark - 24 | #pragma mark load methods 25 | 26 | -(void)didLoad:(PLTexture *)texture; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLTransition.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLObjectBase.h" 20 | #import "PLScene.h" 21 | #import "PLTransitionDelegate.h" 22 | 23 | @protocol PLIView; 24 | 25 | @interface PLTransition : PLObjectBase 26 | { 27 | #pragma mark - 28 | #pragma mark member variables 29 | @private 30 | NSTimer *timer; 31 | NSTimeInterval interval; 32 | PLTransitionType type; 33 | NSUInteger progressPercentage; 34 | 35 | UIView *view; 36 | NSObject *scene; 37 | 38 | BOOL isRunning; 39 | 40 | NSObject *delegate; 41 | } 42 | 43 | #pragma mark - 44 | #pragma mark properties 45 | 46 | @property(nonatomic, assign) NSTimeInterval interval; 47 | @property(nonatomic, readonly) NSUInteger progressPercentage; 48 | @property(nonatomic, readonly) PLTransitionType type; 49 | @property(nonatomic, assign) NSObject *delegate; 50 | 51 | #pragma mark - 52 | #pragma mark init methods 53 | 54 | -(id)initWithInterval:(NSTimeInterval)interval type:(PLTransitionType)type; 55 | 56 | #pragma mark - 57 | #pragma mark control methods 58 | 59 | -(BOOL)executeWithView:(UIView *)view scene:(NSObject *)scene; 60 | -(void)stop; 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLTransition.m: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLTransitionProtected.h" 20 | #import "PLView.h" 21 | 22 | @implementation PLTransition 23 | 24 | @synthesize interval; 25 | @synthesize progressPercentage; 26 | @synthesize type; 27 | @synthesize delegate; 28 | 29 | #pragma mark - 30 | #pragma mark init methods 31 | 32 | -(id)initWithInterval:(NSTimeInterval)intervalValue type:(PLTransitionType)typeValue 33 | { 34 | if(self = [self init]) 35 | { 36 | interval = intervalValue; 37 | type = typeValue; 38 | } 39 | return self; 40 | } 41 | 42 | -(void)initializeValues 43 | { 44 | [super initializeValues]; 45 | progressPercentage = 0; 46 | isRunning = NO; 47 | } 48 | 49 | #pragma mark - 50 | #pragma mark property methods 51 | 52 | -(NSTimer *)timer 53 | { 54 | return timer; 55 | } 56 | 57 | -(void)setTimer:(NSTimer *)value 58 | { 59 | if(timer) 60 | { 61 | [timer invalidate]; 62 | timer = nil; 63 | } 64 | timer = value; 65 | } 66 | 67 | -(UIView *)view 68 | { 69 | return view; 70 | } 71 | 72 | -(NSObject *)scene 73 | { 74 | return scene; 75 | } 76 | 77 | -(void)setProgressPercentage:(NSUInteger)value 78 | { 79 | progressPercentage = value; 80 | } 81 | 82 | -(void)setDelegate:(NSObject *)value 83 | { 84 | if(!isRunning) 85 | delegate = value; 86 | } 87 | 88 | #pragma mark - 89 | #pragma mark internal control methods 90 | 91 | -(void)beginExecute 92 | { 93 | } 94 | 95 | -(void)endExecute 96 | { 97 | } 98 | 99 | -(void)process 100 | { 101 | if(view) 102 | { 103 | BOOL isEnd = [self processInternally]; 104 | [view drawView]; 105 | 106 | if(delegate && [delegate respondsToSelector:@selector(transition:didProcessTransition:progressPercentage:)]) 107 | [delegate transition:self didProcessTransition:type progressPercentage:progressPercentage]; 108 | 109 | if(isEnd) 110 | [self stop]; 111 | } 112 | } 113 | 114 | -(BOOL)processInternally 115 | { 116 | return YES; 117 | } 118 | 119 | #pragma mark - 120 | #pragma mark control methods 121 | 122 | -(BOOL)executeWithView:(UIView *)plView scene:(NSObject *)plScene 123 | { 124 | if(!plView || !plScene) 125 | return NO; 126 | 127 | isRunning = YES; 128 | 129 | view = plView; 130 | scene = plScene; 131 | progressPercentage = 0; 132 | self.timer = nil; 133 | 134 | [plView stopAnimation]; 135 | 136 | [self beginExecute]; 137 | 138 | self.timer = [NSTimer scheduledTimerWithTimeInterval:interval target:self selector:@selector(process) userInfo:nil repeats:YES]; 139 | 140 | if(delegate && [delegate respondsToSelector:@selector(transition:didBeginTransition:)]) 141 | [delegate transition:self didBeginTransition:type]; 142 | 143 | [self endExecute]; 144 | 145 | return YES; 146 | } 147 | 148 | -(void)stop 149 | { 150 | self.timer = nil; 151 | view = nil; 152 | scene = nil; 153 | if(delegate && [delegate respondsToSelector:@selector(transition:didEndTransition:)]) 154 | [delegate transition:self didEndTransition:type]; 155 | delegate = nil; 156 | isRunning = NO; 157 | } 158 | 159 | #pragma mark - 160 | #pragma mark dealloc methods 161 | 162 | -(void)dealloc 163 | { 164 | self.timer = nil; 165 | view = nil; 166 | scene = nil; 167 | delegate = nil; 168 | [super dealloc]; 169 | } 170 | 171 | @end 172 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLTransitionDelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLEnums.h" 20 | 21 | @class PLTransition; 22 | 23 | @protocol PLTransitionDelegate 24 | 25 | @optional 26 | 27 | #pragma mark - 28 | #pragma mark transition methods 29 | 30 | -(void)transition:(PLTransition *)transition didBeginTransition:(PLTransitionType)type; 31 | -(void)transition:(PLTransition *)transition didProcessTransition:(PLTransitionType)type progressPercentage:(NSUInteger)progressPercentage; 32 | -(void)transition:(PLTransition *)transition didEndTransition:(PLTransitionType)type; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLTransitionFadeBase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLTransition.h" 20 | #import "PLHotspot.h" 21 | 22 | @interface PLTransitionFadeBase : PLTransition 23 | { 24 | #pragma mark - 25 | #pragma mark member variables 26 | @private 27 | float fadeStep; 28 | } 29 | 30 | #pragma mark - 31 | #pragma mark properties 32 | 33 | @property(nonatomic, assign) float fadeStep; 34 | 35 | #pragma mark - 36 | #pragma mark reset methods 37 | 38 | -(void)resetSceneAlpha; 39 | 40 | @end -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLTransitionFadeBase.m: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLTransitionFadeBaseProtected.h" 20 | #import "PLView.h" 21 | 22 | @implementation PLTransitionFadeBase 23 | 24 | @synthesize fadeStep; 25 | 26 | #pragma mark - 27 | #pragma mark init methods 28 | 29 | -(void)initializeValues 30 | { 31 | [super initializeValues]; 32 | fadeStep = kDefaultStepFade; 33 | } 34 | 35 | #pragma mark - 36 | #pragma mark reset methods 37 | 38 | -(void)resetSceneAlpha 39 | { 40 | if(self.view) 41 | [self.view resetSceneAlpha]; 42 | } 43 | 44 | #pragma mark - 45 | #pragma mark property methods 46 | 47 | -(void)setFadeStep:(float)value 48 | { 49 | if(value > 0.0f) 50 | fadeStep = value; 51 | } 52 | 53 | #pragma mark - 54 | #pragma mark internal control methods 55 | 56 | -(void)beginExecute 57 | { 58 | PLScene *scene = self.scene; 59 | float alpha = 0.0f; 60 | switch(self.type) 61 | { 62 | case PLTransitionTypeFadeIn: 63 | alpha = 0.0f; 64 | break; 65 | case PLTransitionTypeFadeOut: 66 | alpha = 1.0f; 67 | break; 68 | } 69 | for(PLSceneElement *element in scene.elements) 70 | { 71 | if(element.type == PLSceneElementTypeHotspot) 72 | { 73 | PLHotspot *hotspot = (PLHotspot *)element; 74 | if(hotspot.touchStatus != PLHotspotTouchStatusOut) 75 | { 76 | [hotspot touchOut:self]; 77 | [hotspot touchBlock]; 78 | } 79 | } 80 | 81 | } 82 | scene.alpha = MIN(alpha, scene.defaultAlpha); 83 | [self.view drawView]; 84 | } 85 | 86 | -(BOOL)processInternally 87 | { 88 | BOOL isEnd = NO; 89 | PLScene *scene = self.scene; 90 | switch(self.type) 91 | { 92 | case PLTransitionTypeFadeIn: 93 | scene.alpha = MIN(scene.alpha + fadeStep, scene.defaultAlpha); 94 | [self setProgressPercentage:MIN(scene.alpha * 100, 100)]; 95 | isEnd = (scene.alpha >= 1.0f); 96 | break; 97 | case PLTransitionTypeFadeOut: 98 | scene.alpha = MAX(0.0f, scene.alpha - fadeStep); 99 | [self setProgressPercentage:MAX((1.0f - scene.alpha) * 100, 0)]; 100 | isEnd = (scene.alpha <= 0.0f); 101 | break; 102 | } 103 | if(isEnd) 104 | { 105 | for(PLSceneElement *element in self.scene.elements) 106 | if(element.type == PLSceneElementTypeHotspot) 107 | [(PLHotspot *)element touchUnblock]; 108 | } 109 | return isEnd; 110 | } 111 | 112 | @end 113 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLTransitionFadeBaseProtected.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLTransitionProtected.h" 20 | #import "PLTransitionFadeBase.h" 21 | 22 | @interface PLTransitionFadeBase(Protected) 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLTransitionFadeIn.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLTransitionFadeBase.h" 20 | 21 | @interface PLTransitionFadeIn : PLTransitionFadeBase 22 | { 23 | } 24 | 25 | #pragma mark - 26 | #pragma mark init methods 27 | 28 | -(id)initWithInterval:(NSTimeInterval)interval; 29 | +(id)transitionWithInterval:(NSTimeInterval)interval; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLTransitionFadeIn.m: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLTransitionFadeBaseProtected.h" 20 | #import "PLTransitionFadeIn.h" 21 | 22 | @implementation PLTransitionFadeIn 23 | 24 | #pragma mark - 25 | #pragma mark init methods 26 | 27 | -(id)initWithInterval:(NSTimeInterval)intervalValue 28 | { 29 | return [super initWithInterval:intervalValue type:PLTransitionTypeFadeIn]; 30 | } 31 | 32 | +(id)transitionWithInterval:(NSTimeInterval)interval 33 | { 34 | return [[[PLTransitionFadeIn alloc] initWithInterval:interval] autorelease]; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLTransitionFadeOut.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLTransitionFadeBase.h" 20 | 21 | @interface PLTransitionFadeOut : PLTransitionFadeBase 22 | { 23 | } 24 | 25 | #pragma mark - 26 | #pragma mark init methods 27 | 28 | -(id)initWithInterval:(NSTimeInterval)interval; 29 | +(id)transitionWithInterval:(NSTimeInterval)interval; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLTransitionFadeOut.m: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLTransitionFadeBaseProtected.h" 20 | #import "PLTransitionFadeOut.h" 21 | 22 | @implementation PLTransitionFadeOut 23 | 24 | #pragma mark - 25 | #pragma mark init methods 26 | 27 | -(id)initWithInterval:(NSTimeInterval)intervalValue 28 | { 29 | return [super initWithInterval:intervalValue type:PLTransitionTypeFadeOut]; 30 | } 31 | 32 | +(id)transitionWithInterval:(NSTimeInterval)interval 33 | { 34 | return [[[PLTransitionFadeOut alloc] initWithInterval:interval] autorelease]; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLTransitionProtected.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLObjectBaseProtected.h" 20 | #import "PLTransition.h" 21 | 22 | @interface PLTransition(Protected) 23 | 24 | #pragma mark - 25 | #pragma mark properties 26 | 27 | @property(nonatomic, assign, getter=timer, setter=setTimer:) NSTimer *timer; 28 | @property(nonatomic, readonly, getter=view) UIView *view; 29 | @property(nonatomic, readonly, getter=scene) PLScene *scene; 30 | 31 | #pragma mark - 32 | #pragma mark property methods 33 | 34 | -(NSTimer *)timer; 35 | -(void)setTimer:(NSTimer *)timer; 36 | 37 | -(UIView *)view; 38 | -(PLScene *)scene; 39 | 40 | -(void)setProgressPercentage:(NSUInteger)value; 41 | 42 | #pragma mark - 43 | #pragma mark internal control methods 44 | 45 | -(void)beginExecute; 46 | -(void)endExecute; 47 | 48 | -(void)process; 49 | -(BOOL)processInternally; 50 | 51 | @end 52 | 53 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #import 19 | @interface PLUtils : NSObject 20 | 21 | #pragma mark - 22 | #pragma mark swap methods 23 | 24 | + (void)swapFloatValues:(float *)firstValue :(float *)secondValue; 25 | + (void)swapIntValues:(int *)firstValue :(int *)secondValue; 26 | ///尺寸必须是2的N次方,convertUpDimension为YES向上转换,convertUpDimension为NO向下转换 27 | +(int)convertValidValueForDimension:(int)dimension ifNoPowerOfTwoConvertUpDimension:(BOOL)convertUpDimension; 28 | //向上转换 29 | + (int)convertUpValidValueForDimension:(int)dimension; 30 | //向下转换 31 | + (int)convertDownValidValueForDimension:(int)dimension; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLUtils.m: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLUtils.h" 20 | 21 | @implementation PLUtils 22 | 23 | #pragma mark - 24 | #pragma mark init methods 25 | 26 | -(id)init 27 | { 28 | return nil; 29 | } 30 | 31 | #pragma mark - 32 | #pragma mark swap methods 33 | 34 | +(void)swapFloatValues:(float *)firstValue :(float *)secondValue 35 | { 36 | float swapValue = *firstValue; 37 | *firstValue = *secondValue; 38 | *secondValue = swapValue; 39 | } 40 | 41 | +(void)swapIntValues:(int *)firstValue :(int *)secondValue 42 | { 43 | *firstValue = *firstValue ^ *secondValue; 44 | *secondValue = *secondValue ^ *firstValue; 45 | *firstValue = *firstValue ^ *secondValue; 46 | } 47 | #pragma mark - 48 | #pragma mark utility methods 49 | +(int)convertValidValueForDimension:(int)dimension ifNoPowerOfTwoConvertUpDimension:(BOOL)convertUpDimension{ 50 | if (convertUpDimension) { 51 | return [self convertUpValidValueForDimension:dimension]; 52 | }else{ 53 | return [self convertDownValidValueForDimension:dimension]; 54 | } 55 | } 56 | 57 | +(int)convertUpValidValueForDimension:(int)dimension 58 | { 59 | if(dimension <= 4) 60 | return 4; 61 | else if(dimension <= 8) 62 | return 8; 63 | else if(dimension <= 16) 64 | return 16; 65 | else if(dimension <= 32) 66 | return 32; 67 | else if(dimension <= 64) 68 | return 64; 69 | else if(dimension <= 128) 70 | return 128; 71 | else if(dimension <= 256) 72 | return 256; 73 | else if(dimension <= 512) 74 | return 512; 75 | else if(dimension <= 1024) 76 | return 1024; 77 | else if(dimension <= 2048) 78 | return 2048; 79 | else if(dimension <= 4096) 80 | return 4096; 81 | else if(dimension <= 8192) 82 | return 8192; 83 | else if(dimension <= 16384) 84 | return 16384; 85 | else 86 | return 2048; 87 | } 88 | 89 | //向下转换 90 | + (int)convertDownValidValueForDimension:(int)dimension{ 91 | if(dimension <= 4) 92 | return 4; 93 | else if(dimension < 8) 94 | return 4; 95 | else if(dimension < 16) 96 | return 8; 97 | else if(dimension < 32) 98 | return 16; 99 | else if(dimension < 64) 100 | return 32; 101 | else if(dimension < 128) 102 | return 64; 103 | else if(dimension < 256) 104 | return 128; 105 | else if(dimension < 512) 106 | return 256; 107 | else if(dimension < 1024) 108 | return 512; 109 | else if(dimension < 2048) 110 | return 1024; 111 | else if(dimension < 4096) 112 | return 2048; 113 | else if(dimension < 8192) 114 | return 4096; 115 | else if(dimension < 16384) 116 | return 8192; 117 | else 118 | return 2048; 119 | } 120 | @end 121 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLVector3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | /* 20 | * This class is a port from C++ to Objective-C of CVec3 class in 21 | * "Demonstration of a line mesh intersection test (Sample1-Mesh_Line_Intersection.zip)" 22 | * example by Jonathan Kreuzer http://www.3dkingdoms.com/weekly. 23 | * See vec3.h. 24 | */ 25 | 26 | #import "PLStructs.h" 27 | 28 | @interface PLVector3 : NSObject 29 | { 30 | #pragma mark - 31 | #pragma mark member variables 32 | @private 33 | float x, y, z; 34 | } 35 | 36 | #pragma mark - 37 | #pragma mark properties 38 | 39 | @property(nonatomic, assign) float x,y,z; 40 | @property(nonatomic, readonly, getter=getPosition) PLPosition position; 41 | 42 | #pragma mark - 43 | #pragma mark init methods 44 | 45 | -(id)initWithVertex:(PLVertex)vertex; 46 | -(id)initWithPosition:(PLPosition)position; 47 | -(id)initWithX:(float)x y:(float)y z:(float)z; 48 | -(id)initWithVector3:(PLVector3 *)vector3; 49 | 50 | +(id)vector3; 51 | +(id)vector3WithX:(float)x y:(float)y z:(float)z; 52 | +(id)vector3WithVertex:(PLVertex)vertex; 53 | +(id)vector3WithPosition:(PLPosition)position; 54 | +(id)vector3WithVector3:(PLVector3 *)vector3; 55 | 56 | #pragma mark - 57 | #pragma mark property methods 58 | 59 | -(PLPosition)getPosition; 60 | 61 | -(void)setValuesWithX:(float)x y:(float)y z:(float)z; 62 | -(void)setValuesWithPosition:(PLPosition)position; 63 | -(void)setValues:(float *)values; 64 | 65 | #pragma mark - 66 | #pragma mark vector methods 67 | 68 | -(BOOL)equals:(PLVector3 *)value; 69 | 70 | -(PLVector3 *)add:(PLVector3 *)value; 71 | -(PLVector3 *)sub:(PLVector3 *)value; 72 | -(PLVector3 *)minus; 73 | -(PLVector3 *)div:(PLVector3 *)value; 74 | -(PLVector3 *)divf:(float)value; 75 | -(PLVector3 *)mult:(PLVector3 *)value; 76 | -(PLVector3 *)multf:(float)value; 77 | 78 | -(float)dot:(PLVector3 *)value; 79 | -(PLVector3 *)crossProduct:(PLVector3 *)value; 80 | 81 | -(float)magnitude; 82 | -(float)distance:(PLVector3 *)value; 83 | -(void)normalize; 84 | 85 | #pragma mark - 86 | #pragma mark clone methods 87 | 88 | -(PLVector3 *)clone; 89 | 90 | @end -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLVector3.m: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | /* 20 | * This class is a port from C++ to Objective-C of CVec3 class in 21 | * "Demonstration of a line mesh intersection test (Sample1-Mesh_Line_Intersection.zip)" 22 | * example by Jonathan Kreuzer http://www.3dkingdoms.com/weekly. 23 | * See vec3.h. 24 | */ 25 | 26 | #import "PLVector3.h" 27 | 28 | @implementation PLVector3 29 | 30 | @synthesize x, y, z; 31 | 32 | #pragma mark - 33 | #pragma mark init methods 34 | 35 | -(id)init 36 | { 37 | if(self = [super init]) 38 | x = y = z = 0.0f; 39 | return self; 40 | } 41 | 42 | -(id)initWithX:(float) xValue y:(float) yValue z:(float) zValue 43 | { 44 | if(self = [super init]) 45 | { 46 | x = xValue; 47 | y = yValue; 48 | z = zValue; 49 | } 50 | return self; 51 | } 52 | 53 | -(id)initWithVertex:(PLVertex)vertex 54 | { 55 | return [self initWithX:vertex.x y:vertex.y z:vertex.z]; 56 | } 57 | 58 | -(id)initWithPosition:(PLPosition)position 59 | { 60 | return [self initWithX:position.x y:position.y z:position.z]; 61 | } 62 | 63 | -(id)initWithVector3:(PLVector3 *)vector3 64 | { 65 | return [self initWithX:vector3.x y:vector3.y z:vector3.z]; 66 | } 67 | 68 | +(PLVector3 *)vector3 69 | { 70 | return [[[PLVector3 alloc] init] autorelease]; 71 | } 72 | 73 | +(PLVector3 *)vector3WithX:(float) x y:(float) y z:(float) z 74 | { 75 | return [[[PLVector3 alloc] initWithX:x y:y z:z] autorelease]; 76 | } 77 | 78 | +(PLVector3 *)vector3WithVertex:(PLVertex)vertex 79 | { 80 | return [[[PLVector3 alloc] initWithVertex:vertex] autorelease]; 81 | } 82 | 83 | +(PLVector3 *)vector3WithPosition:(PLPosition)position 84 | { 85 | return [[[PLVector3 alloc] initWithPosition:position] autorelease]; 86 | } 87 | 88 | +(PLVector3 *)vector3WithVector3:(PLVector3 *)vector3 89 | { 90 | return [[[PLVector3 alloc] initWithVector3:vector3] autorelease]; 91 | } 92 | 93 | #pragma mark - 94 | #pragma mark property methods 95 | 96 | -(PLPosition)getPosition 97 | { 98 | return PLPositionMake(x, y, z); 99 | } 100 | 101 | -(void)setValuesWithX:(float)xValue y:(float)yValue z:(float)zValue 102 | { 103 | x = xValue; 104 | y = yValue; 105 | z = zValue; 106 | } 107 | 108 | -(void)setValuesWithPosition:(PLPosition)position 109 | { 110 | x = position.x; 111 | y = position.y; 112 | z = position.z; 113 | } 114 | 115 | -(void)setValues:(float *)values 116 | { 117 | x = values[0]; 118 | y = values[1]; 119 | z = values[2]; 120 | } 121 | 122 | #pragma mark - 123 | #pragma mark vector methods 124 | 125 | -(BOOL)equals:(PLVector3 *)value 126 | { 127 | return (x == value.x && y == value.y && z == value.z); 128 | } 129 | 130 | -(PLVector3 *)add:(PLVector3 *)value 131 | { 132 | return [PLVector3 vector3WithX:x+value.x y:y+value.y z:z+value.z]; 133 | } 134 | 135 | -(PLVector3 *)sub:(PLVector3 *)value 136 | { 137 | return [PLVector3 vector3WithX:x-value.x y:y-value.y z:z-value.z]; 138 | } 139 | 140 | -(PLVector3 *)minus 141 | { 142 | return [PLVector3 vector3WithX:-x y:-y z:-z]; 143 | } 144 | 145 | -(PLVector3 *)div:(PLVector3 *)value 146 | { 147 | return [PLVector3 vector3WithX:x/value.x y:y/value.y z:z/value.z]; 148 | } 149 | 150 | -(PLVector3 *)divf:(float)value 151 | { 152 | float invert = 1.0f / value; 153 | return [PLVector3 vector3WithX:x*invert y:y*invert z:z*invert]; 154 | } 155 | 156 | -(PLVector3 *)mult:(PLVector3 *)value 157 | { 158 | return [PLVector3 vector3WithX:x*value.x y:y*value.y z:z*value.z]; 159 | } 160 | 161 | -(PLVector3 *)multf:(float)value 162 | { 163 | return [PLVector3 vector3WithX:x*value y:y*value z:z*value]; 164 | } 165 | 166 | -(float)dot:(PLVector3 *)value 167 | { 168 | return x*value.x + y*value.y + z*value.z; 169 | } 170 | 171 | -(PLVector3 *)crossProduct:(PLVector3 *)value 172 | { 173 | return [PLVector3 vector3WithX:y * value.z - z * value.y 174 | y:z * value.x - x * value.z 175 | z:x * value.y - y * value.x]; 176 | } 177 | 178 | -(float)magnitude 179 | { 180 | return sqrtf(x*x + y*y + z*z); 181 | } 182 | 183 | -(float)distance:(PLVector3 *)value 184 | { 185 | return [[self sub:value] magnitude]; 186 | } 187 | 188 | -(void)normalize 189 | { 190 | float mag = (x*x + y*y + z*z); 191 | if (mag == 0) 192 | return; 193 | float mult = 1.0f / sqrtf(mag); 194 | x *= mult; 195 | y *= mult; 196 | z *= mult; 197 | } 198 | 199 | #pragma mark - 200 | #pragma mark clone methods 201 | 202 | -(PLVector3 *)clone 203 | { 204 | return [PLVector3 vector3WithVector3:self]; 205 | } 206 | 207 | @end -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import 20 | 21 | #import "PLViewBase.h" 22 | #import "PLSceneElement.h" 23 | #import "PLImage.h" 24 | #import "PLTexture.h" 25 | 26 | #import "PLCubicPanorama.h" 27 | #import "PLSphericalPanorama.h" 28 | #import "PLSpherical2Panorama.h" 29 | #import "PLCylindricalPanorama.h" 30 | 31 | #import "PLSphericalRatioPanorama.h" 32 | 33 | @interface PLView : PLViewBase 34 | { 35 | #pragma mark - 36 | #pragma mark member variables 37 | @private 38 | UIActivityIndicatorView *progressBar; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLView.m: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLView.h" 20 | #import "PLViewBaseProtected.h" 21 | 22 | @implementation PLView 23 | 24 | #pragma mark - 25 | #pragma mark progressbar methods 26 | 27 | -(BOOL)showProgressBar 28 | { 29 | if(!progressBar) 30 | { 31 | progressBar = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; 32 | CGSize size = self.bounds.size; 33 | progressBar.frame = CGRectMake(0, 0, 50, 50); 34 | progressBar.center = CGPointMake(size.width / 2.0f, size.height / 2.0f); 35 | [self addSubview:progressBar]; 36 | [progressBar startAnimating]; 37 | [progressBar release]; 38 | return YES; 39 | } 40 | return NO; 41 | } 42 | 43 | -(void)resetProgressBar 44 | { 45 | if(progressBar) 46 | { 47 | [self hideProgressBar]; 48 | [self showProgressBar]; 49 | } 50 | } 51 | 52 | -(BOOL)hideProgressBar 53 | { 54 | if(progressBar) 55 | { 56 | [progressBar stopAnimating]; 57 | [progressBar removeFromSuperview]; 58 | progressBar = nil; 59 | return YES; 60 | } 61 | return NO; 62 | } 63 | 64 | #pragma mark - 65 | #pragma mark layout methods 66 | 67 | -(void)layoutSubviews 68 | { 69 | [super layoutSubviews]; 70 | if(progressBar) 71 | { 72 | [self hideProgressBar]; 73 | [self showProgressBar]; 74 | } 75 | } 76 | 77 | #pragma mark - 78 | #pragma mark clear methods 79 | 80 | -(void)clear 81 | { 82 | NSObject *panorama = [self panorama]; 83 | if(panorama) 84 | { 85 | @synchronized(self) 86 | { 87 | [panorama clearPanorama]; 88 | } 89 | } 90 | } 91 | 92 | #pragma mark - 93 | #pragma mark load methods 94 | 95 | -(void)load:(NSObject *)loader 96 | { 97 | if(loader) 98 | { 99 | @synchronized(self) 100 | { 101 | [self stopOnlyAnimation]; 102 | [loader load:self]; 103 | } 104 | } 105 | else 106 | [NSException raise:@"PanoramaGL" format:@"loader param is NULL"]; 107 | } 108 | 109 | #pragma mark - 110 | #pragma mark dealloc methods 111 | 112 | -(void)dealloc 113 | { 114 | [self hideProgressBar]; 115 | [super dealloc]; 116 | } 117 | 118 | @end 119 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLViewBase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLIView.h" 20 | 21 | @protocol PLIRenderer; 22 | 23 | @interface PLViewBase : UIView 24 | { 25 | #pragma mark - 26 | #pragma mark member variables 27 | @private 28 | NSObject *renderer; 29 | NSObject *scene; 30 | 31 | NSTimer *animationTimer; 32 | NSTimeInterval animationInterval; 33 | 34 | BOOL isBlocked; 35 | 36 | CGPoint startPoint, endPoint; 37 | CGPoint startFovPoint, endFovPoint; 38 | 39 | BOOL isValidForFov; 40 | float fovDistance; 41 | NSUInteger fovCounter; 42 | 43 | BOOL isAccelerometerEnabled, isAccelerometerLeftRightEnabled, isAccelerometerUpDownEnabled; 44 | float accelerometerSensitivity; 45 | NSTimeInterval accelerometerInterval; 46 | 47 | BOOL isScrollingEnabled, isValidForScrolling, isScrolling; 48 | NSUInteger minDistanceToEnableScrolling; 49 | 50 | BOOL isInertiaEnabled, isValidForInertia; 51 | NSTimer *inertiaTimer; 52 | NSTimeInterval inertiaInterval; 53 | float inertiaStepValue; 54 | 55 | BOOL isResetEnabled, isShakeResetEnabled; 56 | uint8_t numberOfTouchesForReset; 57 | 58 | PLShakeData shakeData; 59 | float shakeThreshold; 60 | 61 | BOOL isValidForTouch; 62 | 63 | NSObject *delegate; 64 | 65 | BOOL displayLinkSupported, isDisplayLinkSupported; 66 | id displayLink; 67 | NSUInteger animationFrameInterval; 68 | BOOL isAccelerometerActivated; 69 | BOOL isAnimating; 70 | 71 | CMMotionManager *motionManager; 72 | NSTimer *motionTimer; 73 | CLLocationManager *locationManager; 74 | int lastAccelerometerPitch; 75 | float accelerometerPitch; 76 | float firstMagneticHeading, magneticHeading; 77 | PLSensorType sensorType; 78 | BOOL isSensorialRotationRunning; 79 | 80 | BOOL isValidForTransition; 81 | NSString * isValidForTransitionString; 82 | PLTransition *currentTransition; 83 | 84 | PLTouchStatus touchStatus; 85 | 86 | BOOL isPointerVisible; 87 | } 88 | 89 | @end -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLViewBaseProtected.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLViewBase.h" 20 | #import "PLIInitializeObject.h" 21 | 22 | @interface PLViewBase(Protected) 23 | 24 | #pragma mark - 25 | #pragma mark properties 26 | 27 | @property(nonatomic, assign, getter=animationTimer, setter=setAnimationTimer:) NSTimer *animationTimer; 28 | @property(nonatomic, assign, getter=displayLink, setter=setDisplayLink:) id displayLink; 29 | @property(nonatomic, readonly, getter=scene) NSObject *scene; 30 | @property(nonatomic, readonly, getter=renderer) NSObject *renderer; 31 | 32 | #pragma mark - 33 | #pragma mark property methods 34 | 35 | -(NSTimer *)animationTimer; 36 | -(void)setAnimationTimer:(NSTimer *)timer; 37 | 38 | -(id)displayLink; 39 | -(void)setDisplayLink:(id)displayLink; 40 | 41 | -(NSObject *)scene; 42 | 43 | -(NSObject *)renderer; 44 | 45 | //-(BOOL)setAccelerometerDelegate:(id )accelerometerDelegate; 46 | 47 | -(void)startAccelerometer; 48 | 49 | -(void)setIsValidForTransition:(BOOL)value; 50 | 51 | #pragma mark - 52 | #pragma mark fov methods 53 | 54 | -(BOOL)calculateFov:(NSSet *)touches; 55 | 56 | #pragma mark - 57 | #pragma mark action methods 58 | 59 | -(BOOL)executeDefaultAction:(NSSet *)touches eventType:(PLTouchEventType)type; 60 | -(BOOL)executeResetAction:(NSSet *)touches; 61 | 62 | #pragma mark - 63 | #pragma mark accelerometer methods 64 | 65 | -(void)activateAccelerometer; 66 | -(void)deactiveAccelerometer; 67 | 68 | #pragma mark - 69 | #pragma mark animation methods 70 | 71 | -(void)stopOnlyAnimation; 72 | -(void)stopAnimationInternally; 73 | 74 | #pragma mark - 75 | #pragma mark inertia methods 76 | 77 | -(void)startInertia; 78 | -(void)stopInertia; 79 | -(void)inertia; 80 | 81 | #pragma mark - 82 | #pragma mark touch methods 83 | 84 | -(BOOL)isTouchInView:(NSSet *)touches; 85 | -(CGPoint)getLocationOfFirstTouch:(NSSet *)touches; 86 | 87 | #pragma mark - 88 | #pragma mark draw methods 89 | 90 | -(void)drawViewInternally; 91 | -(void)drawViewInternallyNTimes:(NSUInteger)times; 92 | 93 | #pragma mark - 94 | #pragma mark shake methods 95 | 96 | -(BOOL)resetWithShake:(CMAcceleration)acceleration; 97 | 98 | @end 99 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/PLViewDelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PanoramaGL library 3 | * Version 0.1 4 | * Copyright (c) 2010 Javier Baez 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #import "PLStructs.h" 20 | #import "PLTransition.h" 21 | #import "PLHotspot.h" 22 | 23 | @protocol PLIView; 24 | 25 | @protocol PLViewDelegate 26 | 27 | @optional 28 | 29 | #pragma mark - 30 | #pragma mark touch methods 31 | 32 | -(void)view:(UIView *)pView touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; 33 | -(void)view:(UIView *)pView touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; 34 | -(void)view:(UIView *)pView touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; 35 | 36 | -(BOOL)view:(UIView *)pView shouldBeginTouching:(NSSet *)touches withEvent:(UIEvent *)event; 37 | -(void)view:(UIView *)pView didBeginTouching:(NSSet *)touches withEvent:(UIEvent *)event; 38 | -(BOOL)view:(UIView *)pView shouldTouch:(NSSet *)touches withEvent:(UIEvent *)event; 39 | -(void)view:(UIView *)pView didTouch:(NSSet *)touches withEvent:(UIEvent *)event; 40 | -(BOOL)view:(UIView *)pView shouldEndTouching:(NSSet *)touches withEvent:(UIEvent *)event; 41 | -(void)view:(UIView *)pView didEndTouching:(NSSet *)touches withEvent:(UIEvent *)event; 42 | 43 | #pragma mark - 44 | #pragma mark accelerometer methods 45 | //-(BOOL)view:(UIView *)pView shouldAccelerate:(UIAcceleration *)acceleration withAccelerometer:(UIAccelerometer *)accelerometer; 46 | //-(void)view:(UIView *)pView didAccelerate:(UIAcceleration *)acceleration withAccelerometer:(UIAccelerometer *)accelerometer; 47 | 48 | -(BOOL)view:(UIView *)pView shouldAccelerate:(CMAccelerometerData *)accelerometerData; 49 | -(void)view:(UIView *)pView didAccelerate:(CMAccelerometerData *)accelerometerData; 50 | 51 | #pragma mark - 52 | #pragma mark inertia methods 53 | 54 | -(BOOL)view:(UIView *)pView shouldBeginInertia:(CGPoint)starPoint endPoint:(CGPoint)endPoint; 55 | -(void)view:(UIView *)pView didBeginInertia:(CGPoint)starPoint endPoint:(CGPoint)endPoint; 56 | -(BOOL)view:(UIView *)pView shouldRunInertia:(CGPoint)starPoint endPoint:(CGPoint)endPoint; 57 | -(void)view:(UIView *)pView didRunInertia:(CGPoint)starPoint endPoint:(CGPoint)endPoint; 58 | -(void)view:(UIView *)pView didEndInertia:(CGPoint)starPoint endPoint:(CGPoint)endPoint; 59 | 60 | #pragma mark - 61 | #pragma mark reset methods 62 | 63 | -(BOOL)viewShouldReset:(UIView *)pView; 64 | -(void)viewDidReset:(UIView *)pView; 65 | 66 | #pragma mark - 67 | #pragma mark zooming methods 68 | 69 | -(BOOL)viewShouldBeginZooming:(UIView *)pView; 70 | -(void)view:(UIView *)pView didBeginZooming:(CGPoint)starPoint endPoint:(CGPoint)endPoint; 71 | -(BOOL)view:(UIView *)pView shouldRunZooming:(float)distance isZoomIn:(BOOL)isZoomIn isZoomOut:(BOOL)isZoomOut; 72 | -(void)view:(UIView *)pView didRunZooming:(float)distance isZoomIn:(BOOL)isZoomIn isZoomOut:(BOOL)isZoomOut; 73 | -(void)view:(UIView *)pView didEndZooming:(float)distance isZoomIn:(BOOL)isZoomIn isZoomOut:(BOOL)isZoomOut; 74 | 75 | #pragma mark - 76 | #pragma mark moving methods 77 | 78 | -(BOOL)view:(UIView *)pView shouldBeginMoving:(CGPoint)starPoint endPoint:(CGPoint)endPoint; 79 | -(void)view:(UIView *)pView didBeginMoving:(CGPoint)starPoint endPoint:(CGPoint)endPoint; 80 | -(BOOL)view:(UIView *)pView shouldRunMoving:(CGPoint)starPoint endPoint:(CGPoint)endPoint; 81 | -(void)view:(UIView *)pView didRunMoving:(CGPoint)starPoint endPoint:(CGPoint)endPoint; 82 | -(void)view:(UIView *)pView didEndMoving:(CGPoint)starPoint endPoint:(CGPoint)endPoint; 83 | 84 | #pragma mark - 85 | #pragma mark scrolling methods 86 | 87 | -(BOOL)view:(UIView *)pView shouldBeingScrolling:(CGPoint)starPoint endPoint:(CGPoint)endPoint; 88 | -(void)view:(UIView *)pView didBeginScrolling:(CGPoint)starPoint endPoint:(CGPoint)endPoint; 89 | -(BOOL)view:(UIView *)pView shouldScroll:(CGPoint)starPoint endPoint:(CGPoint)endPoint; 90 | -(void)view:(UIView *)pView didScroll:(CGPoint)starPoint endPoint:(CGPoint)endPoint; 91 | -(void)view:(UIView *)pView didEndScrolling:(CGPoint)starPoint endPoint:(CGPoint)endPoint; 92 | 93 | #pragma mark - 94 | #pragma mark transition methods 95 | 96 | -(void)view:(UIView *)pView didBeginTransition:(PLTransition *)transition; 97 | -(void)view:(UIView *)pView didProcessTransition:(PLTransition *)transition progressPercentage:(NSUInteger)progressPercentage; 98 | -(void)view:(UIView *)pView didEndTransition:(PLTransition *)transition; 99 | 100 | #pragma mark - 101 | #pragma mark camera methods 102 | 103 | -(BOOL)view:(UIView *)pView didRotateCamera:(PLCamera *)camera rotation:(PLRotation)rotation; 104 | 105 | #pragma mark - 106 | #pragma mark hotspot methods 107 | 108 | -(void)view:(UIView *)pView didOverHotspot:(PLHotspot *)hotspot screenPoint:(CGPoint)point scene3DPoint:(PLPosition)position; 109 | -(void)view:(UIView *)pView didOutHotspot:(PLHotspot *)hotspot screenPoint:(CGPoint)point scene3DPoint:(PLPosition)position; 110 | -(void)view:(UIView *)pView didClickHotspot:(PLHotspot *)hotspot screenPoint:(CGPoint)point scene3DPoint:(PLPosition)position; 111 | 112 | @end 113 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/glues/glu.h: -------------------------------------------------------------------------------- 1 | #import "glues.h" -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/glues/glues_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) 3 | * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice including the dates of first publication and 13 | * either this permission notice or a reference to 14 | * http://oss.sgi.com/projects/FreeB/ 15 | * shall be included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 | * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 22 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | * 25 | * Except as contained in this notice, the name of Silicon Graphics, Inc. 26 | * shall not be used in advertising or otherwise to promote the sale, use or 27 | * other dealings in this Software without prior written authorization from 28 | * Silicon Graphics, Inc. 29 | * 30 | * OpenGL ES CM 1.0 port of part of GLU by Mike Gorchak 31 | */ 32 | 33 | #ifndef __GLUES_REGISTRY_H__ 34 | #define __GLUES_REGISTRY_H__ 35 | 36 | #include 37 | 38 | #define GLAPI GL_API 39 | #define APIENTRY GL_APIENTRY 40 | 41 | #ifndef APIENTRYP 42 | #define APIENTRYP APIENTRY * 43 | #endif /* APIENTRYP */ 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /* ErrorCode */ 50 | #define GLU_INVALID_ENUM 100900 51 | #define GLU_INVALID_VALUE 100901 52 | #define GLU_OUT_OF_MEMORY 100902 53 | #define GLU_INCOMPATIBLE_GL_VERSION 100903 54 | #define GLU_INVALID_OPERATION 100904 55 | 56 | /* TessError */ 57 | #define GLU_TESS_ERROR1 100151 58 | #define GLU_TESS_ERROR2 100152 59 | #define GLU_TESS_ERROR3 100153 60 | #define GLU_TESS_ERROR4 100154 61 | #define GLU_TESS_ERROR5 100155 62 | #define GLU_TESS_ERROR6 100156 63 | #define GLU_TESS_ERROR7 100157 64 | #define GLU_TESS_ERROR8 100158 65 | #define GLU_TESS_MISSING_BEGIN_POLYGON 100151 66 | #define GLU_TESS_MISSING_BEGIN_CONTOUR 100152 67 | #define GLU_TESS_MISSING_END_POLYGON 100153 68 | #define GLU_TESS_MISSING_END_CONTOUR 100154 69 | #define GLU_TESS_COORD_TOO_LARGE 100155 70 | #define GLU_TESS_NEED_COMBINE_CALLBACK 100156 71 | 72 | /* NurbsError */ 73 | #define GLU_NURBS_ERROR1 100251 74 | #define GLU_NURBS_ERROR2 100252 75 | #define GLU_NURBS_ERROR3 100253 76 | #define GLU_NURBS_ERROR4 100254 77 | #define GLU_NURBS_ERROR5 100255 78 | #define GLU_NURBS_ERROR6 100256 79 | #define GLU_NURBS_ERROR7 100257 80 | #define GLU_NURBS_ERROR8 100258 81 | #define GLU_NURBS_ERROR9 100259 82 | #define GLU_NURBS_ERROR10 100260 83 | #define GLU_NURBS_ERROR11 100261 84 | #define GLU_NURBS_ERROR12 100262 85 | #define GLU_NURBS_ERROR13 100263 86 | #define GLU_NURBS_ERROR14 100264 87 | #define GLU_NURBS_ERROR15 100265 88 | #define GLU_NURBS_ERROR16 100266 89 | #define GLU_NURBS_ERROR17 100267 90 | #define GLU_NURBS_ERROR18 100268 91 | #define GLU_NURBS_ERROR19 100269 92 | #define GLU_NURBS_ERROR20 100270 93 | #define GLU_NURBS_ERROR21 100271 94 | #define GLU_NURBS_ERROR22 100272 95 | #define GLU_NURBS_ERROR23 100273 96 | #define GLU_NURBS_ERROR24 100274 97 | #define GLU_NURBS_ERROR25 100275 98 | #define GLU_NURBS_ERROR26 100276 99 | #define GLU_NURBS_ERROR27 100277 100 | #define GLU_NURBS_ERROR28 100278 101 | #define GLU_NURBS_ERROR29 100279 102 | #define GLU_NURBS_ERROR30 100280 103 | #define GLU_NURBS_ERROR31 100281 104 | #define GLU_NURBS_ERROR32 100282 105 | #define GLU_NURBS_ERROR33 100283 106 | #define GLU_NURBS_ERROR34 100284 107 | #define GLU_NURBS_ERROR35 100285 108 | #define GLU_NURBS_ERROR36 100286 109 | #define GLU_NURBS_ERROR37 100287 110 | 111 | GLAPI const GLubyte* APIENTRY gluErrorString(GLenum errorCode); 112 | 113 | #ifdef __cplusplus 114 | } 115 | #endif 116 | 117 | #endif /* __GLUES_REGISTRY_H__ */ 118 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/glues/glues_mipmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) 3 | * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice including the dates of first publication and 13 | * either this permission notice or a reference to 14 | * http://oss.sgi.com/projects/FreeB/ 15 | * shall be included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 | * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 22 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | * 25 | * Except as contained in this notice, the name of Silicon Graphics, Inc. 26 | * shall not be used in advertising or otherwise to promote the sale, use or 27 | * other dealings in this Software without prior written authorization from 28 | * Silicon Graphics, Inc. 29 | * 30 | * OpenGL ES CM 1.0 port of part of GLU by Mike Gorchak 31 | */ 32 | 33 | #ifndef __GLUES_MIPMAP_H__ 34 | #define __GLUES_MIPMAP_H__ 35 | 36 | #include 37 | 38 | #define GLAPI GL_API 39 | #define APIENTRY GL_APIENTRY 40 | 41 | #ifndef APIENTRYP 42 | #define APIENTRYP APIENTRY * 43 | #endif /* APIENTRYP */ 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /* ErrorCode */ 50 | #define GLU_INVALID_ENUM 100900 51 | #define GLU_INVALID_VALUE 100901 52 | #define GLU_OUT_OF_MEMORY 100902 53 | #define GLU_INCOMPATIBLE_GL_VERSION 100903 54 | #define GLU_INVALID_OPERATION 100904 55 | 56 | GLAPI GLint APIENTRY gluScaleImage(GLenum format, GLsizei widthin, 57 | GLsizei heightin, GLenum typein, 58 | const void* datain, GLsizei widthout, 59 | GLsizei heightout, GLenum typeout, void* dataout); 60 | GLAPI GLint APIENTRY gluBuild2DMipmapLevels(GLenum target, GLint internalFormat, 61 | GLsizei width, GLsizei height, GLenum format, 62 | GLenum type, GLint userLevel, GLint baseLevel, 63 | GLint maxLevel, const void *data); 64 | GLAPI GLint APIENTRY gluBuild2DMipmaps(GLenum target, GLint internalFormat, 65 | GLsizei width, GLsizei height, GLenum format, 66 | GLenum type, const void* data); 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* __GLUES_REGISTRY_H__ */ 73 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/glues/glues_project.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) 3 | * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice including the dates of first publication and 13 | * either this permission notice or a reference to 14 | * http://oss.sgi.com/projects/FreeB/ 15 | * shall be included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 | * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 22 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | * 25 | * Except as contained in this notice, the name of Silicon Graphics, Inc. 26 | * shall not be used in advertising or otherwise to promote the sale, use or 27 | * other dealings in this Software without prior written authorization from 28 | * Silicon Graphics, Inc. 29 | * 30 | * OpenGL ES CM 1.0 port of part of GLU by Mike Gorchak 31 | */ 32 | 33 | #ifndef __GLUES_PROJECT_H__ 34 | #define __GLUES_PROJECT_H__ 35 | 36 | #include 37 | 38 | #define GLAPI GL_API 39 | #define APIENTRY GL_APIENTRY 40 | 41 | #ifndef APIENTRYP 42 | #define APIENTRYP APIENTRY * 43 | #endif /* APIENTRYP */ 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | GLAPI void APIENTRY gluOrtho2D(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top); 50 | GLAPI void APIENTRY gluPerspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar); 51 | GLAPI void APIENTRY gluLookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez, 52 | GLfloat centerx, GLfloat centery, GLfloat centerz, 53 | GLfloat upx, GLfloat upy, GLfloat upz); 54 | GLAPI GLint APIENTRY gluProject(GLfloat objx, GLfloat objy, GLfloat objz, 55 | const GLfloat modelMatrix[16], const GLfloat projMatrix[16], 56 | const GLint viewport[4], GLfloat* winx, GLfloat* winy, GLfloat* winz); 57 | GLAPI GLint APIENTRY gluUnProject(GLfloat winx, GLfloat winy, GLfloat winz, 58 | const GLfloat modelMatrix[16], const GLfloat projMatrix[16], 59 | const GLint viewport[4], GLfloat* objx, GLfloat* objy, GLfloat* objz); 60 | GLAPI GLint APIENTRY gluUnProject4(GLfloat winx, GLfloat winy, GLfloat winz, GLfloat clipw, 61 | const GLfloat modelMatrix[16], const GLfloat projMatrix[16], 62 | const GLint viewport[4], GLclampf nearVal, GLclampf farVal, 63 | GLfloat* objx, GLfloat* objy, GLfloat* objz, GLfloat* objw); 64 | GLAPI void APIENTRY gluPickMatrix(GLfloat x, GLfloat y, GLfloat deltax, GLfloat deltay, GLint viewport[4]); 65 | 66 | GLAPI void APIENTRY glPerspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar); 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* __GLUES_PROJECT_H__ */ 73 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/glues/glues_quad.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) 3 | * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice including the dates of first publication and 13 | * either this permission notice or a reference to 14 | * http://oss.sgi.com/projects/FreeB/ 15 | * shall be included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 | * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 22 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | * 25 | * Except as contained in this notice, the name of Silicon Graphics, Inc. 26 | * shall not be used in advertising or otherwise to promote the sale, use or 27 | * other dealings in this Software without prior written authorization from 28 | * Silicon Graphics, Inc. 29 | * 30 | * OpenGL ES CM 1.0 port of part of GLU by Mike Gorchak 31 | */ 32 | 33 | #ifndef __GLUES_QUAD_H__ 34 | #define __GLUES_QUAD_H__ 35 | 36 | #include 37 | 38 | #define GLAPI GL_API 39 | #define APIENTRY GL_APIENTRY 40 | 41 | #ifndef APIENTRYP 42 | #define APIENTRYP APIENTRY * 43 | #endif /* APIENTRYP */ 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /* ErrorCode */ 50 | #define GLU_INVALID_ENUM 100900 51 | #define GLU_INVALID_VALUE 100901 52 | #define GLU_OUT_OF_MEMORY 100902 53 | #define GLU_INCOMPATIBLE_GL_VERSION 100903 54 | #define GLU_INVALID_OPERATION 100904 55 | 56 | /* QuadricDrawStyle */ 57 | #define GLU_POINT 100010 58 | #define GLU_LINE 100011 59 | #define GLU_FILL 100012 60 | #define GLU_SILHOUETTE 100013 61 | 62 | /* QuadricCallback */ 63 | #define GLU_ERROR 100103 64 | 65 | /* QuadricNormal */ 66 | #define GLU_SMOOTH 100000 67 | #define GLU_FLAT 100001 68 | #define GLU_NONE 100002 69 | 70 | /* QuadricOrientation */ 71 | #define GLU_OUTSIDE 100020 72 | #define GLU_INSIDE 100021 73 | 74 | #ifdef __cplusplus 75 | class GLUquadric; 76 | #else 77 | typedef struct GLUquadric GLUquadric; 78 | #endif 79 | 80 | typedef GLUquadric GLUquadricObj; 81 | 82 | #ifndef APIENTRYP 83 | #define APIENTRYP APIENTRY * 84 | #endif /* APIENTRYP */ 85 | 86 | /* Internal convenience typedefs */ 87 | typedef void (APIENTRYP _GLUfuncptr)(); 88 | 89 | GLAPI GLUquadric* APIENTRY gluNewQuadric(void); 90 | GLAPI void APIENTRY gluDeleteQuadric(GLUquadric* state); 91 | GLAPI void APIENTRY gluQuadricCallback(GLUquadric* qobj, GLenum which, 92 | _GLUfuncptr fn); 93 | GLAPI void APIENTRY gluQuadricNormals(GLUquadric* qobj, GLenum normals); 94 | GLAPI void APIENTRY gluQuadricTexture(GLUquadric* qobj, GLboolean textureCoords); 95 | GLAPI void APIENTRY gluQuadricOrientation(GLUquadric* qobj, GLenum orientation); 96 | GLAPI void APIENTRY gluQuadricDrawStyle(GLUquadric* qobj, GLenum drawStyle); 97 | GLAPI void APIENTRY gluCylinder(GLUquadric* qobj, GLfloat baseRadius, 98 | GLfloat topRadius, GLfloat height, 99 | GLint slices, GLint stacks); 100 | GLAPI void APIENTRY gluDisk(GLUquadric* qobj, GLfloat innerRadius, 101 | GLfloat outerRadius, GLint slices, GLint loops); 102 | GLAPI void APIENTRY gluPartialDisk(GLUquadric* qobj, GLfloat innerRadius, 103 | GLfloat outerRadius, GLint slices, 104 | GLint loops, GLfloat startAngle, 105 | GLfloat sweepAngle); 106 | GLAPI void APIENTRY gluSphere(GLUquadric* qobj, GLfloat radius, GLint slices, 107 | GLint stacks); 108 | GLAPI void APIENTRY gluHemisphere(GLUquadric* qobj, GLboolean positive, GLfloat radius, GLint slices, GLint stacks); 109 | GLAPI void APIENTRY glu3DArc(GLUquadric* qobj, GLfloat angleWidth, GLfloat offsetAngle, GLboolean positive, GLfloat radius, GLint slices, GLint stacks); 110 | 111 | #ifdef __cplusplus 112 | } 113 | #endif 114 | 115 | #endif /* __GLUES_QUAD_H__ */ 116 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/glues/glues_registry.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) 3 | * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice including the dates of first publication and 13 | * either this permission notice or a reference to 14 | * http://oss.sgi.com/projects/FreeB/ 15 | * shall be included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 | * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 22 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | * 25 | * Except as contained in this notice, the name of Silicon Graphics, Inc. 26 | * shall not be used in advertising or otherwise to promote the sale, use or 27 | * other dealings in this Software without prior written authorization from 28 | * Silicon Graphics, Inc. 29 | * 30 | * OpenGL ES CM 1.0 port of part of GLU by Mike Gorchak 31 | */ 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | #include "glues_registry.h" 38 | 39 | #ifdef _WIN32 40 | #pragma warning(disable: 4996) 41 | #endif /* _WIN32 */ 42 | 43 | static const GLubyte versionString[]="1.3"; 44 | static const GLubyte extensionString[]=""; 45 | 46 | GLAPI const GLubyte* APIENTRY gluGetString(GLenum name) 47 | { 48 | if (name==GLU_VERSION) 49 | { 50 | return versionString; 51 | } 52 | else 53 | { 54 | if (name==GLU_EXTENSIONS) 55 | { 56 | return extensionString; 57 | } 58 | } 59 | 60 | return NULL; 61 | } 62 | 63 | /* extName is an extension name. 64 | * extString is a string of extensions separated by blank(s). There may or 65 | * may not be leading or trailing blank(s) in extString. 66 | * This works in cases of extensions being prefixes of another like 67 | * GL_EXT_texture and GL_EXT_texture3D. 68 | * Returns GL_TRUE if extName is found otherwise it returns GL_FALSE. 69 | */ 70 | GLAPI GLboolean APIENTRY gluCheckExtension(const GLubyte* extName, const GLubyte* extString) 71 | { 72 | GLboolean flag=GL_FALSE; 73 | char* word; 74 | char* lookHere; 75 | char* deleteThis; 76 | 77 | if (extString==NULL) 78 | { 79 | return GL_FALSE; 80 | } 81 | 82 | deleteThis=lookHere=(char*)malloc(strlen((const char*)extString)+1); 83 | if (lookHere==NULL) 84 | { 85 | return GL_FALSE; 86 | } 87 | 88 | /* strtok() will modify string, so copy it somewhere */ 89 | strcpy(lookHere,(const char*)extString); 90 | 91 | while ((word=strtok(lookHere, " "))!=NULL) 92 | { 93 | if (strcmp(word,(const char*)extName)==0) 94 | { 95 | flag=GL_TRUE; 96 | break; 97 | } 98 | lookHere=NULL; /* get next token */ 99 | } 100 | free((void*)deleteThis); 101 | 102 | return flag; 103 | } 104 | -------------------------------------------------------------------------------- /PanoramaGL/PanoramaGL/glues/glues_registry.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) 3 | * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice including the dates of first publication and 13 | * either this permission notice or a reference to 14 | * http://oss.sgi.com/projects/FreeB/ 15 | * shall be included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 | * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 22 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | * 25 | * Except as contained in this notice, the name of Silicon Graphics, Inc. 26 | * shall not be used in advertising or otherwise to promote the sale, use or 27 | * other dealings in this Software without prior written authorization from 28 | * Silicon Graphics, Inc. 29 | * 30 | * OpenGL ES CM 1.0 port of part of GLU by Mike Gorchak 31 | */ 32 | 33 | #ifndef __GLUES_REGISTRY_H__ 34 | #define __GLUES_REGISTRY_H__ 35 | 36 | #include 37 | 38 | #define GLAPI GL_API 39 | #define APIENTRY GL_APIENTRY 40 | 41 | #ifndef APIENTRYP 42 | #define APIENTRYP APIENTRY * 43 | #endif /* APIENTRYP */ 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /* Version */ 50 | #define GLU_VERSION_1_1 0x00000001 51 | #define GLU_VERSION_1_2 0x00000001 52 | #define GLU_VERSION_1_3 0x00000001 53 | 54 | /* StringName */ 55 | #define GLU_VERSION 100800 56 | #define GLU_EXTENSIONS 100801 57 | 58 | GLAPI const GLubyte* APIENTRY gluGetString(GLenum name); 59 | GLAPI GLboolean APIENTRY gluCheckExtension(const GLubyte* extName, const GLubyte* extString); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif /* __GLUES_REGISTRY_H__ */ 66 | -------------------------------------------------------------------------------- /PanoramaGL/Resources/Car/back.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/PanoramaGL/Resources/Car/back.jpg -------------------------------------------------------------------------------- /PanoramaGL/Resources/Car/down.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/PanoramaGL/Resources/Car/down.jpg -------------------------------------------------------------------------------- /PanoramaGL/Resources/Car/front.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/PanoramaGL/Resources/Car/front.jpg -------------------------------------------------------------------------------- /PanoramaGL/Resources/Car/left.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/PanoramaGL/Resources/Car/left.jpg -------------------------------------------------------------------------------- /PanoramaGL/Resources/Car/right.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/PanoramaGL/Resources/Car/right.jpg -------------------------------------------------------------------------------- /PanoramaGL/Resources/Car/up.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/PanoramaGL/Resources/Car/up.jpg -------------------------------------------------------------------------------- /PanoramaGL/Resources/hotspot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/PanoramaGL/Resources/hotspot.png -------------------------------------------------------------------------------- /PanoramaGL/Resources/json.data: -------------------------------------------------------------------------------- 1 | { 2 | "urlBase": "res://", 3 | "type": "spherical", 4 | "sensorialRotation": false, 5 | "images": 6 | { 7 | "preview": "pano_sphere_preview.jpg", 8 | "image": "pano_sphere.jpg" 9 | }, 10 | "camera": 11 | { 12 | "vlookat": 0, 13 | "hlookat": 0, 14 | "atvmin": -90, 15 | "atvmax": 90, 16 | "athmin": -180, 17 | "athmax": 180 18 | }, 19 | "hotspots": [ 20 | { 21 | "id": 1, 22 | "atv": 0, 23 | "ath": 0, 24 | "width": 0.08, 25 | "height": 0.08, 26 | "image": "hotspot.png" 27 | } 28 | ] 29 | } -------------------------------------------------------------------------------- /PanoramaGL/Resources/json_cubic.data: -------------------------------------------------------------------------------- 1 | { 2 | "urlBase": "res://", 3 | "type": "cubic", 4 | "sensorialRotation": false, 5 | "images": 6 | { 7 | "preview": "pano_preview.jpg", 8 | "front": "pano_f.jpg", 9 | "back": "pano_b.jpg", 10 | "left": "pano_l.jpg", 11 | "right": "pano_r.jpg", 12 | "up": "pano_u.jpg", 13 | "down": "pano_d.jpg" 14 | }, 15 | "camera": 16 | { 17 | "vlookat": 0, 18 | "hlookat": 0, 19 | "atvmin": -90, 20 | "atvmax": 90, 21 | "athmin": -180, 22 | "athmax": 180 23 | }, 24 | "hotspots": [ 25 | { 26 | "id": 1, 27 | "atv": 0, 28 | "ath": 0, 29 | "width": 0.08, 30 | "height": 0.08, 31 | "image": "hotspot.png" 32 | } 33 | ] 34 | } -------------------------------------------------------------------------------- /PanoramaGL/Resources/json_s2.data: -------------------------------------------------------------------------------- 1 | { 2 | "urlBase": "res://", 3 | "type": "spherical2", 4 | "sensorialRotation": false, 5 | "images": 6 | { 7 | "preview": "pano_sphere_preview.jpg", 8 | "image": "pano_sphere2.jpg" 9 | }, 10 | "camera": 11 | { 12 | "vlookat": 0, 13 | "hlookat": 0, 14 | "atvmin": -90, 15 | "atvmax": 90, 16 | "athmin": -180, 17 | "athmax": 180 18 | }, 19 | "hotspots": [ 20 | { 21 | "id": 1, 22 | "atv": 0, 23 | "ath": 0, 24 | "width": 0.08, 25 | "height": 0.08, 26 | "image": "hotspot.png" 27 | } 28 | ] 29 | } -------------------------------------------------------------------------------- /PanoramaGL/Resources/pano_b.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/PanoramaGL/Resources/pano_b.jpg -------------------------------------------------------------------------------- /PanoramaGL/Resources/pano_d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/PanoramaGL/Resources/pano_d.jpg -------------------------------------------------------------------------------- /PanoramaGL/Resources/pano_f.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/PanoramaGL/Resources/pano_f.jpg -------------------------------------------------------------------------------- /PanoramaGL/Resources/pano_l.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/PanoramaGL/Resources/pano_l.jpg -------------------------------------------------------------------------------- /PanoramaGL/Resources/pano_preview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/PanoramaGL/Resources/pano_preview.jpg -------------------------------------------------------------------------------- /PanoramaGL/Resources/pano_r.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/PanoramaGL/Resources/pano_r.jpg -------------------------------------------------------------------------------- /PanoramaGL/Resources/pano_sphere.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/PanoramaGL/Resources/pano_sphere.jpg -------------------------------------------------------------------------------- /PanoramaGL/Resources/pano_sphere2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/PanoramaGL/Resources/pano_sphere2.jpg -------------------------------------------------------------------------------- /PanoramaGL/Resources/pano_sphere_preview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/PanoramaGL/Resources/pano_sphere_preview.jpg -------------------------------------------------------------------------------- /PanoramaGL/Resources/pano_u.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/PanoramaGL/Resources/pano_u.jpg -------------------------------------------------------------------------------- /PanoramaGL/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // PanoramaGL 4 | // 5 | // Created by Jakey on 15/8/13. 6 | // Copyright © 2015年 Jakey. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PLView.h" 11 | #import "PLJSONLoader.h" 12 | 13 | 14 | //1.drawViewInternally crash 15 | //https://code.google.com/p/panoramagl/issues/detail?id=18 16 | 17 | 18 | @interface ViewController : UIViewController 19 | 20 | @property(nonatomic, weak) IBOutlet UISegmentedControl *segmentedControl; 21 | @property(nonatomic, weak) IBOutlet PLView *plView; 22 | 23 | -(void)selectPanorama:(NSInteger)index; 24 | 25 | -(IBAction)segmentedControlIndexChanged:(id)sender; 26 | 27 | @end 28 | 29 | -------------------------------------------------------------------------------- /PanoramaGL/ViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /PanoramaGL/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // PanoramaGL 4 | // 5 | // Created by Jakey on 15/8/13. 6 | // Copyright © 2015年 Jakey. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PanoramaGL 全景展示 2 | PanoramaGL, fixed some issues,share to someone need it,supports arm64,create by xcode7 3 | 4 | based https://code.google.com/p/panoramagl 5 | 6 | ![](https://raw.githubusercontent.com/shaojiankui/PanoramaGL/master/demo.gif) 7 | 8 | 9 | ## 变更 10 | 11 | * fix arm64 PLHotspot bug 修正arm64下PLHotspot不能点击的bug 12 | * texture supports 2048*2048 纹理支持2048*2048 13 | * remove some warning 移除一些警告 14 | * use CMMotionManager replace UIAccelerometer 对重力感应做了向下兼容 15 | * add Accelerometer Effect 添加了重力感应效果 16 | 17 | ## 其他选择 18 | 19 | * Panorama https://github.com/robbykraft/Panorama 20 | * JAPanoView https://bitbucket.org/javieralonso/japanoview 21 | * threejs.org http://threejs.org/examples/webgl_panorama_equirectangular.html 22 | * SceneKit自己动手实现全景展示 https://github.com/shaojiankui/Panorama-SceneKit 23 | * OpenGL自己动手实现全景展示 https://github.com/shaojiankui/Panorama-OpenGL 24 | 25 | ## 工具 26 | * Pano2vr 全景图像转化与制作软件 27 | Pano2vr软件非常强大,可以鱼眼图与六方图互相转换,可以确定hotspot交互热点,可以输出html flash文件直接浏览。 28 | ![](https://raw.githubusercontent.com/shaojiankui/PanoramaGL/master/pano2vr.png) 29 | 30 | 31 | ## 扩展阅读 32 | 33 | [iOS开发之360°/720°全景展示](http://www.skyfox.org/ios-720-panoramic-show.html) 34 | 35 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/demo.gif -------------------------------------------------------------------------------- /pano2vr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaojiankui/PanoramaGL/8e28ab7c1d08462e0f4f0fa69fba1b4a41244031/pano2vr.png --------------------------------------------------------------------------------