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
- 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.
- 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?