The VAC Partial Engine V1.3 Out Now

Hi everyone,

I wrote my own partial engine form compatibility reasons in my game due to working on many different platforms and I though I would release it for anyone who is interested.

Now Its not the fastest, most efficient or versatile, but it should work out the box on any platform.
It uses sprite batch for rendering, and uses a basic xml file system to allow easy loading of partials on any system.

ezgif-4-8ddff4422c32

Here is a video of the editor and some of what the engine can do https://youtu.be/t3SwLtOEQfo

VAC Version 1.3
Change List Added Offset to emitters Fixed crashes Added new Modifiers system (Now you can create your own) Added ability to swap out background in editor Added ability to Change Blend effect in editor (You will sill have to manually set blendsate in spritebatch.Begin if you want it in your game, Ill change this later) New Rotation Velocity Emitter All Emitters now have start time and End time properties.

References to include in your game here

Example Project Here

Full documentation Coming Soon

The entire purpose is easy of use in a project, and compatibility.

So you create a load a particle effect like this

ParticlEffect effect = ParticalEffect.LoadFromStream(stream, _device);

then you just have

///UPDATE
effect.Update(dt);

///IN DRAW
effect.Render(sb);


///TRIGGER
effect.Trigger(pos, 1);

In order to have an effect loaded in you just need to put the particle effect file in your content and have it copy to output along with the textures that it uses.

So very simple, very quickly you can have particle effects with great compatibility.

Just add reference to ParticalEditor.dll, Riddlersoft.Graphics.dll
, Riddlersoft.core.dll and Winforms.dll in your project.

then add the following using statements where you want to use the particals

using Riddlersoft.Graphics.Particals;

Matt

4 Likes

Are you using any effects or is it purely spritebatch?

I’m interested how you got the smoke effect at about 2 minutes 10 in the video. If it’s purely spritebatch what blendstate are you using?

Are you just rotating, fading and scaling the texture for each smoke particle?

This is purely spritebatch. The particle engine has modifiers for fade etc.

Not only is this spritebatch but its designed to be used with your existing spritebatch for your game.
In this instance its just spriteBatch.Begin();

The effect has basic rotation and fade to create the smoke effect.

here is the render code for an effect

public void Render(SpriteBatch sb)
        {
            foreach (Partical p in Particals)
            {
                sb.Draw(ParticalTexture, p.Position, null, p.Colour * p.Fade, p.Rotation, ParticalCenter, p.Scale, 
                    SpriteEffects.None, 0f);
            }
        }
///here is how its called in my test game
_effect.Render(sb);

there is also a Render option that takes in a camera. Alternatively you can just use a matrix in your spritebatch begin.

Now in the instance of an explosion effect or fire effect you would just change the blend mode to additive.

here is the update logic

   public void Update(float dt)
        {
            foreach(Partical p in Particals)
            {
                p.Position += p.Velocity;
                p.Rotation += p.AngulorRotation;
                p.LifeTime -= dt;
                p.Age += dt;
            }

            for (int i = Particals.Count - 1; i >= 0; i--)
                if (Particals[i].LifeTime < 0)
                    Particals.RemoveAt(i);
                else
                    foreach (Modifyer mod in Modifyers)
                        mod.Processes(Particals[i], dt);
        }

Iv just fixed a crash in the editor and an issue with cone emitters Iv update link with new version.

Great thanks!

Just working on some improvements
Haveing a background IMG.
Blendstates
Start and End Time for modifiers
General improvements

ezgif-4-8ddff4422c32

Will have update soon.

I’m also working on adding the ability for anyone to make custom Modifiers.
When you create your modifier it will get saved in to the xml file.
The editor will also allow you to add the modifier and set modifier properties.

For example here is a test I’m working on. I needed a modifier that would set the rotation of a partial based on its velocity.

 public class RotationVectorModifyer : CustomModifyer
    {
        public float Rotation;

        public RotationVectorModifyer()
        {
            XmlTag = "RotationVector";
            Rotation = 0;
        }


        public override void SetUpEditorProperties()
        {
 //set up editor stuff
            EditorProperties.Clear();
            EditorProperties.Add(new EditorData("Rotation", EditorInputType.Textbox, EditorInputDataType.Float)
            {
                Set = (object input) =>
                {
                    Rotation = (float)Convert.ToDouble((string)input);
                },

                Read = () =>
                {
                    return Rotation;
                }

            });
        }

        protected override CustomModifyer _create()
        {
                       
            return new RotationVectorModifyer();
        }


        public override void ReadFromFile(CustomXmlReader reader)
        {
            Rotation = reader.ReadAttributeFloat("Rot");
        }

        public override void WriteToFile(CustomXmlWriter writer)
        {
            writer.WriteAttributeString("Type", XmlTag);
            writer.WriteAttributeFloat("Rot", Rotation);
        }



        protected override void _prosses(Partical input, float dt)
        {
            input.Rotation = (float)Math.Atan2(input.Velocity.Y, input.Velocity.X) + MathHelper.PiOver2 + Rotation;
        }
    }

Here is the effect
ezgif-4-8d699937bef5

So if the partial engine dos not do what you need you should be able to make a modifier for it very easy.

1 Like

VAC Version 1.3
Change List
Added Offset to emitters
Fixed crashes
Added new Modifiers system (Now you can create your own)
Added ability to swap out background in editor
Added ability to Change Blend effect in editor (You will sill have to manually set blendsate in spritebatch.Begin if you want it in your game, Ill change this later)
New Rotation Velocity Emitter
All Emitters now have start time and End time properties.

References to include in your game here

Example Project Here

Documentation Coming Soon