美文网首页
PanoramaGL全景图

PanoramaGL全景图

作者: 天码行空 | 来源:发表于2018-01-04 16:49 被阅读0次

    -(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向上取一个满足的,NO向下取一个满足的

            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];

    }

    相关文章

      网友评论

          本文标题:PanoramaGL全景图

          本文链接:https://www.haomeiwen.com/subject/ykornxtx.html