Back to Attractor with ToxicLibs

Simon returned to his old Attractor sketch in Processing once again, now adding some new functions:

The code original came from Daniel Shiffman’s book The Nature of Code, Chapter 5 (Physics Libraries) and from the ToxicLibs library, but Simon has customized it quite a bit.

Cloud Simulation. Simon’s Own Code.

In for a shower? Simon made a beautiful Cloud Simulation in Processing (Java). He wrote this code himself. This is the final version of the project:

The whole project is on GitHub, you can download it at: https://github.com/simon-tiger/rain

The videos below show Simon creating the cloud simulation step by step:

 

 

 

 

 

 

Translating Car On Terrain project from Phaser.io into Processing

Today Simon spent hours translating this Car On Terrain project from Phaser.io (where it appears in JavaScript) into Processing (Java). He loved doing it in a form of a lesson for me, while I was filming him and asking questions about loops, arrays, fixtures, shapes and bodies (and there are many things I don’t understand). Simon also spoke about “the three most important properties: density, friction and restitution”. The project involved a lot of Physics, using many Box2D sub-libraries and translating between pixels and mm.

In the end, he got tired of writing all the coordinates for the terrain vertices, but he did get quite far.

 

 

 

 

 

Applying Box2D to translate from pixels into mm:

CarOnTerrain translating from pixels into mm

Path Following (Simon’s own code). Applying restitution.

On Thursday Simon was busy with writing his own code in Java. He called it “Path Following”. The project basically involved simulating different phenomena with a physics particle (having it follow a path, fall and bounce).

The most interesting part of this challenge Simon invented for himself was applying restitution to make the particle bounce in a realistic way (Simon failed several times but eventually succeeded). “If a bound hits the physics particle I’m going to multiply the physics particle’s velocity by -0.8 (0.8 is the arbitrary restitution, so I multiply the velocity by the negative restitution)”, Simon explained.

He also planned to incorporate collision detection in this project but didn’t succeed.

Here the particle is drawing a graph (“noise without a noise function”):

Here Simon adds one more particle and is trying to create collision detection and make the particles restitute:

Debugging and using inheritance for the second particle:

Making the particle remember the graph:

Applying gravity to the physics particle:

Trying to make the physics particle bounce (apply restitution). In this video Simon doesn’t succeed.

Simon manages to control the particle’s bounce (with the mouse) but there’s still no restitution:

In the following video Simon finally won: he figured out how to apply restitution to the bouncing particle making it look like a bouncing ball. After a few bounces however, the particle collapsed (Simon solved the collapsing problem later on: in his code, the < and > should be <= and >=).

In a steering behavior variation, trying to teach a particle to follow a given path (road). Simon hoped to apply a genetic algorithm here but got stuck:

2D and 3D Cloth with ToxicLibs

Simon built this awesome animation that looks and moves like a hammock on Sunday, a coding challenge on Daniel Shiffman’s channel. In this challenge Simon used the toxiclibs physics library to create a 3D cloth in Processing (Java). Creating a 2D cloth involved programming particles and springs, looping them to one single row and later looping them to form a grid.

 

 

 

 

After the 2D cloth was ready, Simon turned it into a 3D cloth by adding the z-axis.

 

 

 

 

 

 

 

Matter.js (Physics Library)

Simon got seriously hooked on Matter.js, a a 2D JavaScript physics library that supports rigid body collisions and constraints.

He started with Daniel Shiffman intro to Matter.js, downloaded it using GitBash and then went on by following further Matter.js tutorials on Daniel Shiffman’s channel. Simon built two physics simulations with static shapes and circular bodies: one resembling a waterfall and another resembling a dangling chain. The sketches involved constraints for mouse interaction. Simon also learned how to delete off-screen bodies from the physics world, removing them from both his particle array as well as Matter.world.