iOS PanoramaGL(全景展示)用法
来源:互联网 发布:小学生合适学编程吗 编辑:程序博客网 时间:2024/05/29 16:50
初做项目,两次涉及到了360度全景展示(也可以是720的旋转),查找了很多资料,基本都是用PanoramaGL这个库实现的,下面我就这两次用这个库出现的问题以及应项目需求在库里做的改动简单的总结一下。技术就是前人栽树,后人乘凉,我老在大树下乘凉心里有点过意不去,时不时的也种点小树苗。
在code4app里面用到的那个库其实只是基础,不完善,灵活度和可操作性都不够,所以建议大家舍弃这个库,直接在csdn里面下载。下载地址:http://download.csdn.net/detail/pingyan88/5697173
PanoramaGL用法:将库下载下来导入项目中,并添加相关的依赖框架(框架缺一不可),但并不是单纯的导入框架就可以了,我自己在第一次导入的时候做了很多修改,那错误就像个无底洞,但后来几次就轻松多了,主要是得对照源代码在
Build Settings 里进行配置。(由于要修改的地方太多,这里就不一一列举出来了。)
因为,这个库是12年更新的,所以没有使用ARC,如果,你引用了它的库,你会发现ARC错误,即使你全部加上-fno-objc-arc,你也会发现**变量的错误,网上有改正的方法,但是有的地方,改了还是报错,而且许多地方都要更改(**,-fno-objc-arc),所以,我选择建立工程后,把工程修改为不适用ARC,对自己新建的文件修改,添加-f-objc-arc,使用ARC。这样即使报错,双击fix一下就编译通过了。
多说无益,直接上代码。
- (void)viewDidLoad
{
[super viewDidLoad];
plView = (PLView *)self.view;
plView.delegate = self;
plView.PLdelegate =self;
panorama =nil;
cubicPanorama= [PLCubicPanorama panorama];
//下面就是核心代码,用6张JPG的图片来实现。相当于拼成了一个正方体。
[cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"quito1_f" ofType:@"jpg"]]] face:PLCubeFaceOrientationFront];
[cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"quito1_b" ofType:@"jpg"]]] face:PLCubeFaceOrientationBack];
[cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"quito1_l" ofType:@"jpg"]]] face:PLCubeFaceOrientationLeft];
[cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"quito1_r" ofType:@"jpg"]]] face:PLCubeFaceOrientationRight];
[cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"quito1_u" ofType:@"jpg"]]] face:PLCubeFaceOrientationUp];
[cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"quito1_d" ofType:@"jpg"]]] face:PLCubeFaceOrientationDown];
panorama = cubicPanorama;
[plView setPanorama:panorama];
//改变初始化的位置(有些项目需要点击全景进去是指定的某一个角度)
[panorama.currentCamera lookAtWithPitch:0.0f yaw:40.0f];(具体角度根据需要调整)
currentCamera = panorama.currentCamera;
//添加热点(这个类可以实现在全景里面添加按钮,并且按钮跟随场景的转动而转动。有的需求是,当转动到某一个页面时,随之出现一个按钮,后面会说到)
PLTexture *hotspotTexture = [PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"360_f_arrow@2x" ofType:@"png"]]];
PLHotspot *hotspot = [PLHotspot hotspotWithId:1 texture:hotspotTexture atv:-20.0f ath:-40.0f width:0.08f height:0.08f];(角度是相对场景而调整,可自设置)
//width height热点大小 atv上正数下负数 ath位置右边正数 左边负数
[panorama addHotspot:hotspot];
当旋转到某一个页面的时候出现一个按钮(yaw是横向,pitch是纵向)
if ((camera.yaw <90.f && camera.yaw >=0 && !isshow)) //|| (camera.pitch <10 && camera.pitch >5.f))
{
self.curtainLabel = [[UIButton alloc]initWithFrame:CGRectMake(290, 0, 30, 30)];
self.curtainLabel.backgroundColor = [UIColor blueColor];
self.curtainLabel.layer.cornerRadius = 5.0f;
self.curtainLabel.hidden = YES;
self.curtainLabel.layer.shadowColor = [UIColor blackColor].CGColor;
self.curtainLabel.layer.shadowOffset = CGSizeMake(2, 2);
//添加触发到视频也的按钮
[self.curtainLabel addTarget:self action:@selector(curtainBtn) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:self.curtainLabel];
}
-(void)view:(UIView<PLIView> *)pView didClickHotspot:(PLHotspot *)hotspot screenPoint:(CGPoint)point scene3DPoint:(PLPosition)position
{
NSLog(@"hhhhhh");
}
前面有说到,该库支持360和720旋转。具体修改旋转角度是在Plconstants类里面
我项目中所涉及的技术也就这些吧。如果还有别的功能,大家就自己在研究研究吧。
- iOS PanoramaGL(全景展示)用法
- iOS PanoramaGL(全景展示)用法及集成中的那些坑
- ios全景展示panoramaGL的一些总结
- iOS开发笔记--简单的全景展示利器panoramagl
- iOS开发笔记--简单的全景展示利器panoramagl
- iPhone:简单的全景展示利器panoramagl
- 简单的全景展示利器panoramagl
- [iOS开发必备工具之]简单的全景展示利器panoramagl
- [iOS开发必备工具之]简单的全景展示利器panoramagl
- Android 360全景开发(PanoramaGL)
- ios全景展示
- 全景图(PanoramaGL)
- 360°全景影像移动端类库--PanoramaGL
- 全景图2.0 DEMO 下载 PanoramaGL
- PanoramaGL在IOS的使用
- 源码推荐: 720度全景展示 for iOS
- 点量源动闪媒Flash全景展示系统(可提供源码),提供360度全景展示
- 360度全景展示
- android基础adb常用操作
- while( *p++ ); 和while( *p ) {p++;}的区别
- android的消息处理机制(图+源码分析)——Looper,Handler,Message
- 盘点2014上半年网络信息泄密事件
- magento删除订单
- iOS PanoramaGL(全景展示)用法
- floodfill算法的几种实现
- 高薪就业就学Java软件开发技术
- 盗梦空间
- 杂类-------VS2008在win7找不到输入序列号的地方
- 项目管理之管理方法
- Linux下手动配置IP地址
- Oracle Trading Community Architecture(Oracle TCA)
- OCP 1Z0 053 102