【iOS】720°全景图 HelloPanorama 介绍以及在使用过程中的一些问题
来源:互联网 发布:电气cad制图软件 编辑:程序博客网 时间:2024/05/29 13:40
HelloPanorama是由国外一名老外写的,2009年最后一版之后再也没有更新,所以现在一直使用的是version 0.1 Beta 。目前可以找到的全景图的开放源代码能找到的只有它,所以还只能用它,这就导致了使用过程中你会遇到很多问题,还没有人解答说明。由于项目所需,我也采用了这个,下面我将自己遇到的问题以及前任总结的经验总结共享一下。
下面我从说两方面,一方面是一些遇到的问题,另一方面是关于的详细介绍,第一次接触该开源框架的从介绍看起,本文的重点在于使用中遇到的问题
1.PanoramaGL使用过程中遇到的一些问题
1).PanoramaGL缩放问题
问题定位路线如下:【前人经验:http://bbs.9ria.com/thread-228628-1-1.html】
1、PLViewBase类的 -(BOOL)calculateFov: (NSSet*)touches,因为是触摸出发缩放,所以开始先想到触摸事件,然后找到了触摸关联FOV的函数。该函数OK。
2、继续向下:进入PLCamera的 -(void)addFovWithDistance: (float)distance;再次log,单步,发现入参没问题,self.fov 这个变量同时其他地方没有呗修改,可以却很诡异的在切换不同全景后,缩放不是最大值1.000,就是最小值-0.20000。
3、怀疑fovSensitivity这个变量出的问题,最后发现是它在每次PLCamera初始话时,就会被赋给默认值。而我们在PLView中的setPanorama函数里调用render时会根据render是否存在,分别调用start或者resizeFromLayer,问题就在resizeFromLayer里每次会根据view的宽高来设置fovSensitivity,那么问题就很清楚了,每次程序启动时,它才会被正确赋值,而其他切换上部选择器时,调用的是start函数,fovSensitivity是默认值。
最后我们修改render的start函数,加入(位置:PanoramaGL->PLRenderer.m->start)-(void)start{ if(!isValid) { @synchronized(self) { isValid = YES; if(scene.currentCamera.fovSensitivity==kDefaultFovSensitivity) { scene.currentCamera.fovSensitivity=(aspect>=1.0f?backingWidth:backingHeight)*10.0f; } } }}
2).PanoramaGL图片模糊问题(或者说图片过于放大)
这个问题很简单,但是却不好找,只需要修改一个宏定义的值,但是刚开始就是找不到。。好了,不废话了;转到正题:这个问题只需要修改PLConstants.h 中的
kPerspectiveValue 的值就可以了,原来的值给的是 290.0f 将它改为255~270之间,即:#define kPerspectiveValue255.0f
关于这个问题,需要了解一下OpenGL中的gluPerspective,具体方法:gluPerspective(GLfloat fovy,GLfloat aspect,GLfloat zNear,GLfloat zFar),我是通过这个方法找到问题答案的,它在库中的位置:【PanoramaGL->PLRenderer->render方法】
-(void)render{@try{if(context && isValid){---------------------------------PLCamera * camera = scene.currentCamera;BOOL isCorrectedRatio = (backingWidth > backingHeight);float zoomFactor = (camera.isFovEnabled ? (isCorrectedRatio ? camera.fovFactorCorrected : camera.fovFactor) : 1.0f);float perspective = kPerspectiveValue + (isCorrectedRatio ? 25.0f : 0.0f); gluPerspective(MIN(perspective * zoomFactor, 359.0f), aspect, kPerspectiveZNear, kPerspectiveZFar);glMatrixMode(GL_MODELVIEW);glLoadIdentity();---------------------------------------}}@catch(NSException *e){}}
3).PanoramaGL图片缩放灵敏度低的问题
该问题还在探索中,解决后会更新,以后遇到的其他问题会 陆续更新
2.关于HelloPanorama的详细介绍
关于它的的介绍与使用,请进入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;l // 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 width, height; // 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 isXAxisEnabled, isYAxisEnabled, isZAxisEnabled; // 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 xRange, yRange, zRange; // Define the range in which it can move in the x, y, z eg.plView.camera.xRange = PLRangeMake (-100, 100);
- BOOL isPitchEnabled, isYawEnabled, isRollEnabled; // 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 pitchRange, yawRange, rollRange; // 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];
- 【iOS】720°全景图 HelloPanorama 介绍以及在使用过程中的一些问题
- 全景图 HelloPanorama 的使用
- bootstrap使用中的一些问题以及解决过程
- Jlink在使用的过程中的一些实用问题
- Jlink在使用的过程中的一些实用问题
- robotium在使用过程中的一些问题和知识点
- MySQL在使用过程中的一些小问题
- 一、H5全景图-朋友圈全景图-720°全景-VR -----工具使用
- 一、H5全景图-朋友圈全景图-720°全景-VR -----工具使用
- H5全景图-朋友圈全景图-720°全景-VR -----工具使用
- 安装CocoaPods以及一些常用命令,过程中的一些问题
- 在使用WSAAsyncSelect中的搜集到的一些资料以及发现的一些问题
- QTcpSocket使用过程中的一些问题记录
- MongoDB使用过程中的一些问题
- xe8End使用过程中的一些问题
- WebViews使用过程中的一些问题
- QTcpSocket使用过程中的一些问题记录
- webrtc使用过程中的一些问题
- alter database datafile offline drop 和 alter tablespace drop datafile 的区别
- 次方求模
- Paparazzi 数据链
- leecode5 Longest Palindromic Substring
- 页面生命周期
- 【iOS】720°全景图 HelloPanorama 介绍以及在使用过程中的一些问题
- Lua开发环境搭建
- Spring中的事务管理
- 解决TextView在显示文字的时候,一行还没显示满就跳到下一行(最新)
- 获取图片文件尺寸效率比较
- Android四大主件之服务Service
- web项目访问首页问题
- 云计算 基础
- 使用IOCP需要注意的一些问题~~(不断补充)