Flint Particle System Forum - PV3DParticleRenderer.addParticle: null object? Sat, 25 Dec 2010 17:37:48 +0000 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher PV3DParticleRenderer.addParticle: null object? http://flintparticles.org/forum/comments.php?DiscussionID=233&Focus=850#Comment_850 http://flintparticles.org/forum/comments.php?DiscussionID=233&Focus=850#Comment_850 Fri, 10 Jul 2009 04:43:49 +0100 kirbysayshi
I'm at a loss for what the issue is, as it seems to be happening rather deep in the Flint code. Perhaps there's a confusion between Flint's Particle object and Papervision3D's? I'm using the current version of Flint (from teh downloads page) and the trunk code of Papervision. Either way, if someone gets the following code to run, I will be excited.


package
{
import org.flintparticles.common.counters.Steady;
import org.flintparticles.threeD.actions.Move;
import org.flintparticles.threeD.emitters.Emitter3D;
import org.flintparticles.threeD.geom.Point3D;
import org.flintparticles.threeD.initializers.Position;
import org.flintparticles.threeD.initializers.Velocity;
import org.flintparticles.threeD.papervision3d.PV3DParticleRenderer;
import org.flintparticles.threeD.zones.PointZone;
import org.papervision3d.cameras.CameraType;
import org.papervision3d.core.geom.Particles;
import org.papervision3d.view.BasicView;

public class SpaceDebris extends BasicView
{
private var _emitter:Emitter3D;
private var _renderer:PV3DParticleRenderer;
private var _particles:Particles;

public function SpaceDebris()
{
super(stage.stageWidth, stage.stageHeight, true, false, CameraType.FREE);

_particles = new Particles();
scene.addChild(_particles);

_emitter = new Emitter3D();
_emitter.position.z = 100;
_emitter.counter = new Steady(10);

var startingPosition:Point3D = new Point3D(0, 0, 200);
var startingZone:PointZone = new PointZone(startingPosition);
var sPos:Position = new Position(startingZone);
_emitter.addInitializer(sPos);

var direction:Point3D = new Point3D(2, 0, 0);
var zone:PointZone = new PointZone(direction);
var vel:Velocity = new Velocity(zone);
_emitter.addInitializer(vel);

_emitter.addAction( new Move() );

_renderer = new PV3DParticleRenderer(_particles);
_renderer.addEmitter(_emitter);

_emitter.start();
startRendering();
}
}
}
]]>
PV3DParticleRenderer.addParticle: null object? http://flintparticles.org/forum/comments.php?DiscussionID=233&Focus=851#Comment_851 http://flintparticles.org/forum/comments.php?DiscussionID=233&Focus=851#Comment_851 Fri, 10 Jul 2009 08:45:06 +0100 Richard
You need to define a 3D object for PV3D to use when rendering the particles. e.g. these two lines from the BrownianMotion example define a grey circle as the 3D object...

_emitter.addInitializer( new PV3DObjectClass( Particle, null, 4 ) );
_emitter.addInitializer( new ApplyMaterial( ParticleMaterial, 0x666666, 1, ParticleMaterial.SHAPE_CIRCLE ) );
]]>
PV3DParticleRenderer.addParticle: null object? http://flintparticles.org/forum/comments.php?DiscussionID=233&Focus=859#Comment_859 http://flintparticles.org/forum/comments.php?DiscussionID=233&Focus=859#Comment_859 Mon, 13 Jul 2009 03:18:23 +0100 kirbysayshi
I couldn't get my original original code to work, but I started over and have a simple explosion working now with the Particle renderer:

package
{
import org.flintparticles.common.actions.Age;
import org.flintparticles.common.actions.Fade;
import org.flintparticles.common.counters.Blast;
import org.flintparticles.common.initializers.ColorInit;
import org.flintparticles.common.initializers.Lifetime;
import org.flintparticles.threeD.actions.Move;
import org.flintparticles.threeD.emitters.Emitter3D;
import org.flintparticles.threeD.geom.Point3D;
import org.flintparticles.threeD.initializers.Velocity;
import org.flintparticles.threeD.papervision3d.PV3DParticleRenderer;
import org.flintparticles.threeD.papervision3d.initializers.PV3DObjectClass;
import org.flintparticles.threeD.zones.SphereZone;
import org.papervision3d.cameras.CameraType;
import org.papervision3d.core.geom.Particles;
import org.papervision3d.core.geom.renderables.Particle;
import org.papervision3d.materials.special.ParticleMaterial;
import org.papervision3d.view.BasicView;
import org.papervision3d.view.layer.BitmapEffectLayer;

public class SpaceDebris extends BasicView
{
private var _emitter:Emitter3D;
private var _renderer:PV3DParticleRenderer;
private var _particles:Particles;

private var emitter:Emitter3D;
private var flintRenderer:PV3DParticleRenderer;
private var bfx:BitmapEffectLayer;
private var particles:Particles;

[SWF(width='800', height='600', backgroundColor='#000000', frameRate='31')]
public function SpaceDebris()
{
super(stage.stageWidth, stage.stageHeight, true, false, CameraType.DEBUG);

camera.z = -300;
particles = new Particles();
scene.addChild(particles);

emitter = new Emitter3D();

emitter.counter = new Blast(100);

var mat:ParticleMaterial = new ParticleMaterial(0x000000, 1, 1);

emitter.addInitializer( new ColorInit( 0xFFCCCCFF, 0xFF6666FF ) );
emitter.addInitializer( new Velocity( new SphereZone( new Point3D(0, 0, 0), 100, 0) ) );
emitter.addInitializer( new Lifetime( 2 ) );
emitter.addInitializer( new PV3DObjectClass(Particle, mat, 5));

emitter.addAction( new Move() );
emitter.addAction( new Fade() );
emitter.addAction( new Age() );

emitter.position.y = -100;

flintRenderer = new PV3DParticleRenderer(particles);
flintRenderer.addEmitter( emitter );
emitter.start();
startRendering();
}
}
}


Thanks again. ]]>