[SOLVED] How to make a fireball in jME3.1

I am having trouble with creating a fireball type model which has a particle emitter attached to it.

I am creating a node and then creating a particle emitter object.
I am setting the setInWorldSpace() method to true.

When I try to move the particles it does not want to move at all.

Any help would be appreciated.

PS: This used to work in jME3.0.

Sample code:

package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;

/**
 * This is the Main Class of your Game. You should only do initialization here.
 * Move your Logic into AppStates or Controls
 *
 * @author normenhansen
 */
public class Main extends SimpleApplication {
    
    private ParticleEmitter fireEffect;
    private float speed = 1;

    public static void main(String[] args) {
        Main app = new Main();
        app.start();
    }

    @Override
    public void simpleInitApp() {
        
        cam.setLocation(new Vector3f(0, 5, 10));
        cam.lookAt(new Vector3f(0, 0, 0), Vector3f.UNIT_Y);
        
        
        Box b = new Box(10, 0.1f, 10);
        Geometry geom = new Geometry("Box", b);

        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setColor("Color", ColorRGBA.Gray);
        geom.setMaterial(mat);

        rootNode.attachChild(geom);

        /**
         * Uses Texture from jme3-test-data library!
         */
        fireEffect = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 60);
        Material fireMat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
        fireMat.setTexture("Texture", assetManager.loadTexture("com/jme3/app/Monkey.png"));
        fireEffect.setMaterial(fireMat);
        fireEffect.setImagesX(1);
        fireEffect.setImagesY(1); // 2x2 texture animation
        fireEffect.setEndColor(new ColorRGBA(1f, 0f, 0f, 1f));   // red
        fireEffect.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f)); // yellow
        fireEffect.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 2, 0));
        fireEffect.setStartSize(0.35f);
        fireEffect.setEndSize(0.1f);
        fireEffect.setGravity(0f, 0f, 0f);
        fireEffect.setLowLife(2f);
        fireEffect.setHighLife(3f);
        
        //If the particle emitter is in world space it does not want to move.
        fireEffect.setInWorldSpace(true);
        
        fireEffect.getParticleInfluencer().setVelocityVariation(0.1f);
        rootNode.attachChild(fireEffect);
        
        

    }

    @Override
    public void simpleUpdate(float tpf) {
        //TODO: add update code        
        fireEffect.move(tpf*speed, 0, 0);
        
        if (fireEffect.getWorldTranslation().x > 5 || fireEffect.getWorldTranslation().x < -5) {
            speed = speed * -1;
        }
    }

    @Override
    public void simpleRender(RenderManager rm) {
        //TODO: add render code
    }
}

1 Like

I offer to use toneg0d.emitter library, it provides more advanced particles API and I provide supporting of this library. Also, jMB has very good integration with it.

1 Like

The problem is it used to work and I think it needs to be fixed.
Also I prefer keeping the standard particle emitter.

2 Likes

jMB has integration with the default particle system as well, so, can you play with this problem in jMB? I just want to know how much relevant this problem for jME 3.2 :slight_smile:

1 Like

Your example works for me (particle emitter moving back and forth, emitting particles upwards).
I’m building from master (a couple of weeks old)
Edit: I also tried TestMovingParticle, which is a similar use case and it also worked fine
Edit 2: My latest pull was on Dec 5th

1 Like

It’s probably related to this roll back PR 746 (worldTransform to identity) in master branch · jMonkeyEngine/jmonkeyengine@e0230a4 · GitHub
There was a discussion too but I can’t find it

1 Like

My code is based on master and I build the code 12 Dec.
It is definitely not working for me.
It is also not working in @javasabr, jMB.

1 Like

I’ve tested the sample code with both JME 3.1.0-stable and JME 3.2.0-alpha3, and it behaved as I expected it to.

If your build is based on ‘master’ branch of JME as of 12 December 2017, then you’re not using 3.1; you’re using a build equivalent to JME 3.2.0-alpha3.

The issue rickard referred to was present in ‘master’ branch from 27 September to 1 December 2017. It was fixed by the following commit:
roll back PR 746 (worldTransform to identity) in master branch · jMonkeyEngine/jmonkeyengine@e0230a4 · GitHub

1 Like

I can’t reproduce the issue neither, the particle emitter is moving

2 Likes

That is really very strange. I am now clueless.

So what I did was to checkout the jME3.2 master code and made a build with it.

I then ran this,

gradlew.bat -PbuildJavaDoc=true install

After that I checked out the sdk code and made a build with in netbeans of the sdk.

I then installed the sdk and created a new project with that piece of code.

My results is not the same as that.

I think there is more things to do in the SDK to have the latest engine version to be taken into account when you create a new project (@Darkchaos could you confirm?)

When you run the app at the beginning of the log you have the version / git hash and build date of your JME version could you post that here please?

1 Like

Sure, here it is:

run:
Dec 23, 2017 11:39:21 AM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.2-6419
 * Branch: master
 * Git Hash: 9578b04
 * Build Date: 2017-12-11
Dec 23, 2017 11:39:22 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 2.9.3 context running on thread jME3 Main
 * Graphics Adapter: igdumdim64
 * Driver Version: 10.18.14.4170
 * Scaling Factor: 1
Dec 23, 2017 11:39:22 AM com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFO: OpenGL Renderer Information
 * Vendor: Intel
 * Renderer: Intel(R) HD Graphics 4600
 * OpenGL Version: 4.3.0 - Build 10.18.14.4170
 * GLSL Version: 4.30 - Build 10.18.14.4170
 * Profile: Compatibility
Dec 23, 2017 11:39:22 AM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.blender.BlenderModelLoader
Dec 23, 2017 11:39:22 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio Renderer Information
 * Device: OpenAL Soft
 * Vendor: OpenAL Community
 * Renderer: OpenAL Soft
 * Version: 1.1 ALSOFT 1.15.1
 * Supported channels: 64
 * ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_loopback
 * AL extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_source_latency
Dec 23, 2017 11:39:22 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
WARNING: Pausing audio device not supported.
Dec 23, 2017 11:39:22 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio effect extension version: 1.0
Dec 23, 2017 11:39:22 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio max auxiliary sends: 4

How can I point the SDK build to make use of the jme3.2-beta1?

1 Like

Ok it’s actually November 12th not December
your JME is based on this commit

The fix was a later commit from @sgold at the beginning of december.
So… just pull and rebuild :wink:

2 Likes

Let me give it a try.

1 Like

The SDK from Master builds the lastest 3.2 it can find, but this can be changed at the beginning of build.gradle

1 Like

And if I don’t use ant and I want to build from Netbeans?

How do I specify the jme version?

1 Like

You actually use gradle which invokes ant for you, you need gradlew buildSdk first since it creates the .xml files ant or netbeans (which uses ant internally) need. So same method, including gradlew buildSdk

1 Like

I did however notice that the sdk needs to pull its own jme and build it into the engine folder, is that correct?
And does it use that build as jME engine libs?

1 Like

Exactly. Thats because things like jbullet.jar and test data are missing in the official jCenter.

Just invoke gradlew -PbuildJavaDoc … install as mentioned above which will install jme3 into your Local Maven Repository.

This however means that if your own projects dont specify a specific Version, they will also run off Master instead of the latest alpha

1 Like

That is what I thought but when I run the build this is what happens.
Do you have any idea?

C:\workspaces\privatework\gitprojects\sdk>gradlew buildSdk
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/2.11/userguide/gradle_da
emon.html.
Full Version: 3.2-1776
POM Version: 3.2.0-SNAPSHOT
NBM Revision: 1776
NBM UC Suffix: nightly/3.2/plugins

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\workspaces\privatework\gitprojects\sdk\build.gradle' line: 342

* What went wrong:
A problem occurred evaluating root project 'sdk'.
> Could not resolve all dependencies for configuration ':optlibs'.
   > Could not resolve org.jmonkeyengine:jme3-jbullet:3.2.0-SNAPSHOT.
     Required by:
         :sdk:unspecified
      > Could not resolve org.jmonkeyengine:jme3-jbullet:3.2.0-SNAPSHOT.
         > Could not parse POM file:/C:/Users/Nidebruyn/.m2/repository/org/jmonkeyengine/jme3-jbullet/3.2.0-SNAPSHOT/jme3-jbullet-3.2.0-SNAPSHOT.pom
            > Unable to resolve version for dependency 'jbullet:jbullet:jar'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 16.118 secs
1 Like