Git Product home page Git Product logo

nphysics's Introduction

crates.io Build status

2D Documentation | 3D Documentation | Forum

nphysics

nphysics is a 2 and 3-dimensional physics engine for games and animations. It uses ncollide for collision detection, and nalgebra for vector/matrix math. 2D and 3D implementations both share the same code!

Examples are available in the examples2d and examples3d directories. There is also a short (outdated) demonstration video. An on-line version of this documentation is available here. Feel free to ask for help and discuss features on the official user forum.

Why another physics engine?

There are a lot of physics engine out there. However having a physics engine written in Rust is much more fun than writing bindings and has several advantages:

  • It shows that Rust is suitable for soft real-time applications.
  • It shows how well Rust behaves with highly generic code.
  • It shows that there is no need to write two separate engine for 2D and 3D: genericity wrt the dimension is possible (modulo low level arithmetic specializations for each dimension).
  • In a not-that-near future, C++ will die of ugliness. Then, people will search for a physics engine and nphysics will be there, proudly exhibiting its Rusty sexyness.

Compilation

You will need the latest release of the Rust compiler and the official package manager: Cargo.

If you want to use the 2D version of nphysics, add the crate named nphysics2d to your dependencies:

[dependencies]
nphysics2d = "0.5.*"

For the 3D version, add the crate named nphysics3d:

[dependencies]
nphysics3d = "0.5.*"

Use make examples to build the demos and execute ./your_favorite_example_here --help to see all the cool stuffs you can do.

Features

  • Static and dynamic rigid bodies.
  • Common convex primitives: cone, box, ball, cylinder.
  • Concave geometries build from convex primitives (aka. compound geometries).
  • Stable stacking.
  • Island based sleeping (objects deactivation).
  • Ray casting.
  • Swept sphere based continuous collision detection.
  • Ball-in-socket joint.
  • Fixed joint.
  • Sensors.

What is missing?

nphysics is a very young library and needs to learn a lot of things to become a grown up. Many missing features are because of missing features on ncollide. Features missing from nphysics itself include:

  • Kinematic bodies.
  • Efficient signaling system.
  • More joints, joint limits, joint motors and breakable joints.
  • Soft-bodies.
  • Parallel pipeline.
  • GPU-based pipeline.

Dependencies

All dependencies are automatically cloned with a recursive clone. The libraries needed to compile the physics engine are:

  • ncollide: the collision detection library.
  • nalgebra: the linear algebra library.

The libraries needed to compile the examples are:

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.