现在的位置: 首页 > 综合 > 正文

PanoramaGL在IOS的使用

2017年10月20日 ⁄ 综合 ⁄ 共 2169字 ⁄ 字号 评论关闭

其实,对于普通基本的使用来说,PanoramaGL不难。

按照Google上的步骤,很简单。其中注意一下几点:

因为,这个项目是12年更新的,所以没有使用ARC,如果,你引用了它的库,你会发现ARC错误,即使你全部加上-fno-objc-arc,你也会发现**变量的错误,网上有改正的方法,但是有的地方,改了还是报错,而且许多地方都要更改(**,-fno-objc-arc),所以,我选择建立工程后,把工程修改为不适用ARC,对自己新建的文件修改,添加-f-objc-arc,使用ARC。这样即使报错,双击fix一下就编译通过了。

以下是我的代码。

.h文件

@interface ViewController : UIViewController  <PLViewDelegate>//热点代理
{
@private
    PLView *plView;
}

.m文件

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    plView = (PLView *)self.view;
    plView.delegate = self;
    //开启加速
    plView.isAccelerometerEnabled = YES;
    //水平 加速
    plView.isAccelerometerLeftRightEnabled = YES;
    //灵敏度
    plView.accelerometerSensitivity = kAccelerometerSensitivityMinValue;
    /*
     #define kDefaultAccelerometerSensitivity	7.0f
     #define kDefaultAccelerometerInterval		1.0f/60.0f
     #define kAccelerometerSensitivityMinValue	1.0f
     #define kAccelerometerSensitivityMaxValue	10.0f
     #define kAccelerometerMultiplyFactor		100.0f
     */
    //刷新时间间隔 秒[NSTimeInterval
    plView.accelerometerInterval = 0.01f ;
    [self _loadView];

- (void)_loadView
{
    //添加全景图片
    NSObject<PLIPanorama> *panorama = [PLSphericalPanorama panorama];
    [(PLSphericalPanorama *)panorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"3" ofType:@"jpg"]]]];
    
    //Add a hotspot
    //添加热点
    PLTexture *hotspotTexture = [PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"hotspot" ofType:@"png"]]];
    PLHotspot *hotspot = [PLHotspot hotspotWithId:1 texture:hotspotTexture atv:0.10f ath:0.10f width:0.08f height:0.08f];
    //width height 热点大小 atv上正数下负数 ath 位置右边正数 左边负数
    [panorama addHotspot:hotspot];
    
    PLHotspot *hotspot1 = [PLHotspot hotspotWithId:2 texture:hotspotTexture atv:-13.1f ath:55.10f width:0.08f height:0.08f];
    [panorama addHotspot:hotspot1];
    
    [plView setPanorama:panorama];
}

//Hotspot event
//热点事件
- (void)view:(UIView<PLIView> *)pView didClickHotspot:(PLHotspot *)hotspot screenPoint:(CGPoint)point scene3DPoint:(PLPosition)position
{
    NSLog(@"点击了热点%d",(int)hotspot.identifier);
}

热点的作用为:随着图片转动。所以,你想标示一个图片上的固定点,你就需要热点了。
最后给出两个参考的网址

http://www.codeproject.com/Articles/60635/Panorama-iPod-Touch-iPhone 许多博客都是翻译的这个

https://code.google.com/p/panoramagl/wiki/UserGuide  可以根据这个建立工程

一个重要的文件

PLConstants.h许多不懂的参数可以到这来看看默认的设置

转载是请保留:来自http://blog.csdn.net/ralbatr

抱歉!评论已关闭.