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