I've been yearning to know the inner working of physics engine. That's why I made this one. Why java though? Cause I'm porting it to android. Sure I could use NDK, but for now it should suffice.
The engine supports convex shapes (boxes, cylinders, cones, spheres are treated specially), the collision detection is done using GJK algorithm, there are two contact generation schemes:
1. Using ISA-GJK (from Gino Van den Bergen paper) for collision detection + EPA (Expanding Polytope Algorithm) for contact generation
2. Using "pure" GJK to find closest point between the "shrunk" shapes (shrunk by a specified margin) a.k.a. "core shapes". Some people argue this is more robust.
Both schemes only produce one contact point, so we need to cache them over time to build a stable manifold. I learnt them all from Dirk Gregorious paper.
The contact solver use Sequential Impulse as described by Erin Catto. The restitution is modeled as "bias" component, and is clamped to zero when it's below a specified threshold. Not accurate, but it produces plausible motion.
Edit: The simulation runs @ 30Hz, 7 solver iteration, 3 position solver iteration. It also shows ball joint and distance joint at play. When the kinetic energy of the body is too low, it's being put to sleep. This gives huge relief to the engine, as pair of sleeping bodies doesn't need to be put into narrow phase (collision detection). But still, in java it's a lot slower than the c++ version, but perhaps it's due to my incompetence when coding in Java.
Edit2: The actual simulation renders @ 60 fps (interpolation), very smooth. For some reason the screen recorder cap it to 30fps, and after uploading, it got compressed more, giving blocky appearance, sorry!
On this page of the site you can watch the video online Java 3D Physics Engine with a duration of hours minute second in good quality, which was uploaded by the user Glowie 02 January 2017, share the link with friends and acquaintances, this video has already been watched 4,763 times on youtube and it was liked by 74 viewers. Enjoy your viewing!