Particle System Source Code if ya want it…

@icamefromspace said: hey @t0neg0d, im late to the game here but ive got a little minor input on the bug youre speaking about (where setParticlesFollowEmitter(false) ) seems to not work to create the effect of particles being casted into the world, i think this might help reveal how to fix the problem. I think your underlying concept works, just perhaps you have a typo or a minor mistake somewhere in the logic.

anyways using your example code from the original post (with the exception that I make an “attachmentNode” where i add the control to, isntead of adding the emitter control to the rootnode.

anyway my first try to make this work i did just this:
[java]
e1.setParticlesFollowEmitter(false);

@Override
public void simpleUpdate(float tpf) {
super.simpleUpdate(tpf);

            attachmentNode.move(tpf, 0, 0); // emitter moves to the right



    }

[/java]

of course the smoke trail effect is going straight up, so i thought, “i wonder if i move the emitter node instead?”

so i do this

[java]
@Override
public void simpleUpdate(float tpf) {
super.simpleUpdate(tpf);

            e1.getEmitterNode().move(tpf, 0, 0);



    }

[/java]

well now it looks like the emitter is moving to the right, because its trailing off in to the left… however the emitter itself is standing still.

but if you combine the two lines of code… 0_o it creates the desired effect (moving particle emitter, and particles appear to be cast in to the world).

so its like its just using the translation of the wrong parent node.

i havent yet had the chance to fully understand your emitter system, but from your previous post it looks like the relevant code for this is in ParticleDataTriMesh.java on line 297ish… so I put this in there

[java]
if (emitter.getEmitterNode().getParent() != null) {
System.out.println(“not null”);
tempV3.set(p.position).subtractLocal(emitter.getEmitterNode().getParent().getWorldTranslation().subtract(p.initialPosition));
} else {
System.out.println(“wtf null?”);
tempV3.set(p.position).subtractLocal(emitter.getEmitterNode().getWorldTranslation().subtract(p.initialPosition));
}
[/java]

however its always “wtf null”. this goes into a subthought: perhaps the fact that the emitter node’s parent is null is why the trailing effect isnt working properly.

or maybe you already know all this and im wasting your time >.<. just trying to throw in my discoveries here so that maybe this could be figured out.

Just use emitter.setLocalTranslation(etc);

I’m a little out of it atm, so I’ll look at this closer tomorrow!

ah i didnt even realize emitter had setLocalTranslation() on it. now i kind of see how this is meant to be used.i guess a simple fix would be to add a little line of code to the control’s update() to constantly copy in the local translation to it on every frame… (my goal for my first emitter is bassicaly the exaust on a car)

thanks.

@icamefromspace said: ah i didnt even realize emitter had setLocalTranslation() on it. now i kind of see how this is meant to be used.i guess a simple fix would be to add a little line of code to the control's update() to constantly copy in the local translation to it on every frame.. (my goal for my first emitter is bassicaly the exact on a car)

thanks.

Yeah, unfortunately, for the time being the emitter doesn’t seem to like being nested when particles are supposed to act independent of the emitter. Best to keep them separate and update via the controls loop for now. I will get back to this and finish it up soon, however, I’m in the middle of more android crisis’ and trying to get some stuff resolved with the 2D framework (more of a best-practices guideline than crisis… but you get the idea).

you sure do have a lot on your plate! no one would kill you if you opted to take a day off :stuck_out_tongue:

btw ive been working on some enhancements to your emitter system. I created a control to coordinate multiple particle emitters to work together, and im working on some changes to emitter mesh to allow more customization on how/where particles are spawned on the mesh.

If youre interested in any of this stuff I can send you my changes after i get further along. if youre not interested thats ok too, Im doing this with plans to use your system in the game im working on, just thought id offer to share back.

1 Like
@icamefromspace said: you sure do have a lot on your plate! no one would kill you if you opted to take a day off :P

btw ive been working on some enhancements to your emitter system. I created a control to coordinate multiple particle emitters to work together, and im working on some changes to emitter mesh to allow more customization on how/where particles are spawned on the mesh.

If youre interested in any of this stuff I can send you my changes after i get further along. if youre not interested thats ok too, Im doing this with plans to use your system in the game im working on, just thought id offer to share back.

Looking forward to it!

@t0negod: any idea why the particles do not show up? When i enable EmitterTestMode(true,true) the wireframe objects look good. However, the textureing is not working at all.

Tried with my own material, as well as with Unshaded as you showed on the first page.

I use following code to create the particles:

[java]
Emitter emitter = new Emitter();
emitter.setMaxParticles(30);
emitter.setShape(new Quad(64, 64));
emitter.setSprite(“assets/textures/bullets/CommonBullet.png”, “ColorTexture”, 1, 1);
//emitter.setEmitterTestMode(true, true);
ColorInfluencer colorInfluencer = new ColorInfluencer();
colorInfluencer.addColor(ColorRGBA.Red);
colorInfluencer.addColor(ColorRGBA.White);
emitter.addInfluencer(colorInfluencer);
SizeInfluencer sizeInfluencer = new SizeInfluencer();
sizeInfluencer.addSize(10);
sizeInfluencer.addSize(50);
emitter.addInfluencer(sizeInfluencer);
emitter.setBillboardMode(Emitter.BillboardMode.Camera);
emitter.setDirectionType(EmitterMesh.DirectionType.Normal);

    Material material = gameMaterial.clone();
    material.getAdditionalRenderState().setDepthTest(false);
    material.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);
    setMaterialTexture(material, commonBullet);
    setMaterialVertexColor(material, true);
    emitter.setMaterial(material, "ColorTexture", true);


    emitter.setLifeMinMax(1, 5);
    emitter.setForceMinMax(2.25f, 5.0f);
    emitter.setUseRandomEmissionPoint(true);

    emitter.initialize(assetManager);
    emitter.setEnabled(true);
    objectNode.addControl(emitter);
    emitter.emitAllParticles();

[/java]

@zzuegg said: @t0negod: any idea why the particles do not show up? When i enable EmitterTestMode(true,true) the wireframe objects look good. However, the textureing is not working at all.

Tried with my own material, as well as with Unshaded as you showed on the first page.

I use following code to create the particles:

[java]
Emitter emitter = new Emitter();
emitter.setMaxParticles(30);
emitter.setShape(new Quad(64, 64));
emitter.setSprite(“assets/textures/bullets/CommonBullet.png”, “ColorTexture”, 1, 1);
//emitter.setEmitterTestMode(true, true);
ColorInfluencer colorInfluencer = new ColorInfluencer();
colorInfluencer.addColor(ColorRGBA.Red);
colorInfluencer.addColor(ColorRGBA.White);
emitter.addInfluencer(colorInfluencer);
SizeInfluencer sizeInfluencer = new SizeInfluencer();
sizeInfluencer.addSize(10);
sizeInfluencer.addSize(50);
emitter.addInfluencer(sizeInfluencer);
emitter.setBillboardMode(Emitter.BillboardMode.Camera);
emitter.setDirectionType(EmitterMesh.DirectionType.Normal);

    Material material = gameMaterial.clone();
    material.getAdditionalRenderState().setDepthTest(false);
    material.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);
    setMaterialTexture(material, commonBullet);
    setMaterialVertexColor(material, true);
    emitter.setMaterial(material, "ColorTexture", true);


    emitter.setLifeMinMax(1, 5);
    emitter.setForceMinMax(2.25f, 5.0f);
    emitter.setUseRandomEmissionPoint(true);

    emitter.initialize(assetManager);
    emitter.setEnabled(true);
    objectNode.addControl(emitter);
    emitter.emitAllParticles();

[/java]

I just tested this (without the custom material that is)… and see everything just fine. So… it has something to do with the material setup. Have you messed around with the BlendMode? It shouldn’t matter, however setting it to AlphaAdditive to help narrow down possibilities would be a good idea.

Also, are the particles/emitter shape supposed to be so big? At first I saw nothing because I was right near the bottom left corner of the emitter shape and didn’t realize the particles were above me.

If there is any way to send me the material/image being used, I would be able to help figure out the issue. Let me know if this is possible.

@zzuegg

ARGH!!! My post got et’ again >.<

Shorter version of reply:

Using the default material… I see the particles… so it is likely the material setup.

Can you post the MaterialDef and the image used so I can help figure it out for you?

With default material you are refering to non setting up the material at all?

[java]
Emitter emitter = new Emitter();
emitter.setMaxParticles(30);
emitter.setShape(new Quad(128, 64));
emitter.setSprite(“assets/textures/bullets/CommonBullet.png”, 1, 1);

    //  emitter.setEmitterTestMode(true, true);
    //   emitter.setParticleType(ParticleDataImpostorMesh.class);
    ColorInfluencer colorInfluencer = new ColorInfluencer();
    colorInfluencer.addColor(ColorRGBA.Red);
    colorInfluencer.addColor(ColorRGBA.White);
    emitter.addInfluencer(colorInfluencer);
    SizeInfluencer sizeInfluencer = new SizeInfluencer();
    sizeInfluencer.addSize(10);
    sizeInfluencer.addSize(20);
    emitter.addInfluencer(sizeInfluencer);
    emitter.setBillboardMode(Emitter.BillboardMode.Camera);
    emitter.setDirectionType(EmitterMesh.DirectionType.Normal);


    //Material material = gameMaterial.clone();
    //material.getAdditionalRenderState().setDepthTest(false);
    //material.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);
    //setMaterialTexture(material, commonBullet);
    //setMaterialVertexColor(material, true);
    //emitter.setMaterial(material, "ColorTexture", true);


    emitter.setLifeMinMax(1, 5);
    emitter.setForceMinMax(2.25f, 5.0f);
    emitter.setUseRandomEmissionPoint(true);

    emitter.initialize(assetManager);
    emitter.setEnabled(false);
    objectNode.addControl(emitter);
    emitter.emitAllParticles();

[/java]

does not work for me :frowning:

Is there a special requirement for the textures?

Oh, found the error.

It seems that the whole thing is not working when attached to the guiNode… god knows why.

Any solution to that?

@zzuegg said: Oh, found the error.

It seems that the whole thing is not working when attached to the guiNode… god knows why.

Any solution to that?

That’s odd… Though, it’s been some time since I tested this in the GUI Node as the 2D emitter in the GUI Library is far more efficient for this sort of thing. Let me run some tests here and figure out what the problem is.

MOTHER FOOOOOOOKER GOD DAMB PEICE OF FOOOKING SHEEET! The forum keeps eating my posts >.<

@zzuegg

Trying again…

I’ll run some tests and try to figure out what has changed. This used to work just fine in the GUI Node, though I haven’t used it that way in… well… forever as the 2D emitter provided in the GUI Library is far more efficient for this sort of thing.

I fixed your posts…that’s pretty strange. You’re posting so often the forum thinks you’re a bot :stuck_out_tongue:

2 Likes

@nehon
Can you do me a favor and try quoting this post to see if your post shows up? The forum seems to only swallow up posts using blockquotes… I think.

@t0neg0d said: @nehon Can you do me a favor and try quoting this post to see if your post shows up? The forum seems to only swallow up posts using blockquotes... I think.
I'm admin I hope the forum won't think I'm a spammer :p

@nehon
Yeah… I tried to quote your response. It got et’

rhoo damn it…
I have no idea why it does that, you’re not reported as a spammer, or a splogger (whatever it is). I’ll look if I can find something

1 Like

@nehon
Same problem for me 3 or 4 times yesterday!

Edit: Just tried 1 minute ago using your last post: Page was reloaded but no new post.

…It’s not the forum we want but it’s the one we deserve. (heheh)

1 Like

hahahaha