@ -29,13 +29,16 @@
* NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF THIS
* NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
* SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
* /
* /
package jme3test.effect ;
package jme3test.effect ;
import com.jme3.app.SimpleApplication ;
import com.jme3.app.SimpleApplication ;
import com.jme3.effect.ParticleEmitter ;
import com.jme3.effect.ParticleEmitter ;
import com.jme3.effect.ParticleMesh.Type ;
import com.jme3.effect.ParticleMesh.Type ;
import com.jme3.effect.shapes.EmitterSphereShape ;
import com.jme3.effect.shapes.EmitterSphereShape ;
import com.jme3.input.KeyInput ;
import com.jme3.input.controls.ActionListener ;
import com.jme3.input.controls.InputListener ;
import com.jme3.input.controls.KeyTrigger ;
import com.jme3.material.Material ;
import com.jme3.material.Material ;
import com.jme3.math.FastMath ;
import com.jme3.math.FastMath ;
import com.jme3.math.Vector3f ;
import com.jme3.math.Vector3f ;
@ -57,7 +60,7 @@ public class TestMovingParticle extends SimpleApplication {
@Override
@Override
public void simpleInitApp ( ) {
public void simpleInitApp ( ) {
emit = new ParticleEmitter ( "Emitter" , Type . Triangle , 2 00) ;
emit = new ParticleEmitter ( "Emitter" , Type . Triangle , 3 00) ;
emit . setGravity ( 0 , 0 , 0 ) ;
emit . setGravity ( 0 , 0 , 0 ) ;
emit . setVelocityVariation ( 1 ) ;
emit . setVelocityVariation ( 1 ) ;
emit . setLowLife ( 1 ) ;
emit . setLowLife ( 1 ) ;
@ -69,6 +72,17 @@ public class TestMovingParticle extends SimpleApplication {
emit . setMaterial ( mat ) ;
emit . setMaterial ( mat ) ;
rootNode . attachChild ( emit ) ;
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 ) ) ;
}
}
@Override
@Override
@ -79,5 +93,4 @@ public class TestMovingParticle extends SimpleApplication {
float y = FastMath . sin ( angle ) * 2 ;
float y = FastMath . sin ( angle ) * 2 ;
emit . setLocalTranslation ( x , 0 , y ) ;
emit . setLocalTranslation ( x , 0 , y ) ;
}
}
}
}