Gravity Balls is a physics-based 3D simulation project built using OpenGL and GLUT, where multiple balls move under the influence of gravity, friction, and collision dynamics. This project is a fun and interactive way to visualize basic physics in action using graphical rendering.
- β Realistic gravity-based motion simulation
- β Collision detection and response between balls
- β Boundary collisions with wall rebound effects
- β Frictional slowdown to simulate energy loss
- β
Rendered using
glutSolidSpherein a 3D space
- Language: C++
- Graphics: OpenGL, GLUT
- Platform: Windows Visual Studio 2022 (VS Solution File included)
- Download all the files on your computer.
- Open
GravityBalls.slnin Visual Studio. - Make sure your system has OpenGL and GLUT libraries set up (Visual Studio should handle this if you're using the included files).
- Press
Ctrl + F5to build and run.
The simulation starts automatically, but you can interact and modify parameters in real time using the following keyboard shortcuts:
| Key | Action |
|---|---|
2 / 8 |
Decrease / Increase Gravity |
4 / 6 |
Decrease / Increase Friction |
A / D |
Decrease / Increase Elasticity |
Q / E |
Decrease / Increase Entropy |
< / > |
Decrease / Increase Time Scale |
N |
Add New Balls |
M |
Toggle Magnetize Walls |
B |
Toggle Black Hole Mode |
G |
Toggle Cursor Gravity |
+ / - |
Zoom In/Out |
SPACE |
Pause/Play |
R |
Reset |
C |
Clear |
ESC |
Quit |
| (Shown on top of simulation window) | Real-time updated values: Gravity, Friction, Elasticity, Ball Count, Entropy, Time Scale, etc. |
You can also customize the number of balls and initial settings directly in main.cpp before compiling.
π§ͺ Feel free to experiment with combinations to see how the environment reacts!
This project is for educational purposes and open to contributions.
Feel free to fork and modify it!
Samdeep Sharma
Final Year CSE Student at Thapar Institute
LinkedIn
Sangeet Kumar
Final Year CSE Student at Thapar Institute
LinkedIn