use of com.jme3.effect.ParticleEmitter in project jmonkeyengine by jMonkeyEngine.
the class EffectTrack method findEmitter.
/**
* recursive function responsible for finding the newly cloned Emitter
*
* @param spat
* @return
*/
private ParticleEmitter findEmitter(Spatial spat) {
if (spat instanceof ParticleEmitter) {
//spat is a PArticleEmitter
ParticleEmitter em = (ParticleEmitter) spat;
//getting the UserData TrackInfo so check if it should be attached to this Track
TrackInfo t = (TrackInfo) em.getUserData("TrackInfo");
if (t != null && t.getTracks().contains(this)) {
return em;
}
return null;
} else if (spat instanceof Node) {
for (Spatial child : ((Node) spat).getChildren()) {
ParticleEmitter em = findEmitter(child);
if (em != null) {
return em;
}
}
}
return null;
}
use of com.jme3.effect.ParticleEmitter in project jmonkeyengine by jMonkeyEngine.
the class EffectTrack method read.
/**
* Internal use only serialization
*
* @param im importer
* @throws IOException Exception
*/
public void read(JmeImporter im) throws IOException {
InputCapsule in = im.getCapsule(this);
this.particlesPerSeconds = in.readFloat("particlesPerSeconds", 0);
//reading the emitter even if the track will then reference its cloned counter part if it's loaded with the assetManager.
//This also avoid null pointer exception if the model is not loaded via the AssetManager.
emitter = (ParticleEmitter) in.readSavable("emitter", null);
emitter.setParticlesPerSec(0);
//if the emitter was saved with a KillParticleControl we remove it.
// Control c = emitter.getControl(KillParticleControl.class);
// if(c!=null){
// emitter.removeControl(c);
// }
//emitter.removeControl(KillParticleControl.class);
length = in.readFloat("length", length);
startOffset = in.readFloat("startOffset", 0);
}
use of com.jme3.effect.ParticleEmitter in project jmonkeyengine by jMonkeyEngine.
the class TranslucentBucketFilter method makeSoftParticleEmitter.
private void makeSoftParticleEmitter(Spatial scene, boolean enabled) {
if (scene instanceof Node) {
Node n = (Node) scene;
for (Spatial child : n.getChildren()) {
makeSoftParticleEmitter(child, enabled);
}
}
if (scene instanceof ParticleEmitter) {
ParticleEmitter emitter = (ParticleEmitter) scene;
if (enabled) {
enabledSoftParticles = enabled;
emitter.getMaterial().selectTechnique("SoftParticles", renderManager);
if (processor.getNumSamples() > 1) {
emitter.getMaterial().setInt("NumSamplesDepth", processor.getNumSamples());
}
emitter.getMaterial().setTexture("DepthTexture", processor.getDepthTexture());
emitter.setQueueBucket(RenderQueue.Bucket.Translucent);
logger.log(Level.FINE, "Made particle Emitter {0} soft.", emitter.getName());
} else {
emitter.getMaterial().clearParam("DepthTexture");
emitter.getMaterial().selectTechnique("Default", renderManager);
// emitter.setQueueBucket(RenderQueue.Bucket.Transparent);
logger.log(Level.FINE, "Particle Emitter {0} is not soft anymore.", emitter.getName());
}
}
}
use of com.jme3.effect.ParticleEmitter in project jmonkeyengine by jMonkeyEngine.
the class TestExplosionEffect method createFlame.
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);
}
use of com.jme3.effect.ParticleEmitter in project jmonkeyengine by jMonkeyEngine.
the class TestExplosionEffect method createFlash.
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.setInitialVelocity(new Vector3f(0, 5f, 0));
flash.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);
}
Aggregations