全景图 HelloPanorama 的使用

HelloPanorama是由国外一名老外写的,所以很久没有更新,最近开始做全景视图,开始使用他所提供的库,将遇到的问题说明一下

首先下载HelloPanorama项目,在gitHub可以搜索到,

https://github.com/heroims/HelloPanoramaGL

下载完成后,发现这个项目是用MRC写的,然而我习惯用ARC,所以将项目中的资源文件以及库导入到我的项目中,

导入之后,进入Build Phases,设置PanoramaGL的文件为-fno-objc-arc,这样就可以在ARC项目中编译MRC的文件了,

编译一下,会发现报错了,在PLPanoramaBase.h文件中报错,

改成这样就好了

@private
	PLTexture *__unsafe_unretained*previewTextures;
	PLTexture *__unsafe_unretained*textures;
}

修改完成后,就可以完成显示了,根据原来项目的代码,我们可以直接拷贝,将PLView显示出来

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"全景图片";
    self.view.backgroundColor = [UIColor whiteColor];
    
    NSArray * items = @[@"球体2048x1024",@"球体1024x512",@"6面体1024x1024",@"柱形1024x1024"];
    
    self.plView = [[PLView alloc] init];
    [self.plView setFrame:self.view.frame];
    self.plView.delegate = self;
    self.plView.isAccelerometerEnabled = NO;
    self.plView.isScrollingEnabled = YES;
    self.plView.isInertiaEnabled = YES;
    [self.view addSubview:self.plView];
    
    UISegmentedControl * segmented = [[UISegmentedControl alloc]initWithItems:items];
    segmented.frame = CGRectMake(5, 74, self.view.frame.size.width - 10, 40);
    segmented.tintColor = [UIColor lightGrayColor];
    segmented.selectedSegmentIndex = 0;
    [segmented addTarget:self action:@selector(clickSegmented:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:segmented];

}

当UISegmentedControl值改变时,响应

- (void)clickSegmented:(UISegmentedControl *)seg{
    
    NSObject<PLIPanorama> *panorama = nil;

    switch (seg.selectedSegmentIndex) {
            
        case 0:
        //Spherical2 panorama example (supports up 2048x1024 texture 全景图 球体)
        panorama = [PLSpherical2Panorama panorama];
        [(PLSpherical2Panorama *)panorama setImage:[PLImage  imageWithPath:[[NSBundle mainBundle] pathForResource:@"1" ofType:@"jpeg"]]];
            break;
        case 1:
        //Spherical panorama example (supports up 1024x512 texture 全景图 球体)
        panorama = [PLSphericalPanorama panorama];
        [(PLSphericalPanorama *)panorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"pano_sphere" ofType:@"jpg"]]]];
            break;
        case 2:
        //Cubic panorama example (supports up 1024x1024 texture per face 6张图 6面体)
        panorama = [PLCubicPanorama panorama];
        [(PLCubicPanorama *)panorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"pano_f" ofType:@"jpg"]]] face:PLCubeFaceOrientationFront];
        [(PLCubicPanorama *)panorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"pano_b" ofType:@"jpg"]]] face:PLCubeFaceOrientationBack];
        [(PLCubicPanorama *)panorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"pano_l" ofType:@"jpg"]]] face:PLCubeFaceOrientationLeft];
        [(PLCubicPanorama *)panorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"pano_r" ofType:@"jpg"]]] face:PLCubeFaceOrientationRight];
        [(PLCubicPanorama *)panorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"pano_u" ofType:@"jpg"]]] face:PLCubeFaceOrientationUp];
        [(PLCubicPanorama *)panorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"pano_d" ofType:@"jpg"]]] face:PLCubeFaceOrientationDown];
//            panorama = cubicPanorama;
            break;
        case 3:
        //Cylindrical panorama example (supports up 1024x1024 texture 全景图 显示为柱形)
        panorama = [PLCylindricalPanorama panorama];
        ((PLCylindricalPanorama *)panorama).isHeightCalculated = NO;
        [(PLCylindricalPanorama *)panorama setTexture:[PLTexture  textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"pano_sphere" ofType:@"jpg"]]]];
            break;
            
        default:
            break;
    }

    [self.plView setPanorama:panorama];
}

这就可以将简单的全景图添加到屏幕中并显示了

如果想了解一些具体的参数含义可以参考文档

http://www.codeproject.com/Articles/60635/Panorama-iPod-Touch-iPhone

The supported features in version 0.1 Beta are:   

  • Supports OpenGLES 1.1
  • Tested with SDK 3.0 to 3.2
  • Supports cubic, spherical and cylindrical panoramic images
  • Allows scrolling and continuous scrolling
  • Supports scrolling left to right and from top to bottom using the accelerometer
  • Allows to use the inertia to stop scrolling
  • Supports zoom in and zoom out (moving two fingers on the screen)
  • Supports reset (placing three fingers on the screen)
  • Allows you to control the range of rotation in the x, y and z axis
  • Supports Portrait, Portrait Upside Down, Landscape Left and Landscape Right orientation using the accelerometer
  • Supports for events on view

Classes Documentation

Then proceed to explain briefly the operation of the classes used:

PLView class, this class is a view (inherits from UIView) allowing a simple set of features for power display panoramic images. The properties and methods of this class are:

  • BOOL isDeviceOrientationEnabled; //If the view allows you to enable orientation of the device supports (manually, typical of the Library)
  • UIDeviceOrientation deviceOrientation; //lets see what orientation has this view, or set in that we want the view orientation appears. Eg. plView.deviceOrientation=UIDeviceOrientationLandscapeLeft;
  • PLOrientationSupported deviceOrientationSupported;  //This property allows you to tell the view that positions of orientation is enabled and running. Eg. PlView.deviceOrientationSupported = (PLOrientationSupportedPortrait | PLOrientationSupportedLandscapeLeft) <- in this case only allows for Portrait orientation and LandscapeLeft
  • BOOL isAccelerometerEnabled; //This property enables the operation of the accelerometer
  • BOOL isAccelerometerLeftRightEnabled; // This property activates the accelerometer operation only in the x-axis and depends on this active property isAccelerometerEnabled
  • BOOL isAccelerometerUpDownEnabled; // This property activates the accelerometer operation only in the y-axis and depends on this active property isAccelerometerEnabled
  • float accelerometerSensitivity; // Set the sensitivity with which to operate the accelerometer (motion sensing)
  • NSTimeInterval accelerometerInterva;// Sets the refresh time in seconds of accelerometer
  • CGPoint startPoint; // This property tells us which position he made the first touch when the event occurs (Touch Begin event)
  • CGPoint endPoint; // This property will be cooling while moving the finger on the screen (Touch Move event)
  • BOOL isScrollingEnabled; // This property tells us if you could make a scrolling at the hearing, if not active, only move when the fingers moving on the screen
  • NSUInteger minDistanceToEnableScrolling; // Minimum distance that must be traveled with the fingers to activate the scrolling
  • BOOL isInertiaEnabled; / / Check the inertia that means that when someone performs a scroll inertia is activated to slow the scroll to stop the movement
  • NSTimeInterval inertiaInterval; // Duration of inertia in seconds
  • BOOL isResetEnabled; // Property that can be enabled to reset the view to its original position when placing three fingers on the screen
  • PLViewType type; // Type of view to be used can be (PLViewTypeSpherical, PLViewTypeCubeFaces, PLViewTypeCylindrical)
  • PLCamera * camera; / / Property allows us to change or take the parameters of the camera  
  • - (void) addTexture: (PLTexture *) texture; // Add a texture to be used, in the case of spherical and cylindrical single view to invoke this method once, in the case of cubic view use this method six times (one texture per face)
  • - (void) removeTexture: (PLTexture *) texture; // Removes an object of type texture of the view
  • - (void) removeTextureAtIndex: (NSUInteger) index; // Removes an object of type texture by index of the view
  • - (void) removeAllTextures; // Removes all the textures that the view can use


PLTexture class allows us to load a texture that will be used by the view, its properties and methods are:  

  • GLuint textureId; // read-only property giving the identifier of an OpenGL texture
  • int widthheight; // read-only properties for the width and height of a texture loaded
  • BOOL isValid; // Property to know if the texture failed to load
  • - (id) init; // Default Constructor
  • - (id) initWithImage: (UIImage *) image; // Constructor that receives an object of type UIImage where an image must be loaded
  • - (id) initWithImage: (UIImage *) image rotate (int) angle; // Same as the previous method but can rotate the image 90, 180, 270 degrees
  • - (id) initWithPath: (NSString *) path; // Constructor that receives the  image path (jpeg, png)
  • - (id) initWithPath: (NSString *) path rotate (int) angle; // Same as the previous method but can rotate the image 90, 180, 270 degrees

// Constructors static type that operate with the same parameters that the init equivalent  functions  

  • + (id) textureWithImage: (UIImage *) image;  
  • + (id) textureWithPath: (NSString *) path;
  • + (id) textureWithImage: (UIImage *) image rotate (int) angle;
  • + (id) textureWithPath: (NSString *) path rotate (int) angle;
  • - (BOOL) loadTextureWithImage: (UIImage *) image; // Load a texture from an image object
  • - (BOOL) loadTextureWithImage: (UIImage *) image rotate (int) angle; / / Same as the previous method but can rotate the image 90, 180, 270 degrees
  • - (BOOL) loadTextureWithPath: (NSString *) path,  // Load a texture from image path (jpeg, png)
  • - (BOOL) loadTextureWithPath: (NSString *) path rotate (int) angle; / / Same as the previous method but can rotate the image 90, 180, 270 degrees

PLCamera class allows us to change the display settings of the hearing, their properties are:

  • BOOL  IsFovEnabled; // Enable zoom in or zoom out eg. plView.camera.isFovEnabled  = NO;
  • float fov; // zoom level for the Hearing eg. plView.camera.fov = 10;
  • float fovSensitivity; // sensitivity for the zoom when you place two fingers on the screen eg.plView.camera.fovSensitivity = 70;
  • PLRange fovRange; // Range in values that will allow for the default zoom from -180 to 180 eg.plView.camera.fovRange = PLRangeMake (-10.10);
  • PLRange fovFactorRange; // Range in which the zoom will work internaly (This range is for internal use with fovFactor property)
  • BOOL isXAxisEnabledisYAxisEnabledisZAxisEnabled;  // This properties enabled if the camera can move in the x, y, z eg. plView.camera.isXAxisEnabled = NO;
  • PLPosition position;  // property to place the camera in a position. PLPosition has the property x, y, z eg.plView.camera.x = 6;
  • PLRange xRangeyRangezRange; // Define the range in which it can move in the x, y, z eg.plView.camera.xRange = PLRangeMake (-100, 100);
  • BOOL isPitchEnabledisYawEnabledisRollEnabled; // These properties enable that axes can rotate the camera x, y, z eg.  plView.camera.isPitchEnabled = NO;
  • BOOL  IsReverseRotation; // Enable the rotation of the camera displacement is inversely related to the user to do with the touch or accelerometer.  Eg. plView.camera.isReverseRotation = YES;
  • PLRotation rotation; // angles of rotation (in degrees) of the camera x, y, z eg.plView.camera.rotation.pitch = 80;
  • PLRange pitchRangeyawRangerollRange; // Range in which the camera can rotate in x, y, z eg.plView.camera.pitchRange = PLRangeMake (-90, 90); <- on the x axis can only rotate the angle - 90 to 90
  • float rotateSensitivity;  // value of sensitivity in which the camera will rotate when the user moves the view eg . plView.camera.rotateSensitivity = 40;  
  • - (void) reset; / / Lets reset the camera settings back to the original position of the camera  eg.[plView.camera reset];











  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
八倍全景漫游者是一款Flash的三维虚拟漫游制作软件,您可以用它将球型全景地图或户型图、场景音乐和解说、文字信息等各种多媒体元素结合起来,创建出带有交互式多地图、热点、雷达、声音、视频、动态文本等效果的专业Flash虚拟漫游。是一款行业领先的虚拟漫游制作软件,可以发布Flash格式的虚拟漫游。其可以广泛应用于房产楼盘、旅游景点、宾馆酒店、校园等场景的虚拟漫游效果的网上展示,让观看者足不出户即可获得身临其境的感受。 功能介绍 1. 创新的功能  * 高质量的flash播放器 全景漫游者拥有高质量的Flash播放器,同时支持球形全景,立方体全景图。 *支持多种格式的全景图:普通图片格式的jpg,透明通道的PNG,视频格式Flv,F4V, Gif动画格式的。Flash格式的swf全景图。 * 动作技术 这是一项全新的技术,让用户可以根据不同的情况添加相应的动作。  * 多地图功能 通过地图功能可以制作更加丰富的虚拟漫游效果,如别墅等。 * 大地图缩放功能 通过大地图缩放功能可以制作更加丰富的虚拟漫游效果,如别墅等。 * 视频墙功能 在场景中加入了视频墙功能等。 * 墙壁画功能 在场景中加入了墙壁画功能等。 * Flash壁功能 在场景中墙壁中 加入了Flash功能等。 * 弹出图像,视频,Flash 在场景中的一些重要位置添加弹出图像,可以着重展示这块区域的效果。  * 性能增强 全景漫游者运用了更好的算法,可以支持诸如8000*4000及以上精度的图片,并且发布的虚拟漫游运行起来效果更平滑、更稳定。  * 组件外观 可以自定义所有组件的外观。 * 自主漫游 可以自主进行漫游。    2 交互功能 通过使用热点、雷达及导航组件,可以使制作的虚拟漫游更具有交互性:  * 热点 热点可以添加在场景和地图中,点击它可以切换到另一个场景、地图、URL、声音及弹出图像等。  * 雷达 雷达添加到地图中并与某一场景同步,使观看者可以轻松地识别出所看场景的具体方位。  * 导航组件  缩略图、组合框及列表框可以让观看者在不同场景、地图及漫游路线之间任意地转换。 * 走入效果 场景切换过程中增加了一种走入效果,即让观看者感觉自己是从一个场景走入到另一个场景。  3 发布多版本  可以根据用户的需要,发布flash player 10.0版本,或者flash player 9.0版本。 4 多媒体  全景漫游者在支持多媒体方面有了很大的进步,诸如支持视频虚拟漫游的发布及多种音频格式:  * 发布视频虚拟漫游 新版本中虚拟漫游可以发布成视频,如"flv", "3gp", "mp4", "mov"等格式。 * 多种音频格式 除了.au的音频格式,新版本还支持.mp3、.wav、.midi音频格式。可以根据不同的场景,切换不同的声音。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值