[SOLVED] ParticleMonkey bug?

I have this code, very similar to the documentation on the store:

            emitter.getInfluencer(SizeInfluencer.class).setSizeOverTime(new ValueType(new Curve()
                    .addControlPoint(null, new Vector2f(1.0f, 1.0f), new Vector2f(0.7f, 1.0f))
                    .addControlPoint(new Vector2f(0.7f, 1.0f), new Vector2f(0.5f, 1.0f), new Vector2f(0.3f, 1.0f))
                    .addControlPoint(new Vector2f(0.3f, 0.1f), new Vector2f(0.0f, 0.0f), null)
            ));

see

But instead of the desired effect, I get:

java.lang.NullPointerException
	at com.epaga.particles.valuetypes.Curve.getValue(Curve.java:89)
	at com.epaga.particles.valuetypes.ValueType.getValue(ValueType.java:113)
	at com.epaga.particles.influencers.SizeInfluencer.update(SizeInfluencer.java:57)
	at com.epaga.particles.particle.ParticleData.update(ParticleData.java:173)
	at com.epaga.particles.Emitter.updateEmitter(Emitter.java:660)
	at com.epaga.particles.EmitterControl.update(EmitterControl.java:85)
	at com.jme3.scene.Spatial.runControlUpdate(Spatial.java:737)
	at com.jme3.scene.Spatial.updateLogicalState(Spatial.java:880)
	at com.jme3.scene.Node.updateLogicalState(Node.java:231)
	at com.jme3.scene.Node.updateLogicalState(Node.java:242)
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:262)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:153)
	at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:193)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:234)
	at java.lang.Thread.run(Thread.java:745)

So, what you need to remember when working with curves is that the ‘X’ value represents time. In this case, you add the control points and internally it sorts them based on the control point. Since the last point, you add is 0, it becomes the first point and it expects there to be an “out” control point.

emitter.getInfluencer(SizeInfluencer.class).setSizeOverTime(new ValueType(new Curve()
            .addControlPoint(null, new Vector2f(0.0f, 1.0f), new Vector2f(0.7f, 1.0f))
            .addControlPoint(new Vector2f(0.7f, 1.0f), new Vector2f(0.5f, 1.0f), new Vector2f(0.3f, 1.0f))
            .addControlPoint(new Vector2f(0.3f, 0.1f), new Vector2f(1.0f, 0.0f), null)
    ));
1 Like