Originally, a slight change to the coordinate method can achieve this cylindrical rotation effect. As shown in the figure above, the principle is to use two cycles for replication. When copying, you can change the coordinate of the Y axis to achieve the above effect:
Look at the source code:
Package <br/> {<br/> Import flash. display. sprite; <br/> Import flash. events. *; <br/> Import Org. papervision3d. cameras. camera3d; <br/> Import Org. papervision3d. scenes. scene3d; <br/> Import Org. papervision3d. materials. *; <br/> Import Org. papervision3d. objects. displayobject3d; <br/> Import Org. papervision3d. view. viewport3d; <br/> Import Org. papervision3d. render. basicrenderengine; <br/> Import Org. papervision3d. objects. primitives. *; <br/> Import Org. papervision3d. materials. utils. materialslist; </P> <p> public class example extends sprite <br/> {<br/> private var viewport: viewport3d = new viewport3d (800,600 ); // create a window <br/> private var Renderer: basicrenderengine = new basicrenderengine (); // rendering engine <br/> private var camera: camera3d = new camera3d (); // 'camera <br/> private var PC: plane = new plane (); <br/> private var scene: scene3d = new scene3d (); // create a 3D scenario <br/> private var angle: Number = 0; // angle <br/> private var N: Int = 1; <br/> Public Function example () <br/>{< br/> init3d (); // initialize the 3D model <br/>}< br/> private function init3d (): void <br/>{< br/> addchild (viewport ); // Add a display window <br/> camera. z = 400; <br/> camera.tar get = pc; <br/> var num: Int = 100; <br/> var numofrotations: Number = 5; <br/> var angleper: Number = (math. pI * 2) * 5)/num; <br/> var ypos: Number = 0; <br/> // var PA: array = new array (); <br/> // create a plane and assign a texture <br/> for (var j: uint = 0; j <6; j ++) <br/>{< br/> for (var I: uint = 0; I <50; I ++) <br/>{< br/> var CM: bitmapassetmaterial = new bitmapassetmaterial ("air1"); <br/> CM. oneside = false; <br/> var P: plane = new plane (mm, 100,100); <br/> P. X = math. cos (I * angleper) * 500; <br/> P. z = math. sin (I * angleper) * 500; <br/> P. y = 120 * j; // change the Y axis coordinates to achieve the cylindrical effect <br/> P. rotationy = (-I * angleper) * (180/math. pi) + 270; <br/> scene. addchild (p); <br/>}< br/> addeventlistener (event. enter_frame, run); </P> <p >}< br/> private function run (Event: Event): void <br/>{< br/> var Dist: number = (stage. mousey)-stage. stageheight * 0.5) *-0.1; <br/> var dist2: Number = (stage. mousex)-stage. stagewidth * 0.5) * 0.0005; <br/> Angle + = dist2; <br/> camera. X = math. cos (angle) * 1000; <br/> camera. z = math. sin (angle) * 1000; <br/> camera. Y + = DIST; <br/> If (camera. Y <369) <br/>{< br/> camera. y = 369; <br/>}< br/> If (camera. y> 4755) <br/>{< br/> camera. y = 4755; <br/>}< br/> PC. y = camera. y; <br/> Renderer. renderscene (scene, camera, viewport); // render the image <br/>}< br/>}
Key points:
This is because the image is copied by scanning two cycles. After each External Loop is completed, P. Y in the inner loop will change accordingly.
Create a cylindrical effect.
P. Y = 120 * j; // change the Y axis coordinates to achieve the cylindrical effect.
For (var j: uint = 0; j <6; j ++) <br/>{< br/> for (var I: uint = 0; I <50; I ++) <br/>{< br/> var CM: bitmapassetmaterial = new bitmapassetmaterial ("air1"); <br/> CM. oneside = false; <br/> var P: plane = new plane (mm, 100,100); <br/> P. X = math. cos (I * angleper) * 500; <br/> P. z = math. sin (I * angleper) * 500; <br/> P. y = 120 * j; // change the Y axis coordinates to achieve the cylindrical effect <br/> P. rotationy = (-I * angleper) * (180/math. pi) + 270; <br/> scene. addchild (p); <br/>}< br/>}
2. Change the effect
We will rebuild it. By modifying its radius, we will find that there are different effects.
For (var j: uint = 0; j <6; j ++) <br/>{< br/> for (var I: uint = 0; I <50; I ++) <br/>{< br/> var CM: bitmapassetmaterial = new bitmapassetmaterial ("air1"); <br/> CM. oneside = false; <br/> var P: plane = new plane (mm, 100,100); <br/> P. X = math. cos (I * angleper) * (350 + J * 30); <br/> P. z = math. sin (I * angleper) * (350 + J * 30); <br/> P. y = 120 * j; // change the Y axis coordinates to achieve the cylindrical effect <br/> P. rotationy = (-I * angleper) * (180/math. pi) + 270; <br/> scene. addchild (p); <br/>}< br/>}