@ -36,6 +36,9 @@ import com.jme3.app.SimpleApplication;
import com.jme3.effect.ParticleEmitter ;
import com.jme3.effect.ParticleMesh.Type ;
import com.jme3.effect.shapes.EmitterBoxShape ;
import com.jme3.input.KeyInput ;
import com.jme3.input.controls.ActionListener ;
import com.jme3.input.controls.KeyTrigger ;
import com.jme3.material.Material ;
import com.jme3.math.ColorRGBA ;
import com.jme3.math.Vector3f ;
@ -49,13 +52,13 @@ public class TestPointSprite extends SimpleApplication {
@Override
public void simpleInitApp ( ) {
ParticleEmitter emit = new ParticleEmitter ( "Emitter" , Type . Point , 10000 ) ;
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 ) ;
emit . setLowLife ( 60 ) ;
emit . setHighLife ( 60 ) ;
emit . setInitialVelocity ( new Vector3f ( 0 , 0 , 0 ) ) ;
emit . getParticleInfluencer ( ) . setInitialVelocity ( new Vector3f ( 0 , 0 , 0 ) ) ;
emit . setImagesX ( 15 ) ;
emit . setStartSize ( 0 . 05f ) ;
emit . setEndSize ( 0 . 05f ) ;
@ -70,6 +73,17 @@ public class TestPointSprite extends SimpleApplication {
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 ( 5000 ) ;
emit . emitAllParticles ( ) ;
}
}
} , "setNum" ) ;
inputManager . addMapping ( "setNum" , new KeyTrigger ( KeyInput . KEY_SPACE ) ) ;
}