Physics Simulation (CGP3012), University of Lincoln · April 2025 · Project page: Wrecking Ball Simulator

The idea

The brief was to build an interactive physics simulation in C++ using NVIDIA PhysX. I wanted something you could drive: a small crane with a wrecking ball, and a brick wall to knock down. I based the machine on a real one, the Caterpillar 324E, which has the same two-part design: a base on wheels and a top half that spins independently.

Building the crane from joints

Everything in the crane is a physics body held together by joints, so it moves because of the physics, not animation.

  • The base is a heavy box with four sphere wheels, each attached with a revolute joint so they roll
  • The top sits on another revolute joint, locked so it can only turn around the vertical axis. It wobbled badly at first, so I disabled the joint’s drive and tightened its tolerances to keep it steady
  • The arm is two sections fixed to the top, so the whole arm swings with it
  • The chain is where it gets fun: 50 small links, each joined to the next with a revolute joint, fixed to the arm at one end and the ball at the other. That’s what gives the ball a believable swing and lag when you turn

Getting the masses right took a lot of tweaking: the base ended up with an enormous density to keep it planted while the ball swings, and the ball and chain links were made heavier so the ball actually carries enough momentum to break the wall.

The wall

The wall is built from individual brick boxes (15 rows high and 50 long) in a staggered pattern, with every other row offset by half a brick, just like a real wall. Each brick is its own rigid body, so it cracks, topples and scatters naturally.

Every frame, the wall counts how many bricks have fallen below a set height. Once 60% of the wall is down, the simulation pauses and you’ve won.

Driving it

  • W / S: drive forwards and backwards
  • A / D: turn the base
  • Q / E: swing the arm left and right

A camera follows the crane around. You can swing the ball into the wall, or just drive straight into it and bulldoze it over.

What I took from it

This project was mostly about learning how much a simulation depends on tuning: joint limits, masses and tolerances decide whether a chain swings nicely or explodes. Splitting the code into small classes (wheels, chain links, arm parts, the wall) made it much easier to adjust one part at a time. Where I adapted code from the PhysX tutorials, it’s marked in the source.