[置頂] ios 全景瀏覽效果demo

來源:互聯網
上載者:User

demo功能:全景瀏覽 效果,可上下左右前後轉動瀏覽。

demo說明:項目中pano.jpg 是貼圖 。將這個圖貼到球型模型上,攝像機設定為球的中心點,在內向球外觀看貼圖。

demo截屏:

demo主要代碼:plview.m部分(顯示全景的view)

 

#import "PLView.h"@interface PLView ()- (void)initializeValues;@end@implementation PLView@synthesize type;@synthesize camera;#pragma mark -#pragma mark init methods- (void)allocAndInitVariables{[super allocAndInitVariables];scene = [PLScene scene];renderer = [PLRenderer rendererWithView:self scene:[scene retain]];camera = [PLCamera camera];}- (void)initializeValues{[super initializeValues];textures = [[NSMutableArray array] retain];type = PLViewTypeUnknown;}- (void)reset{if(camera)[camera reset];[super reset];}#pragma mark -#pragma mark property methods- (void)setType:(PLViewType)value{type = value;if(sceneElement)[sceneElement release];switch (value) {case PLViewTypeCylindrical:camera.fovFactorRange = PLRangeMake(kDefaultCylinderFovFactorMinValue, kDefaultCylinderFovFactorMaxValue);sceneElement = [PLCylinder cylinder];break;case PLViewTypeSpherical:camera.fovFactorRange = PLRangeMake(kDefaultFovFactorMinValue, kDefaultFovFactorMaxValue);sceneElement = [PLSphere sphere];break;case PLViewTypeCubeFaces:camera.fovFactorRange = PLRangeMake(kDefaultFovFactorMinValue, kDefaultFovFactorMaxValue);sceneElement = [PLCube cube];break;case PLViewTypeUnknown:sceneElement = nil;break;default:[NSException raise:@"Invalid panorama type" format:@"Type unknown", nil];break;}if(sceneElement){sceneElement = [sceneElement retain];for(PLTexture * texture in textures)[sceneElement addTexture:texture];[scene addElement:sceneElement];}}#pragma mark -#pragma mark draw methods- (void)drawView {    [super drawView];[sceneElement clonePropertiesOf:camera];[scene.currentCamera cloneCameraProperties:camera];scene.currentCamera.rotation = PLRotationMake(0.0f, 0.0f, 0.0f);scene.currentCamera.position = PLPositionMake(0.0f, 0.0f, 0.0f);if(!isValidForFov && !isValidForOrientation)[sceneElement rotateWithStartPoint:startPoint endPoint:endPoint sensitivity:camera.rotateSensitivity];[renderer render];camera.rotation = PLRotationMake(sceneElement.pitch, sceneElement.yaw, sceneElement.roll);}#pragma mark -#pragma mark fov methods- (BOOL)calculateFov:(NSSet *)touches{if([super calculateFov:touches]){[camera addFovWithDistance:fovDistance];[scene.currentCamera addFovWithDistance:fovDistance];return YES;}return NO;}#pragma mark -#pragma mark texture methods- (void)addTexture:(PLTexture *)texture{[textures addObject:texture];if(sceneElement)[sceneElement addTexture:texture];}- (void)removeTexture:(PLTexture *)texture{[textures removeObject:texture];if(sceneElement)[sceneElement removeTexture:texture];}- (void)removeTextureAtIndex:(NSUInteger) index{[textures removeObjectAtIndex:index];if(sceneElement)[sceneElement removeTextureAtIndex:index];}- (void)removeAllTextures{[textures removeAllObjects];if(sceneElement)[sceneElement removeAllTextures];}#pragma mark -#pragma mark orientation methods- (void)orientationChanged:(UIDeviceOrientation)orientation{if(camera && sceneElement){camera.orientation = orientation;sceneElement.orientation = orientation;camera.pitchRange = sceneElement.pitchRange;camera.yawRange = sceneElement.yawRange;camera.rollRange = sceneElement.rollRange;camera.rotation = PLRotationMake(sceneElement.pitch, sceneElement.yaw, sceneElement.roll);}}#pragma mark -#pragma mark dealloc methods- (void)dealloc {    if(textures)[textures release];if(camera)[camera release];if(sceneElement)[sceneElement release];if(scene)[scene release];    if(renderer)[renderer release];[super dealloc];}@end

demo:http://download.csdn.net/detail/donny_zhang/5552467

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.