Re: Physics Patch-a-Day Thread – Join the fun!!!

Forums > Jitter > Physics Patch-a-Day Thread – Join the fun!!!
September 21, 2012 | 7:20 pm

A while back I was interested in creating a mini particle system that had points of force exerting themselves on the particles. After I got into it a bit, things became a little too complex to manage, and I abandoned it. Then along came Jitter Physics! Using jit.phys.multiple and jit.phys.ghost, was able to prototype this idea in about an hour, and I really love the results. Its endlessly tweakable, and as I have attempted to keep it simple, there is lots of room for expanding the idea. The patterns that emerge are really mesmerizing, and playing with various colors, materials, shapes, and positions of everything can provide some great visuals.

The set up for this patch is that there are four "force points" in a diamond shape. These are jit.phys.ghost objects. They can be attractors or repellers. Then, in the middle, there is a moveable force point, which is a combination of a jit.phys.body and a jit.phys.ghost. This gives the effect of having a body which also can attract or repel. The functionality is achieved by using the ‘kinematic’ attribute of the jit.phys.body, and handling all of the positioning of the object (and force), by mouse tracking in the jit.window. A object is used to visualize the center ghost/body position.

The "particles" are all handled by the combination of jit.phys.multiple and In this patch, there are 400 bodies generated, and their color, torque, scale and mass are all generated by a single jit.noise object. The random matrix is then scaled by the use of jit.expr objects. Another even easier way to do it is in jit.gen, where you have the ‘scale’ operator. Depending on your computer, you may have to alter the amount of bodies to maintain smooth performance.

Try changing the central_force of all of the jit.phys.ghost objects. Positive repels and negative attracts. Setting the central_force to 0 effectively disables the ghost force. Sending central_impulse messages to the ghost objects create single shockwave-like forces through the physics world. Move the central "Moveable Force" around by click-dragging in the jit.window. See how the spheres are colliding with it, but also attracted or repelled.

This is just the tip of the jit.phys iceberg, so experiment and enjoy!