SFML community forums

General => SFML projects => Topic started by: zarka on September 22, 2007, 11:51:00 pm

Title: Particles!
Post by: zarka on September 22, 2007, 11:51:00 pm
I thought i would share some screen shoots of my current SFML project, as the topic already reveled it's about particle systems.
I have used an approach similar to that of Ogre3ds with particle systems built up by emitters and affectors. the system is being developed for use in 2d but shouldn't be to hard to scale up to 3d.

(http://thumbnails.freeimagehost.eu/108/40933b1073243.gif) (http://www.freeimagehost.eu/image/40933b1073243)

what is seen in the picture?
one particle system containing 2 point emitters. each emitter is affected by a fade in affector a fade out affector and a linear force affector.

what is currently on my to do list? Adding manager and factory classes, perhaps some way to create system from config files,  code cleanup and bug testing.

EDIT: code now available on the wiki: http://www.sfml-dev.org/wiki/en/projects/particle_system
Title: Particles!
Post by: dabo on September 23, 2007, 02:01:28 am
Looking good, good luck with it!
Title: Particles!
Post by: zarka on September 28, 2007, 11:28:35 pm
So i have made some (slow) progress, and implemented a bunch of different emitters and affectors and here you can see the result

(http://thumbnails.freeimagehost.eu/113/517aed1128634.gif) (http://www.freeimagehost.eu/image/517aed1128634)
Title: Particles!
Post by: dabo on September 29, 2007, 11:51:19 am
Really impressive I must say, the top left one looks great.
Title: Particles!
Post by: tgm on March 08, 2008, 10:46:12 pm
do you use direct openGL calls for rendering??
Title: Particles!
Post by: zarka on March 09, 2008, 01:14:53 pm
I have derived my ParticleSystem class from sf::Drawable and written my own rendering function. i did this to be able to optimize the drawing of multiple particles with the same texture/material. (less texture switches = greater speed).

hmm been a while since i posted this.. not much have happened visually now I have mostly been working on getting a nice file format for loading particle systems and optimizing it a bit.. next step would be to get rid of immediate mode OpenGL rendering ... but I really suck at OpenGL so we wil lsee how long it will take to get it done .. probably a while ;)
Title: Particles!
Post by: tgm on March 09, 2008, 04:12:55 pm
well, thats what I thought^^ just wondering;) cause I was thinking about doing some particles for my game and was not sure  wether it would be fast enought to render a few hundret sprites.. (In fact 3000 are no problem at hmm 30-60 FPS on my old machine with compiz desktop->even slower^^)
Title: Particles!
Post by: Laurent on March 10, 2008, 02:14:26 am
I'm planning to improve the performances a lot, especially when rendering a lot of sprites with the same texture / states.
Title: Particles!
Post by: zarka on August 09, 2008, 03:57:31 pm
So, i have now finally managed to make a more sfml friendly version of this code (no dependencies on boost/my other code) and added it as a contribution on the wiki http://www.sfml-dev.org/wiki/en/projects/particle_system . It builds and links with the latest SVN sources.

if you find any bugs with the code please don't hesitate to tell me and i will try to fix them :)
Title: Particles!
Post by: Wizzard on August 10, 2008, 03:57:36 am
Awesome work!

I almost want to create a sandbox game with this.
Title: Particles!
Post by: quasius on August 10, 2008, 06:37:26 am
What license are you releasing this under?  Can the code be used/modified in commercial apps?
Title: Particles!
Post by: zarka on August 10, 2008, 09:54:59 am
zlib/libpng so it's the same as SFML :)

EDIT: This is now also stated in the wiki page
Title: Particles!
Post by: dabo on August 12, 2008, 05:08:29 pm
I finally got it working, nice job!

I used to get a stack overflow error. The reason was that the path to the font was wrong.
Title: Particles!
Post by: zarka on August 17, 2008, 09:20:30 pm
Quote from: "dabo"
I finally got it working, nice job!

I used to get a stack overflow error. The reason was that the path to the font was wrong.


ah yes, the code assumes you have the "bin" folder as working directory :)
Title: Particles!
Post by: dewyatt on September 03, 2008, 09:20:52 pm
Wow, funny enough I just did this exact same thing about a month ago.
I based it off of Ogre3D's system as well.

I wrote Squirrel bindings for mine so you could have scripts like:
Code: [Select]

TestParticleSys = ParticleMgr.addSystem(300);
local Params =
{
Position = Vector2f(getMouseX().tofloat(), getMouseY().tofloat()),
Direction = Vector2f(1.0, 1.0),
EmissionRate = 100.0,
MinimumAngle = 0.0,
MaximumAngle = 360.0,
MinimumSpeed = 20.0,
MaximumSpeed = 20.0,
MinimumTimeToLive = 1.0,
MaximumTimeToLive = 1.0,
MinimumColor = Color(0, 0, 255, 255),
MaximumColor = Color(0, 120, 255, 255),
MinimumScale = 0.5,
MaximumScale = 0.6,
};
TestEmitter = TestParticleSys.addEmitter("Point", Params);
Params =
{
SubtractAlpha = 0.5
};
TestParticleSys.addAffector("Color Fader", Params);


Particle systems are too much fun.
I've spent so many hours just staring at cool particle effects.

P.S: I wish your screenshots would load.  :(
Title: Particles!
Post by: zarka on September 04, 2008, 10:10:58 am
Quote from: "dewyatt"
Wow, funny enough I just did this exact same thing about a month ago.
I based it off of Ogre3D's system as well.

I wrote Squirrel bindings for mine so you could have scripts like:


Particle systems are too much fun.
I've spent so many hours just staring at cool particle effects.

P.S: I wish your screenshots would load.  :(


Cool :) in the version i use i have made a particle definition language where you can give initial params to the system (this also quite heavily based on how ogre does it ;) ). But i to have had plans to use squirrel for adding scriptable emitters/affectors :)

hmm the imagehost i used must have deleted the pictures.. il see if i can find another one and upload some pics  :)
Title: Particles!
Post by: coral on October 09, 2008, 08:32:59 pm
#include "Affectorfactory.h"
#include "Random.h"
#include "ConfigData.h"
#include "Variant.h"

Where are these?
They wasn't included in your package!
Title: Particles!
Post by: zarka on October 10, 2008, 10:47:34 am
Quote from: "coral"
#include "Affectorfactory.h"
#include "Random.h"
#include "ConfigData.h"
#include "Variant.h"

Where are these?
They wasn't included in your package!


oops some leftovers from my other code.. it should work by just removing them.. i do not believe they are used anywhere... but i will try to get a new package up when i get home :)
Title: Particles!
Post by: zarka on October 12, 2008, 07:53:49 pm
Quote from: "coral"
#include "Affectorfactory.h"
#include "Random.h"
#include "ConfigData.h"
#include "Variant.h"

Where are these?
They wasn't included in your package!


where did it complain about theese? i can't find theese includes anywhere in the package i uploaded here: http://www.mediafire.com/?i1hwmluqmgq