Coding practise for "animation timed" particle effects?

I’ve started getting to know JME3, playing with tutorials and such. Still very much a newbie, so pardon any silly questions.

Thought I’d make myself some exploding things, when I realized that having “composite” effects could be handy, for instance for when you want something big to explode in stages. I’m not at all experienced in 3D development, but I figure the way to create the thing I’m looking for would be to have an animation where the model breaks up into little pieces, then in the code add several delayed explosions using particle emitters and at the end some bigger explosion complete with shockwave, debris etc.

Assuming I’m on the right track here, is there anyone that could give me some hints on how to control these emitters? Maybe there’s something done for this already? I’m guessing one could create a subclass of Node (or Geometry? I’m still quite fuzzy on the concepts) that is triggered by an AnimEventListener and starts/stops the emitters at the proper times?

About the uncertainties towards the scenegraph:

I’d say you should just replace the model with the smaller parts in the moment it breaks so that you don’t have the additional overhead of the single parts when the model isn’t broken. Playing some effects at the points where stuff breaks and you should basically have it yes.

I think the cinematic system would work great for this. Cinematics can be used to create such predefined animation sequences with events happening at certain times.

Ah, so you can use the cinematics to control only certain aspects of the scene graph? Interesting. Could one use cinematics to handle interpolation to get some rudimentary client prediction in a server-client setup? Haven’t gotten to SpiderMonkey yet, but I’m guessing interpolation is something I will have to look into…

I seem to have run into a bit of a snag when trying to get my effects down on disk. I write the ParticleEmitter using

[java]XMLExporter.getInstance().save(effect.emitter, new File(effect.emitterFileName));[/java]

and all seems fine with the resulting xml (I think) but when I try to load it up again later with

[java]Savable emitter = XMLImporter.getInstance().load(new BufferedInputStream(new FileInputStream(emitterFileName)));[/java]

I run into a NullPointerException at

[java]def = (MaterialDef) im.getAssetManager().loadAsset(new AssetKey(defName));[/java]

I’m obviously doing something wrong, because the AssetManager on the JmeImporter here is null. You’re not supposed to call XMLExporter/Importer directly like that? I found some info on how to use the AssetManager on the Wiki, but that seems to be only for loading stuff, not writing. What’s the general idea when it comes to saving and reading a ParticleEmitter (or other generic Savable, like my CompositeEffect :)) on disk?

If you use XMLImporter directly, you have to set the asset manager on it to your application’s asset manager, so it can find things such as material definitions and textures

Thanks Momoko, works fine now. Well, mostly. There seems to be a bug in where it doesn’t call setImagesXY() on its particleMesh after fetching imagesX and imagesY. Got some pretty interesting effects… :slight_smile: