@sgold said:
Do you plan to write a tutorial on this?
I’ll be pushing out an update for the emitter and the builder tonight or tomorrow. Why do I mention this? Because it effects how the emitter is created via code (slightly… paramless constructor, setMaxPartilcles method and in initialize(assetManager) method). So, that being said, I’ll likely put together a Wiki (though the builder will also let you view the code, or export the entire project via j3o now). Boy, that was a lot of blah blah blah… to say this:
With the changes, it looks like this:
[java]
Emitter e1 = new Emitter();
e1.setName(“e1”);
e1.setMaxParticles(6000);
e1.addInfluencers(
new ColorInfluencer(),
new SizeInfluencer(),
new SpriteInfluencer()
);
e1.setShape(branchmesh); // The tree branches as the emitter shape
// Screw using Particle.j3md in this case, you can use any material you like. You just need to pass in the new
// uniform name when calling setSprite if the name differs from “Texture”
Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
mat.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
mat.getAdditionalRenderState().setAlphaTest(true);
mat.getAdditionalRenderState().setAlphaFallOff(.5f);
// Override the material used by emitter
e1.setMaterial(mat);
// Set the texture to use
e1.setSprite(“Textures/leaves.png”, “ColorMap”, 2, 2); // ColorMap is the uniform in Unshaded.j3md
e1.setBillboardMode(Emitter.BillboardMode.Velocity_Z_Up_Y_Left);
e1.setParticleEmissionPoint(Emitter.ParticleEmissionPoint.Particle_Edge_Bottom);
e1.setForce(0.001f);
e1.setLife(1f); // Not really important, just anything but 0
e1.setEmissionsPerSecond(0);
e1.setParticlesPerEmission(0);
e1.setUseRandomEmissionPoint(true);
// Change a few influencer params
e1.getInfluencer(SizeInfluencer.class).addSize(1.5f);
e1.getInfluencer(ColorInfluencer.class).addColor(ColorRGBA.White);
e1.getInfluencer(SpriteInfluencer.class).setAnimate(false);
e1.getInfluencer(SpriteInfluencer.class).setUseRandomStartImage(true);
// And initialize
e1.initialize(assetManager);
rootNode.addControl(e1);
// Now, emit all particles and turn the emitter update loop off
e1.emitAllParticles();
e1.setEnabled(false);
[/java]