Bug with particle mesh?

  1. Don't believe the bug was brought up before, therefor im doubting if its a bug or me doing something wrong


  2. I've been toying arround with the new particlemesh and particlefactory and came to the conclusion I couldn't move them with "setLocalTranslation". Whenever I create a particlemesh and want to move it, I need to set the localTranslation of the node instead of the particlemesh. I believe that's strange since there is a "setLocalTranslation" for particlemesh's



   
   private void buildFire()
   {
      
       AlphaState as1 = display.getRenderer().createAlphaState();
       as1.setBlendEnabled(true);
       as1.setSrcFunction(AlphaState.SB_SRC_ALPHA);
       as1.setDstFunction(AlphaState.DB_ONE);
       as1.setTestEnabled(true);
       as1.setTestFunction(AlphaState.TF_GREATER);
       as1.setEnabled(true);

       TextureState ts = display.getRenderer().createTextureState();
       ts.setTexture(
           TextureManager.loadTexture(
           TestParticleSystem.class.getClassLoader().getResource(
           "jmetest/data/texture/flaresmall.jpg"),
           Texture.MM_LINEAR_LINEAR,
           Texture.FM_LINEAR));
       ts.setEnabled(true);
      
      manager = ParticleFactory.buildParticles( "Particles", 300);//, display.getRenderer().etCamera());
      manager.setGravityForce(new Vector3f(0.0f, 0.0f, 0.0f));
      manager.setEmissionDirection(new Vector3f(0.0f, 1.0f, 0.0f));
      manager.setMaximumAngle(0.20943952f);
      manager.setMinimumAngle(0.0f);
      manager.setSpeed(1.0f);
      manager.setMinimumLifeTime(1000.0f);
      manager.setStartSize(40.0f);
      manager.setEndSize(40.0f);
      manager.setStartColor(new ColorRGBA(1.0f, 0.312f, 0.121f, 1.0f));
      manager.setEndColor(new ColorRGBA(1.0f, 0.312f, 0.121f, 0.0f));
      manager.setRandomMod(6.0f);
      manager.setControlFlow(true);
      manager.setReleaseRate(300);
      manager.setReleaseVariance(0.0f);
      manager.setInitialVelocity(0.29999998f);
      manager.setParticleSpinSpeed(0.0f);
//      manager.setLocalTranslation(new Vector3f(0, 1000,0));
      
      manager.warmUp(1000);

      partNode = new Node("Particle Nodes");
      partNode.setRenderState(as1);
      partNode.setRenderState(ts);
      partNode.attachChild(manager);
      partNode.setLocalScale(0.02f);
//      partNode.setLocalTranslation(new Vector3f(0,-1000,0));
      ZBufferState zstate = DisplaySystem.getDisplaySystem().getRenderer().createZBufferState();
      zstate.setWritable(false);
      zstate.setEnabled(true);
      zstate.setFunction( ZBufferState.CF_LEQUAL );
      manager.setRenderState(zstate);
      
      scene.attachChild(partNode);
      
   }



Uncomment the first comment and nothing changes. Uncomment the second and the particle mesh gets moved. Uncomment both and the particle mesh moves the same way.


3. Had no error messages

4. System specs: AMD Opteron 165
                        1gb OCZ PC4800 Platinum Edition
                        7800GT 2x SLI
                        DFI Lanparty eXpert UT nForce4
                        Windows XP Sp2
                       

i think a ParticleMesh uses setOriginOffset and disregards anything set with setLocalTranslation…(dunno why actually)

The ParticleMesh itself disregards setLocalTranslation, you're right about that.



I checked the setOriginOffset and it appears I can move stuff arround again. Something strange is that all of a sudden my coordinates are wrong. In jME 0.9 I had to use Vector3f(2,5 , 1 , -1) to get to place it on a specific location. Now I have to use 500,200,-200 for instance. Why was this change made?

cause originOffset is not affected by your 0.02f scaling…maybe it should though, just like translation is affected through localToWorld…renanse?

MrCoder said:

cause originOffset is not affected by your 0.02f scaling...maybe it should though, just like translation is affected through localToWorld...renanse?


So a quick solution to this would then be to multiply my coords by 50?

Or to divide it by 0.02f :wink:

Problem solved!  :smiley:

Please log an issue in the tracker to clear up this confusion, I'd like to get find and get rid of all these inconsistencies.

Much of the tweaks in ParticleMesh were to allow it to run in much more complex situations than a point, so what makes sense for a particle emitter coming from a point can make issues in systems where you say have a point emitter attached to the hand of an animated model, or for example an emitter that emits from random points on a sword being held by the hand bone of an animated model.  origin offset should use scale definitely either way, but I can look again into using local translation in place of that field.  (iirc, the issue was something to do with scenegraph transforms colliding with particle emission point calculations)

TestDynamicSmoker is also broken.

Fixed locally, it wasn't changed to read back the model correctly.  Will check in tomorrow after looking at a particle issue.

fixed? you sure? i'm used last version from cvs

when invoke  doExpl() (automaticaly in update method) explosion has coords 150 0 150

but when i'm invoke  doExpl() in another place in program it has coords 0 0 0

any ideas?

use particles.setOriginOffset(); not help



   public static void init() {
        System.out.println("init");
        World.getInstance().getBack().init();
        getDisplaySystemProvider().getRoot().attachChild(World.getInstance().getBack().getBack());
        getDisplaySystemProvider().getRoot().updateRenderState();
        getDisplaySystemProvider().getRoot().attachChild(World.getInstance().getBack().getSky());
        MouseInput.get().addListener(World.getInstance().getDsp().getCamhand());
        mesh();
    }
    private static float count;

    public static void update() {
        timer.update();
        if (count > 1) {
            doExpl();
            count = 0;
        }
        system.getRenderer().clearBuffers();
        system.getRoot().updateGeometricState(timer.getTimePerFrame(), true);
        system.getRoot().updateRenderState();
        system.getRenderer().draw(system.getRoot());
        count = count + timer.getTimePerFrame();
    }   
    public static void doExpl() {
        particles.forceRespawn();
    }
    public static void mesh() {
        particles = ParticleFactory.buildParticles("particles", 100);
        particles.setEmissionDirection(new Vector3f(0, 1, 0));
        particles.setMinimumLifeTime(1000.0f);
        particles.setMaximumLifeTime(1500.0f);
        particles.setStartSize(310.0f);
        particles.setEndSize(310.0f);
        particles.setWorldEmit(new Vector3f(30, 30, 30));
        particles.setStartColor(new ColorRGBA(1.0f, 0.0625f, 0.0f, 1.0f));
        particles.setEndColor(new ColorRGBA(1.0f, 0.0625f, 0.0f, 0.0f));
        particles.setMaximumAngle(3.1415927f);
        particles.setMinimumAngle(0);
        particles.getParticleController().setControlFlow(false);
        particles.getLocalTranslation().set(new Vector3f(20, 20, 20));
        particles.getParticleController().setSpeed(2.9f);
        particles.getParticleController().setControlFlow(false);
        particles.getParticleController().setRepeatType(Controller.RT_CLAMP);
//        SwarmInfluence swarm = new SwarmInfluence(new Vector3f(particles.getWorldTranslation()), .001f);
//        swarm.setMaxSpeed(.3f);
//        swarm.setSpeedBump(0.035f);
//        swarm.setTurnSpeed(FastMath.DEG_TO_RAD * 360);
//        particles.addInfluence(swarm);
        AlphaState as1 = World.getInstance().getDsp().getRenderer().createAlphaState();
        as1.setBlendEnabled(true);
        as1.setSrcFunction(AlphaState.SB_SRC_ALPHA);
        as1.setDstFunction(AlphaState.DB_ONE);
        as1.setTestEnabled(true);
        as1.setTestFunction(AlphaState.TF_GREATER);
        as1.setEnabled(true);
        particles.setRenderState(as1);
        particles.setRenderQueueMode(Renderer.QUEUE_SKIP);
        TextureState ts = World.getInstance().getDsp().getRenderer().createTextureState();
        ts.setTexture(
                TextureManager.loadTexture(

                        "client\resource\images\flaresmall.jpg",
                        Texture.MM_LINEAR_LINEAR,
                        Texture.FM_LINEAR));
        ts.setEnabled(true);
        particles.setRenderState(ts);
        ZBufferState zstate = World.getInstance().getDsp().getRenderer().createZBufferState();
        zstate.setEnabled(false);
        particles.setRenderState(zstate);
        particles.setModelBound(new BoundingBox());
        particles.setLocalScale(0.003f);
        particles.updateRenderState();
        particles.updateModelBound();
        particles.setLocalTranslation(new Vector3f(150, 0, 150));
//        particles.setOriginOffset(new Vector3f(150,0,150));
        Node partNode = new Node("Particle Nodes");
//        partNode.setRenderState(as1);
//        partNode.setRenderState(ts);
        partNode.attachChild(particles);
        partNode.setLocalTranslation(new Vector3f(150, 0, 150));
        partNode.updateRenderState();
// partNode.setLocalTranslation(new Vector3f(0,-1000,0));
//        system.getRoot().attachChild(particles);
        system.getRoot().attachChild(partNode);
    }