ParticleMesh origin-bug

Hi,



Im able to set the location of where i want to place my particlemesh ( a small fire).  However, when im placing out these fires, there seems to be some bug in point (0,0,0). ( a small wink of fire appers ). i've tried setting a range of sensible values in warmUp(…) as suggested in other threads here, but this does not seem to have any effect.



Any ideas?

Just a guess, but maybe you set the direction (0,0,0).

That would explain, why you can see a small wink of fire.



Your code would be helpfull

DarkPhoenixX said:

Just a guess, but maybe you set the direction (0,0,0).


Thank you for your reply.

I'm guessing you mean location, and not direction? The emission direction should have no relevance.

The location is at no point set to (0,0,0).

The code below is part of a class that extends a node.
So in my main class i just add instances of these.

 
....
....
....

pMesh = ParticleFactory.buildParticles("particles", 300);
      pMesh.getParticleController().setActive(false);
      pMesh.addInfluence(SimpleParticleInfluenceFactory
            .createBasicGravity(new Vector3f(0, 0, -3f), true));
      pMesh.setMaximumAngle(0.5f);
      pMesh.setMinimumAngle(0);
      pMesh.getParticleController().setSpeed(1.0f);
      pMesh.setStartSize(30.0f);
      pMesh.setEndSize(100.0f);
      pMesh.setStartColor(new ColorRGBA(0.204f, 0.255f, 0.355f, 0.3f));
      pMesh.setEndColor(new ColorRGBA(0.204f, 0.255f, 0.355f, 0.0f));
      pMesh.getParticleController().setControlFlow(true);
      pMesh.getParticleController().setRepeatType(Controller.RT_WRAP);
      pMesh.setReleaseRate(300);
      pMesh.warmUp(10);


                Node particleBatch = new Node();
      particleBatch.attachChild(pMesh);
      particleBatch.setLocalTranslation(location);       // "location" is set in the constructor
      pMesh.setEmissionDirection(direction);
      DisplaySystem display = DisplaySystem.getDisplaySystem();
      BlendState as1 = display.getRenderer().createBlendState();
      as1.setBlendEnabled(true);
      as1.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
      as1.setDestinationFunction(BlendState.DestinationFunction.One);
      as1.setTestEnabled(true);
      as1.setTestFunction(BlendState.TestFunction.GreaterThan);
      as1.setEnabled(true);
      as1.setEnabled(true);

      TextureState ts = display.getRenderer().createTextureState();
      ts.setTexture(
            TextureManager.loadTexture(
                  TestParticleSystem.class.getClassLoader().getResource(
                  "particlefiles/flaresmall.jpg"),
                  Texture.MinificationFilter.Trilinear,
                  Texture.MagnificationFilter.Bilinear));
      ts.setEnabled(true);

      ZBufferState zstate = display.getRenderer().createZBufferState();
      zstate.setWritable( false );
      zstate.setEnabled( true );
      zstate.setFunction( ZBufferState.TestFunction.LessThanOrEqualTo);

      particleBatch.setLocalScale(0.02f);    // DEFAULT SCALE
      particleBatch.setRenderState(zstate);
      particleBatch.setRenderState(as1);
      particleBatch.setRenderState(ts);
      attachChild(particleBatch);

...
...
...



Edit: i've tried to tune up warmUp(..) .


It would be a lot easier to help if there was a test (simpleGame test) or even a screenshot showing the exact problem…

Thank you for your reply.



Here’s a screenshot to give you an idea.









Edit:



This is a smoke effect, i snapped this one because the origin-bug seems to stay longer. Probably because of the much slower initial velocitiy.

I wonder if this is not a reference problem (with your Vector3f)



try this:


particleBatch.getLocalTranslation().set(location);



instead of this:


particleBatch.setLocalTranslation(location);




(I don't think it is, but its worth a shot; and its the only thing that pops out...)

Thank you again for your reply.



I tried changing

particleBatch.setLocalTranslation(location);



to

particleBatch.getLocalTranslation().set(location);





Sadly, this did not fix the problem.







I've made som changes to the code. A jme file (identical to the fire example from particleeditor) is imported with a binary loader ( works fine ), and then this init method is run. thats it.


public void init(Vector3f location, Vector3f direction) {
      pMesh.setEmissionDirection(direction);
      setLocalTranslation(location);
            
      DisplaySystem display = DisplaySystem.getDisplaySystem();
      BlendState as1 = display.getRenderer().createBlendState();
      as1.setBlendEnabled(true);
      as1.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
      as1.setDestinationFunction(BlendState.DestinationFunction.One);
      as1.setTestEnabled(true);
      as1.setTestFunction(BlendState.TestFunction.GreaterThan);
      as1.setEnabled(true);
      TextureState ts = display.getRenderer().createTextureState();
      ts.setTexture(
            TextureManager.loadTexture(
                  TestParticleSystem.class.getClassLoader().getResource(
                  "no/hig/rss/particlefiles/flaresmall.jpg"),
                  Texture.MinificationFilter.Trilinear,
                  Texture.MagnificationFilter.Bilinear));
      ts.setEnabled(true);
      ZBufferState zstate = display.getRenderer().createZBufferState();
      zstate.setWritable( false );
      zstate.setEnabled( true );
      zstate.setFunction( ZBufferState.TestFunction.LessThanOrEqualTo);
      setRenderState(zstate);
      setRenderState(as1);
      setRenderState(ts);
      
      setLocalScale(0.02f);   
      attachChild(pMesh);
      
   }




We've been able to simulate fire distribution quite nicely, but we're still having some trouble with this origin-issue.




Again, any ideas?   :?


Try to call rootnode.updateGeometricState() after setting the location and attaching the particle to the scene.

I often had similar problems with particles but i don't know how i eventually got rid of them.



Can you reproduce the problem in a small test case?

That solved the problem!



Thank you very, very much!  :slight_smile: