Particle emitter problem

I have posted another thread, but this time im posting again with a video, hope this will clarify the problem.



http://www.youtube.com/watch?v=dwDx98AQLX0



I have a particle system, which is the following method,



[java]

public void throwFireball()

{

pe_fire = new ParticleEmitter(“Emitter”, Type.Triangle, 100);

Material mat_red = new Material(assetManager, “Common/MatDefs/Misc/Particle.j3md”);

mat_red.setTexture(“m_Texture”, assetManager.loadTexture(“Effects/Explosion/flame.png”));

pe_fire.setMaterial(mat_red);

pe_fire.setImagesX(2); pe_fire.setImagesY(2); // 2x2 texture animation

pe_fire.setEndColor( new ColorRGBA(1f, 0f, 0f, 1f)); // red

pe_fire.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f)); // yellow

pe_fire.setInitialVelocity(new Vector3f(0, 7, 0));

pe_fire.setStartSize(2.5f);

pe_fire.setEndSize(.1f);

pe_fire.setGravity(0);

pe_fire.setLowLife(0.5f);

pe_fire.setHighLife(2.75f);

pe_fire.setVelocityVariation(0.3f);

pe_fire.setRandomAngle(true);

pe_fire.setRotateSpeed(5);

pe_fire.setParticlesPerSec(3);



SphereCollisionShape cs_fire = new SphereCollisionShape(3);

pn_fire = new PhysicsNode(pe_fire, cs_fire, 1);

pn_fire.setLocalTranslation(-300,13, 122);

pn_fire.attachDebugShape(assetManager);

rootNode.attachChild(pn_fire);

bulletAppState.getPhysicsSpace().add(pn_fire);

pn_fire.setGravity(new Vector3f(0,-3,0));

pn_fire.applyImpulse(pn_fire.getLocalTranslation().subtract(pn_player.getLocalTranslation()).normalizeLocal().mult(100).negate(), Vector3f.ZERO/pn_fire.getLocalTranslation()/);

pe_fire.emitAllParticles();

}

[/java]



which is triggered by

[java]

if(fireTime>10)

{

if(rootNode.hasChild(pn_fire))

{

pe_fire.killAllParticles();

rootNode.detachChild(pn_fire);

bulletAppState.getPhysicsSpace().remove(pn_fire);

}

throwFireball();

fireTime = 0;

}

[/java]

this code is in the simpleUpdate



This code is called after every 10 sec, and a ‘fireball physicsNode’(pn_fire) is thrown towards the player with a particle emitter(pe_fire) attached.


  • Before diving into the issue, i wanna point out another thing, is that, even before calling explosion.emitAllParticles(), whenever i attach it(emitter) to the root node, is automatically emits.The fire particle example in the doc does this thing.What if i dont want it to happen?



    The problem, I will only see the incoming fireball when the particle emitter is in my view frustum.



    Two weird thing
  1. Why the particle emitter is at 0,0,0 position.(Yes, in the video, that is Vector3f.ZERO)When I havnt specified any location is the code about it.
  2. Why I need to have the particle emitter in the view frustum to see the flying fireball_physicsNode.



    In the video, you will see, the emitter appears at the same time, when the fireball appears. The fireball doesn’t appear when the emitter is out of my view(when I walk forward a little).When i walk back and bring the particle emitter again in the view frustum, i see the fireball again. It is like, optimizing, the scene, I cannt see the fireball when the particle emitter is out of my view, because, the actual position of the particle emitter is at 0,0,0



    :?



    Any explanation?

I guess it’s related to this issue

http://code.google.com/p/jmonkeyengine/issues/detail?id=251&q=label:Product-jME3&colspec=ID%20Type%20Status%20Component%20Priority%20Product%20Milestone%20Owner%20Summary

Is there any way that i can make it work?



Tried with setting culling to Never and updatingModelBound, first one, results in nothing and second on results in null Pointer. :frowning:

Can we make a test case that reproduces this issue?

mhh…it must be a different issue, the cull hint never should fix it if it was the issue i linked.

It has been fixed, but i still need to setCullHint to never.

Now it works like a charm :slight_smile:


  • I dont understand what a bounding box is?My guess is that it is used to check whether a object is within view frustum or not. In which cases i need to handle bounding box manually?

The setCullHint issue should be fixed in SVN now

pe_fire.setParticlesPerSec(3);



says that you want to emmit 3 per second, or you eman that it still emmits all particles at once?

I am not actually sure why this is like that. You emit all particles at once, and once all of those particles die, it will emit in the usual amount (3 particles per sec).