Flint Particle System Forum - Emitters not drawn unless Filter applied Sun, 26 Dec 2010 14:00:37 +0000 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher Emitters not drawn unless Filter applied http://flintparticles.org/forum/comments.php?DiscussionID=33&Focus=148#Comment_148 http://flintparticles.org/forum/comments.php?DiscussionID=33&Focus=148#Comment_148 Wed, 21 May 2008 13:32:53 +0100 robotz
I wanted to create a single FullStagePixelRenderer that had 10 different emitters working on it.

I use a for() loop to create 10 emitters, setting random values.

When all of the emitters are started, only one of them appears rendered.

However, if you enable a filter on the renderer (such as blur), you can see all of the other emitters running.

Most confusing! Here is a zip file with the fla and AS code, ready to run.


/**
* Mass Emitter Test
* @author Richard Davey
* @version 0.1
*/

package
{
import flash.display.Sprite;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.filters.BlurFilter;

import org.flintparticles.actions.*;
import org.flintparticles.activities.*;
import org.flintparticles.counters.*;
import org.flintparticles.debug.*;
import org.flintparticles.displayObjects.*;
import org.flintparticles.emitters.Emitter;
import org.flintparticles.initializers.*;
import org.flintparticles.renderers.*;
import org.flintparticles.utils.*;
import org.flintparticles.zones.*;

public class massflint extends Sprite
{
private var emitters:Array = new Array();
private var globalRenderer:FullStagePixelRenderer;

public function massflint():void
{
createRenderer();

createRandomEmitters();

addChild(globalRenderer);

startEmitters();
}

private function createRenderer():void
{
globalRenderer = new FullStagePixelRenderer();

globalRenderer.cacheAsBitmap = true;

// Uncomment the filter and you can see all of the emitters!
//globalRenderer.addFilter(new BlurFilter(1, 1, 1), false);
}

private function createRandomEmitters():void
{
var tempEmitter:Emitter;

for (var i:uint = 0; i < 10; i++)
{
trace("Creating Emitter " + i);

tempEmitter = new Emitter();

tempEmitter.counter = new Steady(40);
tempEmitter.renderer = globalRenderer;

tempEmitter.x = 100 + Math.random() * 350;
tempEmitter.y = 50 + Math.random() * 300;

tempEmitter.addInitializer(new ColorInit(0xFFFFFFFF, 0xFFFFFFFF));
tempEmitter.addInitializer(new Position(new PointZone(new Point(0, 0))));
tempEmitter.addInitializer(new Velocity(new DiscZone(new Point(0, 0), 100, 250)));
tempEmitter.addInitializer(new Lifetime(1));

tempEmitter.addAction(new LinearDrag(1));
tempEmitter.addAction(new Move());
tempEmitter.addAction(new Age());

emitters[i] = tempEmitter;

tempEmitter = null;
}
}

private function startEmitters():void
{
for (var i:uint = 0; i < 10; i++)
{
emitters[i].start();
}
}
}
}


Any ideas anyone? I'm using Flint 1.0.2.

Cheers,

Rich ]]>
Emitters not drawn unless Filter applied http://flintparticles.org/forum/comments.php?DiscussionID=33&Focus=150#Comment_150 http://flintparticles.org/forum/comments.php?DiscussionID=33&Focus=150#Comment_150 Wed, 21 May 2008 18:19:48 +0100 ericr
The Emitter objects, in your case, grab the renderer and wipe out the previous canvas to draw their updated particles. If you specify a blur filter, however, then they don't wipe the canvas clean: they blur the old canvas and then draw on top of it.

Without the blur filter your 10 emitters are each clearing the renderer and drawing their particles in succession. Thus the last emitter to run is the only one whose pixels you would see represented.

I believe the concept of associating multiple emitters with a single renderer (and vice versa) is planned for the next version of Flint.

That said you could easily modify the current code to allow this to work (or even apply the blur filter without actually blurring anything)... ]]>
Emitters not drawn unless Filter applied http://flintparticles.org/forum/comments.php?DiscussionID=33&Focus=152#Comment_152 http://flintparticles.org/forum/comments.php?DiscussionID=33&Focus=152#Comment_152 Wed, 21 May 2008 18:49:10 +0100 Richard Emitters not drawn unless Filter applied http://flintparticles.org/forum/comments.php?DiscussionID=33&Focus=153#Comment_153 http://flintparticles.org/forum/comments.php?DiscussionID=33&Focus=153#Comment_153 Wed, 21 May 2008 23:32:27 +0100 robotz