notice: Flash editor updated! Join the development! Thanks to MiniBuilder


embed

FORKED
  1. // forked from sake's PV3Dその8 Pixels使ってみる
  2. /*
  3.    久々のPV3D。
  4.    やっぱASは打ってて楽しい。
  5. */
  6. package
  7. {
  8.     import flash.events.Event;
  9.     import flash.filters.BlurFilter;
  10.     import org.papervision3d.core.effects.BitmapLayerEffect;
  11.     import org.papervision3d.core.effects.utils.BitmapClearMode;
  12.     import org.papervision3d.core.geom.Pixels;
  13.     import org.papervision3d.core.geom.renderables.Pixel3D;
  14.     import org.papervision3d.view.BasicView;
  15.     import org.papervision3d.view.layer.BitmapEffectLayer;
  16.     [SWF(width="465", height="465", backgroundColor="0x000000", frameRate="40")]
  17.     public class PV3D_pixels extends BasicView
  18.     {
  19.         private var pixels:Pixels;
  20.         private var rotateX:Number;
  21.         private var rotateY:Number;
  22.         public function PV3D_pixels()
  23.         {
  24.             super(00truetrue);
  25.             var layer:BitmapEffectLayer=new BitmapEffectLayer(viewport, 800800true0, BitmapClearMode.CLEAR_PRE, true);
  26.             viewport.containerSprite.addLayer(layer);
  27.             layer.addEffect(new BitmapLayerEffect(new BlurFilter(884), false));
  28.             camera.z=-500;
  29.             rotateX=rotateY=0;
  30.             pixels=new Pixels(layer);
  31.             scene.addChild(pixels);
  32.             for(var i:int=0; i < 1000; i++)
  33.             {
  34.                 // 赤
  35.                 var theta1:Number=360 * Math.random() * Math.PI / 180;
  36.                 var theta2:Number=(180 * Math.random() - 90) * Math.PI / 180;
  37.                 var radius:Number=200;
  38.                 var xx:Number=radius * Math.cos(theta2) * Math.sin(theta1);
  39.                 var yy:Number=radius * Math.sin(theta2);
  40.                 var zz:Number=radius * Math.cos(theta2) * Math.cos(theta1);
  41.                 var p:Pixel3D=new Pixel3D((0xffff0000), xx, yy, zz);
  42.                 pixels.addPixel3D(p);
  43.                 // 黄色
  44.                 theta1=360 * Math.random() * Math.PI / 180;
  45.                 theta2=(180 * Math.random() - 90) * Math.PI / 180;
  46.                 radius=200;
  47.                 xx=radius * Math.cos(theta2) * Math.sin(theta1);
  48.                 yy=radius * Math.sin(theta2);
  49.                 zz=radius * Math.cos(theta2) * Math.cos(theta1);
  50.                 p=new Pixel3D((0xffffff00), xx, yy, zz);
  51.                 pixels.addPixel3D(p);
  52.                 // 白
  53.                 theta1=360 * Math.random() * Math.PI / 180;
  54.                 theta2=(180 * Math.random() - 90) * Math.PI / 180;
  55.                 radius=200;
  56.                 xx=radius * Math.cos(theta2) * Math.sin(theta1);
  57.                 yy=radius * Math.sin(theta2);
  58.                 zz=radius * Math.cos(theta2) * Math.cos(theta1);
  59.                 p=new Pixel3D((0xffffffff), xx, yy, zz);
  60.                 pixels.addPixel3D(p);
  61.                 // オレンジ
  62.                 theta1=360 * Math.random() * Math.PI / 180;
  63.                 theta2=(180 * Math.random() - 90) * Math.PI / 180;
  64.                 radius=200;
  65.                 xx=radius * Math.cos(theta2) * Math.sin(theta1);
  66.                 yy=radius * Math.sin(theta2);
  67.                 zz=radius * Math.cos(theta2) * Math.cos(theta1);
  68.                 p=new Pixel3D((0xffff8c00), xx, yy, zz);
  69.                 pixels.addPixel3D(p);
  70.             }
  71.             addEventListener(Event.ENTER_FRAME, onFrame);
  72.         }
  73.         private function onFrame(e:Event):void
  74.         {
  75.             rotateX+=(-viewport.containerSprite.mouseX - rotateX) * 0.1;
  76.             rotateY+=(-viewport.containerSprite.mouseY - rotateY) * 0.1;
  77.             pixels.rotationY=rotateX;
  78.             pixels.rotationX=rotateY;
  79.             startRendering();
  80.         }
  81.     }
  82. }
noswf
  1. //forked from :   sake's  PV3Dその8 Pixels使ってみる
  2. package
  3. {
  4.     import flash.events.Event;
  5.     import flash.filters.BlurFilter;
  6.     
  7.     import org.papervision3d.core.effects.BitmapLayerEffect;
  8.     import org.papervision3d.core.effects.utils.BitmapClearMode;
  9.     import org.papervision3d.core.geom.Pixels;
  10.     import org.papervision3d.core.geom.renderables.Pixel3D;
  11.     import org.papervision3d.materials.special.ParticleMaterial;
  12.     import org.papervision3d.objects.DisplayObject3D;
  13.     import org.papervision3d.objects.special.ParticleField;
  14.     import org.papervision3d.view.BasicView;
  15.     import org.papervision3d.view.layer.BitmapEffectLayer;
  16.     [SWF(width="512", height="512", backgroundColor="0x000000", frameRate="40")]
  17.     public class PapervisionEffect2 extends BasicView
  18.     {
  19.         private var ary:Array;
  20.         private var layer:BitmapEffectLayer;
  21.         
  22.         public function PapervisionEffect2()
  23.         {
  24.             camera.zoom = 100;
  25.             layer=new BitmapEffectLayer(viewport, 500500true, 0x000000, BitmapClearMode.CLEAR_PRE, true);
  26.             viewport.containerSprite.addLayer(layer);
  27.             layer.addEffect(new BitmapLayerEffect(new BlurFilter(884), false));
  28.             startRendering();
  29.             
  30.             ary = [];
  31.             for(var i:uint = 0; i < 5; i++){
  32.                 createPixels();
  33.             }
  34.             
  35.             addEventListener(Event.ENTER_FRAME, onFrame);
  36.         }
  37.         
  38.         private function createPixels():void{
  39.             var color:uint = (0xff << 24 | (0xff-0x99)*Math.random()+0x99 << 16  | 0x66*Math.random() << 8 | 0xff);
  40.             var rX:Number;
  41.             var rY:Number;
  42.             for(var i:uint = 0; i < 10; i++){    
  43.                 var pixels:Particle = new Particle(layer);
  44.                 scene.addChild(pixels);
  45.                 for(var s:Number=0; s < Math.PI * 2; s+=0.02){
  46.                     var p:Pixel3D=new Pixel3D(color, Math.cos(s)*200, Math.sin(s)*2000);
  47.                     pixels.addPixel3D(p);
  48.                 }
  49.                 pixels.x = 0;
  50.                 pixels.y = 0;
  51.                 pixels.vrx = Math.random()*10-5;
  52.                 pixels.vry = Math.random()*10-5;
  53.                 
  54.                 ary.push(pixels);
  55.             }
  56.         }
  57.         private function onFrame(e:Event):void
  58.         {
  59.             var pixels:Particle;
  60.             var i:uint = ary.length;
  61.             while(i--){
  62.                 pixels = ary[i];
  63.                 pixels.rotationX += pixels.vrx;
  64.                 pixels.rotationY += pixels.vry;
  65.             }
  66.             camera.x += (stage.stageWidth/2 - mouseX)/10;
  67.             camera.y += (stage.stageHeight/2 - mouseY)/10;
  68.             camera.z += (stage.stageHeight/2 - mouseY)/10;
  69.         }
  70.     }
  71. }
  72.     import org.papervision3d.core.geom.Pixels;
  73.     import org.papervision3d.view.layer.BitmapEffectLayer;
  74.     
  75. class Particle extends Pixels{
  76.     public var vrx:Number;
  77.     public var vry:Number;
  78.     
  79.     public function Particle(effectLayer:BitmapEffectLayer, name:String = "pixels3D"):void{
  80.         super(effectLayer, name);
  81.     }
  82. }
noswf
  1. // forked from sake's PV3Dその8 Pixels使ってみる
  2. /*
  3.    久々のPV3D。
  4.    やっぱASは打ってて楽しい。
  5. */
  6. package
  7. {
  8.     import flash.events.Event;
  9.     import flash.filters.BlurFilter;
  10.     import org.papervision3d.core.effects.BitmapLayerEffect;
  11.     import org.papervision3d.core.effects.utils.BitmapClearMode;
  12.     import org.papervision3d.core.geom.Pixels;
  13.     import org.papervision3d.core.geom.renderables.Pixel3D;
  14.     import org.papervision3d.view.BasicView;
  15.     import org.papervision3d.view.layer.BitmapEffectLayer;
  16.     [SWF(width="465", height="465", backgroundColor="0x000000", frameRate="40")]
  17.     public class PV3D_pixels extends BasicView
  18.     {
  19.         private var pixels:Pixels;
  20.         private var rotateX:Number;
  21.         private var rotateY:Number;
  22.                   private var pixelList:Array = [];
  23.         public function PV3D_pixels()
  24.         {
  25.             super(00truetrue);
  26.             var layer:BitmapEffectLayer=new BitmapEffectLayer(viewport, 800800true0, BitmapClearMode.CLEAR_PRE, true);
  27.             viewport.containerSprite.addLayer(layer);
  28.             layer.addEffect(new BitmapLayerEffect(new BlurFilter(222), false));
  29.             camera.z=-500;
  30.             rotateX=rotateY=0;
  31.             pixels=new Pixels(layer);
  32.             scene.addChild(pixels);
  33.             for(var i:int=0; i < 500; i++)
  34.             {
  35.                 // 赤
  36.                 var theta1:Number=360 * Math.random() * Math.PI / 180;
  37.                 var theta2:Number=(180 * Math.random() - 90) * Math.PI / 180;
  38.                 var radius:Number=200;
  39.                 var xx:Number=radius * Math.cos(theta2) * Math.sin(theta1);
  40.                 var yy:Number=radius * Math.sin(theta2);
  41.                 var zz:Number=radius * Math.cos(theta2) * Math.cos(theta1);
  42.                 var p:Pixel3DEX=new Pixel3DEX((0xffff0000), xx, yy, zz);
  43.                 pixels.addPixel3D(p);
  44.                                     pixelList.push(p);
  45.                 // 黄色
  46.                 theta1=360 * Math.random() * Math.PI / 180;
  47.                 theta2=(180 * Math.random() - 90) * Math.PI / 180;
  48.                 radius=200;
  49.                 xx=radius * Math.cos(theta2) * Math.sin(theta1);
  50.                 yy=radius * Math.sin(theta2);
  51.                 zz=radius * Math.cos(theta2) * Math.cos(theta1);
  52.                 p=new Pixel3DEX((0xffffff00), xx, yy, zz);
  53.                 pixels.addPixel3D(p);
  54.                                     pixelList.push(p);
  55.                 // 白
  56.                 theta1=360 * Math.random() * Math.PI / 180;
  57.                 theta2=(180 * Math.random() - 90) * Math.PI / 180;
  58.                 radius=200;
  59.                 xx=radius * Math.cos(theta2) * Math.sin(theta1);
  60.                 yy=radius * Math.sin(theta2);
  61.                 zz=radius * Math.cos(theta2) * Math.cos(theta1);
  62.                 p=new Pixel3DEX((0xffffffff), xx, yy, zz);
  63.                 pixels.addPixel3D(p);
  64.                                     pixelList.push(p);
  65.                 // オレンジ
  66.                 theta1=360 * Math.random() * Math.PI / 180;
  67.                 theta2=(180 * Math.random() - 90) * Math.PI / 180;
  68.                 radius=200;
  69.                 xx=radius * Math.cos(theta2) * Math.sin(theta1);
  70.                 yy=radius * Math.sin(theta2);
  71.                 zz=radius * Math.cos(theta2) * Math.cos(theta1);
  72.                 p=new Pixel3DEX((0xffff8c00), xx, yy, zz);
  73.                 pixels.addPixel3D(p);
  74.                                     pixelList.push(p);
  75.             }
  76.             addEventListener(Event.ENTER_FRAME, onFrame);
  77.         }
  78.         private function onFrame(e:Event):void
  79.         {
  80.                             /*
  81.             rotateX+=(-viewport.containerSprite.mouseX - rotateX) * 0.1;
  82.             rotateY+=(-viewport.containerSprite.mouseY - rotateY) * 0.1;
  83.             pixels.rotationY=rotateX;
  84.             pixels.rotationX=rotateY;
  85.                             */
  86.                             for(var i:int = 0;i < pixelList.length;i++){
  87.                                 var p:Pixel3DEX = Pixel3DEX(pixelList[i]);
  88.                                 p.move();
  89.                             }
  90.             startRendering();
  91.         }
  92.     }
  93. }
  94. import org.papervision3d.core.geom.renderables.Pixel3D;
  95. import flash.events.Event;
  96. class Pixel3DEX extends Pixel3D{
  97.     private var startX:Number;
  98.     private var startY:Number;
  99.     private var startZ:Number;
  100.     private var rgb:uint;
  101.     private var alpha:Number;
  102.     private var startAlpha:Number;
  103.     private var decrease:Number = 0.99;
  104.     public function Pixel3DEX(color:uint,x:Number=0,y:Number=0,z:Number=0){
  105.         super(color,x,y,z);
  106.         startX = x;
  107.         startY = y;
  108.         startZ = z;
  109.         rgb = 0xffffff & color;
  110.         startAlpha = alpha = (0xff000000 & color) >> 48;
  111.         decrease = Math.random() * 0.09 + 0.9;
  112.     }
  113.     
  114.     public function move():void{
  115.         
  116.         //Pixel3Dってアルファきかないのかしらん?
  117.         if(Math.abs(this.x) < Math.abs(this.startX * 0.1)){
  118.             this.x = startX;
  119.             this.y = startY;
  120.             this.z = startZ;
  121.             this.alpha = startAlpha;
  122.             decrease = Math.random() * 0.09 + 0.9;
  123.         }else{
  124.             this.x *= decrease;
  125.             this.y *= decrease;
  126.             this.z *= decrease;
  127.             alpha *= decrease;
  128.             var a:uint = Math.floor(alpha);
  129.             this.color = uint(alpha) << 48 | color;
  130.         }
  131.     }
  132. }
noswf

PV3Dその8 Pixels使ってみる 土星 [diff(111)]

  1. // forked from sake's PV3Dその8 Pixels使ってみる
  2. /*
  3.     以下を参考にさせて頂きました。
  4.     PV3Dその5 Planeを球体っぽく並べるのをPV3Dで。 http://wonderfl.kayac.com/code/8967e3b45baea801deac174fabea02453fc94164
  5.     PV3Dその8 Pixels使ってみる http://wonderfl.kayac.com/code/834affa8c7b8c668f2de620b62fa61c217df2805
  6. */
  7. package
  8. {
  9.     import flash.events.Event;
  10.     import flash.filters.BlurFilter;
  11.     
  12.     import org.papervision3d.core.effects.BitmapLayerEffect;
  13.     import org.papervision3d.core.effects.utils.BitmapClearMode;
  14.     import org.papervision3d.core.geom.Pixels;
  15.     import org.papervision3d.core.geom.renderables.Pixel3D;
  16.     import org.papervision3d.view.BasicView;
  17.     import org.papervision3d.view.layer.BitmapEffectLayer;
  18.     
  19.     [SWF(width = "465", height = "465", backgroundColor = "0x000000", frameRate = "30")]
  20.     public class Saturn extends BasicView
  21.     {
  22.         private var _pixels:Pixels;
  23.         
  24.         
  25.         public function Saturn()
  26.         {
  27.             graphics.beginFill(0x000000);
  28.             graphics.drawRect(00465465);
  29.             var layer:BitmapEffectLayer = new BitmapEffectLayer(viewport, stage.stageWidth, stage.stageHeight, true0, BitmapClearMode.CLEAR_PRE, true); 
  30.             viewport.containerSprite.addLayer(layer);
  31.             layer.addEffect(new BitmapLayerEffect(new BlurFilter(884), false));
  32.             _pixels = new Pixels(layer);
  33.             scene.addChild(_pixels);
  34.             
  35.             globe();
  36.             ring();
  37.             dust();
  38.             
  39.             _pixels.rotationZ = 30;
  40.             camera.y = -150;
  41.             
  42.             startRendering();
  43.         }
  44.         
  45.         private function globe():void
  46.         {
  47.             var radius:int = 250;
  48.             var H:int=(2 * radius * Math.PI) / 2 / 30;
  49.             var theta1:Number;
  50.             var theta2:Number=90;
  51.             var color:uint;
  52.             
  53.             for(var i:int=0; i < H; i++)
  54.             {
  55.                 (i%2 == 0)? color=0xFFFCBD5C : color=0xFFC68A2F;
  56.                 theta1=0;
  57.                 var pn:int=Math.floor((2 * radius * Math.cos(theta2 * Math.PI / 180) * Math.PI) / 20);
  58.                 for(var j:int=0; j < pn; j++)
  59.                 {
  60.                     var xx:int=radius * Math.cos(theta2 * Math.PI / 180) * Math.sin(theta1 * Math.PI / 180);
  61.                     var yy:int=radius * Math.sin(theta2 * Math.PI / 180);
  62.                     var zz:int=radius * Math.cos(theta2 * Math.PI / 180) * Math.cos(theta1 * Math.PI / 180);
  63.                     var p:Pixel3D=new Pixel3D((color), xx, yy, zz);
  64.                     _pixels.addPixel3D(p);
  65.                     theta1+=360 / pn;
  66.                 }
  67.                 theta2-=180 / H;
  68.             }
  69.         }
  70.         
  71.         private function ring():void
  72.         {
  73.             var radius:int = 450;
  74.             for (var i:uint=0; i<3000; i++)
  75.             {
  76.                 var theta:Number=360 * Math.random() * Math.PI / 180;
  77.                 var xx:Number=radius * Math.sin(theta) + Math.random()*100 - 50;
  78.                 var yy:Number=0;
  79.                 var zz:Number=radius * Math.cos(theta) + Math.random()*100 - 50;
  80.                 var p:Pixel3D=new Pixel3D((0xFF8E6F53), xx, yy, zz);
  81.                 _pixels.addPixel3D(p);
  82.             }
  83.         }
  84.         
  85.         private function dust():void
  86.         {
  87.             for (var i:uint=0; i<100; i++)
  88.             {
  89.                 var xx:Number=Math.random()*930-465;
  90.                 var yy:Number=Math.random()*930-465;
  91.                 var zz:Number=Math.random()*930-465;
  92.                 var p:Pixel3D=new Pixel3D(((Math.random()*0x80 + 0x60) << 24 | 0xFF << 16 | 0xFF << 8 | 0xFF), xx, yy, zz);
  93.                 _pixels.addPixel3D(p);
  94.             }
  95.         }
  96.         
  97.         override protected function onRenderTick(e:Event=null):void
  98.         {
  99.             _pixels.yaw(0.3);
  100.             renderer.renderScene(scene, camera, viewport);
  101.         }
  102.     }
  103. }
noswf
  1. // forked from sake's PV3Dその8 Pixels使ってみる
  2. /*
  3.    久々のPV3D。
  4.    やっぱASは打ってて楽しい。
  5. */
  6. package
  7. {
  8.     import flash.events.Event;
  9.     import flash.filters.BlurFilter;
  10.     import org.papervision3d.core.effects.BitmapLayerEffect;
  11.     import org.papervision3d.core.effects.utils.BitmapClearMode;
  12.     import org.papervision3d.core.geom.Pixels;
  13.     import org.papervision3d.core.geom.renderables.Pixel3D;
  14.     import org.papervision3d.view.BasicView;
  15.     import org.papervision3d.view.layer.BitmapEffectLayer;
  16.     [SWF(width="465", height="465", backgroundColor="0x000000", frameRate="40")]
  17.     public class PV3D_pixels extends BasicView
  18.     {
  19.         private var pixels:Pixels;
  20.         private var rotateX:Number;
  21.         private var rotateY:Number;
  22.         public function PV3D_pixels()
  23.         {
  24.             super(00truetrue);
  25.             var layer:BitmapEffectLayer=new BitmapEffectLayer(viewport, 800800true0, BitmapClearMode.CLEAR_PRE, true);
  26.             viewport.containerSprite.addLayer(layer);
  27.             layer.addEffect(new BitmapLayerEffect(new BlurFilter(224), true));
  28.             camera.z=-500;
  29.             rotateX=rotateY=0;
  30.             pixels=new Pixels(layer);
  31.             scene.addChild(pixels);
  32.             for(var i:int=0; i < 1000; i++)
  33.             {
  34.                 // 赤
  35.                 var theta1:Number=360 * Math.random() * Math.PI / 180;
  36.                 var theta2:Number=(180 * Math.random() - 90) * Math.PI / 180;
  37.                 var radius:Number=300 * Math.random();
  38.                 var xx:Number=radius * Math.cos(theta2) * Math.sin(theta1);
  39.                 var yy:Number=radius * Math.sin(theta2 * 2);
  40.                 var zz:Number=radius * Math.cos(theta2) * Math.cos(theta1);
  41.                 var p:Pixel3D=new Pixel3D((0xff00ffff), xx, yy, zz);
  42.                 pixels.addPixel3D(p);
  43.                 // 黄色
  44.                 theta1=360 * Math.random() * Math.PI / 180;
  45.                 theta2=(180 * Math.random() - 90) * Math.PI / 180;
  46.                 radius=300 * Math.random();
  47.                 xx=radius * Math.cos(theta2) * Math.sin(theta1);
  48.                 yy=radius * Math.sin(theta2);
  49.                 zz=radius * Math.cos(theta2) * Math.cos(theta1);
  50.                 p=new Pixel3D((0xff00ff00), xx, yy, zz);
  51.                 pixels.addPixel3D(p);
  52.                 // 白
  53.                 theta1=360 * Math.random() * Math.PI / 180;
  54.                 theta2=(180 * Math.random() - 90) * Math.PI / 180;
  55.                 radius=200 * Math.random();
  56.                 xx=radius * Math.cos(theta2) * Math.sin(theta1);
  57.                 yy=radius * Math.sin(theta2);
  58.                 zz=radius * Math.cos(theta2) * Math.cos(theta1);
  59.                 p=new Pixel3D((0xffffffff), xx, yy, zz);
  60.                 pixels.addPixel3D(p);
  61.                 // オレンジ
  62.                 theta1=360 * Math.random() * Math.PI / 180;
  63.                 theta2=(180 * Math.random() - 90) * Math.PI / 180;
  64.                 radius=300 * Math.random();
  65.                 xx=radius * Math.cos(theta2) * Math.sin(theta1);
  66.                 yy=radius * Math.sin(theta2);
  67.                 zz=radius * Math.cos(theta2) * Math.cos(theta1);
  68.                 p=new Pixel3D((0xffff00ff), xx, yy, zz);
  69.                 pixels.addPixel3D(p);
  70.             }
  71.             addEventListener(Event.ENTER_FRAME, onFrame);
  72.         }
  73.         private function onFrame(e:Event):void
  74.         {
  75.             rotateX+=(-viewport.containerSprite.mouseX - rotateX) * 0.1;
  76.             rotateY+=(-viewport.containerSprite.mouseY - rotateY) * 0.1;
  77.             pixels.rotationY=rotateX;
  78.             pixels.rotationX=rotateY;
  79.             startRendering();
  80.         }
  81.     }
  82. }
noswf
Get Adobe Flash Player