Particles

Nov 23, 2011 at 1:03 PM

I've just started playing with the particles code and i notice that in ParticleSystem the code to load the ParticleEffect is commented out - i'm guessing this is because you don't have the content pipeline importer in IGF - is there any reason behind this ?? I really want to be able to define particle effects in the mercury editor now it is beginning to support 3d and it looks like at the moment you have to build all the particle effects manually in code.

 

Coordinator
Nov 24, 2011 at 10:38 AM

Hi bamyazi,

Yes, I commented the code used to load from a Mercury xml file because at the time I released v0.8.0.0, the Xna 4 Project Mercury Editor wasn't able to save and load correctly the ParticleEffect.

I don't know if it is still the case. If you wanna give a check, let me know of your conclusions and I'll add it back again. ;)

Nov 24, 2011 at 1:33 PM

Ok - just wanted to check before i got stuck in - if i make any changes to get things working i'll submit a patch. 

Coordinator
Nov 25, 2011 at 12:15 PM

Hi,

It's really related to the XML files generated by Mercury editor. If they managed to get it working, it should definitivelly works within IGF. I don't have the time to try myself but if you do and it works, I'll get it back on. ;)

Dec 4, 2011 at 5:18 PM

I managed to get this working last night without any significant changes to the IGF code, however i used the Content Pipeline and Editor from the 4.0 branch of Mercury which is not stable so i don't think worth integrating anything at the moment, however in case anyone wants to implement it themselves here's how...

Add a reference to the ProjectMercury.ContentPipeline project from the 4.0 branch.

In the references for ProjectMercury.ContentPipeline remove the broken one for ProjectMercury.Particles.Windows and and one for Indiefreaks.Game.Particles.Windows.

Uncomment the 3 commented lines in Indiefreaks.Xna.Rendering.Particles.ParticleSystem.LoadContent.

Create your particles system in the Mercury editor and add the xml file to your content project (you'll also need to add any textures you have used and perhaps adjust the ParticleTexturePath in the xml file)

Add a reference to the ProjectMercury.Content pipeline project to your content project.

At this stage you should be able to build and run the project and create a particle system as follows

        private void CreateParticleSystems()
        {
            _bloodParticleSystem = new ParticleSystem("Particles\\blood");            
            Content.Add(_bloodParticleSystem);
            _bloodParticleSystem.Effect.Emitters[0].BillboardStyle = BillboardStyle.Spherical;

            _particleSystemManager.SubmitParticleSystem(_bloodParticleSystem);

            _bloodTest = new ParticleTrigger()
            {
                ParticleSystem = _bloodParticleSystem,
                ParticlesPerSecond = 100,            
                UpdateType = UpdateType.Automatic
            };
            Application.SunBurn.ObjectManager.Submit(_bloodTest);
        }
There is a slight hack required 

_bloodParticleSystem.Effect.Emitters[0].BillboardStyle = BillboardStyle.Spherical;
Since the serializers don't save/load the BillboardStyle. If you're happy to fork the ProjectMercury code you can just modify the AbstractEmitterSerializer
so that this field is saved/loaded and you don't need the little hack. So far everything seems to work but there's bound to be some issues so i wouldn't use
it in production unless you're happy getting your hands dirty and fixing bugs when they come up.
Coordinator
Dec 6, 2011 at 6:23 AM

That's great to see it just works ;)

Maybe I should get on the Mercury Content Processors library and once I get it working, send them back the advancements so that I can get the whole Project Mercury binded to IGF's assemblies... What do you think?

Feb 2, 2012 at 1:22 AM

Any idea when this will be supported natively?

I saw a changeset recently that said that this was working, but I spent all night yesterday trying to figure out how to get the particle effects from the Mercury editor to be properly imported using the content processor and it was causing me nightmares. Right now I'm trying to do it by code, but I would much prefer to be able to make them in the editor and then just import them into my project.

Coordinator
Feb 2, 2012 at 8:07 AM

Hi Wudek,

The sole task I need to do to get that working properly is by adding the Mercury Content Processor assemblies to the framework slightly modified to use the Indiefreaks.Game.Particles.dll. Once this is done, everything will be setup for you to use the Editor without hacking.

Until then, you'll need to use the above bamyazi hack to make it work within IGF.

Feb 2, 2012 at 4:50 PM

Alright, sounds good, I'll be patient, i've got it working pretty well in code anyway, its just a little slower to test them. :)

Coordinator
Feb 8, 2012 at 11:39 AM

Just a quick message to let you know that I just added to the latest changeset full support for particle systems loading through content pipeline.

You just need to use the slightly modified version of the Project Mercury Editor (select the one that fits your SunBurn edition) and add the ProjectMercury.ContentPipeline.dll found in the solution to your own content project.