com.jme3.effect.shapes.EmitterBoxShape Java Examples

The following examples show how to use com.jme3.effect.shapes.EmitterBoxShape. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EmitterShapePropertyBuilder.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
@Override
@FxThread
protected void buildForImpl(@NotNull final Object object, @Nullable final Object parent,
                            @NotNull final VBox container, @NotNull final ModelChangeConsumer changeConsumer) {

    if (!(object instanceof EmitterShape)) return;

    final EmitterShape shape = (EmitterShape) object;

    if (shape instanceof EmitterPointShape) {
        createControls(container, changeConsumer, (EmitterPointShape) object);
    } else if (shape instanceof EmitterBoxShape) {
        createControls(container, changeConsumer, (EmitterBoxShape) object);
    } else if (shape instanceof EmitterSphereShape) {
        createControls(container, changeConsumer, (EmitterSphereShape) object);
    }
}
 
Example #2
Source File: EmitterShapePropertyBuilder.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
/**
 * Create controls.
 *
 * @param container      the container.
 * @param changeConsumer the change consumer.
 * @param shape          the shape.
 */
@FxThread
private void createControls(@NotNull final VBox container, @NotNull final ModelChangeConsumer changeConsumer,
                            @NotNull final EmitterBoxShape shape) {

    final Vector3f length = shape.getLen();
    final Vector3f min = shape.getMin();

    final Vector3fPropertyControl<ModelChangeConsumer, EmitterBoxShape> lengthControl =
            new Vector3fPropertyControl<>(length, Messages.MODEL_PROPERTY_LENGTH, changeConsumer);

    lengthControl.setSyncHandler(EmitterBoxShape::getLen);
    lengthControl.setApplyHandler(EmitterBoxShape::setLen);
    lengthControl.setEditObject(shape);

    final Vector3fPropertyControl<ModelChangeConsumer, EmitterBoxShape> minControl =
            new Vector3fPropertyControl<>(min, Messages.MODEL_PROPERTY_MIN, changeConsumer);

    minControl.setSyncHandler(EmitterBoxShape::getMin);
    minControl.setApplyHandler(EmitterBoxShape::setMin);
    minControl.setEditObject(shape);

    FXUtils.addToPane(lengthControl, container);
    FXUtils.addToPane(minControl, container);
}
 
Example #3
Source File: CreateBoxShapeEmitterAction.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
protected @NotNull EmitterShape createEmitterShape(@NotNull final VarTable vars) {
    final Vector3f min = vars.get(PROPERTY_MIN);
    final Vector3f max = vars.get(PROPERTY_MAX);
    return new EmitterBoxShape(min, max);
}
 
Example #4
Source File: TestPointSprite.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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);
    emit.setLowLife(60);
    emit.setHighLife(60);
    emit.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 0));
    emit.setImagesX(15);
    emit.setStartSize(0.05f);
    emit.setEndSize(0.05f);
    emit.setStartColor(ColorRGBA.White);
    emit.setEndColor(ColorRGBA.White);
    emit.setSelectRandomImage(true);
    emit.emitAllParticles();
    
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
    mat.setBoolean("PointSprite", true);
    mat.setTexture("Texture", assetManager.loadTexture("Effects/Smoke/Smoke.png"));
    emit.setMaterial(mat);

    rootNode.attachChild(emit);
    inputManager.addListener(new ActionListener() {
        
        @Override
        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));
    
}
 
Example #5
Source File: TestPointSprite.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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);
    emit.setLowLife(60);
    emit.setHighLife(60);
    emit.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 0));
    emit.setImagesX(15);
    emit.setStartSize(0.05f);
    emit.setEndSize(0.05f);
    emit.setStartColor(ColorRGBA.White);
    emit.setEndColor(ColorRGBA.White);
    emit.setSelectRandomImage(true);
    emit.emitAllParticles();
    
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
    mat.setBoolean("PointSprite", true);
    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(5000);
                emit.emitAllParticles();
            }
        }
    }, "setNum");
    
    inputManager.addMapping("setNum", new KeyTrigger(KeyInput.KEY_SPACE));
    
}
 
Example #6
Source File: EmitterBoxShapeTreeNode.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
public EmitterBoxShapeTreeNode(@NotNull final EmitterBoxShape element, final long objectId) {
    super(element, objectId);
}