/** * This method fills the point with data. * It does not fill the normal. * @param store the variable to store the point data * @param normal not used in this class */ @Override public void getRandomPointAndNormal(Vector3f store, Vector3f normal) { this.getRandomPoint(store); }
/** * Constructor. It stores a copy of vertex list of all meshes. * @param meshes * a list of meshes that will form the emitter's shape */ public EmitterMeshVertexShape(List<Mesh> meshes) { this.setMeshes(meshes); }
@Override public void getRandomPointAndNormal(Vector3f store, Vector3f normal) { this.getRandomPoint(store); }
fire.setShape(new EmitterSphereShape(Vector3f.ZERO, 0.1f)); fire.setImagesX(2); fire.setImagesY(2); // 2x2 texture animation smoke.setShape(new EmitterSphereShape(Vector3f.ZERO, 5)); smoke.setImagesX(1); smoke.setImagesY(1); // 2x2 texture animation
shape = shape.deepClone(); particleInfluencer = particleInfluencer.clone();
@Override public void influenceParticle(Particle particle, EmitterShape emitterShape) { emitterShape.getRandomPoint(particle.position); this.applyVelocityVariation(particle); }
/** * This method fills the point with coordinates of randomly selected point inside a convex hull * of randomly selected mesh. * @param store * the variable to store with coordinates of randomly selected selected point inside a convex hull * of randomly selected mesh */ @Override public void getRandomPoint(Vector3f store) { super.getRandomPoint(store); // now move the point from the meshe's face towards the center of the mesh // the center is in (0, 0, 0) in the local coordinates store.multLocal(FastMath.nextRandomFloat()); }
/** * This method fills the point with coordinates of randomly selected point inside a convex hull * of randomly selected mesh. * The normal param is not used. * @param store * the variable to store with coordinates of randomly selected selected point inside a convex hull * of randomly selected mesh * @param normal * not used in this class */ @Override public void getRandomPointAndNormal(Vector3f store, Vector3f normal) { super.getRandomPointAndNormal(store, normal); // now move the point from the meshe's face towards the center of the mesh // the center is in (0, 0, 0) in the local coordinates store.multLocal(FastMath.nextRandomFloat()); } }
switch (from) { case PART_FROM_VERT: result.setShape(new EmitterMeshVertexShape()); break; case PART_FROM_FACE: result.setShape(new EmitterMeshFaceShape()); break; case PART_FROM_VOLUME: result.setShape(new EmitterMeshConvexHullShape()); break; default:
@Override public void influenceParticle(Particle particle, EmitterShape emitterShape) { emitterShape.getRandomPointAndNormal(particle.position, particle.velocity); // influencing the particle's velocity if (surfaceTangentFactor == 0.0f) { particle.velocity.multLocal(normalVelocity); } else { // calculating surface tangent (velocity contains the 'normal' value) temp.set(particle.velocity.z * surfaceTangentFactor, particle.velocity.y * surfaceTangentFactor, -particle.velocity.x * surfaceTangentFactor); if (surfaceTangentRotation != 0.0f) {// rotating the tangent Matrix3f m = new Matrix3f(); m.fromAngleNormalAxis(FastMath.PI * surfaceTangentRotation, particle.velocity); temp = m.multLocal(temp); } // applying normal factor (this must be done first) particle.velocity.multLocal(normalVelocity); // adding tangent vector particle.velocity.addLocal(temp); } if (velocityVariation != 0.0f) { this.applyVelocityVariation(particle); } }
@Override public void simpleInitApp() { final ParticleEmitter emit = new ParticleEmitter("Emitter", Type.Point, 10000); emit.setShape(new EmitterBoxShape(new Vector3f(-1.8f, -1.8f, -1.8f), new Vector3f(1.8f, 1.8f, 1.8f))); emit.setGravity(0, 0, 0);
((EmitterMeshVertexShape) emitterShape).setMeshes(meshes);
@Override public void simpleInitApp() { ParticleEmitter emit = new ParticleEmitter("Emitter", Type.Triangle, 200); emit.setShape(new EmitterSphereShape(Vector3f.ZERO, 1f)); emit.setGravity(0, 0, 0); emit.setLowLife(5); emit.setHighLife(10); emit.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 0)); emit.setImagesX(15); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); mat.setTexture("Texture", assetManager.loadTexture("Effects/Smoke/Smoke.png")); emit.setMaterial(mat); ParticleEmitter emit2 = emit.clone(); emit2.move(3, 0, 0); rootNode.attachChild(emit); rootNode.attachChild(emit2); ParticleEmitter emit3 = BinaryExporter.saveAndLoad(assetManager, emit); emit3.move(-3, 0, 0); rootNode.attachChild(emit3); }
clone.shape = shape.deepClone();
private void prepareEffect(AssetManager assetManager) { int COUNT_FACTOR = 1; float COUNT_FACTOR_F = 1f; effect = new ParticleEmitter("Flame", Type.Triangle, 32 * COUNT_FACTOR); effect.setSelectRandomImage(true); effect.setStartColor(new ColorRGBA(1f, 0.4f, 0.05f, (float) (1f / COUNT_FACTOR_F))); effect.setEndColor(new ColorRGBA(.4f, .22f, .12f, 0f)); effect.setStartSize(1.3f); effect.setEndSize(2f); effect.setShape(new EmitterSphereShape(Vector3f.ZERO, 1f)); effect.setParticlesPerSec(0); effect.setGravity(0, -5f, 0); effect.setLowLife(.4f); effect.setHighLife(.5f); effect.getParticleInfluencer() .setInitialVelocity(new Vector3f(0, 7, 0)); effect.getParticleInfluencer().setVelocityVariation(1f); effect.setImagesX(2); effect.setImagesY(2); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png")); effect.setMaterial(mat); }
shape = shape.deepClone();
private void createRoundSpark(){ roundspark = new ParticleEmitter("RoundSpark", EMITTER_TYPE, 20 * COUNT_FACTOR); roundspark.setStartColor(new ColorRGBA(1f, 0.29f, 0.34f, (float) (1.0 / COUNT_FACTOR_F))); roundspark.setEndColor(new ColorRGBA(0, 0, 0, (float) (0.5f / COUNT_FACTOR_F))); roundspark.setStartSize(1.2f); roundspark.setEndSize(1.8f); roundspark.setShape(new EmitterSphereShape(Vector3f.ZERO, 2f)); roundspark.setParticlesPerSec(0); roundspark.setGravity(0, -.5f, 0); roundspark.setLowLife(1.8f); roundspark.setHighLife(2f); roundspark.getParticleInfluencer() .setInitialVelocity(new Vector3f(0, 3, 0)); roundspark.getParticleInfluencer().setVelocityVariation(.5f); roundspark.setImagesX(1); roundspark.setImagesY(1); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/roundspark.png")); mat.setBoolean("PointSprite", POINT_SPRITE); roundspark.setMaterial(mat); explosionEffect.attachChild(roundspark); }
private void createFlame(){ flame = new ParticleEmitter("Flame", EMITTER_TYPE, 32 * COUNT_FACTOR); flame.setSelectRandomImage(true); flame.setStartColor(new ColorRGBA(1f, 0.4f, 0.05f, (float) (1f / COUNT_FACTOR_F))); flame.setEndColor(new ColorRGBA(.4f, .22f, .12f, 0f)); flame.setStartSize(1.3f); flame.setEndSize(2f); flame.setShape(new EmitterSphereShape(Vector3f.ZERO, 1f)); flame.setParticlesPerSec(0); flame.setGravity(0, -5, 0); flame.setLowLife(.4f); flame.setHighLife(.5f); flame.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 7, 0)); flame.getParticleInfluencer().setVelocityVariation(1f); flame.setImagesX(2); flame.setImagesY(2); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png")); mat.setBoolean("PointSprite", POINT_SPRITE); flame.setMaterial(mat); explosionEffect.attachChild(flame); }
private void prepareEffect() { int COUNT_FACTOR = 1; float COUNT_FACTOR_F = 1f; effect = new ParticleEmitter("Flame", Type.Triangle, 32 * COUNT_FACTOR); effect.setSelectRandomImage(true); effect.setStartColor(new ColorRGBA(1f, 0.4f, 0.05f, (float) (1f / COUNT_FACTOR_F))); effect.setEndColor(new ColorRGBA(.4f, .22f, .12f, 0f)); effect.setStartSize(1.3f); effect.setEndSize(2f); effect.setShape(new EmitterSphereShape(Vector3f.ZERO, 1f)); effect.setParticlesPerSec(0); effect.setGravity(0, -5, 0); effect.setLowLife(.4f); effect.setHighLife(.5f); effect.getParticleInfluencer() .setInitialVelocity(new Vector3f(0, 7, 0)); effect.getParticleInfluencer().setVelocityVariation(1f); effect.setImagesX(2); effect.setImagesY(2); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png")); effect.setMaterial(mat); // effect.setLocalScale(100); rootNode.attachChild(effect); }
private void createFlash(){ flash = new ParticleEmitter("Flash", EMITTER_TYPE, 24 * COUNT_FACTOR); flash.setSelectRandomImage(true); flash.setStartColor(new ColorRGBA(1f, 0.8f, 0.36f, (float) (1f / COUNT_FACTOR_F))); flash.setEndColor(new ColorRGBA(1f, 0.8f, 0.36f, 0f)); flash.setStartSize(.1f); flash.setEndSize(3.0f); flash.setShape(new EmitterSphereShape(Vector3f.ZERO, .05f)); flash.setParticlesPerSec(0); flash.setGravity(0, 0, 0); flash.setLowLife(.2f); flash.setHighLife(.2f); flash.getParticleInfluencer() .setInitialVelocity(new Vector3f(0, 5f, 0)); flash.getParticleInfluencer().setVelocityVariation(1); flash.setImagesX(2); flash.setImagesY(2); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flash.png")); mat.setBoolean("PointSprite", POINT_SPRITE); flash.setMaterial(mat); explosionEffect.attachChild(flash); }