Particles based on Daniel Shiffman's teaching

Hi all,

have been meaning to post this example for a while but here goes…

The most accessible resource I have found for learning about particles/vectors/forces etc is Daniel Shiffman’s online ‘Nature of Code’ syllabus for Tisch School of the Arts, which uses Processing:
http://www.shiffman.net/teaching/nature/

I started working with OF shortly after discovering this and really wanted to be able to apply this info as directly as possible. So as an exercise I remade his ‘Simple Particle System’ example using OF. This then made it much easier for me to apply the concept in the other examples to OF too so hopefully someone else will get some use out of it:
http://renechristen.net/archive/code/na-…-system.zip

The big differences between this and the Processing version are:
-Using c++ std::vector in place of Java’s dynamic arrays, I chose std::vector as the syntax is the closest to Java’s.
-Using the ofxVec2f class in place of Daniel Shiffman’s vector class (replace with ofxVec3f if you want 3D particles)

thanks to everyone who offered advice on linked lists in c++, some helpful info about optimisation in that thread:
http://forum.openframeworks.cc/t/list,-vector-or-deque-for-particle-system-demo/882/0

another helpful thread on optimising the use of images for particles is here:
http://forum.openframeworks.cc/t/using-a-single-texture-for-multiple-objects/858/0

cheers
nay.

*edit* another big difference was separating the draw function into draw and update functions

Thanks you very much for this, I am doing the same, starting oF by recoding my P5 previous work.

First time can be difficult and frustrating, but once you get its awesome

Cheers
rS

FYI,

The link to the source code zip file is 404.

Any chance of getting a the zip reposted?

niiiiiice… thanks for sharing!

sorry - just saw this thread was dug up. seems i lost some stuff moving my site to a diff server. src for that project now attached to this post…

src.zip

thanks a lot for this code!

now i took this and wanted to do some advanced things in Particle.cpp like playing soundfiles or using ofxTween. unfortunately i run into problems, according to this post http://forum.openframeworks.cc/t/communicate-a-class-with-testapp—via-ofevents/2087/0 using pointers could solve the problem. how would this particle system have to be updated to create pointers instead?

mama mia somehow i managed to change this myself (i guess).
would be cool if someone could validate that this is correct.

[attachment=0:zqjmp5d7]nayParticlePointers.zip[/attachment:zqjmp5d7]

this is basically what i did:

vector<Particle *> particles; (adding the pointer)
particles[i]->update(); (instead of particles[i].update())
particles.push_back(&p); (adding the reference)

nayParticlePointers.zip

I’ve just ported the particle examples from Shiffmans Nature of Code Book, so if someone lands here, this might be a good start: https://github.com/firmread/NatureOfCode/tree/master/chp4-systems

/m

1 Like