Particles are basically quads that you texture and set colors etc. So I should be able to rotate those quads, so that they look like tiny "floors" that float up.
So what I'm saying is I want to rotate each particle so that it is oriented like the ground that the player is standing on, and have those float directly up, like stacks of paper.
I have already used setCameraFacing(false); to prevent it from rotating the quads at the camera, now all I need to do is have them float upwards. Any help is appreciated.
hi
i guess i solved your problem some time ago.
http://www.jmonkeyengine.com/jmeforum/index.php?topic=9215.0
I had the problem that i liked to have the particles stay in position and facing upwards.
I found that the localRotation and the localTranslation get reset in the updadeWold() of ParticleGeometry.
At least in the jme1 version.
I suggest to check if this is still the case in jme2.
I verified that it's possible to emit the particles upwards and facing upwards.
So here is the slightly altered test (you can compare it with the one in my Thread):
import com.jme.app.SimpleGame;
import com.jme.math.FastMath;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.shape.Box;
import com.jme.scene.shape.Sphere;
import com.jmex.effects.particles.ParticleFactory;
import com.jmex.effects.particles.ParticleMesh;
public class TestParticles extends SimpleGame {
@Override
protected void simpleInitGame() {
//Set up floor and indicators for the axis.
Box floor = new Box("",Vector3f.ZERO,30,0.2f,30);
floor.setLocalTranslation(0, -0.4f, 0);
rootNode.attachChild(floor);
Box xBox = new Box("",new Vector3f(5,0,0),1,1,1);
rootNode.attachChild(xBox);
Sphere zSphere = new Sphere("", new Vector3f(0,0,5),4,4,1);
rootNode.attachChild(zSphere);
//init the particles
ParticleMesh particles = ParticleFactory.buildParticles("Fountain", 4, ParticleMesh.PT_QUAD);
particles.setLocalTranslation(0,0,0);
particles.setStartColor(ColorRGBA.blue);
particles.setEndColor(new ColorRGBA(255,0,0,0));
particles.setStartSize(1.5f);
particles.setEndSize(3);
particles.setMinimumLifeTime(500);
particles.setMaximumLifeTime(800);
particles.setEmitType(ParticleMesh.ET_POINT);
particles.setEmissionDirection(Vector3f.UNIT_Z.negate());
particles.setMinimumAngle(0);
particles.setMaximumAngle(0);
particles.setInitialVelocity(0.01f);
particles.setSpeed(0.3f);
particles.warmUp(1);
//dont want the particles direction to be influenced by velocity or camera
particles.setCameraFacing(false);
particles.setVelocityAligned(false);
//**Interesting Part**
//****Approach I:****
//try to rotate the particles to be emmited in +y direction and facing +y by
// particles.setEmissionDirection(new Vector3f(0,0,0));
particles.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.PI/2, Vector3f.UNIT_X));
// particles.setRotateWithScene(true);
// particles.setWorldEmit(new Vector3f(0,0,1));
// particles.setParticleOrientation(FastMath.PI/2);
// particles.rotateUpTo(Vector3f.UNIT_Y);
// particles.lookAt(new Vector3f(0,500,0), Vector3f.UNIT_Y);
// ParticleController controller = (ParticleController) particles.getControllers().get(0);
// controller.getParticles().setLocalRotation(new Quaternion().fromAngleAxis(FastMath.PI/2, Vector3f.UNIT_X));
// controller.getParticles().lookAt(new Vector3f(0,500,0), Vector3f.UNIT_Y);
rootNode.attachChild(particles);
//****Approach II:****
//try to put the particles into a new node and rotate the particles using the nodes translation
// particles.setLocalRotation(new Quaternion().fromAngleAxis(0, Vector3f.UNIT_X));
// Node particleNode = new Node();
// particleNode.attachChild(particles);
// particleNode.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.PI/2, Vector3f.UNIT_X));
// rootNode.attachChild(particleNode);
rootNode.updateGeometricState(0, true);
rootNode.updateRenderState();
}
//main()
public static void main(String[] args) {
TestParticles app = new TestParticles();
app.start();
}
}
hope this helps.
greetz
Imm0