首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

圆球组成的球体,入门PV3D

2012-12-21 
球体组成的球体,入门PV3Dpackage {import flash.display.Spriteimport flash.events.Eventimport org.pa

球体组成的球体,入门PV3D

package {import flash.display.Sprite;import flash.events.Event;import org.papervision3d.objects.DisplayObject3D;import org.papervision3d.objects.primitives.Sphere;import org.papervision3d.scenes.Scene3D;import org.papervision3d.view.BasicView;public class VerticesExample extends BasicView{/** * 声明一个实例 * */private var pivotDO3D:DisplayObject3D;public function VerticesExample(){this.init();this.startRendering();}/** * 初始化方法 * */private function init():void{pivotDO3D = new DisplayObject3D();scene.addChild(pivotDO3D);var bigSphere:Sphere = new Sphere(null,700,12,8);/** * 循环变量大球体的顶点数组 * */var numberOfVerts:uint = bigSphere.geometry.vertices.length;for(var i:uint = 0;i<numberOfVerts;i++){var smallSphere:Sphere = new Sphere(null,Math.random()*30,2,2);smallSphere.x = bigSphere.geometry.vertices[i].x;smallSphere.y = bigSphere.geometry.vertices[i].y;smallSphere.z = bigSphere.geometry.vertices[i].z;pivotDO3D.addChild(smallSphere);}pivotDO3D.addChild(bigSphere);}/** * 重写渲染功能 * */override protected function onRenderTick(event:Event=null):void{pivotDO3D.localRotationY--;super.onRenderTick();}}}

热点排行