com.jme3.effect.influencers.ParticleInfluencer Java Examples

The following examples show how to use com.jme3.effect.influencers.ParticleInfluencer. 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: ChangeParticleInfluencerOperation.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
private void switchInfluencer(final @NotNull ModelChangeConsumer editor) {

        final ParticleInfluencer influencer = emitter.getParticleInfluencer();
        final ParticleInfluencer newInfluencer = prevInfluencer;
        prevInfluencer = influencer;
        emitter.setParticleInfluencer(newInfluencer);

        EXECUTOR_MANAGER.addFxTask(() -> editor.notifyFxReplaced(emitter, prevInfluencer, newInfluencer, true, true));
    }
 
Example #2
Source File: ParticleInfluencerPropertyBuilder.java    From jmonkeybuilder with Apache License 2.0 5 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 ParticleInfluencer)) return;

    final ParticleInfluencer influencer = (ParticleInfluencer) object;
    final Vector3f initialVelocity = influencer.getInitialVelocity();

    final float velocityVariation = influencer.getVelocityVariation();

    final Vector3fPropertyControl<ModelChangeConsumer, ParticleInfluencer> initialVelocityControl =
            new Vector3fPropertyControl<>(initialVelocity, Messages.MODEL_PROPERTY_INITIAL_VELOCITY, changeConsumer);

    initialVelocityControl.setSyncHandler(ParticleInfluencer::getInitialVelocity);
    initialVelocityControl.setApplyHandler(ParticleInfluencer::setInitialVelocity);
    initialVelocityControl.setEditObject(influencer);

    FXUtils.addToPane(initialVelocityControl, container);

    if (object instanceof RadialParticleInfluencer) {
        createControls(container, changeConsumer, (RadialParticleInfluencer) object);
    } else {
        buildSplitLine(initialVelocityControl);
    }

    if (influencer instanceof EmptyParticleInfluencer) {
        initialVelocityControl.setDisable(true);
    }

    final FloatPropertyControl<ModelChangeConsumer, ParticleInfluencer> velocityVariationControl =
            new FloatPropertyControl<>(velocityVariation, Messages.MODEL_PROPERTY_VELOCITY_VARIATION, changeConsumer);

    velocityVariationControl.setSyncHandler(ParticleInfluencer::getVelocityVariation);
    velocityVariationControl.setApplyHandler(ParticleInfluencer::setVelocityVariation);
    velocityVariationControl.setEditObject(influencer);

    FXUtils.addToPane(velocityVariationControl, container);
}
 
Example #3
Source File: DefaultParticlesTreeNodeFactory.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
public <T, V extends TreeNode<T>> @Nullable V createFor(@Nullable final T element, final long objectId) {

    if (element instanceof ParticleEmitter) {
        return unsafeCast(new ParticleEmitterTreeNode((ParticleEmitter) element, objectId));
    } else if (element instanceof EmitterShape) {

        if (element instanceof EmitterBoxShape) {
            return unsafeCast(new EmitterBoxShapeTreeNode((EmitterBoxShape) element, objectId));
        } else if (element instanceof EmitterSphereShape) {
            return unsafeCast(new EmitterSphereShapeTreeNode((EmitterSphereShape) element, objectId));
        } else if (element instanceof EmitterPointShape) {
            return unsafeCast(new EmitterPointShapeTreeNode((EmitterPointShape) element, objectId));
        } else if (element instanceof EmitterMeshConvexHullShape) {
            return unsafeCast(new EmitterMeshConvexHullShapeTreeNode((EmitterMeshConvexHullShape) element, objectId));
        } else if (element instanceof EmitterMeshFaceShape) {
            return unsafeCast(new EmitterMeshFaceShapeTreeNode((EmitterMeshFaceShape) element, objectId));
        } else if (element instanceof EmitterMeshVertexShape) {
            return unsafeCast(new EmitterMeshVertexShapeTreeNode((EmitterMeshVertexShape) element, objectId));
        }

        return unsafeCast(new EmitterShapeTreeNode((EmitterShape) element, objectId));

    } else if (element instanceof ParticleInfluencer) {

        if (element instanceof EmptyParticleInfluencer) {
            return unsafeCast(new EmptyParticleInfluencerTreeNode((EmptyParticleInfluencer) element, objectId));
        } else if (element instanceof RadialParticleInfluencer) {
            return unsafeCast(new RadialParticleInfluencerTreeNode((RadialParticleInfluencer) element, objectId));
        } else if (element instanceof DefaultParticleInfluencer) {
            return unsafeCast(new DefaultParticleInfluencerTreeNode((DefaultParticleInfluencer) element, objectId));
        }

        return unsafeCast(new ParticleInfluencerTreeNode((ParticleInfluencer) element, objectId));
    }

    return null;
}
 
Example #4
Source File: ParticleEmitterTreeNode.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
public @NotNull Array<TreeNode<?>> getChildren(@NotNull final NodeTree<?> nodeTree) {

    final ParticleEmitter element = getElement();
    final TreeNode<ParticleInfluencer> influencerTreeNode = FACTORY_REGISTRY.createFor(element.getParticleInfluencer());
    final TreeNode<EmitterShape> shapeTreeNode = FACTORY_REGISTRY.createFor(element.getShape());

    final Array<TreeNode<?>> children = ArrayFactory.newArray(TreeNode.class);
    if (influencerTreeNode != null) children.add(influencerTreeNode);
    if (shapeTreeNode != null) children.add(shapeTreeNode);
    children.addAll(super.getChildren(nodeTree));

    return children;
}
 
Example #5
Source File: AbstractCreateParticleInfluencerAction.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
protected void process() {
    super.process();

    final NodeTree<ModelChangeConsumer> nodeTree = getNodeTree();
    final ModelChangeConsumer changeConsumer = notNull(nodeTree.getChangeConsumer());

    final TreeNode<?> treeNode = getNode();
    final ParticleEmitter emitter = (ParticleEmitter) treeNode.getElement();
    final ParticleInfluencer influencer = createInfluencer();

    changeConsumer.execute(new ChangeParticleInfluencerOperation(influencer, emitter));
}
 
Example #6
Source File: JmeParticleEmitter.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected Sheet createSheet() {
    //TODO: multithreading..
    Sheet sheet = super.createSheet();
    Sheet.Set set = Sheet.createPropertiesSet();
    set.setDisplayName("ParticleEmitter");
    set.setName(ParticleEmitter.class.getName());
    ParticleEmitter obj = geom;//getLookup().lookup(Spatial.class);
    if (obj == null) {
        return sheet;
    }


    set.put(createButtonProperty());
    set.put(makeProperty(obj, boolean.class, "isEnabled", "setEnabled", "Enabled"));
    set.put(makeProperty(obj, ParticleMesh.Type.class, "getMeshType", "setMeshType", "Mesh Type"));
    set.put(makeProperty(obj, EmitterShape.class, "getShape", "setShape", "Emitter Shape"));
    set.put(makeProperty(obj, int.class, "getMaxNumParticles", "setNumParticles", "Num Particles"));
    set.put(makeProperty(obj, float.class, "getParticlesPerSec", "setParticlesPerSec", "Particles Per Sec"));
    set.put(makeProperty(obj, ColorRGBA.class, "getStartColor", "setStartColor", "Start Color"));
    set.put(makeProperty(obj, ColorRGBA.class, "getEndColor", "setEndColor", "End Color"));
    set.put(makeProperty(obj, float.class, "getStartSize", "setStartSize", "Start Size"));
    set.put(makeProperty(obj, float.class, "getEndSize", "setEndSize", "End Size"));
    set.put(makeProperty(obj, float.class, "getHighLife", "setHighLife", "High Life"));
    set.put(makeProperty(obj, float.class, "getLowLife", "setLowLife", "Low Life"));
    set.put(makeProperty(obj, Vector3f.class, "getGravity", "setGravity", "Gravity"));
    set.put(makeEmbedProperty(obj.getParticleInfluencer(), ParticleInfluencer.class, Vector3f.class, "getInitialVelocity", "setInitialVelocity", "Initial Velocity"));
    set.put(makeEmbedProperty(obj.getParticleInfluencer(), ParticleInfluencer.class, float.class, "getVelocityVariation", "setVelocityVariation", "Velocity Variation"));
    set.put(makeProperty(obj, Vector3f.class, "getFaceNormal", "setFaceNormal", "Face Normal"));
    set.put(makeProperty(obj, boolean.class, "isFacingVelocity", "setFacingVelocity", "Facing Velocity"));
    set.put(makeProperty(obj, boolean.class, "isRandomAngle", "setRandomAngle", "Random Angle"));
    set.put(makeProperty(obj, boolean.class, "isInWorldSpace", "setInWorldSpace", "World Space"));
    set.put(makeProperty(obj, float.class, "getRotateSpeed", "setRotateSpeed", "Rotate Speed"));
    set.put(makeProperty(obj, boolean.class, "isSelectRandomImage", "setSelectRandomImage", "Select Random Image"));
    set.put(makeProperty(obj, int.class, "getImagesX", "setImagesX", "Images X"));
    set.put(makeProperty(obj, int.class, "getImagesY", "setImagesY", "Images Y"));
    sheet.put(set);

    return sheet;

}
 
Example #7
Source File: CreateRadialParticleInfluencerAction.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
@Override
@FxThread
protected @NotNull ParticleInfluencer createInfluencer() {
    return new RadialParticleInfluencer();
}
 
Example #8
Source File: CreateEmptyParticleInfluencerAction.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
@Override
@FxThread
protected @NotNull ParticleInfluencer createInfluencer() {
    return new EmptyParticleInfluencer();
}
 
Example #9
Source File: CreateDefaultParticleInfluencerAction.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
@Override
@FxThread
protected @NotNull ParticleInfluencer createInfluencer() {
    return new DefaultParticleInfluencer();
}
 
Example #10
Source File: ParticleInfluencerTreeNode.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
@Override
@FromAnyThread
public @NotNull String getName() {
    final ParticleInfluencer element = getElement();
    return element.getClass().getSimpleName();
}
 
Example #11
Source File: ParticleInfluencerTreeNode.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
public ParticleInfluencerTreeNode(@NotNull final ParticleInfluencer element, final long objectId) {
    super(element, objectId);
}
 
Example #12
Source File: AbstractCreateParticleInfluencerAction.java    From jmonkeybuilder with Apache License 2.0 2 votes vote down vote up
/**
 * Create influencer particle influencer.
 *
 * @return the particle influencer
 */
@FxThread
protected abstract @NotNull ParticleInfluencer createInfluencer();
 
Example #13
Source File: ParticleEmitter.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Set the {@link ParticleInfluencer} to influence this particle emitter.
 *
 * @param particleInfluencer the {@link ParticleInfluencer} to influence
 * this particle emitter.
 *
 * @see ParticleInfluencer
 */
public void setParticleInfluencer(ParticleInfluencer particleInfluencer) {
    this.particleInfluencer = particleInfluencer;
}
 
Example #14
Source File: ParticleEmitter.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Returns the {@link ParticleInfluencer} that influences this
 * particle emitter.
 *
 * @return the {@link ParticleInfluencer} that influences this
 * particle emitter.
 *
 * @see ParticleInfluencer
 */
public ParticleInfluencer getParticleInfluencer() {
    return particleInfluencer;
}
 
Example #15
Source File: MyParticleEmitter.java    From OpenRTS with MIT License 2 votes vote down vote up
/**
 * Set the {@link ParticleInfluencer} to influence this particle emitter.
 * 
 * @param particleInfluencer the {@link ParticleInfluencer} to influence 
 * this particle emitter.
 * 
 * @see ParticleInfluencer
 */
@Override
public void setParticleInfluencer(ParticleInfluencer particleInfluencer) {
    this.particleInfluencer = particleInfluencer;
}
 
Example #16
Source File: MyParticleEmitter.java    From OpenRTS with MIT License 2 votes vote down vote up
/**
 * Returns the {@link ParticleInfluencer} that influences this 
 * particle emitter.
 * 
 * @return the {@link ParticleInfluencer} that influences this 
 * particle emitter.
 * 
 * @see ParticleInfluencer
 */
@Override
public ParticleInfluencer getParticleInfluencer() {
    return particleInfluencer;
}
 
Example #17
Source File: ParticleEmitter.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Set the {@link ParticleInfluencer} to influence this particle emitter.
 * 
 * @param particleInfluencer the {@link ParticleInfluencer} to influence 
 * this particle emitter.
 * 
 * @see ParticleInfluencer
 */
public void setParticleInfluencer(ParticleInfluencer particleInfluencer) {
    this.particleInfluencer = particleInfluencer;
}
 
Example #18
Source File: ParticleEmitter.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Returns the {@link ParticleInfluencer} that influences this 
 * particle emitter.
 * 
 * @return the {@link ParticleInfluencer} that influences this 
 * particle emitter.
 * 
 * @see ParticleInfluencer
 */
public ParticleInfluencer getParticleInfluencer() {
    return particleInfluencer;
}
 
Example #19
Source File: ChangeParticleInfluencerOperation.java    From jmonkeybuilder with Apache License 2.0 2 votes vote down vote up
/**
 * Instantiates a new Add particle influencer operation.
 *
 * @param influencer the influencer
 * @param emitter    the particle emitter
 */
public ChangeParticleInfluencerOperation(@NotNull final ParticleInfluencer influencer,
                                         @NotNull final ParticleEmitter emitter) {
    this.prevInfluencer = influencer;
    this.emitter = emitter;
}