Inspiration
Physics engines are the invisible backbone of every game and simulation — but most developers never look under the hood. I wanted to build one entirely from scratch to deeply understand rigid body dynamics, collision response, and real-time 3D rendering. The goal was a system expressive enough to simulate anything from a crumbling tower to an exploding cube array.
What it does
PhysicsEngine3D is a real-time 3D physics simulation engine that models rigid body dynamics including friction, momentum, and collision detection across five primitive shape types: cubes, spheres, cylinders, planes, and pyramids. Each shape has its own custom collision resolution logic. The engine is presented through five handcrafted demo scenes:
Explosion A 3D grid of cubes hit by an exploding sphere, showcasing impulse-based force propagation
Tower drop A stacked cube tower collapsing under gravity with realistic contact stacking..
Newton's cradle Two walls and two cubes demonstrating elastic momentum transfer between bodies.
Sandbox Spawn any shape at any size and watch it collide freely — a fully interactive physics playground.
Mesh loader Loads custom .obj meshes (e.g. the classic OpenGL backpack) with lighting and reflection support.
How we built it
The engine is architected using a clean object-oriented design with a central entity-ID system. Each object in the simulation is assigned a unique ID, allowing physics attributes — mass, gravity scale, restitution, friction — to be dynamically attached or modified without restructuring the scene graph.
Rendering is handled by OpenGL with GLSL shaders for lighting and reflections. The UI layer uses ImGui, giving users an in-engine menu to tweak parameters, switch scenes, and spawn objects at runtime. Collision detection is handled per-shape-pair with custom manifold generation and resolution impulses.
Challenges we ran into
Implementing stable stacking — preventing jitter in resting-contact scenarios required careful constraint solving and position correction. Per-shape collision geometry — each shape pair (e.g. sphere-pyramid, cylinder-plane) needs its own contact point algorithm. Keeping the entity-ID system lightweight while still being expressive enough to support varied physics parameters per object.
Accomplishments that we're proud of
Five fully realized demo scenes that each isolate and showcase a distinct physics concept. A general-purpose sandbox mode that lets users compose and destroy scenes in real time. A clean, extensible ECS-style architecture that makes adding new shapes or behaviors straightforward. Custom mesh loading with proper lighting — bridging physics simulation and real rendering quality.
What we learned
Building a physics engine from scratch forced a deep understanding of linear algebra, impulse-based dynamics, and the subtle numerical issues that arise in real-time simulation. It also reinforced how good software architecture particularly decoupled entity management makes complex systems dramatically easier to extend and debug.
What's next
Collision showcase: A dedicated stress-test scene with dozens of mixed shapes raining into an arena, with collision normals and contact points visualized in real time as debug overlays
Light & refraction: A dark-room scene featuring transparent glass spheres and prisms that refract and bend a moving light beam as they roll and collide combining physically-based rendering with live rigid body simulation to show how light and physics interact in the same space.
Log in or sign up for Devpost to join the conversation.