O'Reilly logo

Mastering openFrameworks: Creative Coding Demystified by Denis Perevalov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The attraction, repulsion, and spinning forces

Let's extend our particle's model with three new control parameters—attraction/repulsion, spinning forces inside the emitter (the force and spinning parameters), and friction that freezes the motion (the friction parameter).

Note

An example of this is 03-Particles/03-ParticlesForces.

The example is based on the 03-Particles/02-ParticlesEmitter project, implemented in the previous section. Add a declaration of the new parameters to the Params class declaration:

float force;       //Attraction/repulsion force inside emitter
float spinning;    //Spinning force inside emitter
float friction;    //Friction, in the range [0, 1]

Then add their initialization in Params::setup():

force = 0;
spinning = 0;
friction = 0;

Finally, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required