Chef de Rang

 

Galton Box

Description

This sample work is a multi-threaded simulation of a Galton Box using metal, wooden and rubber balls. The simulation can be run as a single box or as two boxes distributed across a network using Winsock networking over port 2001, in this mode balls are transferred across the network to the other box when they pass the centre of the box.

Features

The multithreaded physics code uses a scalable design that treats each physics object that needs to be updated as a job. The jobs are completed by a number of multithreaded workers that take multiple jobs out of the job queue. In the event that no jobs are available workers will take unprocessed jobs from other workers to load balance.

 

Ongoing Work

This is a piece of work that I'm really proud of and am still adding to. Recently the job queue was reimplemented using the STL queue container which allows jobs to once again be processed in a FIFO context. My own simple queue system originally processed in FIFO but this had to be changed when the networking element was implemented.

Controls

‘s’

Pause Simulation

‘x’

Close Simulation

‘n’

Toggle Cloth

Space Bar

Switch between real-time & 1/10th speed

‘1’

Make all balls metal

‘2’

Make all balls wooden

‘3’

Make all balls rubber

‘4’

Randomise ball types

‘r’

Reset camera

‘+’ / ‘b’

Add balls

‘-‘ / ‘p’

Remove balls

‘<’

Zoom out

‘>’

Zoom in

Left mouse button & mouse left/right

Rotate camera about y-axis

Right mouse button & mouse up/down

Rotate camera about x-axis

Middle mouse button & mouse left/right

Rotate camera about z-axis

Source Code

The source code for this project is provided here and includes an executable. To compile, the GXBase libraries developed at the University of Hull and distributed under the LPLG Licence can be found here.