dyn4j is a 2D collision detection and rigid body physics engine written 100% in the Java programming language. The library is built for Java 1.6 or higher, has zero dependencies, and is primarily developed for games.
The project as a whole includes the core library, a suite of over 2000 JUnit test cases, and a samples project.
Overall goals of the project are:
A side goal of the project is to serve as a well designed example of a collision detection from which others can learn the patterns, pipelines, algorithms, and more.
dyn4j uses the New BSD license. You may use the library in commercial applications without releasing your application code, or any modifications to the library, or citing attribution.
I do encourage those using or modifying the library to report any issues by using GitHub discussions so that all can benefit.
See the Getting Started page first. This will help you setup your project and give you a few tips to get going. Then you can check out the samples. From there, I recommend that you read the Advanced wiki page to learn more about key aspects of the engine.
Any platform that has a Java 1.6 or higher virtual machine. Testing is primarily performed on Windows 10 64bit with OpenJDK 11 as the runtime. Less frequent testing occurs on Mac OS
If you have a question like “How Can I…” please review the samples project and any answered discussions first. Finally, if you are unable to resolve your problem or find the answer you are looking for, feel free to open a new discussion.
If you are having problems with compilation, Java 2D, or something else unrelated to dyn4j, you’ll want to use other mediums, StackOverflow, to ask/resolve your questions.
NOTE: GitHub Issues are for confirmed problems with dyn4j or pending changes/enhancements. At a minimum, you should fill out the issue template with all relevant information and attach a test case. If you aren’t sure if what you are seeing is a bug, open a discussions and after confirmation, an issue will be created for you.
You should, at a minimum, be very familiar with the Java programming language and the tools used to compile and run java applications (command line or IDE). The library itself and the samples project are both Maven projects developed in Eclipse, but these are not dependencies.
I would recommend that you have some basic knowledge of physical properties like, force, torque, velocity, mass, etc. In addition, it would be beneficial if you have some experience with Java2D or OpenGL.
The library leaves the rendering up to you. Java has a few options for rendering, standard Java2D that is packaged with the runtime or 3rd party libraries like JOGL. You can see the samples for a Graphics2D example and a JOGL example. The choice of rendering API is totally up to you. All the samples extend the Java 2D rendering framework.
Including rendering, the library does not solve other problems like texturing, user input, networking, and so on.
Shapeinstances among bodies.