Fork me on GitHub

Fountain

Flash required: You need version 10 or later of the free Flash player from Adobe to use this content. To download and install the free player from Adobe's web site click here.

Rendering pixel particles in 3D.

package
{
  import org.flintparticles.threeD.emitters.Emitter3D;
  import org.flintparticles.threeD.renderers.PixelRenderer;
  import org.flintparticles.threeD.renderers.controllers.OrbitCamera;

  import flash.display.Sprite;
  import flash.filters.BlurFilter;
  import flash.filters.ColorMatrixFilter;
  import flash.geom.Rectangle;
  import flash.geom.Vector3D;

  [SWF(width='500', height='500', frameRate='61', backgroundColor='#000000')]
  
  public class Main extends Sprite
  {
    private var emitter:Emitter3D;
    private var renderer:PixelRenderer;
    private var orbitter:OrbitCamera;
    
    public function Main()
    {
      emitter = new Fountain();
      
      renderer = new PixelRenderer( new Rectangle( -250, -250, 500, 500 ), false );
      renderer.camera.dolly( -300 );
      renderer.camera.lift( 100 );
      renderer.camera.target = new Vector3D( 0, -100, 0 );
      renderer.addFilter( new BlurFilter( 2, 2, 1 ), true );
      renderer.addFilter( new ColorMatrixFilter( [ 1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0.99,0 ] ), true );
      renderer.addEmitter( emitter );
      renderer.x = 250;
      renderer.y = 250;
      addChild( renderer );
      
      emitter.start( );
      
      orbitter = new OrbitCamera( stage, renderer.camera );
      orbitter.start();
    }
  }
}
package
{
  import org.flintparticles.common.actions.Age;
  import org.flintparticles.common.counters.Steady;
  import org.flintparticles.common.initializers.ColorInit;
  import org.flintparticles.common.initializers.Lifetime;
  import org.flintparticles.threeD.actions.Accelerate;
  import org.flintparticles.threeD.actions.Move;
  import org.flintparticles.threeD.emitters.Emitter3D;
  import org.flintparticles.threeD.initializers.Velocity;
  import org.flintparticles.threeD.zones.DiscZone;

  import flash.geom.Vector3D;

  public class Fountain extends Emitter3D
  {
    public function Fountain()
    {
      counter = new Steady( 2500 );
      
      addInitializer( new ColorInit( 0xFFCCCCFF, 0xFF6666FF ) );
      addInitializer( new Velocity( new DiscZone( new Vector3D( 0, -250, 0 ), new Vector3D( 0, 1, 0 ), 60 ) ) );
      addInitializer( new Lifetime( 3.2 ) );
      
      addAction( new Move() );
      addAction( new Accelerate( new Vector3D( 0, 150, 0 ) ) );
      addAction( new Age() );
    }
  }
}
import org.flintparticles.common.actions.*;
import org.flintparticles.common.counters.*;
import org.flintparticles.common.initializers.*;
import org.flintparticles.threeD.actions.*;
import org.flintparticles.threeD.emitters.Emitter3D;
import org.flintparticles.threeD.initializers.*;
import org.flintparticles.threeD.renderers.PixelRenderer;
import org.flintparticles.threeD.renderers.controllers.*;
import org.flintparticles.threeD.zones.*;  

var emitter:Emitter3D = new Emitter3D();
emitter.counter = new Steady( 2500 );

emitter.addInitializer( new ColorInit( 0xFFCCCCFF, 0xFF6666FF ) );
emitter.addInitializer( new Velocity( new DiscZone( new Vector3D( 0, -250, 0 ), new Vector3D( 0, 1, 0 ), 60 ) ) );
emitter.addInitializer( new Lifetime( 3.2 ) );

emitter.addAction( new Move() );
emitter.addAction( new Accelerate( new Vector3D( 0, 150, 0 ) ) );
emitter.addAction( new Age() );

var renderer:PixelRenderer = new PixelRenderer( new Rectangle( -250, -250, 500, 500 ), false );
renderer.camera.dolly( -300 );
renderer.camera.lift( 100 );
renderer.camera.target = new Vector3D( 0, -100, 0 );
renderer.addFilter( new BlurFilter( 2, 2, 1 ), true );
renderer.addFilter( new ColorMatrixFilter( [ 1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0.99,0 ] ), true );
renderer.addEmitter( emitter );
renderer.x = 250;
renderer.y = 250;
addChild( renderer );

emitter.start( );

var orbitter:OrbitCamera = new OrbitCamera( stage, renderer.camera );
orbitter.start();
<?xml version="1.0" encoding="utf-8"?>
<s:Application
  xmlns:fx="http://ns.adobe.com/mxml/2009" 
  xmlns:s="library://ns.adobe.com/flex/spark"
  xmlns:f="http://flintparticles.org/2009/flint3d"
  xmlns:geom="flash.geom.*"
  xmlns:filters="flash.filters.*"
  width="500" height="500"
  backgroundColor="#000000">

<f:PixelRenderer id="renderer" width="500" height="500">
  <f:camera>
    <f:Camera>
      <f:position>
        <geom:Vector3D x="0" y="-100" z="-300"/>
      </f:position>
      <f:target>
        <geom:Vector3D x="0" y="-100" z="0"/>
      </f:target>
      <f:controller>
        <f:OrbitCamera/>
      </f:controller>
    </f:Camera>
  </f:camera>
  <f:postFilters>
    <filters:BlurFilter blurX="2" blurY="2" quality="1"/>
    <filters:ColorMatrixFilter matrix="{[ 1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0.99,0 ]}"/>
  </f:postFilters>
  <f:emitters>
    <f:Emitter id="emitter" autoStart="true">
      <f:counter>
        <f:Steady rate="2500"/>
      </f:counter>
      <f:initializers>
        <f:Velocity>
          <f:DiscZone innerRadius="0" outerRadius="60">
            <f:center>
              <geom:Vector3D x="0" y="-250" z="0"/>
            </f:center>
            <f:normal>
              <geom:Vector3D x="0" y="1" z="0"/>
            </f:normal>
          </f:DiscZone>
        </f:Velocity>
        <f:ColorInit minColor="0xFFCCCCFF" maxColor="0xFF6666FF"/>
        <f:Lifetime lifetime="3.2"/>
      </f:initializers>
      <f:actions>
        <f:Move/>
        <f:Age/>
        <f:Accelerate x="0" y="150" z="0" />
      </f:actions>
    </f:Emitter>
  </f:emitters>
</f:PixelRenderer>
</s:Application>
package
{
  import org.flintparticles.integration.papervision3d.PV3DPixelRenderer;
  import org.flintparticles.threeD.emitters.Emitter3D;
  import org.papervision3d.cameras.Camera3D;
  import org.papervision3d.core.effects.BitmapLayerEffect;
  import org.papervision3d.core.geom.Pixels;
  import org.papervision3d.render.BasicRenderEngine;
  import org.papervision3d.scenes.Scene3D;
  import org.papervision3d.view.Viewport3D;
  import org.papervision3d.view.layer.BitmapEffectLayer;

  import flash.display.Sprite;
  import flash.events.Event;
  import flash.filters.BlurFilter;
  import flash.filters.ColorMatrixFilter;

  [SWF(width='500', height='500', frameRate='61', backgroundColor='#000000')]
  
  public class Main extends Sprite
  {
    private var viewport:Viewport3D;
    private var emitter:Emitter3D;
    private var pv3dRenderer:BasicRenderEngine;
    private var flintRenderer:PV3DPixelRenderer;
    private var scene:Scene3D;
    private var camera:Camera3D;
    private var bfx:BitmapEffectLayer;
    private var pixels:Pixels;
    
    public function Main()
    {
      viewport = new Viewport3D( 500, 500 );
      addChild( viewport );
      
      pv3dRenderer = new BasicRenderEngine();
      scene = new Scene3D();
      camera = new Camera3D();
      camera.z = -300;
      
      bfx = new BitmapEffectLayer( viewport, 500, 500 );
      viewport.containerSprite.addLayer( bfx );
      pixels = new Pixels( bfx );
      bfx.addDisplayObject3D( pixels );
      scene.addChild( pixels );
      bfx.addEffect( new BitmapLayerEffect( new BlurFilter( 2, 2, 1 ) ) );
      bfx.addEffect( new BitmapLayerEffect( new ColorMatrixFilter( [ 1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0.99,0 ] ) ) );
      
      emitter = new Fountain();
      emitter.position.y = -100;

      flintRenderer = new PV3DPixelRenderer( pixels );
      flintRenderer.addEmitter( emitter );
      emitter.start();
      
      addEventListener( Event.ENTER_FRAME, render, false, 0, true );
    }
    
    private function render( ev:Event ):void
    {
      // render the view
      pv3dRenderer.renderScene( scene, camera, viewport);
    }
  }
}
package
{
  import org.flintparticles.common.actions.Age;
  import org.flintparticles.common.counters.Steady;
  import org.flintparticles.common.initializers.ColorInit;
  import org.flintparticles.common.initializers.Lifetime;
  import org.flintparticles.threeD.actions.Accelerate;
  import org.flintparticles.threeD.actions.Move;
  import org.flintparticles.threeD.emitters.Emitter3D;
  import org.flintparticles.threeD.initializers.Velocity;
  import org.flintparticles.threeD.zones.DiscZone;

  import flash.geom.Vector3D;

  public class Fountain extends Emitter3D
  {
    public function Fountain()
    {
      counter = new Steady( 2500 );
      
      addInitializer( new ColorInit( 0xFFCCCCFF, 0xFF6666FF ) );
      addInitializer( new Velocity( new DiscZone( new Vector3D( 0, 250, 0 ), new Vector3D( 0, 1, 0 ), 60 ) ) );
      addInitializer( new Lifetime( 3.2 ) );
      
      addAction( new Move() );
      addAction( new Accelerate( new Vector3D( 0, -150, 0 ) ) );
      addAction( new Age() );
    }
  }
}