[Top] IOS panoramic view effect demo

Source: Internet
Author: User

Demo function: provides a panoramic view, which allows you to browse the page from top to bottom, right to back, and right.

Demo Description: In the project, pano.jpg is a texture. Place the image on the Ball Model, set the camera to the center of the ball, and view the texture on the inside ball.

Demo screenshot:

Demo mainCode: Plview. M section (display the panoramic view)

 

# Import "plview. H "@ interface plview ()-(void) initializevalues; @ end @ implementation plview @ synthesize type; @ synthesize camera; # pragma mark-# pragma mark init methods-(void) allocandinitvariables {[Super allocandinitvariables]; scene = [plscene scene]; Renderer = [plrenderer rendererwithview: Self scene: [scene retain]; camera = [plcamera camera]; -(void) initializevalues {[Super initializevalues]; textures = [[Nsmutablearray array] retain]; type = plviewtypeunknown;}-(void) reset {If (CAMERA) [Camera Reset]; [Super Reset];} # pragma mark-# pragma mark property methods-(void) settype :( plviewtype) value {type = value; If (sceneelement) [sceneelement release]; Switch (value) {Case plviewtypecylindrical: camera. fovfactorrange = plrangemake (kdefaultcylinderfovfactorminvalue, kdefaultcylinderfovfactormaxvalue); sceneel Ement = [plcylinder cylinder]; break; Case plviewtypespherical: Camera. fovfactorrange = plrangemake (kdefaultfovfactorminvalue, kdefaultfovfactormaxvalue); sceneelement = [plsphere sphere]; break; Case plviewtypecubefaces: Camera. fovfactorrange = plrangemake (kdefaultfovfactorminvalue, kdefafofovfactormaxvalue); sceneelement = [plcube cube]; break; Case plviewtypeunknown: sceneelement = nil; break; default: [neuron Xception raise: @ "invalid panorama type" Format: @ "type unknown", nil]; break;} If (sceneelement) {sceneelement = [sceneelement retain]; for (pltexture * texture in textures) [sceneelement addtexture: texture]; [scene addelement: sceneelement] ;}# Pragma mark-# pragma mark draw methods-(void) drawview {[Super drawview]; [sceneelement clonepropertiesof: Camera]; [scene. currentcamera clonecameraproperties: Camera]; Scene. currentcamera. Rotation = plrotationmake (0.0f, 0.0f, 0.0f); scene. currentcamera. Position = plpositionmake (0.0f, 0.0f, 0.0f); If (! Isvalidforfov &&! Isvalidfororientation) [sceneelement rotatewithstartpoint: startpoint endpoint: endpoint sensiti.pdf: Camera. rotatesensitider]; [Renderer render]; camera. rotation = plrotationmake (sceneelement. pitch, sceneelement. yaw, sceneelement. roll) ;}# Pragma mark-# pragma mark FOV methods-(bool) calculatefov :( nsset *) touches {If ([Super calculatefov: touches]) {[Camera addfovwithdistance: fovdistance]; [scene. currentcamera addfovwithdistance: fovdistance]; return yes;} return no;} # pragma mark-# pragma mark texture methods-(void) addtexture :( pltexture *) texture {[textures addobject: texture]; If (sceneelement) [sceneelement addtexture: texture];}-(void) removetexture :( pltexture *) texture {[textures removeobject: texture]; If (sceneelement) [sceneelement removetexture: texture];}-(void) returns :( nsuinteger) index {[textures removeobjectatindex: Index]; If (sceneelement) [sceneelement removetextureatindex: Index];} -(void) removealltextures {[textures attributes]; If (sceneelement) [sceneelement attributes];} # pragma mark-# pragma mark orientation methods-(void) orientationchanged :( uideviceorientation) orientation {If (CAMERA & sceneelement) {Camera. orientation = orientation; sceneelement. orientation = orientation; camera. pitchrange = sceneelement. pitchrange; camera. yawrange = sceneelement. yawrange; camera. rollrange = sceneelement. rollrange; camera. rotation = plrotationmake (sceneelement. pitch, sceneelement. yaw, sceneelement. roll) ;}# Pragma mark-# pragma mark dealloc methods-(void) dealloc {If (textures) [textures release]; If (CAMERA) [Camera release]; if (sceneelement) [sceneelement release]; If (scene) [scene release]; If (Renderer) [Renderer release]; [Super dealloc];} @ end

Demo: http://download.csdn.net/detail/donny_zhang/5552467

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.