Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Particles!  (Read 8809 times)

0 Members and 1 Guest are viewing this topic.

zarka

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
Particles!
« 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.



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
//Zzzarka

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
Particles!
« Reply #1 on: September 23, 2007, 02:01:28 am »
Looking good, good luck with it!

zarka

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
Particles!
« Reply #2 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

//Zzzarka

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
Particles!
« Reply #3 on: September 29, 2007, 11:51:19 am »
Really impressive I must say, the top left one looks great.

tgm

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Particles!
« Reply #4 on: March 08, 2008, 10:46:12 pm »
do you use direct openGL calls for rendering??

zarka

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
Particles!
« Reply #5 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 ;)
//Zzzarka

tgm

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Particles!
« Reply #6 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^^)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32080
    • View Profile
    • SFML's website
    • Email
Particles!
« Reply #7 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.
Laurent Gomila - SFML developer

zarka

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
Particles!
« Reply #8 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 :)
//Zzzarka

Wizzard

  • Full Member
  • ***
  • Posts: 214
    • View Profile
Particles!
« Reply #9 on: August 10, 2008, 03:57:36 am »
Awesome work!

I almost want to create a sandbox game with this.

quasius

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Particles!
« Reply #10 on: August 10, 2008, 06:37:26 am »
What license are you releasing this under?  Can the code be used/modified in commercial apps?

zarka

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
Particles!
« Reply #11 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
//Zzzarka

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
Particles!
« Reply #12 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.

zarka

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
Particles!
« Reply #13 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 :)
//Zzzarka

dewyatt

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
    • http://dewyatt.blogspot.com
Particles!
« Reply #14 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.  :(

 

anything