Tabnine Logo
ParticleEmitter
Code IndexAdd Tabnine to your IDE (free)

How to use
ParticleEmitter
in
com.jme3.effect

Best Java code snippets using com.jme3.effect.ParticleEmitter (Showing top 20 results out of 315)

origin: jMonkeyEngine/jmonkeyengine

@Override
public void simpleInitApp() {
 ParticleEmitter fire = 
     new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 30);
 Material mat_red = new Material(assetManager, 
     "Common/MatDefs/Misc/Particle.j3md");
 mat_red.setTexture("Texture", assetManager.loadTexture(
     "Effects/Explosion/flame.png"));
 fire.setMaterial(mat_red);
 fire.setImagesX(2); 
 fire.setImagesY(2); // 2x2 texture animation
 fire.setEndColor(  new ColorRGBA(1f, 0f, 0f, 1f));   // red
 fire.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f)); // yellow
 fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 2, 0));
 fire.setStartSize(1.5f);
 fire.setEndSize(0.1f);
 fire.setGravity(0, 0, 0);
 fire.setLowLife(1f);
 fire.setHighLife(3f);
 fire.getParticleInfluencer().setVelocityVariation(0.3f);
 rootNode.attachChild(fire);
     new ParticleEmitter("Debris", ParticleMesh.Type.Triangle, 10);
 Material debris_mat = new Material(assetManager, 
     "Common/MatDefs/Misc/Particle.j3md");
 debris_mat.setTexture("Texture", assetManager.loadTexture(
     "Effects/Explosion/Debris.png"));
 debris.setMaterial(debris_mat);
 debris.setImagesX(3); 
 debris.setImagesY(3); // 3x3 texture animation
origin: jMonkeyEngine/jmonkeyengine

  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());
      }
    }
  }
}
origin: jMonkeyEngine/jmonkeyengine

emitter.setCullHint(CullHint.Dynamic);
emitter.setEnabled(true);
  emitter.emitAllParticles();
  if (!killParticles.stopRequested) {
    emitter.addControl(killParticles);
    killParticles.stopRequested = true;
  emitter.setParticlesPerSec(particlesPerSeconds);
origin: jMonkeyEngine/jmonkeyengine

private void stop() {
  emitter.setParticlesPerSec(0);
  emitted = false;
  if (!killParticles.stopRequested) {
    emitter.addControl(killParticles);
    killParticles.stopRequested = true;
  }
}
origin: jMonkeyEngine/jmonkeyengine

@Override
protected void controlUpdate(float tpf) {
  if (remove) {
    emitter.removeControl(this);
    return;
  }
  if (emitter.getNumVisibleParticles() == 0) {
    emitter.setCullHint(CullHint.Always);
    emitter.setEnabled(false);
    emitter.removeControl(this);
    stopRequested = false;
  }
}
origin: jMonkeyEngine/jmonkeyengine

  public void onAction(String name, boolean isPressed, float tpf) {
    if ("setNum".equals(name) && isPressed) {
      emit.setNumParticles(5000);
      emit.emitAllParticles();
    }
  }
}, "setNum");
origin: jMonkeyEngine/jmonkeyengine

private void createFire() {
  /**
   * Uses Texture from jme3-test-data library!
   */
  ParticleEmitter fire = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 30);
  Material mat_red = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
  mat_red.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png"));
  fire.setMaterial(mat_red);
  fire.setImagesX(2);
  fire.setImagesY(2); // 2x2 texture animation
  fire.setEndColor(new ColorRGBA(1f, 0f, 0f, 1f));   // red
  fire.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f)); // yellow
  fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 2, 0));
  fire.setStartSize(10f);
  fire.setEndSize(1f);
  fire.setGravity(0, 0, 0);
  fire.setLowLife(0.5f);
  fire.setHighLife(1.5f);
  fire.getParticleInfluencer().setVelocityVariation(0.3f);
  fire.setLocalTranslation(-600, 50, 300);
  fire.setQueueBucket(Bucket.Translucent);
  rootNode.attachChild(fire);
}
origin: jMonkeyEngine/jmonkeyengine

ParticleEmitter fire = new ParticleEmitter("Fire", ParticleMesh.Type.Triangle, 30);
fire.setMaterial(material);
fire.setShape(new EmitterSphereShape(Vector3f.ZERO, 0.1f));
fire.setImagesX(2);
fire.setImagesY(2); // 2x2 texture animation
fire.setEndColor(new ColorRGBA(1f, 0f, 0f, 1f)); // red
fire.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f)); // yellow
fire.setStartSize(0.6f);
fire.setEndSize(0.01f);
fire.setGravity(0, -0.3f, 0);
fire.setLowLife(0.5f);
fire.setHighLife(3f);
fire.setLocalTranslation(0, 0.2f, 0);
ParticleEmitter smoke = new ParticleEmitter("Smoke", ParticleMesh.Type.Triangle, 30);
smoke.setMaterial(material);
smoke.setShape(new EmitterSphereShape(Vector3f.ZERO, 5));
smoke.setImagesX(1);
smoke.setImagesY(1); // 2x2 texture animation
smoke.setStartColor(new ColorRGBA(0.1f, 0.1f, 0.1f,1f)); // dark gray
smoke.setEndColor(new ColorRGBA(0.5f, 0.5f, 0.5f, 0.3f)); // gray      
smoke.setStartSize(3f);
smoke.setEndSize(5f);
smoke.setGravity(0, -0.001f, 0);
smoke.setLowLife(100f);
smoke.setHighLife(100f);
smoke.setLocalTranslation(0, 0.1f, 0);        
smoke.emitAllParticles();
origin: jMonkeyEngine/jmonkeyengine

@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);
}
origin: jMonkeyEngine/jmonkeyengine

result = new ParticleEmitter(particleSettings.getName() + nameSuffix, Type.Triangle, totPart);
if (nameSuffix == 'N') {
  return result;// no need to set anything else
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:
result.setGravity(-acc.get(0).floatValue(), -acc.get(1).floatValue(), -acc.get(2).floatValue());
result.setEndColor(new ColorRGBA(1f, 1f, 1f, 1f));
result.setStartColor(new ColorRGBA(1f, 1f, 1f, 1f));
result.setStartSize(size);
result.setEndSize(size);
float lifetime = ((Number) particleSettings.getFieldValue("lifetime")).floatValue() / fps;
float randlife = ((Number) particleSettings.getFieldValue("randlife")).floatValue() / fps;
result.setLowLife(lifetime * (1.0f - randlife));
result.setHighLife(lifetime);
origin: jMonkeyEngine/jmonkeyengine

public ParticleEmitter(String name, Type type, int numParticles) {
  super(name);
  setBatchHint(BatchHint.Never);
  this.setIgnoreTransform(true);
  this.setShadowMode(ShadowMode.Off);
  this.setQueueBucket(Bucket.Transparent);
    case Point:
      particleMesh = new ParticlePointMesh();
      this.setMesh(particleMesh);
      break;
    case Triangle:
      particleMesh = new ParticleTriMesh();
      this.setMesh(particleMesh);
      break;
    default:
      throw new IllegalStateException("Unrecognized particle type: " + meshType);
  this.setNumParticles(numParticles);
origin: jMonkeyEngine/jmonkeyengine

@Override
public void simpleInitApp() {
  emit = new ParticleEmitter("Emitter", Type.Triangle, 300);
  emit.setGravity(0, 0, 0);
  emit.getParticleInfluencer().setVelocityVariation(1);
  emit.setLowLife(1);
  emit.setHighLife(1);
  emit.getParticleInfluencer()
      .setInitialVelocity(new Vector3f(0, .5f, 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);
  
  rootNode.attachChild(emit);
  
  inputManager.addListener(new ActionListener() {
    
    public void onAction(String name, boolean isPressed, float tpf) {
      if ("setNum".equals(name) && isPressed) {
        emit.setNumParticles(1000);
      }
    }
  }, "setNum");
  
  inputManager.addMapping("setNum", new KeyTrigger(KeyInput.KEY_SPACE));
}

origin: jMonkeyEngine/jmonkeyengine

/**
 * This method clone the Track and search for the cloned counterpart of the
 * original emitter in the given cloned spatial. The spatial is assumed to
 * be the Spatial holding the AnimControl controlling the animation using
 * this Track.
 *
 * @param spatial the Spatial holding the AnimControl
 * @return the cloned Track with proper reference
 */
@Override
public Track cloneForSpatial(Spatial spatial) {
  EffectTrack effectTrack = new EffectTrack();
  effectTrack.particlesPerSeconds = this.particlesPerSeconds;
  effectTrack.length = this.length;
  effectTrack.startOffset = this.startOffset;
  //searching for the newly cloned ParticleEmitter
  effectTrack.emitter = findEmitter(spatial);
  if (effectTrack.emitter == null) {
    logger.log(Level.WARNING, "{0} was not found in {1} or is not bound to this track", new Object[]{emitter.getName(), spatial.getName()});
    effectTrack.emitter = emitter;
  }
  removeUserData(this);
  //setting user data on the new emmitter and marking it with a reference to the cloned Track.
  setUserData(effectTrack);
  effectTrack.emitter.setParticlesPerSec(0);
  return effectTrack;
}
origin: jMonkeyEngine/jmonkeyengine

ParticleEmitter emitter = particleEmitter.clone();
char nameSuffix = emitter.getName().charAt(emitter.getName().length() - 1);
if (nameSuffix == 'B' || nameSuffix == 'N') {
  alphaFunction = MaterialHelper.ALPHA_MASK_NONE;
emitter.setName(emitter.getName().substring(0, emitter.getName().length() - 1));
EmitterShape emitterShape = emitter.getShape();
List<Mesh> meshes = new ArrayList<Mesh>();
for (Spatial spatial : node.getChildren()) {
      meshes.add(mesh);
      Material material = materialHelper.getParticlesMaterial(((Geometry) spatial).getMaterial(), alphaFunction, blenderContext);
      emitter.setMaterial(material);// TODO: divide into several pieces
origin: jMonkeyEngine/jmonkeyengine

/**
 * Sets the Emitter to use in this track
 *
 * @param emitter
 */
public void setEmitter(ParticleEmitter emitter) {
  if (this.emitter != null) {
    TrackInfo data = (TrackInfo) emitter.getUserData("TrackInfo");
    data.getTracks().remove(this);
  }
  this.emitter = emitter;
  //saving particles per second value
  this.particlesPerSeconds = emitter.getParticlesPerSec();
  //setting the emmitter to not emmit.
  this.emitter.setParticlesPerSec(0);
  setUserData(this);
}
origin: jMonkeyEngine/jmonkeyengine

/**
 * Creates and EffectTrack
 *
 * @param emitter the emitter of the track
 * @param length the length of the track (usually the length of the
 * animation you want to add the track to)
 */
public EffectTrack(ParticleEmitter emitter, float length) {
  this.emitter = emitter;
  //saving particles per second value
  this.particlesPerSeconds = emitter.getParticlesPerSec();
  //setting the emmitter to not emmit.
  this.emitter.setParticlesPerSec(0);
  this.length = length;
  //Marking the emitter with a reference to this track for further use in deserialization.
  setUserData(this);
}
origin: jMonkeyEngine/jmonkeyengine

/**
 * Callback from Control.render(), do not use.
 *
 * @param rm
 * @param vp
 */
private void renderFromControl(RenderManager rm, ViewPort vp) {
  Camera cam = vp.getCamera();
  if (meshType == ParticleMesh.Type.Point) {
    float C = cam.getProjectionMatrix().m00;
    C *= cam.getWidth() * 0.5f;
    // send attenuation params
    this.getMaterial().setFloat("Quadratic", C);
  }
  Matrix3f inverseRotation = Matrix3f.IDENTITY;
  TempVars vars = null;
  if (!worldSpace) {
    vars = TempVars.get();
    inverseRotation = this.getWorldRotation().toRotationMatrix(vars.tempMat3).invertLocal();
  }
  particleMesh.updateParticleData(particles, cam, inverseRotation);
  if (!worldSpace) {
    vars.release();
  }
}
origin: jMonkeyEngine/jmonkeyengine

/**
 * Internal use only serialization
 *
 * @param ex exporter
 * @throws IOException exception
 */
@Override
public void write(JmeExporter ex) throws IOException {
  OutputCapsule out = ex.getCapsule(this);
  //reset the particle emission rate on the emitter before saving.
  emitter.setParticlesPerSec(particlesPerSeconds);
  out.write(emitter, "emitter", null);
  out.write(particlesPerSeconds, "particlesPerSeconds", 0);
  out.write(length, "length", 0);
  out.write(startOffset, "startOffset", 0);
  //Setting emission rate to 0 so that this track can go on being used.
  emitter.setParticlesPerSec(0);
}
origin: jMonkeyEngine/jmonkeyengine

public void collision(PhysicsCollisionEvent event) {
  if (space == null) {
    return;
  }
  if (event.getObjectA() == this || event.getObjectB() == this) {
    space.add(ghostObject);
    ghostObject.setPhysicsLocation(getPhysicsLocation(vector));
    space.addTickListener(this);
    if (effect != null && spatial.getParent() != null) {
      curTime = 0;
      effect.setLocalTranslation(spatial.getLocalTranslation());
      spatial.getParent().attachChild(effect);
      effect.emitAllParticles();
    }
    space.remove(this);
    spatial.removeFromParent();
  }
}

origin: jMonkeyEngine/jmonkeyengine

public void collision(PhysicsCollisionEvent event) {
  if (event.getObjectA() instanceof BombControl) {
    final Spatial node = event.getNodeA();
    effect.killAllParticles();
    effect.setLocalTranslation(node.getLocalTranslation());
    effect.emitAllParticles();
  } else if (event.getObjectB() instanceof BombControl) {
    final Spatial node = event.getNodeB();
    effect.killAllParticles();
    effect.setLocalTranslation(node.getLocalTranslation());
    effect.emitAllParticles();
  }
}
com.jme3.effectParticleEmitter

Javadoc

ParticleEmitter is a special kind of geometry which simulates a particle system.

Particle emitters can be used to simulate various kinds of phenomena, such as fire, smoke, explosions and much more.

Particle emitters have many properties which are used to control the simulation. The interpretation of these properties depends on the ParticleInfluencer that has been assigned to the emitter via ParticleEmitter#setParticleInfluencer(com.jme3.effect.influencers.ParticleInfluencer). By default the implementation DefaultParticleInfluencer is used.

Most used methods

  • emitAllParticles
    Instantly emits all the particles possible to be emitted. Any particles which are currently inactive
  • getName
  • setQueueBucket
  • getMaterial
  • setParticlesPerSec
    Set the number of particles to spawn per second.
  • <init>
  • clone
  • getNumVisibleParticles
    Returns the number of visible particles (spawned but not dead).
  • setEndColor
    Set the end color of the particles spawned.The particle color at any time is determined by blending
  • setEndSize
    Set the end size of the particles spawned.The particle size at any time is determined by blending th
  • setGravity
    This method sets the gravity vector.
  • setHighLife
    Set the high value of life.The particle's lifetime/expiration is determined by randomly selecting a
  • setGravity,
  • setHighLife,
  • setLowLife,
  • setMaterial,
  • setNumParticles,
  • setShadowMode,
  • setStartColor,
  • setStartSize,
  • addControl,
  • emitParticle

Popular in Java

  • Start an intent from android
  • setRequestProperty (URLConnection)
  • getSystemService (Context)
  • compareTo (BigDecimal)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now