Git Product home page Git Product logo

jphysics's Introduction

JPhysics

JPhysics is a 2D physics engine with no third-party-library dependencies.

The engine is written in Java and has been created with the intention of being used in games.

Tech demos

The testbed includes numerous tech demos to show what the engine is capable of. Some examples are given below: a relative link a relative link a relative link

Feature List

Physics

  • Rigid body dynamics
  • Primitive joint constraints
  • Momentum
  • Friction
  • Restitution
  • Collision response (Sequential Impulses Solver)
  • Stable object stacking
  • Orbits
  • Explosions
  • Object slicing

Collision

  • AABB queries (Broadphase)
  • One-shot contact manifolds
  • Discrete collision detection
  • Convex polygon and circle collisions
  • Ray casting
  • Position resolution handling

Explosion types

  • Proximity
  • Ray casting
  • Particle

Testbed

  • Java swing for demo graphics
  • Junit4 for junit tests

Future features to implement

  • Multi body shapes
    • collisions optimizations for said shapes
  • Demos illustrating limitations within the engine
  • Dynamic tree broadphase
  • Continuous collision detection
  • Island solution and sleep management
  • Extra types of joints (eg Revolute, pulley)
  • Fluid and soft body simulation

Controls for testbed demos

When a tech demo is active, certain buttons can be pressed to interact with the world as follows;

Trebuchet: Press b to release projectile

Explosion demos: Click to cast an explosion at the location clicked

The camera can be repositioned by holding down right mouse button and dragging across the screen.

All demos can be paused by pressing the space bar.

Getting Started

Follow these simple steps!

Prerequisites

  • An appropriate IDE for example Intellij (with java 1.8+ JDK installed)
  • Junit4 library (for junit tests)

Main files

All you need to do is clone the repository and place the JPhysics/src files in the source directory of your chosen IDE.

Adding JUnit library

For JUnit 4, you will need to add junit4 jar file to class path. This can be done as follows in intellij:

Go to file -> project structure (Ctrl-Alt-Shift-S)

Click the plus button at the top and select "From Maven as shown below"

a relative link

In the search box, type in "junit:junit:4.12" and press ok. This is the JUnit dependency I use and have tested on.

After this, Keep hitting OK until you're back to the original project code.

Testing

Now you can go to "src/testbed/junittests/" and run the tests!

Documentation

Java documentation on the library can be found in the Javadoc folder or follow the link! java documentation

Authors

Hayden Marshall

License

The repository falls under the MIT license. See LICENSE.txt for more information.

Credits

Dirk Gregorius and Erin Catto's gdc talks and documentation have been of great help with the theoretical approach of creating a physics engine.

jphysics's People

Contributors

haydenmarshalla avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.