Physical particles?

Hi guys!



I created a particle generator and tried to make it using JME Physics. But unfortunatly I was only able to have the generator use physics, not the particles. Here's my code:



   private void createParticles() {
//      DynamicPhysicsNode node = getPhysicsSpace().createDynamicNode();
//      node.generatePhysicsGeometry();
//      node.setAffectedByGravity( true );
      
      particles = ParticleFactory.buildParticles("particle", 2000, ParticleMesh.ET_POINT);
      particles.setEmissionDirection(new Vector3f(0, 1, 0));
      particles.setMaximumLifeTime(1000.0f);
      particles.setMinimumLifeTime(60.0f);
        particles.setMaximumAngle(1.0f);
        particles.setMinimumAngle(0.5f);
        particles.setStartSize(0.1f);
        particles.setEndSize(2f);
        particles.setStartColor(new ColorRGBA(1f, 1f, 1f, 1f));
        particles.setEndColor(new ColorRGBA(0f, 0f, 1f, 0f));
        particles.setControlFlow(true);
        particles.setSpeed(0.7f);
        particles.setReleaseRate(1000);
        particles.setReleaseVariance(0.25f);
        particles.setInitialVelocity(0.06f);
        particles.setParticleSpinSpeed(0.0f);
        particles.setParticleMass(1f);
        particles.setParticleSpinSpeed(0.25f);
        particles.warmUp(300);
        particles.setLocalTranslation( new Vector3f(0, terrain.getHeight(0, 0), 0) );

        AlphaState as = DisplaySystem.getDisplaySystem().getRenderer().createAlphaState();
        as.setEnabled(true);
        as.setBlendEnabled(true);
        as.setSrcFunction(AlphaState.SB_SRC_ALPHA);
        as.setDstFunction(AlphaState.DB_DST_ALPHA);
//        as.setReference(0.0f);
//        as.setTestEnabled(true);
//        as.setTestFunction(AlphaState.TF_GEQUAL);
      TextureState ts2 = display.getRenderer().createTextureState();
      ts2.setTexture( TextureManager.loadTexture(
            RealisticSky.class.getClassLoader().getResource( "texture/spark.png"), Texture.MM_LINEAR_LINEAR, Texture.FM_LINEAR));
      ts2.setEnabled(true);

      particles.setRenderState( ts2 );
      particles.setRenderState( as );
      particles.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);
        particles.updateRenderState();
        rootNode.attachChild(particles);
//        node.attachChild(particles);
//        rootNode.attachChild(node);
   }



The physics code is comented out. Is there a way to have particles use physics and therefore obey the law of gravity? I tried to create a fountain like effect with it.

Currently there is no support for particles in jME Physics 2. It would be possible to simulate the movement of particles physically by simply creating a physics entitiy (e.g. in ODE a Body) for each particle. It was done this way in jmephysics0.4, but I'm not sure ODE (used in jmephysics0.4 and the current implementation of jME Physics 2) can handle a lot of such particles (we're speaking of thousands!). For performance reason I'd suggest to have particles simulated by jME and approximate physical behavior. If you really need correct physical simulation I can give you some more hints on how to integrate this in jME Physics 2.

Well, I'd be happy with a simulated behavior. Maybe I should look into the sources of ParticleFactory how the particles are created. Adding an interpolation of the physical calculation to the particle object won't be a problem. I give it a try, maybe I can get somewhere that matches my wishes.