-(void)selectPanorama:(NSInteger)index{ PLRotation ro = PLRotationMake(0.0, 0.0, 0.0); [self.plView.camera resetCurrentC:ro Pitch:ro.pitch yaw:ro.yaw]; NSObject *panorama = nil;
? ? //尺寸必須符合
? ? //Spherical2 panorama example (supports up 4096x2048 texture)
? ? if(index == 0)
? ? {
? ? ? ? panorama = [PLSpherical2Panorama panorama];
? ? ? ? [(PLSpherical2Panorama *)panorama setImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"pano_sphere2" ofType:@"jpg"]]];
? ? }
? ? //Spherical panorama example (supports up 2048x1024 texture)
? ? else if(index == 1)
? ? {
? ? ? ? panorama = [PLSphericalPanorama panorama];
? ? ? ? [(PLSphericalPanorama *)panorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"pano_sphere" ofType:@"jpg"]]]];
? ? }
? ? //尺寸不必須符合奔誓,比例符合2;1即可
? ? else if(index == 5)
? ? {
? ? ? ? //ifNoPowerOfTwoConvertUpDimension 如果圖片不滿足2的N次方萍程,YES向上取一個(gè)滿足的诉稍,NO向下取一個(gè)滿足的
? ? ? ? panorama = [PLSphericalRatioPanorama panorama];
? ? [(PLSphericalRatioPanorama *)panorama setImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"pano_sphere2" ofType:@"jpg"]] ifNoPowerOfTwoConvertUpDimension:NO];
? ? }
? ? //Cubic panorama example (supports up 2048x2048 texture per face)
? ? else if(index == 2)
? ? {
? ? ? ? PLCubicPanorama *cubicPanorama = [PLCubicPanorama panorama];
? ? ? ? [cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"pano_f" ofType:@"jpg"]]] face:PLCubeFaceOrientationFront];
? ? ? ? [cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"pano_b" ofType:@"jpg"]]] face:PLCubeFaceOrientationBack];
? ? ? ? [cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"pano_l" ofType:@"jpg"]]] face:PLCubeFaceOrientationLeft];
? ? ? ? [cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"pano_r" ofType:@"jpg"]]] face:PLCubeFaceOrientationRight];
? ? ? ? [cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"pano_u" ofType:@"jpg"]]] face:PLCubeFaceOrientationUp];
? ? ? ? [cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"pano_d" ofType:@"jpg"]]] face:PLCubeFaceOrientationDown];
? ? ? ? panorama = cubicPanorama;
? ? }
? ? //Car
? ? else if(index == 4)
? ? {
? ? ? ? PLCubicPanorama *cubicPanorama = [PLCubicPanorama panorama];
? ? ? ? [cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"front" ofType:@"jpg"]]] face:PLCubeFaceOrientationFront];
? ? ? ? [cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"back" ofType:@"jpg"]]] face:PLCubeFaceOrientationBack];
? ? ? ? [cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"left" ofType:@"jpg"]]] face:PLCubeFaceOrientationLeft];
? ? ? ? [cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"right" ofType:@"jpg"]]] face:PLCubeFaceOrientationRight];
? ? ? ? [cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"up" ofType:@"jpg"]]] face:PLCubeFaceOrientationUp];
? ? ? ? [cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"down" ofType:@"jpg"]]] face:PLCubeFaceOrientationDown];
? ? ? ? panorama = cubicPanorama;
? ? }
? ? //Cylindrical panorama example (supports up 1024x1024 texture)
? ? else if(index == 3)
? ? {
? ? ? ? panorama = [PLCylindricalPanorama panorama];
? ? ? ? ((PLCylindricalPanorama *)panorama).isHeightCalculated = NO;
? ? ? ? [(PLCylindricalPanorama *)panorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"pano_sphere" ofType:@"jpg"]]]];
? ? }
? ? //Add a hotspot
? ? PLTexture *hotspotTexture = [PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"hotspot" ofType:@"png"]]];
? ? PLHotspot *hotspot = [PLHotspot hotspotWithId:(kIdMin + random() % ((kIdMax + 1) - kIdMin)) texture:hotspotTexture atv:0.0f ath:0.0f width:0.08f height:0.08f];
? ? [panorama addHotspot:hotspot];
? ? [self.plView setPanorama:panorama];
}