A 3D gravity simulation that visualizes n-body interactions using OpenGL, GLFW, GLAD, and GLM.
- CMake 3.20+
- A C++17-compatible compiler (clang or gcc)
- GLFW
- GLM
- GLAD headers (included in
dependencies/)
brew install cmake glfw glmsudo apt update
sudo apt install build-essential cmake libglfw3-dev libglm-dev- Clone the repository and change into the project directory:
git clone https://github.com/<your-user>/<your-repo>.git cd gravity
- Configure the project with CMake:
cmake -B build
- Build the executable:
cmake --build build
- Run the simulator:
./build/gravitysimul
- Source files live in
src/ - External headers are in
dependencies/ - Adjust simulation parameters in
src/finalgravitysim.cpp - Modify rendering constants in
src/config.h
W/A/S/D: Move camera horizontallySpace/Shift: Move camera up / down- Mouse look : Rotate the camera
EscorK: Pause / resume the simulation+ / -: Speed up / slow down time- Mouse left-click : Spawn a new object (drag to position before release)
- Mouse right-click (hold) : Increase mass of the newest object
MIT License © 2025
