All Projects → dyn4j → Dyn4j

dyn4j / Dyn4j

Licence: bsd-3-clause
Java Collision Detection and Physics Engine

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Dyn4j

Reactphysics3d
Open source C++ physics engine library in 3D
Stars: ✭ 730 (+130.28%)
Mutual labels:  collision-detection, physics-engine, simulation
Dmech
3D physics engine for D
Stars: ✭ 70 (-77.92%)
Mutual labels:  physics-engine, simulation
Physac
2D physics header-only library for videogames developed in C using raylib library.
Stars: ✭ 151 (-52.37%)
Mutual labels:  physics-engine, simulation
Physics3d
A 3D physics engine
Stars: ✭ 101 (-68.14%)
Mutual labels:  physics-engine, simulation
TriangleMeshDistance
Header only, single file, simple and efficient C++11 library to compute the signed distance function (SDF) to a triangle mesh
Stars: ✭ 55 (-82.65%)
Mutual labels:  simulation, collision-detection
Vortex2D
Real-time fluid simulation engine running on GPU with Vulkan
Stars: ✭ 91 (-71.29%)
Mutual labels:  simulation, physics-engine
Webots
Webots Robot Simulator
Stars: ✭ 1,324 (+317.67%)
Mutual labels:  physics-engine, simulation
3D interactive graphics rendering engine
Develop a 3D interactive graphics rendering engine
Stars: ✭ 31 (-90.22%)
Mutual labels:  physics-engine, collision-detection
TaichiGAME
GPU Accelerated Motion Engine based on Taichi Lang.
Stars: ✭ 35 (-88.96%)
Mutual labels:  simulation, physics-engine
SmartTrafficIntersection
Another AI toy project, of a traffic intersection controlled by a Reinforcement Learning AI agent to optimize traffic flow in an intersection of vehicles or pedestrians
Stars: ✭ 30 (-90.54%)
Mutual labels:  simulation, collision-detection
Gprmax
gprMax is open source software that simulates electromagnetic wave propagation using the Finite-Difference Time-Domain (FDTD) method for numerical modelling of Ground Penetrating Radar (GPR)
Stars: ✭ 268 (-15.46%)
Mutual labels:  simulation
Inet
INET Framework for the OMNeT++ discrete event simulator
Stars: ✭ 268 (-15.46%)
Mutual labels:  simulation
Pulsar
Protocol Learning and Stateful Fuzzing
Stars: ✭ 285 (-10.09%)
Mutual labels:  simulation
Liquidsimulator
Cellular Automaton 2D Liquid Simulator for Unity
Stars: ✭ 302 (-4.73%)
Mutual labels:  simulation
Exandroidnativeemu
An improved version of AndroidNativeEmu,Allow running android elf on PC
Stars: ✭ 264 (-16.72%)
Mutual labels:  simulation
Simpeg
Simulation and Parameter Estimation in Geophysics - A python package for simulation and gradient based parameter estimation in the context of geophysical applications.
Stars: ✭ 283 (-10.73%)
Mutual labels:  simulation
Gl Water2d
2D liquid simulation in WebGL
Stars: ✭ 260 (-17.98%)
Mutual labels:  simulation
Python corona simulation
An agent-based simulation of corona and other viruses in python
Stars: ✭ 261 (-17.67%)
Mutual labels:  simulation
Omnetpp
OMNeT++ Discrete Event Simulator
Stars: ✭ 259 (-18.3%)
Mutual labels:  simulation
Matsim Libs
Multi-Agent Transport Simulation
Stars: ✭ 318 (+0.32%)
Mutual labels:  simulation

alt tag

Actions Status License Language Java Maven Central javadoc Code Coverage

Java Collision Detection and Physics Engine

A 100% Java 2D collision detection and physics engine. Designed to be fast, stable, extensible, and easy to use. dyn4j is free for use in commercial and non-commercial applications.

The project is comprised of the main project and tests managed here and two others:

  • dyn4j-samples A collection of samples to help get started
  • dyn4j-sandbox A non-trivial desktop application that allows users to build scenes, run, save, and load them - all built with dyn4j as the simulation engine.

Requirements

  • Java 1.6+

Getting Started

dyn4j comes with a lot of features and extensibility, but getting started is easy. If you are looking for a quick start, take a look at the following video.

Getting started with dyn4j

Step 1: Add dyn4j to Your Project

Add dyn4j to your classpath by adding a Maven dependency from Maven Central or GitHub Packages

<dependency>
    <groupId>org.dyn4j</groupId>
    <artifactId>dyn4j</artifactId>
    <version>4.1.4</version>
</dependency>

If you are not using Maven you can download the jar from either of the links above.
NOTE: Releases are no longer being created as of 3.4.0.

Step 2: Create a World

World<Body> world = new World<Body>();

This creates a new simulation environment with default settings. The default settings use the meter-kilogram-seconds system and include the default pipeline classes.

Step 3: Add Some Bodies

Body body = new Body();
body.addFixture(Geometry.createCircle(1.0));
body.translate(1.0, 0.0);
body.setMass(MassType.Normal);
world.addBody(body);

A body is the primary unit of simulation and completely rigid. A body is comprised of many fixtures or shapes. While the shapes of dyn4j are all convex (and must be), a collection of these shapes can be used to create a body that is not. A body can be initially placed in a scene by translating or rotating it. Once the shape(s) of a body is defined, it must be given a mass by calling a setMass method. The mass type is typically MassType.NORMAL or MassType.INFINITE. When set to NORMAL, the mass will be calculated based on the shapes. An INFINITE mass body might represent a floor, ground, or something unmovable.

Step 4: Add Some Joints

PinJoint<Body> joint = new PinJoint<Body>(body, new Vector2(0, 0), 4, 0.7, 1000);
world.addJoint(joint);

A joint is a constraint on the motion of one or more bodies. There are many joint types that serve different purposes. Generally, joints are used to link bodies together in a specified way. Bodies can have multiple joints attached to them making for some interesting combinations.

Step 5: Run the Simulation

for (int i = 0; i < 100; i++) {
    world.step(1);
}

Unlike this example, a GUI based application you would call the World.update(elapsedTime) method in it's render loop. Either way, each time the world is advanced forward in time (which may or may not occur when using the World.update(elapsedTime) methods) the bodies added to it will be moved based on the world gravity (if any) and will interact with other bodies placed in the world.

Next Steps

From here you should take a look at the dyn4j-samples sub project to get a jump start with a simple Java2D framework. You can also check out the documentation here.

Links

Building

  • Maven build goals: clean package
  • Check artifact class version:
    • javap -verbose -classpath /path/to/jar/dyn4j.jar org.dyn4j.Version 50
    • javap -verbose -classpath /path/to/jar/dyn4j.jar module-info 53+
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].