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

Author Topic: SPARK opensource particle engine with an SFML module  (Read 23903 times)

0 Members and 1 Guest are viewing this topic.

Frifron

  • Newbie
  • *
  • Posts: 40
    • View Profile
SPARK opensource particle engine with an SFML module
« on: December 21, 2008, 03:14:03 am »
Hello,

let me introduce to you my particle engine library. This is not really an SFML project but more a libray dependent free project written in C++. However I have just implemented a module for SFML (there is also a module for openGL and one for direct3D is coming) :

DESCRIPTION

SPARK is an opensource particle engine on CPU side written in C++. It was designed to be portable, configurable, evolving, and simple to use. Domains of applications of the library are mainly the rendering of 2D and 3D effect based on particles but it can also be used for slight simulation of numerous physical entities.

FEATURES

  • Several types of parameters for particles :
    • position
    • velocity
    • lifetime
    • color RGBA
    • size
    • weight
    • rotation
    • user customizable parameters
    • parameters evolution, random generation
    • Easy particle management within groups
    • Gravity and friction
    • Particle sorting
    • Physics engine particles vs environment
    • callback system for particle birth, update and death
    • bounding box for groups and systems
    • automatized evolution once configured
    • rendering independent from computation
    • Modifiers to modify particles' behavior in the universe
    • abstract classes insuring system evolutivity :
      • Emitters
      • Modifiers
      • Zones
      • Renderers
      [/list]

      This version contains a set of emitters, modifiers, zones and renderers that will increase in the future :

      • Zones :
        • Sphere
        • Axis Aligned bounded box
        • Plane
        • Point
        • Line
        • Emitters :
          • straight emitter (along a vector)
          • spheric emitter (a portion of sphere)
          • Modifiers
            • Obstacle : to stop particles and have them bounce
            • Destructors : to destroy particles
            • point mass : attract or repulse particles
            • Renderers
              • openGL
                • Points : points, circles or point sprites
                • Lines
                • Quads : billboads orientated camera, direction or arbitrary axis
                • SFML
                  • Points : points, circles or point sprites
                  • Lines
                  • Quads
                  • sf::Drawables (sprites,shapes,postFX,strings...)
                  [/list][/list]

                  DOC AND TUTOS

                  SPARK documentation is available online here. You can also dowload it.

                  There is no real tutorials but a bunch of examples applications well commentated. There is a demo dedicated to SFML.

                  RESOURCE 1.01.01

                  THE SFML MODULE

                  I will speak a bit more of the SFML module as this is the SFML forum. It allows to easily implement particle systems with the SFML 2D engine. A class SFMLSystem extends sf::Drawable and a lot of SFML renderers exist to render particles in different ways.



                  An implementation example is furnished (SFML Demo). It illustrates how to implement a particle system in SFML with SPARK. It is some fires on a tile map. The user can add/remove fires on tile and move/zoom on the map.

                  commands are :
                  • F1 : changes the display of text
                  • F2 : displays or not the grid
                  • F3 : displays or not the BG
                  • F4 : pauses the particle systems
                  • F5 : destroys all particle systems
                  • space : activate/descativate smoke generation
                  • Supp : reinit the particle systems
                  • Esc : quits the app
                  • left click on an empty tile : adds a fire
                  • left click on an occupied tile : removes the fire
                  • mouse wheel : zoom
                  • mouse on the borders : smoves on the map
                  The licence of SPARK is the lgpl so it is very permissive.
                  For more info (in french unfortunately) and screenshots see here.

                  Any comments, suggestions, questions are welcome
                  SPARK
                  Moteur de particule C++ opensource avec modules de rendu openGL et SFML

                  Imbue

                  • Full Member
                  • ***
                  • Posts: 104
                    • View Profile
                  SPARK opensource particle engine with an SFML module
                  « Reply #1 on: December 21, 2008, 04:06:16 am »
                  Very nice. :D

                  I think I'll be using this in my game. Thanks.

                  bullno1

                  • Jr. Member
                  • **
                  • Posts: 66
                    • View Profile
                  SPARK opensource particle engine with an SFML module
                  « Reply #2 on: December 21, 2008, 04:48:08 am »
                  This is cool.
                  I just realized that the particles are actually 3D. This can help to add a fake "depth" feeling to my 2D game.

                  How to change the rendering mode in you demos? Immediate mode is performing poorly for a large number of particle

                  Edit: You have a particle pool, nice. Some SFML particle examples I found just new and delete everywhere. They fragment memory like crazy

                  Frifron

                  • Newbie
                  • *
                  • Posts: 40
                    • View Profile
                  SPARK opensource particle engine with an SFML module
                  « Reply #3 on: December 22, 2008, 07:33:58 pm »
                  Hello,

                  Quote from: "bullno1"

                  I just realized that the particles are actually 3D. This can help to add a fake "depth" feeling to my 2D game.


                  yes particles are 3D in the engine (but can also be 2D by letting the z coordinate to 0). The way they are converted into 2D for a 2D display is :
                  from position3D(x,y,z) we get position2D(x,y - zFactor * z)
                  The zFactor can be set in the SFMLRenderer. This gives an altitude to a particle which influence its y coordinate function of the factor. The z position is also useful for sorting (see setCameraPosition)

                  Quote from: "bullno1"

                  How to change the rendering mode in you demos? Immediate mode is performing poorly for a large number of particle


                  The rendering mode can be changed in the openGL demos by pressing F3. For SFML only immediate mode is available at the moment. However immediate mode operates quite well with particles as there is no need for some additionnal buffers to organize data (store the quad vertex function of the orientation, the texture coordinates function of the angle...). So the gain in performance may vary whether the bottleneck is the processor or the transfer to GPU.
                  SPARK
                  Moteur de particule C++ opensource avec modules de rendu openGL et SFML

                  Frifron

                  • Newbie
                  • *
                  • Posts: 40
                    • View Profile
                  SPARK opensource particle engine with an SFML module
                  « Reply #4 on: January 05, 2009, 11:57:39 pm »
                  Hi, a website for the library is opened in both english and french :
                  http://spark.developpez.com/
                  SPARK
                  Moteur de particule C++ opensource avec modules de rendu openGL et SFML

                  Frifron

                  • Newbie
                  • *
                  • Posts: 40
                    • View Profile
                  SPARK opensource particle engine with an SFML module
                  « Reply #5 on: January 21, 2009, 08:04:14 pm »
                  Hello, a new release :

                  CHANGE LOG 1.02.00

                  • Internal implementation has been modified : the engine is more optimized but a little bit more rigid
                  • This implies the interface has been slightly modified as well (more details on the site)
                  • Handling of texture 3D openGL to perform texture animation for instance
                  • Some new emitters. One allows to emit by following the normals of a zone
                  • A new modifier : A modifier that can contain other modifiers : this allows to partition the space ot to share the same zone with several modifiers
                  • A callback allow to condition accuratly the trigger of a modifier


                  DEMOS

                  Regarding the demos :
                  • F4 allows to change the renderer (normal, basic et none)
                  • pause pauses the system


                  A new demo is available, it shows the behaviour of SPARK with a large amount of particles. It represents some golden flakes in a sphere. The user can rotate the sphere, the gravity will always point towards the bottom of the screen. Space allows to eject particles in random direction.  + and - change the number of particles (50000 by default and up to 500000 (you'd better have a good proc))

                  More info and dowload here

                  Any comment, suggestion is welcome.
                  SPARK
                  Moteur de particule C++ opensource avec modules de rendu openGL et SFML

                  Frifron

                  • Newbie
                  • *
                  • Posts: 40
                    • View Profile
                  SPARK opensource particle engine with an SFML module
                  « Reply #6 on: January 23, 2009, 10:36:19 pm »
                  the SFML module is now updated to SFML 1.4. The main modifications are that internal pointers to const RenderWindow are changed into RenderTarget.

                  The version 1.02.01 also fixes some bugs and optimizes some stuff.
                  SPARK
                  Moteur de particule C++ opensource avec modules de rendu openGL et SFML

                  Astrof

                  • Full Member
                  • ***
                  • Posts: 135
                    • View Profile
                  SPARK opensource particle engine with an SFML module
                  « Reply #7 on: January 30, 2009, 05:05:06 am »
                  I'm having trouble linking the SPARK libs to visual studio (I'm probably just stupid).  

                  When I compile I get:
                  Code: [Select]

                  Error 2 error LNK2001: unresolved external symbol "public: __thiscall SPK::Point::Point(class SPK::Vector3D const &)" (??0Point@SPK@@QAE@ABVVector3D@1@@Z) main.obj SFML Game
                  Error 3 error LNK2001: unresolved external symbol "public: __thiscall SPK::Vector3D::Vector3D(float,float,float)" (??0Vector3D@SPK@@QAE@MMM@Z) main.obj SFML Game
                  Error 4 error LNK2001: unresolved external symbol "public: __thiscall SPK::Model::~Model(void)" (??1Model@SPK@@QAE@XZ) main.obj SFML Game
                  Error 5 error LNK2001: unresolved external symbol "public: __thiscall SPK::Model::Model(int,int,int)" (??0Model@SPK@@QAE@HHH@Z) main.obj SFML Game

                  I thought I could remedy this by including the SPARK.lib and SPARK_SFML.lib in additional dependencies, but that also broke it.  

                  btw I'm trying to use the static libs.  

                  Also I'm sorry if I shouldn't have posted in this particular thread, but I didnt know where else to ask for SPARK help.

                  EDIT: worked with new release of libs, idk why it didnt work before, but ah well.

                  Frifron

                  • Newbie
                  • *
                  • Posts: 40
                    • View Profile
                  SPARK opensource particle engine with an SFML module
                  « Reply #8 on: January 30, 2009, 08:53:31 am »
                  hi, you have added SPARK.lib and SPARK_SFML.lib (the static versions) to the additionnal dependencies of the project but where did you put the libraries ?

                  Have you either added the path to the VC++ library files or to the additional libraries directories of your project ?

                  By the way the libraries are compiled with visual 2008 so if your using another version of visual there might be compatibility issues (not sure about that).

                  Anyway if so, you can either recompile the libs for visual 2005 or wait 1 or 2 days for the next release that will add compiled libraries for visual 2005.
                  SPARK
                  Moteur de particule C++ opensource avec modules de rendu openGL et SFML

                  Astrof

                  • Full Member
                  • ***
                  • Posts: 135
                    • View Profile
                  SPARK opensource particle engine with an SFML module
                  « Reply #9 on: January 30, 2009, 08:46:56 pm »
                  I'm using visual studio 2008 and have included the SPARK include/lib directories in the VC++ Directory place.

                  Frifron

                  • Newbie
                  • *
                  • Posts: 40
                    • View Profile
                  SPARK opensource particle engine with an SFML module
                  « Reply #10 on: January 31, 2009, 12:47:48 am »
                  Another minor release (1.02.02) that fixes some bugs (for a compil mingw and for linux. Thx to Baton) and includes now the solutions and librairies for vc2005, vc2008 and codeblocks.
                  SPARK
                  Moteur de particule C++ opensource avec modules de rendu openGL et SFML

                  Frifron

                  • Newbie
                  • *
                  • Posts: 40
                    • View Profile
                  SPARK opensource particle engine with an SFML module
                  « Reply #11 on: June 17, 2009, 05:29:42 pm »
                  Hi, after a while without update (I lack some time and i was on other stuff) , here is an update with some new things :

                  Release 1.03.00

                  • A factory is implemented which allow registeration, copy and destruction of systems in a simple and robust way.
                  • Systems can now be transformed by keeping the particles in the world (only the emitters and the zone are tranformed)
                  • The internal structure was optimized. The vertex arrays rendering are now faster. These modifications prepare to the shaders integration.
                  • A new renderer openGL was added : particle is rendered as a trail (computed in a procedural manner). This renderer is illustrated in the gravitation demo which has been modified.
                  • A new modifier : linear force
                  • A lot of bugs fixed and small modifications


                  I also put online a tutorial to get started on the site.

                  Now i m gonna concentrate on the shaders integration (vertex ans geometry) to put a bit of the load on the GPU. The use of shaders will be optionnal to keep the compatibility with old configurations. I will also look at a way to load particle systems from an XML definition file.


                  The website : spark.developpez.com
                  SPARK
                  Moteur de particule C++ opensource avec modules de rendu openGL et SFML

                  dunce

                  • Jr. Member
                  • **
                  • Posts: 77
                    • View Profile
                  SPARK opensource particle engine with an SFML module
                  « Reply #12 on: June 18, 2009, 08:22:06 am »
                  There are much faster (up to 50 times) and less memory consuming xml parsers PugiXml and RapidXml. I used tynyxml++ but eventually moved to pugixml. As for RapidXml, it does not even need building, being just a few headers.

                  Frifron

                  • Newbie
                  • *
                  • Posts: 40
                    • View Profile
                  SPARK opensource particle engine with an SFML module
                  « Reply #13 on: June 18, 2009, 04:10:59 pm »
                  Thanks guys.

                  I used tinyXML before. It is very simple to implement and use but not really optimized. So it's better for small config XML rather than big definition XML.

                  I still dont know which parser im gonna use but i want it to be quite easy to implement, quite fast and lightweight for the program (not too much memory use) and also for the user to install.

                  I will have to investigate about the best lib to use, I will check your suggestions. I am also thinking about a propriary format to make the data uneditable and really optimize the loading times ans consumption. XML and propriary format could be both utilized. One for edition and tuning and the other for fast access.
                  SPARK
                  Moteur de particule C++ opensource avec modules de rendu openGL et SFML

                  ptrxyz

                  • Newbie
                  • *
                  • Posts: 32
                    • View Profile
                  SPARK opensource particle engine with an SFML module
                  « Reply #14 on: June 22, 2009, 08:54:24 pm »
                  Quite nice! Will you offer .NET bindings for SPARK+SFML, too?

                   

                  anything