physics
C++

Some physics-based animations with particles and rigid bodies

This is a set of physics-based animations I made at university in C++.

Source code

Flag

The particles are connected by springs and there's an isotropic wind applied to the the triangulated cloth (not to each individual particle).

Point gravity

A group of particles affected by two points of gravity.

Newton's gravity between any two bodies

While the previous simulation uses an approximate gravitational formula, this one uses Newton's law of gravity: every two particles with mass are affected by each other. To be able to see such interactions I made them stick together once they get very close.

The lighter particle has a higher mass.

Super Mario Galaxy's gravity

In Super Mario Galaxy the player is able to walk in planetoids of any shape and size. This is possible because bodies are affected by the gravity of only one planetoid at once and the gravity direction is the inverse of the normal of (usually) the closest surface.

I applied this principle to particles in box-shaped planetoids. The gravity direction is the normalised vector from the particle to a point U, where U is the point on — or in — the planetoid closest to the particle.

RigidBody (OBB)

A rigidbody with the shape of a box (OBB) colliding with a plane.

Collisions between OBBs

Two OBBs colliding with each other.