SFML community forums
Bindings - other languages => DotNet => Topic started by: Mad on August 27, 2013, 01:57:31 pm
-
Hello!
I've found a lot of c++ examples for particle systems, but c++ is really not my passion. ???
So can someone give me an example class for a particle system in C# ?
Thanks!!! :)
-
C++ and C# are not that far apart, if you have a good example of a C++ version, it should be relatively easy to port it to C#.
Otherwise, I'm convinced you'll find a lot of examples by googling for example "particle system c#"
-
I'd have to agree with eXpl0it3r.
But you could also take a stab at porting Mercury from XNA to SFML :D
http://mpe.codeplex.com/
-
But you could also take a stab at porting Mercury from XNA to SFML :D
http://mpe.codeplex.com/
Hell yeah, that's what I'm looking for. :)
but a port to c# might be a little bit to much work :P ..... but those effects look great.
Well its already in C# ;)
It'd have to be ported to SFML.
I have a project that I am going to start working on as soon as I get my head wrapped around SFML more and I was actually thinking about porting a lot of different things over to C#/SFML; one of those being a Particle System. I had my eyes set on DPSF (http://www.xnaparticles.com/index.php) (I've used it before when I was using XNA)... But! DPSF isn't open source :(. So I will probably soon be looking into Mercury (since its already C#).
Anything and everything that I port over to C#/SFML will be open for all to use -- I just need to learn more about SFML and then I can start converting different things over. 8)
I know you need a solution now but I'm not sure what else to do. :-\
-
Well its already in C# ;)
It'd have to be ported to SFML.
yes, I saw it and that's why I removed my post ::)
Anything and everything that I port over to C#/SFML will be open for all to use -- I just need to learn more about SFML and then I can start converting different things over. 8)
lerning SFML it's also my part at the moment.
but less time as usal :P
I know you need a solution now but I'm not sure what else to do. :-\
Nooo! Not now, but in a few weeks it would be ok. 8)
-
yes, I saw it and that's why I removed my post ::)
Haha, I thought it was weird that your post disappeared!
lerning SFML it's also my part at the moment.
but less time as usal :P
Yeah I'm a full time software engineer so I have little time to play too :'(
Nooo! Not now, but in a few weeks it would be ok. 8)
I can't/won't make any promises but I can see if getting a particle system working for SFML .Net could the first adventure I take.
I was just taking a look at Mercury and it seems pretty robust -- they even have a particle editor! That would definitely be a cool thing to carry over... This will be an interesting task... ;D
-
lerning SFML it's also my part at the moment.
but less time as usal :P
Yeah I'm a full time software engineer so I have little time to play too :'(
Me too! You are wellcome! ;D
I was just taking a look at Mercury and it seems pretty robust -- they even have a particle editor! That would definitely be a cool thing to carry over... This will be an interesting task... ;D
no need to convert the editor, because gui development is no fun at all in my opinion.... :o
But I agree, the mercury editor is still a little buggy.... :-\
Edit:
Alright so while I wait for other things to transpire -- I decided to start a port of Mercury to SFML. You can check it out here:
https://sourceforge.net/projects/mpesfml/
Cool. But no download yet? ;)
It's going to be a pain because I want to strip out the 3D portion and just leave the 2D portion there.
I have a short look in the source code, seems there are only 4 classes for the main parts (particle.cs, ParticleEffect.cs, ParticleEffectManager.cs and SpriteBatchRenderer.cs)
all other stuff is only 'nice to have' ;)
-
Alright so it turns out the idea of porting Mercury over to SFML is completely out-of-scope. I am going to be looking into alternatives.
-
Alright so it turns out the idea of porting Mercury over to SFML is completely out-of-scope. I am going to be looking into alternatives.
:-\ bad luck.
But maybe only some good explosion, smoke and fire effects in c#? Heeelp :)
-
Alright so it turns out the idea of porting Mercury over to SFML is completely out-of-scope. I am going to be looking into alternatives.
:-\ bad luck.
But maybe only some good explosion, smoke and fire effects in c#? Heeelp :)
Yeah when going through it I realized that it was tightly coupled to XNA -- I just don't have time to sift through it. I am actually working on my own particle system right now; strictly 2D.
-
You can also have a look at my C++ implementation of Thor.Particles (API documentation (http://www.bromeon.ch/libraries/thor/v2.0/doc/group___particles.html), tutorial (http://www.bromeon.ch/libraries/thor/v2.0/tutorial-particles.html), code (https://github.com/Bromeon/Thor/)). Even though the current status allows a lot of customization and flexibility, the basic principle is rather simple:
- The class thor::Particle represents a particle with attributes like position, color, etc.
- Emitters and affectors are represented with std::function, you could take delegates for C#. Or you take the classical approach of interfaces that are implemented by the user.
- The class thor::ParticleSystem stores particles, affectors and emitters. It uses sf::VertexArray for rendering, the emitters and affectors are invoked in every update() call.
-
You can look at my implementation at: https://github.com/Symeg/Smart2DGameFramework/tree/master/Smart2DGameFramework/Graphics/Particles
Demo on youtube (fire particles, old video, now is better performance) http://www.youtube.com/watch?v=Tybz3uq9HWk
You can also find other useful tools :)
-
(http://s7.postimg.org/u460997d7/sfml_mparticle.png)
Looking good so far -- I'd say. Theres a few things that I need to work out but so far so good. ;D
EDIT:
Heres another shot of it:
(http://s22.postimg.org/hi2vzg0fl/sfml_mparticle_2.png)
-
@Nexus
Thanks for your information. I had a look at Thor early. It's a pitty there is no C# clone :-\
But it seems to be a very useful library!!
@SymegPL
Hey, thanks for sharing. I will have a look at your lib. Is the client/server part stabil?
Mister
Nice one! :D
Can you tell me, what are you using? Sprites or only Vertex?
As I can see from your blog,you have plans to make a Top Down Shooter shooter? Maybe we can stick together?
I have plans to make also a shooter...but Left Right ;D my first idea was an uridium clone with much more features.
http://en.wikipedia.org/wiki/Uridium (http://en.wikipedia.org/wiki/Uridium)
Maybe we can combine Top Down Shooter with Top Down and double knowledge? 8)
-
As I can see from your blog,you have plans to make a Top Down Shooter shooter? Maybe we can stick together?
I have plans to make also a shooter...but Left Right ;D my first idea was an uridium clone with much more features.
http://en.wikipedia.org/wiki/Uridium (http://en.wikipedia.org/wiki/Uridium)
Maybe we can combine Top Down Shooter with Top Down and double knowledge? 8)
I can't really agree to start this new project as a team effort.. not at this time at least. That isnt to say that we can't help each other out with our individual games though. :)
The game that originally inspired me was a game made by one of my friend's brother back in high school.
http://www.youtube.com/watch?v=kZ2s_Le6iw4
Mister
Nice one! :D
Can you tell me, what are you using? Sprites or only Vertex?
The way it sits right now -- its renderer agnostic. The only thing it currently focuses on is the underlying numbers that all particles deal with. You can then tell your images to draw accordingly.
I will have the source code up as soon as I get a decent example running. :D
-
I can't really agree to start this new project as a team effort.. not at this time at least. That isnt to say that we can't help each other out with our individual games though. :)
no problem, it was just an idea, because I'm still in testings things out. :D
Your game is very fast at all. too fast for me.... ;D
I will have the source code up as soon as I get a decent example running. :D
I'm waiting. :)
Meanwhile a short screen of my current particle test. It's not still, what I want to have... :-\
edit
screenshot 2 + 3 look now much better, I think?
-
Looks pretty good so far -- is this a separate particle system that you are making? How'd you end up handling Particles Per Second?
-
Looks pretty good so far -- is this a separate particle system that you are making? How'd you end up handling Particles Per Second?
yes, it's my first experiment in SFML. :)
I'm using the Stopwatch to get the milliseconds since last frame loop and calculate the new position with it.
-
(http://s7.postimg.org/4nfwh72jv/sfml_mparticle_3.png)
Here is a newer update of the particle system so far.
It now calculates the proper particles per second and fades out based on lifetime ;D
I think I'll add color to it, clean up some spots, and then it should be good to upload to sourceforge -- just note that its nowhere near 100% done. :)
-
I think I'll add color to it, clean up some spots, and then it should be good to upload to sourceforge -- just note that its nowhere near 100% done. :)
gogogo, I will see how you handle the drawing process. :D
-
Thanks for your information. I had a look at Thor early. It's a pitty there is no C# clone :-\
But it seems to be a very useful library!!
Actually it does have an almost complete clone. I am currently working on it - particles and large texture/sprite/rendertexture are currently done. I will be publishing it soon too. And here is a screenshot of the ported fireworks example from Thor.
(http://i40.tinypic.com/24lixyw.png)
-
Actually it does have an almost complete clone. I am currently working on it - particles and large texture/sprite/rendertexture are currently done. I will be publishing it soon too. And here is a screenshot of the ported fireworks example from Thor.
YES, that are really good news! :D
At the end, we will have 5 different Particlesystems here for different application areas. Cool 8)
-
YES, that are really good news! :D
At the end, we will have 5 different Particlesystems here for different application areas. Cool 8)
Glad you like the idea, I decided to go ahead and upload it. Here is the thread (http://en.sfml-dev.org/forums/index.php?topic=12819) wherre you can read all about NetEXT.
-
Glad you like the idea, I decided to go ahead and upload it. Here is the thread (http://en.sfml-dev.org/forums/index.php?topic=12819) wherre you can read all about NetEXT.
That was quick! Thanks for sharing. :D I have the fireworks demo up and running. NICE!
I will have a deeper look into the lib to see what effects I can arrange with this particle system. :D
-
https://sourceforge.net/projects/mparticles/
I still haven't added color but I cleaned it up a little bit.
I will be adding a lot to it over the course of Sunday-Monday so watch for updates 8). I will also be making a separate post about it later -- let me know if you think there should be different ways of doing things.
-
Hi there! :)
I will be adding a lot to it over the course of Sunday-Monday so watch for updates 8). I will also be making a separate post about it later -- let me know if you think there should be different ways of doing things.
First I have to say: Good structured souce code, mate! :)
At the moment you use CircleShape for the smoke effect. Some plans to integrate texture effects?
I will have a deeper look later. :)
-
Hi there! :)
I will be adding a lot to it over the course of Sunday-Monday so watch for updates 8). I will also be making a separate post about it later -- let me know if you think there should be different ways of doing things.
First I have to say: Good structured souce code, mate! :)
At the moment you use CircleShape for the smoke effect. Some plans to integrate texture effects?
I will have a deeper look later. :)
Thanks :D
You can use whatever you like 8). All you gotta do is change CircleShape to a Sprite -- UserObject gets passed around per-particle and eventually gets cast into a Drawable and drawn to screen.
So basically, you could have ANY object that inherits from Drawable as UserObject and it will get drawn however you set it up and refresh the object.
For example -- I am making a fire work example particle effect; this is what I do:
public RocketEmitter
() : base(1,
2) { ParticleInitialization
= SmokeParticleInit
; OnEveryUpdate
+= PresetAffectors
.UpdatePositionBasedOnRotationAndVelocity; OnRefreshUserObject
+= RefreshUserObject
; Texture texture
= new Texture
(@"Assets\rocket_triangle.png"); OnParticleCreated
+= particle
=> { Sprite sprite
= new Sprite
(texture
) {Origin
= new Vector2f
(20,
24), Scale
= new Vector2f
(.25f,
.25f
)}; particle
.UserObject = sprite
; }; }
And then I have this:
private void RefreshUserObject
(Particle particle
) { Sprite shape
= (Sprite
)particle
.UserObject; shape
.Position = new Vector2f
(particle
.Position.X, particle
.Position.Y); shape
.Color = new Color
(0,
0,
0,
(byte)particle
.Alpha); shape
.Rotation = particle
.Rotation; }
And then it draws rocket sprites on screen :D
The smoke effect isn't quite done yet -- I will have something better committed soon ;D
-
Ah! :D
so this way, you create a sprite for each particle?
In my code I only create one sprite at the beginning and use this instance to draw all particles.
Not sure if it is a good approach, but it's seems to be faster and less ressouce hungry. ::)
But my code is not clean at the moment and no time to work on it at currently :-\
-
Ah! :D
so this way, you create a sprite for each particle?
In my code I only create one sprite at the beginning and use this instance to draw all particles.
Not sure if it is a good approach, but it's seems to be faster and less ressouce hungry. ::)
But my code is not clean at the moment and no time to work on it at currently :-\
Yep that would be the better approach so we aren't wasting resources ;)
I'll make sure the new examples reflects that.
EDIT:
I added Scaling and more functionality to how Alpha is dealt with.
(http://img801.imageshack.us/img801/3474/0b5j.png)
-
Ah! :D
so this way, you create a sprite for each particle?
In my code I only create one sprite at the beginning and use this instance to draw all particles.
Not sure if it is a good approach, but it's seems to be faster and less ressouce hungry. ::)
But my code is not clean at the moment and no time to work on it at currently :-\
Yep that would be the better approach so we aren't wasting resources ;)
I'll make sure the new examples reflects that.
So we can set the focus on groovy amazing and visionary effects soon ??? 8)
-
(...)
@SymegPL
Hey, thanks for sharing. I will have a look at your lib. Is the client/server part stabil?
(...)
Should be stable, but I cant guarantee that.
-
(http://img443.imageshack.us/img443/5489/gn7f.png)
Updated SVN -- changed mostly everything lol. Color is going in now.
Edit:
Color is in 8)
(http://img24.imageshack.us/img24/9489/zmbf.png)
Edit:
Added a new example to show off different things:
Circle, Square, Line, Point Emitting
(http://img801.imageshack.us/img801/3498/qp6b.png)
Also added acceleration, rotation, rotation velocity, rotation acceleration.
1 more example then I will make my own post. ;D
Final Edit:
I added another example. Next example I will have in my own post dedicated to MParticles. :D
(http://img547.imageshack.us/img547/610/9tan.png)
-
looks nice so far!
Some explosions with splitter would be nice, fire effects aso. 8)
-
looks nice so far!
Some explosions with splitter would be nice, fire effects aso. 8)
http://en.sfml-dev.org/forums/index.php?topic=12869.0
MParticles project post ^
I have 2 fire effects so far :D
-
Aaaaaaaaaaaaaah! Havn't seen it yet.
Locks very good so far!! :)