There is a bit to do with this still, but it’s in good enough working order… here is the source code:
https://code.google.com/p/tonegodemitter/source/browse/
List of TODO’s:
Animation info is not being set in clone and cloneForSpatial
Billboarding does not apply in loaded asset as particle template
I haven’t tested point-based particles since I originally started working on this and it is likely in need of updates.
But, the rest is working as it should…
Here is a sample of how to use via code:
[java]
Emitter e1 = new Emitter();
e1.setName(“e1”); // generated if not set… ignore if you are lazy
e1.addInfluencers(
new ColorInfluencer(),
new AlphaInfluencer(),
new SizeInfluencer(),
new SpriteInfluencer(),
new RotationInfluencer(),
new GravityInfluencer()
);
e1.setMaxParticles(15);
// Emiter shape options:
// Simple point/triangle emitter shape
e1.setShapeSimpleEmitter();
// Or use the following for a JME primitive:
// Sphere e1ES = new Sphere(16, 16, 0.5f);
// e1.setShape(e1ES);
// Or the following for an animated emitter shape:
// Node emitterNode = (Node)assetManager.loadModel(“somePath”);
// e1.setShape(emitterNode, false);
// For particles other than the default quad
// impostor based particle
// e1.setParticleType(ParticleDataImpostorMesh.class);
// Animated asset as particle template
// Node particleNode = (Node)assetManager.loadAsset(“somePath”);
// e1.setParticleType(ParticleDataTemplateMesh.class, particleNode);
e1.setEmissionsPerSecond(15);
e1.setParticlesPerEmission(1);
e1.setDirectionType(DirectionType.Normal);
e1.setBillboardMode(BillboardMode.Camera);
e1.setForceMinMax(2.25f,5.0f);
e1.setLifeMinMax(0.999f,0.999f);
// Some of the other options - there are more… but these are a few
// e1.setUseRandomEmissionPoint(true);
// e1.setParticlesFollowEmitter(true);
// e1.setUseSequentialEmissionFace(true);
// e1.setUseSequentialSkipPattern(true);
// e1.setUseVelocityStretching(true);
// e1.setVelocityStretchFactor(1.25f);
// Set the texture - note there are many other method variations for setting the texture… use what works for you
e1.setSprite(“Textures/default.png”, 1, 1);
// Using an alternate material
/*
// Lighting test
Material mat = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);
mat.setBoolean(“UseVertexColor”, true);
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
mat.getAdditionalRenderState().setAlphaTest(true);
mat.getAdditionalRenderState().setAlphaFallOff(.15f);
e1.setMaterial(mat, “DiffuseMap”, true);
*/
/*
// Unshaded test
Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
mat.setBoolean(“VertexColor”, true);
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
mat.getAdditionalRenderState().setAlphaTest(true);
mat.getAdditionalRenderState().setAlphaFallOff(.15f);
e1.setMaterial(mat, “ColorMap”, true);
*/
// Enabling the test mode shapes (emitter shape, particle mesh)
// e1.setEmitterTestMode(true, false);
// Examples of changing influencer values
// Color Influencer
e1.getInfluencer(ColorInfluencer.class).addColor(new ColorRGBA(1.0f,1.0f,1.0f,1.0f));
e1.getInfluencer(ColorInfluencer.class).addColor(new ColorRGBA(1.0f,1.0f,1.0f,0.0f));
// Alpha Influencer
e1.getInfluencer(AlphaInfluencer.class).addAlpha(1.0f, Interpolation.exp5In);
e1.getInfluencer(AlphaInfluencer.class).addAlpha(0.0f);
// Size Influencer
e1.getInfluencer(SizeInfluencer.class).addSize(new Vector3f(0.5f,0.5f,0.5f));
e1.getInfluencer(SizeInfluencer.class).addSize(new Vector3f(0.1f,0.1f,0.1f));
// Rotation Influencer
e1.getInfluencer(RotationInfluencer.class).addRotationSpeed(new Vector3f(0.0f,0.0f,0.0f));
e1.getInfluencer(RotationInfluencer.class).setUseRandomStartRotation(false,false,false);
e1.getInfluencer(RotationInfluencer.class).setUseRandomDirection(true);
e1.getInfluencer(RotationInfluencer.class).setUseRandomSpeed(true);
// Gravity Influencer
e1.getInfluencer(GravityInfluencer.class).setGravity(new Vector3f(0.0f,4.0f,0.0f));
// Set transforms
e1.setLocalTranslation(0.0f, 0.0f, 0.0f);
e1.setLocalScale(1.0f, 1.0f, 1.0f);
// e1.setLocalRotation(new Quaternion().fromAngles(0.0f,0.0f,0.0f));
// Initialize, Add to scene & Turn it on
e1.initialize(assetManager); // DON’T FORGET TO INITIALIZE THE EMITTER!!
rootNode.addControl(e1);
e1.setEnabled(true); // DON’T FORGET TO TURN IT ON!! (At some point)
[/java]
I’ll post notifications here if any updates available via the repo, but I really could use a break on this for a day or two.